LINUX TERMINAL COMMANDS CHEAT SHEET
Application and Process
whereisLocate the binary, source, and manual page files for a command.
whichGet the full path to a command's executable file.
aptSearch, install, remove, and update packages and dependencies for Debian, Linux Mint, Ubuntu.
dnfSearch, install, remove, and update packages and dependencies for Fedora, CentOS, and Red Hat Enterprise Linux (RHEL).
pacmanSearch, install, remove, and update packages and dependencies for Arch Linux, CachyOS, Manjaro.
zypperSearch, install, remove, and update packages and dependencies for openSUSE.
Console and Output
catDisplay file contents on the terminal.
clearlear the terminal display.
echoPrint text or variables in the terminal.
topGet information about running processes.
Environment Variables
envDisplay all environment variables running on the system.
exportExport environment variables.
printenvPrint a particular environment variable to the console..
sourceExecute commands stored in a file from within the current shell, or refresh environment variables.
Files and Directories
cdChange to another directory.
cpCopy the contents of the source directory or file to a target directory or file.
findLocate a file or directory by name.
grepSearch for a string within an output.
lsList the contents of a directory.
mkdirCreate directories.
moreView and traverse the content of a file or stdout.
mvMove or rename files.
pwdGet the name of the present working directory.
rmDelete files or directories.
tarExtract and compress files.
Documentation and Help
manAccess manual pages for all Linux commands.
tldrCollaborative cheatsheets for console commands. Website | GitHub
wikimanOffline search engine for manual pages, Arch Wiki, Gentoo Wiki and other documentation. GitHub
Network
curlGet or post a file to or from the Internet according to a URL.
ipGets the IP information for the physical or virtual machine.
netstatGet information about network connections and more.
sshEstablish a secure encrypted connection between two hosts over an insecure network.
wgetDirect download files from the Internet.
Process
&&Execute commands in a sequence.
killRemoves a running process from memory.
psDisplay active processes.
Sound
alsamixeralsamixer is an ncurses mixer program for use with the ALSA soundcard drivers. It supports multiple soundcards with multiple devices.
System
poweroffShut down a computer.
rebootRestart a computer.
restartRestart a computer.
User
whoamiDisplay the user ID.
FILE NAVIGATION
List directories (with type indicator)
ls --file-type
Change directory to "example"
cd example
Move up one directory
cd ..
Move up two directories
cd ../..
Change to home directory
cd ~
Get absolute path to a file or folder
readlink -f example
Get file type of "example.ext"
file example.ext
FILE MANAGEMENT
Copy a file in place
cp example.txt example-1.txt
Copy a file to Documents
cp example.txt ~/Documents/example-1.txt
Move a file to Documents
mv example.txt ~/Documents
Remove a file
rm example.txt
Create a directory (folder)
mkdir example
Remove an empty directory
rm example
Remove a directory recursively
rm -r example
Permanently delete a file (secure)
shred example.txt
Download a file from a network location
wget https://example.com/file
SOFTWARE MANAGEMENT
- On Arch based systems: [COMMAND] is pacman and it does not follow the same format. Check the documentation.
- On Fedora: [COMMAND] is dnf
- On Debian based systems, Linux Mint, Ubuntu: [COMMAND] is apt
- On OpenSUSE: [COMMAND] is zypper
- Other distributions may use different commands
Search for an application called example
sudo [COMMAND] search example
Install an application called example
sudo [COMMAND] install example
Uninstall an application called example
sudo [COMMAND] remove example
SERVICES MANAGEMENT
"example" can be bluetooth
Start services
sudo systemctl start example
Restart services
sudo systemctl restart example
Stop services
sudo systemctl Stop example
Get status of services
sudo systemctl status example
Enable services
sudo systemctl enable --now example
Disable services
sudo systemctl disable --now example
SYSTEM MANAGEMENT
Get system, machine, CPU and GPU info
inxi -MSCG
Reboot and enter BIOS/UEFI
systemctl reboot --firmware-setup
APPLICATIONS & TOOLS
CryFS - Keep your data safe in a vault
CryFS encrypts your files, so you can safely store them anywhere. It works well together with cloud services like Dropbox, iCloud, OneDrive and others.
Setup an encrypted directory (vault)
Once installed, you can create an encrypted directory by calling cryfs basedir mountdir in the terminal. You can name the directories like you want, basedir and mountdir are used for demonstration purposes. If the corresponding directories don't exist yet, CryFS will offer to create them for you.
cryfs basedir mountdir
Mount the encrypted directory
The command below will mount the mountdir, in other words, open the vault, where you put your files.
cryfs basedir mountdir
Unmount the encrypted directory
The command below will unmount mountdir, in other words, close the vault and secure the access of your files.
cryfs-unmount mountdir
Summary
basedir is the directory where your files are encrypted.
mountdir is a virtual unencrypted representation of your vault, this is where you add or remove files and directories.
dmidecode
dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision.
sudo dmidecode -t 1
BIOS version
sudo dmidecode -s bios-version
Baseboard / Motherboard info
sudo dmidecode -t 2
fwupdmgr - firmware update manager client utility
fwupdmgr is a command line fwupd client intended to be used interactively. The output between versions of fwupd is not guaranteed to be stable.
[i] Install fwupd first if is not on your system yet: apt install fwupd
fwupdmgr get-devices
Refresh metadata from remote server
fwupdmgr refresh
Gets the list of updates for connected hardware
fwupdmgr get-updates
Updates all devices to latest firmware version
fwupdmgr update
efibootmgr
efibootmgr is a userspace application used to modify the UEFI Boot Manager. This application can create and destroy boot entries, change the boot order, change the next running boot option, and more.
sudo efibootmgr
inxi
inxi is a command line system information script built for console and IRC. It is also used a debugging tool for forum technical support to quickly ascertain users' system configurations and hardware. inxi shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, gcc version(s), Processes, RAM usage, and a wide variety of other useful information.
inxi -b
Get Audio info
inxi -A
Get Battery info
inxi -B
Get CPU info
inxi -C
Get Full info
inxi -F
Get GPU info
inxi -G
Get Machine and System info
inxi -MS
lsblk
lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information.
lsblk
Output info about filesystems
lsblk -f