When you open the Raspberry Pi terminal, the first thing to start with is to grab the upgrade of the OS. Then the update begins. Or, somehow you will need to install some packages. For these purposes, you will use Linux commands more often.
After reading this article, you may feel that Linux is not that tough and you may get well versed in the usage. I have updated the list restricted to the use of Raspberry Pi, but remember that Linux has a huge base of commands.
General Commands
apt-get
Installs, upgrades and uninstalls packages.
First, we will learn to install a package or a language maybe.
1. For example, Pylint is a package for the Python and for installing the package you have to give the above command.
sudo apt-get install pylint
2. This will list the packages it wants to install, tell you how much space it needs for the download, and then get on with it when you tell it to. Sometimes, it asks for Yes/No for upgrading the system. You have to press either Y or N to continue the upgrade.
sudo apt-get upgrade
3. To make sure the system is updated.
sudo apt-get update
4. To clear the previous commands and start over from the beginning
clear
5. To Shutdown the system
poweroff
6. To open the configuration in the Raspberry Pi
raspi-config
7. To reboot the Raspberry Pi
sudo reboot
How do I use sudo last command?
- Simply enter the command again adding sudo before the command.
- Press Up arrow to get the last command and put sudo in front of it.
- Enter sudo !!
8. To shutdown the Pi immediately
shutdown -h now
9. To shutdown the Pi at a specific time period at 11:20 AM
shutdown –h 11:20
10. Opens the Linux text Editor with the new file name file.txt
nano file.txt
11. To find out who you are logged is as
whoami
12. To take a screenshot, that saves in the pi folder.
scrot
13. Lists the currently logged in users
w
14. Obtain information on the Linux computer with the kernel details.
uname -a
uname -r
uname -v
uname -s
- -a an option to see everything
- -s to see the kernal name
- -r to view the release of the kernel
- -v to view the kernel version
15. To set a password for the other user and self. for other user, just use sudo in front of the command.
sudo passwd iot
Here “iot” is the other user
File System
1. To list the files and folders in the current directory
ls
To list the files and folders in the current directory with a detailed listing (long)
ls -l
To include hidden files use the -a
(all files) option
ls -lha
2. echo
The echo
command prints (echoes) a string of text to the terminal window.
echo iot4beginners
The echo
command can show the value of environment variables, for example, the $USER
, $HOME
, and $PATH
environment variables.
echo $PATH
echo $USER
echo $HOME
echo iot4beginners >> out.txt
“iot4beginners” is written and saved as a file named out.txt
3. Creates a new directory named iot4beginners inside the current directory.
mkdir iot4beginners
4. To display the contents of the file
cat out.txt
5. To change the current directory of the some other directory
cd /home/pi
6. To remove or delete the file
rm out.txt
7. To create a new file in the current directory
touch man.txt
8. Removes the entire directory
rmdir iot4beginners
9. To copy the file or the entire directory
cp /home/pi/out.txt /home/pi/Magenta/
Networking Commands
1. To check the status or the ip address of the wired and wireless connection
ifconfig
2. To check the status of the wireless adapter
iwconfig
3. To create a static IP address for the Ethernet adapter
sudo ip a add 192.168.88.xx/24 dev eth0