Raspberry Pi and Linux stuff to remember

To add a user to the sudoers group

Log into the Raspberry Pi as Pi, and add the user with

sudo adduser <username>

Then use usermod to add the user to the specified group:

sudo usermod -G <group> -a <username>

Group is the name of the group, for example sudo.

To set up a Raspberry PI as FTP server

Follow this link

Rotate the screen

If you have one monitor rotated, you can rotate the Raspberry Pi screen, by editing the /boot/config.txt - file

sudo nano /boot/config.txt

At the bottom, add this line:


0 = normal config

1 = 90 degrees

2 = 180 degrees

3 = 270 degrees

Save and reboot!

To check which version of RPi you have

When you have many different Raspberry Pis, and you don't know which is which model, run this command to get the model:

cat /sys/firmware/devicetree/base/model

I ran it on two and got this:

Raspberry Pi 2 Model B Rev 1.1

Raspberry Pi 3 Model B Plus Rev 1.3

To install PIP

sudo apt-get install python-pip

To install Beautiful Soup

sudo pip install bs4

sudo apt-get instal python-requests

To get IP addr on eth0

ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{print $2}'

my_ip = ([l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2]
if not ip.startswith("127.")][:1], [[(s.connect(('', 53)),
s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)]][0][1]]) if l][0][0])

To start a program at boot time

Add program befor exit 0 in this file.

nano /ets/rc.local