Useful Raspberry Pi Terminal Commands

This is not intended to be a guide, but rather a list of useful commands that you can run on your Raspberry Pi from the terminal.
Useful Linux commands are practically as limitless as the possibilities of the Raspberry Pi, but I have chosen to collect here the ones I have found most useful over the years.

First of all, to make things easier: if the command described is not available in your distribution, simply install it by running the following in the terminal

sudo apt install -y [command]

and if you can’t find it

apt list [command]*

or

apt search [command]*

and if you run into insufficient permission problems, simply prefix the command with

sudo su

Let’s start with the basics

man [command name] : opens the command’s manual with all the useful information
ls : lists files and folders
cd [path] : changes directory
mkdir [folder name] : creates a folder
touch [file name] : creates an empty file
rm : deletes files or empty directories
cp [path 1] [path 2] : copies files or folders
mv [path 1] [path 2] : moves files or folders, or renames files
nano [file name] : edits text files
cat [file name] : reads text files. Add
| egrep -v "^\s*(#|$)" to hide all commented-out lines
head [file name] : reads the first lines of a text or output
tail [file name] : reads the last lines of a file; essential for logs
grep : essential for searching for text in a file or output
apt : installs, searches for and removes applications, and updates the operating system
ps -aux | grep [program name]: displays and searches for the name of a running process
top or htop : display resource usage by process
killall [process name] : kills all running tasks with that name
kill [pid] : kills a single specific process by its PID
chown [user:group] [file or folder] : changes the owner of files and folders
chmod +x [file] : makes a script executable
chmod : changes the permissions of files and folders
ssh user@computer : connects via SSH to a computer running an SSH server
ufw limit [port] : opens a port on the software firewall, rate-limiting it in case of attacks
ssh-copy-id user@computer : adds your personal key to the remote host, so you can log in without a password
rsync : copies files and folders; useful for backups, and combined with ssh-copy-id it makes remote backups easy
hostname -I : displays all of the Raspberry Pi’s IP addresses
lsusb : displays all USB devices; useful for checking Wi-Fi dongles
iwconfig and ifconfig : check the status of network adapters
tar -zxvf [file.tar.gz] : extracts archives
du and df : display used disk space
ping [ip or host] : sends packets to see whether a host responds
nmap : scans the network
curl and wget : send and download data
ctrl + l : clears the terminal
page down: types the tilde ~
ctrl + r : searches the history of previously run commands
pip and pip3 : manage Python 2 and Python 3 modules respectively
openssl rand -base64 10 : generates a random value
certbot : enables certificates for local websites

Enjoy!

Leave a Comment

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

Scroll to Top