Have you been working on your Raspberry Pi, but you have no idea what to type into the terminal? This article’s got you covered
What is a Linux command?
A Linux command is a program or utility that runs on the command line. This means that you can type Linux commands in a terminal of a computer or Raspberry Pi. A Linux command can do anything from shutting down or restarting the computer, making, moving, or deleting files, viewing information, or even installing and setting up programs, so here are the following most useful and most used Linux commands that I use very often.
Most used and useful Linux commands
- ls – The #1 most used command in Linux. This command lists the directory in the home folder. For example, if you wanted to set up a headless Raspberry Pi, (No display), then you could SSH into the Raspberry Pi and find your files using the terminal.
- cd – Linux command to navigate through directories. Let’s imagine you have a python script you want to execute via terminal. There’s no mouse or cursor to navigate folders, so you can use cd. The python script you want to execute is at /home/pi/python/script.py. You can do “cd /home/pi/python”, and then “python script.py, to execute the script that’s inside the python folder.
- mkdir – Used to create directories in Linux. A directory is basically a folder to contain specific files. Using the example above, to create the “python” folder/directory to put the python file inside.
- mv – Used to move or rename files in Linux. Pretty self explanatory. Whatever file you want to move, this command can do it.
- rm – Delete files or directories. Also pretty self explanatory. This command removes whatever file or folder you tell it to.
- clear – Clear the terminal display. This command is pretty useful when your terminal is messy and full of text.
- apt-get – This command helps install packages and software to Linux. This is especially useful in Raspberry Pi OS, which is based off Linux
- reboot and restart – Reboots or restarts the computer. What more is there to say?
- ssh – Secure Shell command. This command isn’t limited to just Linux, as it is very popular among operating systems, like Windows, Mac OS, and Raspberry Pi OS. This commands lets you log into another computer’s terminal, and yes, some hackers use ssh to hack into a computer. For example, if I have just set up a Raspberry Pi, but don’t have a display for it, I could just SSH into the Pi and control it without needing an external display.
- sudo – Stands for “super user do”, and does exactly what it sounds like. Sudo is basically an admin command, which lets it do anything, unless the profile you are in has limited sudo access. Many commands listed before this (#1-9) needs to have sudo before the command. For example, you have to do “sudo apt-get *package_name*”
- *Special to Raspberry Pis* raspi-config – Runs the Raspberry Pi config in the terminal. This command is really useful when setting up a new Pi.
Commands are really useful when using any Linux based Operating System like Raspberry Pi OS, especially as a maker. Of course, there are hundreds of other individual commands that can be altered, changed, and added onto. Hopefully, this very basic guide leads you to the wonderful world of Linux commands and will help you navigate and use your Raspberry Pi even better.