Sometimes it’s hard to keep track of all the Raspberry Pi commands you use, so I created a list of some of the most useful and important ones that will make using Linux on the Raspberry Pi a lot easier. But first a quick note about user privileges…
There are two user “modes” you can work with in Linux. One is a user mode with basic access privileges, and the other is a mode with administrator access privileges (AKA super user, or root). Some tasks can’t be performed with basic privileges, so you’ll need to enter them with super user privileges to perform them. You’ll frequently see the prefix sudo before commands, which means you’re telling the computer to run the command with super user privileges.
An alternative to entering sudo before each command is to access the root command prompt, which runs every command with super user privileges. You can access root mode by entering sudo su at the command prompt. After entering sudo su, you’ll see the [email protected]:/home/pi# command prompt, and all subsequent commands will have super user privileges.
Most of the commands below have a lot of other useful options that I don’t mention. To see a list of all the other available options for a command, enter the command, followed by – –help.
- apt-get update: Synchronizes the list of packages on your system to the list in the repositories. Use it before installing new packages to make sure you are installing the latest version.
- apt-get upgrade: Upgrades all of the software packages you have installed.
- clear: Clears previously run commands and text from the terminal screen.
- date: Prints the current date.
- find / -name example.txt: Searches the whole system for the file example.txt and outputs a list of all directories that contain the file.
- nano example.txt: Opens the file example.txt in the Linux text editor Nano.
- poweroff: To shutdown immediately.
- raspi-config: Opens the configuration settings menu.
- reboot: To reboot immediately.
- shutdown -h now: To shutdown immediately.
- shutdown -h 01:22: To shutdown at 1:22 AM.
- startx: Opens the GUI (Graphical User Interface).
File and Directory Commands
- cat example.txt: Displays the contents of the file example.txt.
- cd /abc/xyz: Changes the current directory to the /abc/xyz directory.
- cp XXX: Copies the file or directory XXX and pastes it to a specified location; i.e. cp examplefile.txt /home/pi/office/ copies examplefile.txt in the current directory and pastes it into the /home/pi/ directory. If the file is not in the current directory, add the path of the file’s location (i.e. cp /home/pi/documents/examplefile.txt /home/pi/office/ copies the file from the documents directory to the office directory).
Read more: 42 of the Most Useful Raspberry Pi Commands