Raspberry Pi programming: commands for Raspberry Pi users

Linux users are dealing with a lot of commands within the terminal interface, which is simple and easy to operate, and despite its simplicity, many users are afraid to start using this system because of them, and when it comes to dealing with Raspberry Pi, users are more afraid, so we will offer A set of commands for Raspberry Pi users that will definitely benefit them when working in a Linux environment.

The most important commands for Raspberry Pi users

General orders:

sudo

It is the command responsible for running the rest of the commands, giving them full read, write, and modify permissions on the system, ie the addictive powers, and by default these permissions are not given to use any of the system commands so you must add the word sudo at the beginning of any command that requires the presence of the administrator of the system.

clear

A simple command used to clear all previous commands and their results.

reboot

A generic command that is used to do a reboot immediately.

find

This is followed by the file name to search for in the system.

Commands for handling folders and files:

Let us first assume that there is a folder named Projects with a folder p1 and p2 and an image named image.png and under the folder p1 there is another folder called bin, and suppose to run the terminal command interface in this folder and execute the following commands:

The ls command

The command used to display a list of folders and files within the current folder. It can be used with the -l extension to display more information about the files and folders displayed such as date, permissions, size, etc.

An example in our case displays the command when executed p1 and p2 and image.png

 The cd command

This command is concerned with moving between folders where it is written and followed by the path of the folder to move to within the Terminal, and to return to the previous folder we write in the path two consecutive points.

Example : cd / p1 / bin to go inside the bin folder.

Example : cd ../ .. to return to the father folder.

Example : cd ~ Returns to the system’s home folder.

The pwd command

This command displays the link for the parent folder of the current folder within the command interface.

Example : In our example, this command displays the link

 / home / root / Projects

The cp command

The task of this command is to copy a file from one place to another.

Example : To copy the image file to the bin folder, we type the command under the command interface under the Projects folder

cp image.png / home / root / Projects / p1 / bin

The chmod command

This command is used to change the pattern of file handling where u is written to specify the public owner, g for a specified set of permissions, o for the remaining users, with the commands r read, w to write, and x to execute.

Example : To change the image handling style and allow it to be read only by all users, we write:

chmod o + r image.png

The chown command

It is one of the important commands and the task is to change the permissions related to the file or folder, where Linux users can determine the permissions for each file to ensure the preservation of folders and files from tampering but must write a password before use, which basically needs access instruction by the user who owns the system so we add In its beginning the floor sudo.

Example : To change the owner to pi and set it to the root of the image image we write:

sudo chown pi: root image

There are many other commands for folders and files that Linux users have to deal with, such as:

  • The command cat: to print the content of a file within the Terminal and has several other uses.
  • Nano: Modifies the content of a file within the Terminal.
  • The mkdir command : followed by the folder name to create a new folder.
  • Rmdir : Rename a folder.
  • The rm command : removes a file.
  • The mv command : Moves a file from one folder to another, similar to the copy command, where the file path is written first and then the desired path.

System-related commands:

The htop command

Used to show the current operations of the system, from processor load, RAM usage and various current processes.

The free command

Used to know the available free space of RAM memory, and -m can be written at the end to display the numbers in one megabyte.

The dmesg command

Used to display internal processes within the Kernal, related to the heart of the system.

The apt command

It is responsible for installing the various programs to manage the programs within the computer, where the command is written and preceded by the command sodu and appended to the name of the program required.

The hostname command

It is used to know the host name and if Raspberry Pi is used, it returns its IP address and is used as hostname -I

Network-related commands:

Ifconfig command

Checks the connection status of your current wireless network.

The iwconfig command

To see which current network is being connected.

The ping command

It is used to verify connectivity to the Internet or a particular site with contact information, and can be simply written and after the site that we would like to call , such as ping name Google . Find & compare

The nmap command

Perform a full scan and view the list of networks, port numbers, connected devices, protocol used, the status of each connection is open or closed, the operating system used, the Mac number and many other information.

The wget command

This is followed by a file link and downloads from this link on the Internet and saves its location.

The iwlist wlan0 scan command

View the list of available wireless networks and you can choose the information to be displayed about these networks using grep. grep ESSID.

Commands for Raspberry Pi users in particular:

The raspistill command

This command is used if there is a camera connected to the device where it takes a snapshot of it and stores it in the form of an image and is used as follows:

 raspistill -o image.jpg

The raspivid command

Same as above, but it is specialized in video instead of images and is used as follows:

raspivid -o video.h264 -t 10000

The raspi-gpio command

This command allows controlling GPIO ports within Raspberry Pi and writes:

raspi-gpio get

raspi-gpio get 20

raspi-gpio set 20 a5 

raspi-gpio set 20 op pn dh

The rpi-update command

Do not use this command unless you fully understand what it is doing and make sure you want it, as it updates everything on Raspberry and can cause harm.

sudo rpi-update

Of course there are a lot of commands for Raspberry Pi users and it is important to understand whatever you use and make sure that everything is OK. To find out more commands for Raspberry Pi users click here.