All posts by Anandprakash

Software Engineer having more than 2 years of experience in cloud,virtualization,Linux,Python,ReST,DevOps. M.C.A(Department of computer science ,university of Pune.)

Install operating system on raspberry pi and play with LED on/off

Hi Readers,

Hope all are doing well,

I am going to talk about raspberry pi.

What is raspberry pi –

The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries.

A Raspberry Pi is a credit card-sized computer originally designed for education, inspired by the 1981 BBC Micro. Creator Eben Upton’s goal was to create a low-cost device that would improve programming skills and hardware understanding at the pre-university level. But thanks to its small size and accessible price, it was quickly adopted by tinkerers, makers, and electronics enthusiasts for projects that require more than a basic microcontroller (such as Arduino devices).

The Raspberry Pi is slower than a modern laptop or desktop but is still a complete Linux computer and can provide all the expected abilities that implies, at a low-power consumption level.

 

Need – sd card, card reader, monitor

Insrer sd card in card reader and connect cardreader to computer/laptop

fire command df –

check where your sd card is inserted

you need fire umount command from path where it’s mounted..NOTE- to format any device we need to unmount it first

like you need to umount /dev/mmcblk0px(x is any number) and path of /dev/mmcblk0px (x ia any number ) is /run/media/anandprakashdnyaneshwartandale/SETTINGS

then you need to fire command-

umount /run/media/anandprakashdnyaneshwartandale/root  and

umount /run/media/anandprakashdnyaneshwartandale/SETTINGS

after fireing lsblk command you should be able to see –  ‘mmcblk0’ path

like-

mmcblk0 179:0 0 29.7G 0 disk
├─mmcblk0p2 179:2 0 1K 0 part
├─mmcblk0p7 179:7 0 28.5G 0 part
├─mmcblk0p5 179:5 0 32M 0 part
├─mmcblk0p1 179:1 0 1.1G 0 part
└─mmcblk0p6 179:6 0 63M 0 part

 

After that you need to fire a command  sudo mkdosfs -F 32 -v /dev/mmcblk0 to install format the device(sd card here)

sudo dd bs=1M if=”path to image” of=/dev/mmcblk0 status=progress

 

 

 

fire command sudo mkdosfs -F 32 -v /dev/mmcblk0  – to format your file system

if you are using fedora your path of sd card will be something like /dev/x/x/

if you are using ubuntu then path would be /media/x/x

I will talk about fedora,

so after formatting,  you nned to install something onm that right?

so fire the command ‘sudo dd bs=1M if=”path/of/image/for/raspberrypi” of=/dev/mmcblk0 status=progress’

dd is use to convert and copy a file, you can see man pages of dd

then go to you sd card by cd command – in my case ‘cd /run/media/anandprakashdnyaneshwartandale/46ed1fb6-8b80-414d-b41a-e721d2b37b05’

there you can see filesytem etc,mnt,var,usr etc

go to etc of your sd card and append your internet connection in /network/interfaces fire

to make your raspberrypi system accessible by ssh, you need to make ssh enabled by adding following line in etc/rc.local (NOTE- etc is inside of raspberrypi system not your local)

IP=$(hostname -I) || true
if [ “$_IP” ]; then
printf “My IP address is %s\n” “$_IP”
fi

if [ -e /etc/SSHFLAG ]; then

/usr/sbin/update-rc.d -f ssh defaults

/bin/rm /etc/SSHFLAG

/sbin/shutdown -r now

fi

sudo /etc/init.d/ssh start

 

Then  you need to check ip address of sytem mounted on sd card – how?

ans- just remove sd card reader , insert sd card in raspberry pi connect raspberry pi to any monitor and reoot it, if network is good you can see ip address of system installed on sd card in rasberrypi

you need to copy that ip.

now you rasberry pi is on-

and steps to get gui of raspberrypi sytem using tightvnc and vncviwer

open xterm on your system, enter ‘vncviewer’ command on xterm

then you will see pop up asking for ip address and port to connect using vncviewer

enter ip address of you raspberrypi and enter port it’s listening try port 1/2 as well

then you wiil get gui of sytem install on sd inserted in raspberrypi

you can ssh using ssh pi@ipaddressfound and password is raspberrypi

after successful of ssh you need to require packages related to python on that

i just fired command ‘apt-get install python-dev’

commect LED and  to pins of raspberrypi like-

 

Screenshot from 2017-03-26 22-51-52

 

then fire command python3 on the seesion where you ssh to system installed on sd card inserted in raspberrypi

from RPi import GPIO as io

io.setmode(io.BOARD)

io.setup(16, io.OUT) – to get output from raspberry pi

io.output(16, io.LOW) – to turn off LED

io.output(16, io.HIGH) – to turn on LED

yeahhhhhhhhhhhhhhh, ver long blog but very interesting right?

so now you can do python programs to do ehatever you want to do with LED may be blinking design with many LEDS. so go for it, all the best.

 

 

 

Advertisements

‘Django – python web framework’ session taken by me in Python Pune Meetup Feb 2017

Hi Readers,

On 26th Feb, I took a session on ‘django – python web framework’ in Python Pune Meetup at Tixdo Pvt. Ltd. Cybercity, magarpatta Pune.

I gave a demo as well, but now, I am pasting content of my slides.

slide 1 – django

