40 OF THE MOST USEFUL RASPBERRY PI COMMANDS

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.



GENERAL COMMANDS

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 examplefile.txt /home/pi/office/
Copies examplefile.txt in the current directory and pastes it into the /home/pi/office directory.


ls -l
Lists files in the current directory.


mkdir example_directory
Creates a new directory named example_directory inside the current directory.


mv examplefile.txt /home/pi/office/
Moves examplefile.txt in the current directory to the /home/pi/office directory.


rm example.txt
Deletes the file example.txt.


rmdir example_directory
Deletes the directory example_directory (only if it is empty).


touch example.txt
Creates a new, empty file named example.txt in the current directory.



NETWORKING AND INTERNET COMMANDS

ifconfig
To check the status of the wireless connection you are using (to see if wlan0 has acquired an IP address).


iwconfig
To check which network the wireless adapter is using.


iwlist wlan0 scan
Prints a list of the currently available wireless networks.


nmap
Scans your network and lists connected devices, port number, protocol, state (open or closed) operating system, MAC addresses, and other information.


ping
Tests connectivity between two devices connected on a network. For example, ping 10.0.0.32 will send a packet to the device at IP 10.0.0.32 and wait for a response. It also works with website addresses.


wget http://www.website.com/example.txt
Downloads the file example.txt from the web and saves it to the current directory.



SYSTEM INFORMATION COMMANDS

cat /proc/meminfo
Shows details about your memory.


cat /proc/partitions
Shows the size and number of partitions on your SD card or hard drive.


cat /proc/version:
Shows you which version of the Raspberry Pi you are using.


df -h
Shows information about the available disk space.


df /
Shows how much free disk space is available.


dpkg – –get–selections | grep XXX
Shows all of the installed packages that are related to XXX.


dpkg – –get–selections
Shows all of your installed packages.


free
Shows how much free memory is available.


hostname -I
Shows the IP address of your Raspberry Pi.


lsusb
Lists USB hardware connected to your Raspberry Pi.


UP key
Pressing the UP key will print the last command entered into the command prompt. This is a quick way to repeat previous commands or make corrections to commands.


vcgencmd measure_temp
Shows the temperature of the CPU.


vcgencmd get_mem arm && vcgencmd get_mem gpu
Shows the memory split between the CPU and GPU.




Hopefully this list of commands will make navigating Linux on your Raspberry Pi more efficient and enjoyable. If you have any other commands that you use a lot, you can tell me via Email: info@danykilian.com or use my contact form And be sure to subscribe to my newsletter to get an email when I publish new articles!