These are the most common commands used on a Raspberry Pi

commands

If you have ever gotten to work and configure your Raspberry Pi, surely you have lost yourself among the enormous amount of commands that exist, there are many that you must learn by heart or, at least, always have them on hand in a list so that you can consult them when you need it. With this in mind, today I have proposed to create a list with the most frequent ones, some you surely know and others perhaps not so much.

Before continuing, keep in mind that in Linux there are two different types of users. access the Terminal, one is the user 'normal'with basic access permissions and the other is the mode known as root or superuser you can practically do whatever you want. At this point you have to be especially careful since, when I say 'what you want'is literally whatever you want with all that that means, such as deleting files that literally make the operating system useless.

Obviously, some of the commands to be used cannot be launched by a basic user, so you will need superuser permissions to be able to execute these commands, so it will be quite common that you see the prefix sudo in front of the specific command. Another way to access the superuser without having to put sudo in front of all the commands is to execute the command sudo su and put the password of it. Once we have changed user we can see at the command prompt something like root @ raspberrypi: / home / pi #In this way, it will no longer be necessary to put the sudo prefix in front of each command.

With this little clarification, I will now list the commands that I personally think are necessary and especially useful when configuring or working with our Raspberry Pi:

Related article:
Create your own arcade machine with Raspberry Pi

General Commands:

  • apt-get update: Update your version of Raspbian.
  • apt-get upgrade: Update all the packages that you have installed in the system.
  • clear: clears the terminal window.
  • data: Shows the current date.
  • find / -name test.txt: Searches the entire system for the test.txt file and generates a list of all the directories that contain the file.
  • nano test.txt: Open the file test.txt in "Nano", the Linux text editor.
  • poweroff: Shut down the system immediately.
  • raspi-config: Open the settings menu.
  • reboot: Restart the system immediately.
  • shutdown-h now: Shut down the system immediately.
  • shutdown -h 18:34: Shut down the system at 18:34.
  • startx: Opens the graphical user interface.

Commands for files and directories:

  • cat test.txt: Displays the content of the test.txt file.
  • cd / abc / xyz: Changes the current directory to the / abc / xyz directory.
  • cp XXXCopia el archivo o directorio XXX y lo pega en una ubicación especificada. An example of this command would be: cp fichero.txt /home/pi/fichero.txt en el directorio actual y lo pega en el directorio /home/pi/. Si el archivo no está en el directorio actual debes poner la dirección donde se encuentra.
  • Ls -l: Shows a list with the files present in the current directory as well as other interesting information such as the file size, the modification date and the permissions.
  • mkdir test_folder: Create a new folder test_folder within the current folder.
  • mv XXX: Move the file or folder named XXX to a specific location. An example of this command would be: mv file.txt / home / pi which would move file.txt present in the current folder to the address / home / pi. If the file that we want to move is not in the folder where we are, we have to add its full address. This command can also be used to rename files or folders, all we have to do is move them in the same directory but with a different name, for example: mv file.txt test.txt would rename the file file.txt as test.txt.
  • rm test.txt: Delete the file test.txt
  • rmdir test_folder: Delete the folder test_folder. This action can only be taken if the folder is empty.
  • scp user@10.0.0.32: /some/path/file.txtCopia un archivo a través de SSH. Se puede utilizar para descargar un archivo de un ordenador remoto a nuestra Raspberry Pi. User@10.0.0.32 es el nombre de usuario y la dirección es la IP local del ordenador remoto y /ruta/path/archivo.txt es la ruta y el nombre de archivo del archivo en el ordenador remoto.
  • touch: Create a new empty file in the current directory.

Commands for network configuration:

  • ifconfig: Used to check the status of the wireless connection we are using, for example to see if wlan0 has an IP address assigned or not.
  • iwconfig: To check which network we are connected to wirelessly.
  • iwlist wlan0 scan: Displays a list of all available wireless networks.
  • iwlist wlan0 scan | grep ESSID: If to the previous order we add | grep together with the name of a field, the system will show us only the field we need on the screen. Using the example command, only the ESSID field will be listed.
  • Nmap: Scan your network and list the connected devices, the port number, the protocol, the operating system, the MAC addresses ...
  • pingPrueba la conectividad entre dos dispositivos conectados a una  misma red. Por ejemplo, ping 10.0.0.32 enviará un paquete al dispositivo con IP 10.0.0.32 y esperará una respuesta. También funciona con las direcciones de sitios web lo que nos puede ayudar a saber si tenemos conexión a la red o no utilizando, por ejemplo, ping www.google.es
  • wget http://www.miweb.com/test.txt: Download the test.txt file from the website www.miweb.com and save it in the current directory.
Related article:
Configure your Raspberry Pi as a web server

System information commands:

  • cat / proc / meminfo: Shows information about our memory system.
  • cat / proc / partitions: Displays the size and number of partitions on the SD card or hard disk.
  • cat / proc / version: Shows us the version of the Raspberry Pi that we are using.
  • df -h: Displays the available space on the disc.
  • df /: Shows how much free disk space is available.
  • dpkg –get-selections | grep XXX: Shows all installed packages related to XXX.
  • dpkg –get-selections: Gives information about all installed packages.
  • free: Shows the amount of free memory available in the system.
  • hostname -I: Shows the IP address of our Raspberry Pi.
  • lsusb: It offers us information about all the USB devices connected to our Raspberry Pi.
  • UP keyAl pulsar la tecla UP se introduce el último comando ingresado en el símbolo del sistema. Esta es una manera rápida de corregir los comandos que se hicieron en error.
  • vcgencmd measure_temp: Displays the CPU temperature.
  • vcgencmd get_mem arm && vcgencmd get_mem gpu: Shows the memory divided between CPU and GPU.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.