Linux Commands List
Linux Commands List
The commands from the downloadable cheat sheet are listed below. If you're looking for the must-know commands only and a shorter
cheat sheet, check out Linux Commands All Users Should Know.
lspci -tv Show PCI devices (graphics card, network card, etc.) in a tree-like diagram.
find [path] -name [search_pattern] Find files and directories that match the specified pattern in a specified location.
find [path] -size [+100M] See files and directories larger than a specified size in a directory.
grep [search_pattern] [file_name] Search for a specific pattern in a file with grep.
locate [name] Locate all files and directories related to a particular name.
which [command] Search the command path in the $PATH environment variable.
Page 1 of 11
Command Description
whereis [command] Use the whereis command to find the source, binary, and manual page for a command.
Print all lines matching a pattern in a file. See also the gawk command, the GNU
awk '[search_pattern] {print $0}' [file_name]
of awk.
Note: Some commands are not recommended to use. Learn about them in our list of dangerous Linux commands.
File Commands
File commands help with file and directory management on the system. Create, delete, move, and modify files and directories from
the terminal using the commands in the following table.
Command Description
cp [source_file] [destination_file] Copy the contents of one file to another file using the cp command.
cp -r [source_directory] [destination_directory]
Recursively copy a directory to a second directory.
tail [file_name] Show the last ten lines of a file with the tail command.
less [file_name] Show the contents of a file with navigation using the less command.
nano [file_name] Open or create a file using the nano text editor.
Vi [file_name]
Open or create a file using the Vi/Vim text editor.
vim [file_name]
Page 2 of 11
Command Description
wc -w [file_name] Show the number of words, lines, and bytes in a file using wc.
cut -d [delimiter] [file_name] Cut a section of a file and print the result to standard output.
[data] | cut -d [delimiter] Cut a section of piped data and print the result to standard output.
shred -u [file_name] Overwrite a file to prevent its recovery, then delete it.
source [file_name] Read and execute the file content in the current shell.
[command] | tee [file_name] >/dev/null Store the command output in a file and skip the terminal output.
Note: Want to read more about file creation? Check out our article about how to create a file in Linux using the command line.
And if you want to find out how to determine the type of a file and its data, read the Linux file command article.
ls -a List all files and directories in the current directory (shows hidden files).
cd
Change directory to $HOME.
cd ~
Page 3 of 11
Command Description
gzip [file_name]
Compress or decompress .gz files.
gunzip [file_name.gz]
bzip2 [file_name]
Compress or decompress .bz2 files.
bunzip2 [file_name.bz2]
Note: For a more comprehensive overview of how to use tar refer to our guide tar Command in Linux With Examples. See also how
to unzip tar.bz2 files.
scp [source_file] [user]@[remote_host]:[destination_path] Copy a file to a server directory securely using the Linux scp comman
wget [link] Download files from FTP or web servers via the wget command
sftp [user]@[remote_host] Securely transfer between local and remote hosts using SFTP
Linux is a multiuser system, and there are various commands to add, modify, remove, and manage users and groups. The table below
outlines the critical user and group commands.
Command Description
Page 4 of 11
Command Description
who Display who is currently logged into the system with the who command.
w Show which users are logged in and their activity with the w command.
sudo adduser [user_name] Create a new user account through the adduser command interface.
passwd
Change the current user's password or another user's password with the passwd command
sudo passwd [user_name]
sudo groupmod -n [new_name] [old_name] Modify a user group (change group name).
sudo [command] Temporarily elevate user privileges to superuser or root using the sudo command.
sudo apt-get install [package_name] Install an APT package using the apt-get package utility.
sudo apt install [package_name] Install an APT package using a newer APT package manager.
sudo dpkg -i [package_name.deb] Install a .deb package with the Debian package manager (dpkg command).
Page 5 of 11
Red Hat-Based Distributions (CentOS, Fedora)
Red Hat-based distributions, including CentOS and Fedora, use the yum, dnf, and rpm commands for package installation. The table
below provides the syntax for each option.
Command Description
sudo yum install [package_name] Install a package using the YUM package manager.
yum search [keyword] Find a package in the YUM repositories based on the provided keyword.
sudo dnf install [package_name] Install a package using the DNF package manager.
sudo snap find [keyword] Search for a package in the Snap store.
Note: Check out our comparison between three popular distribution-independent package formats: Flatpak vs. Snap vs. Appimage.
Page 6 of 11
Command Description
trap "[commands]" [signal] Catch a system error signal in a shell script. Executes provided commands when the signal is caught.
wait Pause the terminal or a Bash script until a running process is completed.
Use the terminal to manage the system directly. The commands show how to view basic system information, change options, and
reboot or restart the system.
Command Description
Page 7 of 11
Command Description
Disk usage commands provide insight into disk space status. You can use the df and du commands to check disk space in Linux.
Common disk usage commands are outlined in the table below.
Command Description
fdisk -l Display disk partitions, sizes, and types with the command.
SSH commands enable connecting to a remote host using the SSH protocol. Other commands use this protocol for copying and
transferring files between two systems.
See the table below for common SSH commands. For a detailed explanation of SSH Linux Commands, refer to our SSH Commands in
Linux tutorial.
Page 8 of 11
Command Description
ssh [host] Securely connect to a host via SSH default port 22.
scp [file_name] [user_name]@[remote_host]:[remote_path] Securely copy files between local and remote systems via SSH.
sftp [user_name]@[remote_host] Interactive file transfer over encrypted SSH session using SFTP protocol.
telnet [host] Connect to the host via Telnet default port 23.
File permission commands control user permissions over files and directories. Use these commands to change and manage the owner,
group, and user permissions on the system.
Command Description
chmod 777 [file_name] Assign read, write, and execute file permission to everyone (rwxrwxrwx).
Give read, write, and execute permission to owner, and read and execute permission
chmod 755 [file_name]
group and others (rwxr-xr-x).
Assign full permission to the owner, and read and write permission to the group and othe
chmod 766 [file_name]
(rwxrw-rw-).
chown [user_name] [file_name] Change the ownership of a file with chown command.
The table below shows a brief list of common Linux network commands. For a more comprehensive list, check out our Linux Network
Commands Cheat Sheet.
Description Command
netstat -pnltu See active (listening) ports with the netstat command.
Page 9 of 11
Description Command
netstat -tuln Show TCP and UDP ports and their programs.
dig [domain_name] Show DNS information about a domain using the dig command.
Variable Commands
Shell variables are a convenient way to store critical data in a reusable format. Below are commands to create, view, and remove
variables in the shell.
Command Description
set List the names of all the shell variables and functions.
Create a job to be executed at a certain time (Ctrl+D to exit prompt after you type in th
at [hh:mm]
command).
Page 10 of 11
Command Description
Description
Shortcut
Ctrl + Z Stop the current process. The process can be resumed in the foreground with fg or in the background with bg.
Ctrl + W Cut one word before the cursor and add it to the clipboard.
Ctrl + U Cut part of the line before the cursor and add it to the clipboard.
Ctrl + K Cut part of the line after the cursor and add it to the clipboard.
Ctrl + R Recall the last command that matches the provided characters.
Page 11 of 11