Web framework written in python
MTV – Model(data access), Template(presentation), View(bridge between M and T / logic)
Request response
Fast, secure, scalable, opensource.

 

slide 2 – architecture

django_mvc_mvt_pattern-jpg

 

slide 3-

The developer writes/provides the model and then template and view maps to the url

slide 4 –

Django comes with a lightweight web server for developing and testing applications. This server is pre-configured to work with Django.

slide 5-  Installation

Prerequisites – python
dnf install python-django
git clone git://github.com/django/django.git , pip install -e django/
Install pip/pip3 and then pip/pip3 install django
using virtualenv

 

slide 6 – Imp files in django after creation of project/app

manage.py
settings.py
urls.py
views.py
wsgi.py

 

slide 7 –  important links

http://djangobook.com/https://www.djangoproject.com/https://developer.fedoraproject.org/https://www.tutorialspoint.com/django/

 

 

Popular database now a days – REDIS

Hi readers,

 

Now a days redies database is very famous.

Because it is in memory database. in memory databases are the databases who used main memory to store the data they dont have storage management system/engine like mysql.

Redis is nosql database, you can store your data in hash/key-value pair format.

It is very fasr so many big companies like twitter instagram, github, stackoverflow are using redis.

We have opensource redis and enterprise redis (redis labs).

 

I will keep posting more information about redis in coming blogs.

What is Kubernetes

Hi readers,

I already published blog about Docker and difference between docker and virtual machine.

Imagine you want to deploy docker on many servers and manage those servers by automation. Kubernetes is the solution for that.

What is Kubernetes-

Kubernetes is basically tool or system which manages deployment, scaling, performing operations of containers like docker automatically over the cluster.

Cluster is basically group of servers.

With Kubernetes, you are able to quickly and efficiently respond to customer demand:

best practices to work around kubernetes go through http://containertutorials.com/get_started_kubernetes/index.html

you want to understand components of kubernetes go through https://kubernetes.io/docs/admin/cluster-components/

Docker vs Virtual Machine

Hi readers,

I have already published 1 blog regarding docker.

Today I am going to tell you difference between Docker and Viertual Machine(VM)

The main difference between docker and vm is their architecture.

In vm hypervisor plays very important role.

On top of hardware level it have hypervisor.

Hypervisor distributes the guest os and however os are there we can have that much applications. With each different os we have different kernels.

But in case of docker-

Lxc plays very imp role.

Lxc is basically linux container, is an operating-system-level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel. (in vm concepts we should have different kernel for different os, this is main imp difference)

 

Lxc is an operating-system-level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel.

The Linux kernel provides the cgroups functionality that allows limitation and prioritization of resources (CPU, memory, block I/O, network, etc.) without the need for starting any virtual machines, and also namespace isolation functionality that allows complete isolation of an applications’ view of the operating environment, including process trees, networking, user IDs and mounted file systems.[3]

LXC combines the kernel’s cgroups and support for isolated namespaces to provide an isolated environment for applications. Docker can also use LXC as one of its execution drivers, enabling image management and providing deployment services.

 

 

Useful networking linux commands

Hi readers,

I have talking about cloud, OpenStack for this block readers.

To earn more knowledge about cloud and OpenStack you have to have good knowledge of networking.

Following are the basic networking commands for the linux which you must aware about.

 

ifconfig –

fconfig (interface configurator) command is use to initialize an interface, assign IP Address to interface and enable or disable interface on demand. With this command you can view IP Address and Hardware / MAC address assign to interface and also MTU (Maximum transmission unit) size.

 

ifconfig interface –

e.g.  ifconfig eth0 –

fconfig with interface (eth0) command only shows specific interface details like IP Address, MAC Address etc. with -a options will display all available interface details if it is disable also.

 

ping ip address/url –

e.g. ping google.com or ping x.x.x.x –

PING (Packet INternet Groper) command is the best way to test connectivity between two nodes. Whether it is Local Area Network (LAN) or Wide Area Network (WAN). Ping use ICMP (Internet Control Message Protocol) to communicate to other devices

 

traceroute-

e.g. traceroute ip address

traceroute is a network troubleshooting utility which shows number of hops taken to reach destination also determine packets traveling path. Below we are tracing route to global DNS server IP Address and able to reach destination also shows path of that packet is traveling.

 

netstat-

e.g. netstat -tnlp

It is very imp command to check your desired port listing desire services.

Netstat (Network Statistic) command display connection info, routing table information etc. To displays routing table information use option as -r.

 

dig-

e.g.- dig http://www.google.com

Dig (domain information groper) query DNS related information like A Record, CNAME, MX Record etc. This command mainly use to troubleshoot DNS related query.

 

route-

e.g-

route

route command also shows and manipulate ip routing table. To see default routing table in Linux, type the following command.

 

 



 

what is cloud computing in simple words

Hi readers,

Many people talk about cloud computing in detail like virtualization,storage, but very few are able to explain ‘term’ in basic simple words.

Reader of this blog will understand the basic but important concept of cloud computing.

 

What is Cloud Computing-

It is a type of computing groups of remote servers and

software networks that allow centralized data storage and

online access to computer services or resources.

Using cloud computing we can manipulate,configure and

access the applications online.

Delivery of on-demand computing resources.

screenshot-from-2017-01-26-14-20-20