Linux Commands Cheat Sheet

Auto Update

sudo apt update        # Fetches the list of available updates
sudo apt upgrade       # Installs some updates; does not remove packages
sudo apt full-upgrade  # Installs updates; may also remove some packages, if needed
sudo apt autoremove    # Removes any old packages that are no longer needed
sudo bash -c 'for i in update {,full-}upgrade auto{remove,clean}; do apt-get $i -y; done'

Linux Commands

System ManagementNetworking Commands
CD < Basic Commands>
Changes directory, go to the specified folder
Example
Absolute path: cd /home/pat/test
Relative path: cd test
ssh <user>@<192.168.0.141>:
Connects to another machine via SSH.
PWR
Displays the current working directory
Example
pwr
ifconfig:
Displays network configuration details.
apt-get update:
Updates the list of available packages and their versions.
ping <ip>:
Sends a ping packet to check if a host is reachable.
apt-get upgrade:
Upgrades all installed packages to their latest versions.
reboot:
Reboots the Raspberry Pi.
lsblk:
This will show you a list of all the drives available on your Pi 
  • C D < Basic Commands>

Changes directory, go to the specified folder

Example
Absolute path: cd /home/pat/test
Relative path: cd test
  • PWR

Displays the current working directory

Example
pwr
  • mkdir <folder>

Creates a new directory

Example
mkdir Test
  • rmdir <folder>

Removes an empty directory

Example
rmdir Test
  • touch <file>

Creates a new empty file

Example
touch test.conf
  • lsblk <System>

This will show you a list of all the drives available on your Pi 

Example
lsblk
  • L S <Basic Commands>

Lists files and directory, in the current or
specified folder

Example
Current directory: ls
Specific: ls /home/pat/test
  • Tree <Basic Commands>

Another tool to get details on your current
location, in a tree format

Example
Current directory: tree
Specific folder: tree /home/pat/
  • rm <file>

Deletes the specified file

Example
rm test.conf
  • cp <source> <destination>

Copies a file or directory to another location

Example
cp <source> <destination>
  • mv <source> <destination>

Moves or renames a file or directory

Example
mv <source> <destination>
System ManagementNetworking Commands
poweroff:
Shuts down the Raspberry Pi immediately.
ssh <user>@<192.168.0.141>:
Connects to another machine via SSH.
sudo raspi-config:
Opens the configuration settings menu for system settings.
ifconfig:
Displays network configuration details.
apt-get update:
Updates the list of available packages and their versions.
ping <ip>:
Sends a ping packet to check if a host is reachable.
apt-get upgrade:
Upgrades all installed packages to their latest versions.
reboot:
Reboots the Raspberry Pi.
lsblk:
This will show you a list of all the drives available on your Pi 
GPIO Commands (for Raspberry Pi GPIO control)
gpio read <pin>:
Reads the value from a specified GPIO pin.
gpio write <pin> <value>:
Sets the value of a specified GPIO pin (0 or 1).
Additional Useful Commands
df -h:
Shows disk space usage in a human-readable format.
cat <file>:
Displays the content of a specified file.
nano <file>:
Opens a file in the Nano text editor for editing.
wget <url>:
Downloads files from the internet.
cat [name]:
Show the contents of the file [name]
cd ..
Change to parent directory
cd [path]:
Move to the directory at [path]
cd /:
Change to root directory
cd ~:
Change to your home directory – usually “/home/”