Chapter 7 Finishing up and Remote Login
The Pi is working, What next???? So, if you have followed the previous segments, you should now have a Raspberry pi up and running. It has been: File system expanded to use full SD card New password set Language, keyboard and time zone set Wifi connected Software updated to latest Used Raspberry pi Configuration to set host name and turn on appropriate interfaces Enable Camera, SSH, etc. You may also have: Set up a fixed IP address Transferred to Operating System to an external HDD or SSD Remotely logged in from a terminal on another computer A note about logging in from a terminal. You can login using the IP address as in ssh firstname.lastname@example.org (Or whatever address you used) SSH must be enabled in the Pi.
After a period, you should see that you can also login using the host name you set as in ssh pi@cam1 Each different computer you log in from will need to have you accept the ssh key by responding yes If you reload software and use the same host name and or IP address, you will need to update this key. It will prompt you with a command Copy this comand, then paste it after the current prompt and run it. It will remove the old key. Login again for the new key. A note about system modifications: You have logged in as the user pi. Pi can create and modify its own files, but does not have permission over system files. System files are owned by the administrator, known as root. Several years ago, you could log in as root, having total control over every file. They have deemed that "Too Dangerous" and it has been blocked for years. When you are in a terminal, you can switch users. Assuming Tom, Dick and Harry have accounts on the pi, you can enter su tom. It will ask for Tom's password. It is now like you logged out and Tom logged in. So, to make things more fun, if you just enter su it will assume you want to log in as root. It will ask for your password (Yes, not really secure) and it will be as if you logged in as root. You can do any administrative tasks, but from a command line only. At least you can't click on the wrong thing with the mouse and blow everything away! But, the most popular and safest way to do administrative tasks is, as you have done before, precede the command with sudo. Why is this safer? If you create a file while logged in as root, root becomes the owner of this file. When you log in as pi and want to use this file, you could be blocked as you don't have permission for that file. The most popular way to proceed is to log in as pi, and if a command says you do not have permission, repeat the command with sudo in front. If you are following a guide to install something, it will tell you sudo is needed. Needing sudo before the command will remind you that this is an administrative task.
Useful commands: Enter from command line on a terminal.
ps aux Display all processs
free Show memory use date Show current time and date touch
test.txt Create empty file called 'test.txt' Some programs make decisions just on the presence of a file
rm test.txt Delete file 'test.txt'
nano test.txt Open file 'test.txt' in an editor Ctrl O writes file Ctrl x exits editor
df -h Show partitions
sudo fdisk -l List drives mounted
mkdir test Create a directory called 'test'
cd test Change directory to 'test'
cd .. Move up one level in directory
cd / Move to root directory
rmdir test Delete directory 'test' Will not delete it if it is not empty
cat test Display contents of file 'test'
halt Shutdown software
sudo reboot Reboot pi
sudo shutdown -h now shutdown pi - must powercycle to reboot
dmesg Shows what was just plugged into USB port
lsusb Shows usb connections
cat /proc/cpuinfo Shows cpu speed and model number
cat /proc/meminfo Shows memory used and for what
cat /proc/partitions Shows partitions and size in megs
cat/proc/version Shows software versions
cat /etc/os-release Shows software name and version
uname -a Shows kernel version
vcgencmd measure_temp Shows processor temperature
ip a Shows ethenet connections
iwlist Wlan0 scan Shows wifi available
systemd-analyze blame Shows list of running units and time to initialize
which <program name> Shows path to program
sudo apt-get update Updates list of files and versions on software server
sudo apt-get upgrade Upgrades and files not up to current version
sudo apt-get autoremove Removes any files that are no longer needed by any other files
sudo apt-get dist-upgrade Upgrades to latest distribution. MAY BREAK SOFTWARE!
sudo rpi-update Firmware update MAY LOAD UNSTABLE FIRMWARE! USE WITH CAUTION!!! sudo apt-cache search Use to find useful packages
So, now that you have your pi set up and you have a basic understanding of things, it is time to go out on the web and find some fun things to do with your new pi. You will see that some people do an excellent job of documenting their projects and it is easy to follow. Some assume you are experienced and leave out some steps. You may find a similar project that you can use to fill in the blanks to get that project up. Eventually you will get to the point where you take two or three projects and combine them to do what you want. Make sure you take notes on what you are doing. They will help you decide what to try next if you are having problems getting a project working, as well as help somebody else from what you have learned. The information above, combined with the previous articles, should give you a good basic understanding of the Pi and Linux. There are thousands of projects out there!
Jim Albrecht, K2BHM