Raspberry Pi Bash Command Cheat Sheet
on
There are many commands and most commands accept all sorts of parameters and arguments. To find out what a command is all about you can add ‘--help’ (two dashes) to it, e.g.:
In the following ‘[path]’ refers to a relative or absolute path. An absolute path starts with ‘/’, e.g.
Please note that the table below is not exhaustive and your favourite commands may be missing. You can add remarks, other commands and tips & tricks as a comment below this article.
|
pwd
|
Display the name of the current working directory. |
|
ls
|
List the content of the current directory. |
|
ls [path]
|
List the content of the specified directory. |
|
ls -l
|
List the content of the current directory with additional information. |
|
ls -a
|
List all files including hidden files beginning with ‘.’ (i.e. dotfiles). |
|
cd [path]
|
Change the current directory to [path]. |
|
cd ..
|
Change to parent directory (note the space between ‘cd’ and ‘..’). |
|
cd /
|
Change to root directory (note the space between ‘cd’ and ‘/’). |
|
cd ~
|
Change to home directory (determined by $HOME environment variable). |
|
mkdir [name]
|
Create the directory [name] in the current working directory. |
|
rmdir [name]
|
Remove the empty directory [name] from the current working directory. |
|
rm [name]
|
Remove the specified file. |
|
rm *
|
Remove all the files from the current working directory. |
|
rm -r *
|
Remove all the files and directories from the current working directory. |
|
cp [from] [to]
|
Copy a file from source [from] to destination [to]. |
|
cp -r [from] [to]
|
Copy everything including directories from source [from] to destination [to]. |
|
mv [from] [to]
|
Move a file from source [from] to destination [to]. |
|
mv -r [from] [to]
|
Move everything including directories from source [from] to destination [to]. |
|
find
|
Search for files matching certain patterns. |
|
sudo [command]
|
Superuser do. Execute [command] with elevated privileges. Allows you to do things you are not entitled to. Common examples include: |
|
sudo raspi-config
|
Launch the Raspberry Pi configuration tool. |
|
sudo reboot
|
Safely restart your system. |
|
sudo shutdown -h now
|
Safely shutdown your system now. |
|
sudo apt-get install [package]
|
Install a package. |
|
sudo apt-get update
|
Update the list of packages without installing anything. |
|
sudo apt-get upgrade
|
Upgrade the installed packages to the versions obtained with ‘apt-get update’ |
|
sudo chown pi:root [name]
|
Change the owner of [name] to 'pi' and set the group to 'root'. |
|
sudo su
|
Become Superuser for more than one command. |
|
sudo ku
|
Undocumented. |
|
cat [name]
|
Show the contents of a file. |
|
head [name]
|
Show the beginning of a file. |
|
tail [name]
|
Show the end of a file. |
|
chmod [who][+,-,=][permissions] [name]
|
Change the permissions for a file. |
|
chmod u+x [name]
|
Add execute permission for the owner of the file. |
|
chmod 777 [name]
|
Allow every user to read, write and execute the file [name]. |
|
tar -cvzf [name] [path]
|
Create compressed file [name] from the contents in [path]. |
|
tar -xvzf [name]
|
Extract the contents of a compressed file. |
|
wget [uri]
|
Download a file from the Internet. |
|
man [command]
|
Show the manual page for a command. |
|
man man
|
View the manual page of the ‘man’ command. |
|
grep ‘string’ [name]
|
Search inside one or more files for occurrences of ‘string’. |

Discussion (0 comments)