99 Commands for Linux Administrators
Linux is well-known for its extensive command line operations, which are backed by a huge number of commands. From navigating inside your own system to analyzing networks and connecting to systems remotely, all this is possible using Linux commands. No need for a GUI.
Because of its command line operations and secure operability than the new world, Linux systems are also well-liked for their security, and that’s why more than 90% of the servers in the world are Linux-based.
Keeping all this in view, today, I have compiled a list of 99 Linux commands for Linux administrators.
99 Commands for Linux Administrators
These 99 Linux commands are broadly categorized into four categories. Let’s first start with the basic commands for files, directories, and disk management:
File, Directory, and Disk Management Commands
- ls
Lists files and directories in the current working directory or the provided directory path.
ls [Options] [File]
- pwd
This command shows the absolute path of the present location in a Linux file system.
pwd [option]
- cd
Changes the working directory to any other directory whose path is provided.
cd [directory-name/path]
- history
This command prints the recently used commands on the terminal.
history [option]
- clear
Clears the terminal screen.
clear [option]
- cp
Copies the files or directories.
cp [option] [source] [destination]
- mv
This command serves two purposes, i.e., to move the files/directories or to rename them.
mv [source] [destination]
- touch
Creates a new blank file in the current directory or in the provided address.
touch [option] [file]
- cat
Shows the content of the file in the terminal.
cat [option] [file]
- head
Retrieves the top 10 rows of a file (the output can be printed on the terminal or extracted in a file):
head [option] [file]
- tail
Retrieves and prints the 10 rows from the bottom of the file.
tail [option] [file]
- echo
Prints the variable’s value or the text line.
echo [option] [string]
- lsof
Shows a list of open files engaged by any process.
lsof [option]
- file
This command provides the file type by examining the content of the file.
file [option] [file]
- nano
This is a command-line text editor to make changes to a file.
nano [options] [file]
- vim | vi
These two command-line editors belong to the same family, i.e., vi. Vim is based on vi and is more advanced and interactive than vi.
vim [option] [file]
vi [option] [file]
- sort
Arranges the data in a specific order, i.e., ascending or descending, to analyze or use the data for a specific purpose.
sort [option] [file]
- uniq
Fetches only unique data (rows) from the file.
uniq [option] [file]
- wc
Prints the number of lines, words, and characters.
wc [option] [file]
- cmp
This command compares two files and shows the first difference encountered.
cmp [option] [file1-file2]
- diff
Prints the content of the files one after another on the terminal.
diff [options] [file1,file2]
- find
The find command searches the file by navigating through the filesystem tree structure. It is an effective but time-consuming search.
find [path] [option] [expression]
- locate
This locate command searches for a file inside an index file (generated through the updatedb command). This is a fast search as compared to the find operation. Before using, ensure that the index file is updated.
locate [option] [file-pattern]
- wget
This command usually retrieves files from remote servers or downloads files over HTTPS/HTTP.
wget [Option] [URL]
- curl
Transfers (uploads/downloads) the data on the local server. Also, a useful utility for website and API testing.
curl [Option] [URL]
- rm
Removes the files and the directories (empty/non-empty).
rm [option] [file]
Important: This command recursively deletes the files, so be very careful while using the rm with the “rf” flag.
- mkdir
Creates a new directory in the current directory or at the provided path.
mkdir [option] [directory]
- rmdir
Removes empty directories only.
rmdir [option] [directory]
- chmod
This command changes or modifies the permissions of the files or directories.
chmod [option] [mode] [file-directory]
- chown
The command changes the ownership of the file or the directory.
chown [option] [username][:[group]] file
- df
The command shows the list of mounted drives on the system and the free space on each of the disks.
df [option] [file]
- du
Contrary to df, this command shows the disk usage on each of the disks of the system.
du [option] [file]
- dd
This command duplicates (copies) data, changes the format, or creates the image of a storage drive.
dd [option | operand]
- free
This command lists the total, used, free, and available memory (RAM). Alongside that, it also displays the swap space.
free [option]
- grep
This command searches for a text or a textual pattern and prints the matched one on the terminal.
grep [option] [pattern file]
- sed
A strong command to filter or make changes to the text.
sed [option] [script] [input-file]
- awk
This command processes and extracts data from the text files. The data can be altered and printed on the terminal.
awk [pattern/option] [file]
- tar
Used to create or extract an archive of multiple files in a .tar format.
tar [option] [file]
- zip
zip compresses files in a .zip format.
zip [option] [zip-name] [file1,file2]
- unzip
The unzip command decompresses the files of the .zip format.
unzip [option] [zip-file]
- gzip
gzip compresses the files in .gz format.
gzip [option] [file]
- gunzip
gunzip extracts the files of a .gz format.
gunzip [option] [gzip-file]
- fsck
This command checks the filesystem and repairs any solvable problems with the filesystem.
fsck [option] [filesystem]
- ln
Creates a symbolic link to the files or the executables.
ln [option] [target] [link-name]
- fdisk
This command lets you manage the disk partitions, i.e., creating partitions, organizing drives, and transferring data between drives.
fdisk [option] [disk]
- mkfs
Creates a filesystem on the disk, i.e., partition, and it could be in ext4, xfs, or fat.
mkfs [option] [device]
- parted
This command manages (creates, changes, deletes) partitions on a storage drive.
parted [option] [device]
- umask
This command changes the default permissions with some mask value chosen by the user, i.e., the mask value is a permission denoted in octal values.
umask [octal-permission-value]
- mount | umount
The mount allows you to access a filesystem, and umount detaches the filesystem from the directory.
mount [option] [device] [directory]
umount [option] [source] [directory]
User and Group Management Commands
- adduser
The adduser command adds a new user with additional details, i.e., Password, Full Name, and Phone No.
adduser [option] [username]
- useradd
This command just creates a new user. Unlike the adduser command, it does not create a user with a password or full name, or other info by default.
useradd [option] [username]
- usermod
Modifies the user accounts and supports a large number of parameters that can be modified.
usermod [option] [username/login]
- deluser
Deletes the user profile, data, and account from the Linux system.
deluser [option] [username/login]
- who
This shows the name of the logged-in user, the process associated with it, and the logged-in time.
who [option] [file | argument]
- w
This command also shows the logged-in user but with detailed info, i.e., process, logged in time, total uptime, total idle time, shell.
w [option] [username/login]
- addgroup
Adds a user to a specific group.
addgroup [option] [user]
- groupadd
Creates a new group.
groupadd [option] [group-name]
- groups
Shows the groups associated with the logged-in user or any user on the system.
groups [option] [username]
- groupdel
This command deletes a mentioned group.
groupdel [option] [group]
- gpasswd
This command manages the group, i.e., password and adding/removing the group members.
gpasswd [option] [group]
- id
Prints the UserID, primary Group ID, and IDs of all other associated groups of that user.
id [option] [username/login]
- passwd
Modifies or sets the password for a user account. By default, this command changes/sets the password of the currently signed-in user.
passwd [option] [username/login]
- chage
This command allows you to change the user password expiration policy.
chage [option] [username/login]
- su
Switches the user to a specific user account.
su [option] [user]
Process and System Monitoring Commands
- uname
This command, by default, prints the Kernel name. Its usage can be extended with options to get further Kernel and system info.
uname [option]
- ps
Lists down the currently running processes.
ps [option]
- ps aux
This command provides more details on the processes as compared to ps, i.e., the user associated with each process, the start time, the memory consumption, the total running time, command associated with each process.
ps aux
- chroot
This command changes the root directory of processes/sub-processes, i.e., separate from the Linux system.
chroot [option] [newroot] [command]
- pkill
The pkill command kills the process with its name or a regular expression to match a specific process.
pkill [option] [process/program]
- pidof
Get the process ID of the running process.
pidof [option] [process/program]
- top | htop (interactive version of top)
Lists the number of running processes in a more detailed and interactive way.
top [option]
htop [option]
- uptime
This command shows the total uptime (how long the system has been up and running), the logged-in user, and the total load.
uptime [option]
- systemctl
This utility manages the services and the units on the system.
systemctl [option] command [unit]
- journalctl
This command prints the logs from the systemd journal. The logs are maintained from the first session and are useful to check for any service failures or boot history.
journalctl [option] [matches]
- crontab
This command automates repetitive tasks (shell scripts or jobs). The tasks can then be run in the background or the foreground automatically.
crontab [-u user] file
- at | batch
These commands are used to schedule a job/task for one time only.
at [option]
batch [option]
- alias
Create a command alias (shortcuts or second name):
alias [option] [name=value]
- unalias
Removes the set alias:
unalias [set-alias]
- env | export
These commands refer to viewing or setting environment variables.
env [option] [name=value] [command]
export [option] [name=value]
Network Management Commands
- ifconfig
The ifconfig command prints information about the network interfaces.
ifconfig [option] [interface]
- ping
This command is used to check whether an IP address/domain is live (working fine). It sends the packets to a specific IP address or the domain associated with it.
ping [option] [destination]
- hostnamectl
Manages the system hostname, i.e., changing, viewing all types of hostnames.
hostnamectl [option] [command]
- hostname
By default, this command prints the hostname. However, it can be used to set the hostname temporarily.
hostname [option]
- dig
A troubleshooting and info collection tool that queries the DNS to get information about domain names, MX records, NS records, etc.
dig [host/ip-address] [domain-name] [record-type]
- host
This command is used for DNS lookups, i.e., DNS records retrieval, resolving the domain name / IP mapping issues.
host [name] [server]
- nslookup
This command queries the DNS and looks up the mapping of IP addresses and domains.
nslookup [option] [name] [server]
- ip
This command shows the IP addresses (IPv4 and IPv6) associated with each of the network interfaces.
ip [options] [command]
- iostat
This command shows you the stats of the input/output activity of the disk and the CPU load.
iostat [options] [interval] [count]
- vmstat
The vmstat command denotes the stats of the memory usage, CPU activity, processes, input/output, and swap info.
vmstat [options] [delay [count]]
- tcpdump
Captures the network traffic of a specific network interface or the network as a whole.
tcpdump [option] [interface]
- nmcli
This is the command line interface to manage the network, i.e., configure the IP addresses, set the hostname, and manage the network interfaces.
nmcli [option] [object] [command]
- nmtui
This command triggers the terminal user interface of the network manager. This can be used to manage the hostname, IP address, and network connections.
nmtui
- iptables
This iptables command manages the firewall rules to control the network traffic based on IP addresses, ports, and protocols.
iptables [-t table] {-A|-C|-D} chain rule-specification
- ufw
This ufw utility manages the firewall operations within the Linux system. Firewall rules can also be managed using ufw.
ufw [command]
- ssh
This ssh command is used to manage the remote connections carried out through Secure Socket Shell (SSH) protocol.
ssh username@hostname/ip-address
- sftp
Securely transfers files/data over a network (uses the advanced encryption of SSH).
sftp [destination]
- scp
This scp command allows you to securely copy the files remotely. This scp command also utilizes the SSH protocol for connection.
scp [Option] [Src] [Dest]
- rsync
Another useful command-line utility to synchronize the files while being connected remotely.
rsync [Option] [Src] [Dest]
- shutdown | reboot
The shutdown command schedules a shutdown for your system or you can restart the system using this command as well.
shutdown [option]
reboot [option]
Important Note: Use the “command –help” or the “man command” to get help from the Linux system on the commands.
| Package Management Commands | |||
|---|---|---|---|
| Install a Package | Remove a Package | Update the Repositories | |
| Debian Based Distros | sudo apt install <package-name> | sudo apt install <package-name> | sudo apt update |
| Arch Based Distros | sudo pacman -S <package> | sudo pacman -R <package> | sudo pacman -Sy |
| dnf-supported Distros | sudo dnf install <package> | sudo dnf remove <package> | sudo dnf check-update |
| openSUSE and its derivatives | sudo zypper install <package> | sudo zypper remove <package> | sudo zypper update |
| Flatpak | flatpak install flathub <package-ID> | flatpak uninstall flathub <package-ID> | |
| Snap | sudo snap install <package> | sudo snap remove <package> | sudo snap refresh |
That’s all from this Linux command cheat sheet.
Conclusion
A Linux Administrator has to play with Linux commands in their day-to-day activity. Although most Linux distros now support a GUI, however, command line operations are fast and easy to execute if the administrator knows the exact command. In today’s guide, I have listed the 99 Linux commands for administrators, covering everything from basic navigation to network configuration and remote operations.