Linux is a popular open-source operating system that is widely used by developers, system administrators, and users around the world.
The power of Linux lies in its command line interface (CLI), which offers a wide range of commands that allow users to perform various tasks on the system.
In this guide, we will cover the A-Z most frequently used Linux commands, starting with the letter A and ending with the letter Z. These commands are essential for every Linux user to know and will help you navigate and manage your system with ease.
The “man” command is a short form for manual, and it is an essential tool for every Linux user. The man command provides a comprehensive guide for the various commands and tools available in the Linux operating system.
The man pages are essentially the documentation for the commands, providing details on their usage, options, and examples.
The man pages are an indispensable resource for new Linux users as well as experienced administrators who want to learn more about a specific command or tool.
By using the man command, you can access the manual pages for any command or utility installed on your system, making it a critical resource for anyone working with Linux.
$ man command-name
Table of Contents
A-Z Most Frequently used Linux Commands
Here, we will learn Linux commands which you can execute through Linux Command Line and dive deeper into it using different options for different output.
adduser/addgroup Command
The “adduser” and “addgroup” commands are used in Linux to create new users and groups, respectively as per the default configuration specified in /etc/adduser.conf file.
These commands are commonly used by system administrators to manage the users and groups on their system.
The syntax for the adduser command is as follows:
$ adduser [options] username
The syntax for the addgroup command is as follows:
$ addgroup [options] groupname
Here’s an example of using the adduser command to create a new user:
$ sudo adduser newuser
And an example of using the addgroup command to create a new group:
$ sudo addgroup newgroup
In these examples, “newuser” is the name of the user being added and “newgroup” is the name of the group being created.
The sudo command is used to run these commands with administrative privileges.
It’s important to note that the specific options and syntax for these commands may vary depending on the distribution of Linux you’re using.
You can always consult the man pages for the adduser and addgroup commands for more information.
Check out detailed info about the adduser and addgroup commands: 15 Examples of adduser Commands in Linux.
agetty Command
The “agetty” command is used in Linux to manage virtual terminals (TTYs), invoked by init and provides a login prompt for users and calls up the /bin/login command once it detects a connection.
This command is typically used to configure the system console and virtual terminals, allowing users to log in and access the system.
The syntax for the agetty command is as follows:
$ agetty [options] tty speed
Here’s an example of using the agetty command to set the terminal speed for tty1:
$ agetty -L 115200 tty1
In this example, the -L option sets the terminal speed to 115200 baud, and the tty1 argument specifies the terminal to be configured.
A common use case for the agetty command is to set up the system console and virtual terminals for remote access.
For example, if you have a headless Linux server, you can use the agetty command to configure virtual terminals for remote access using a serial connection. By doing this, you can log in to the system and manage it from a remote location.
Another use case for the agetty command is to configure virtual terminals for multiuser access. By using the agetty command, you can set up multiple virtual terminals on a single system, allowing multiple users to log in and access the system simultaneously.
alias Command
The “alias” command is used in the bash shell to create aliases, or shortened versions, of commands. Aliases are used to make it easier and quicker to run frequently used commands or to run a complex command with a simple name.
The syntax for the alias command is as follows:
$ alias aliasname='command'
Here’s an example of using the alias command to create an alias for the “ls” command with the “–color” option:
$ alias ls='ls --color'
In this example, the alias “ls” is created and is set to run the “ls –color” command. Now, whenever you run the “ls” command, it will run the “ls –color” command instead.
Another example of using the alias command is to create an alias for a complex command:
$ alias update='sudo apt-get update && sudo apt-get upgrade'
In this example, the alias “update” is created and is set to run the commands “sudo apt-get update” and “sudo apt-get upgrade”. Now, whenever you run the “update” command, it will run the commands “sudo apt-get update” and “sudo apt-get upgrade”.
$ alias home="cd /home/adityapandey.org/public_html"
In the above example, the alias called “home” is created, so whenever you type home in the terminal, you will be navigated to /home/adityapandey.org/public_html directory.
It’s important to note that the aliases created using the alias command are only available for the current session. If you want to make the aliases permanent, you can add them to your bash profile.
The alias command is a powerful tool for customizing the bash shell and making it easier and more efficient to run frequently used commands. By creating aliases, you can save time and simplify your workflow.
apt Command
‘apt‘ is a package manager for Debian and Ubuntu based systems. It is used to install, upgrade, and remove packages, as well as manage repositories and perform other package management related tasks.
Syntax:
$ apt [options] [command]
Example use case:
$ apt update # To update the package information database
$ apt upgrade # To upgrade the installed packages
$ apt install [package-name] # To install a package
$ apt remove [package-name] # To remove a package
apt-get Command
‘apt-get ‘is a package management tool used in Debian-based operating systems such as Ubuntu, Linux Mint, and others. It’s used to install, upgrade, remove and manage software packages in a Linux environment.
With apt-get, you can manage packages from the command line, and it will automatically handle dependencies and package conflicts for you. It can be used in the following way:
To install a package: sudo apt-get install
To upgrade a package: sudo apt-get upgrade
To remove a package: sudo apt-get remove
To upgrade all installed packages: sudo apt-get update && sudo apt-get upgrade
Note: You will need to run the commands with sudo to have the necessary permissions to modify the system packages.
The apt-get update command downloads package information from the sources specified in your /etc/apt/sources.list file and updates the local package cache. The apt-get upgrade command then upgrades any outdated packages to their latest versions.
In addition to these basic functions, apt-get also provides options for more advanced package management, such as installing specific versions of a package, downgrading packages, and more.
Overall, apt-get is an essential tool for managing packages in Debian-based systems, and it makes it easy to keep your system up-to-date and secure.
apropos Command
‘apropos‘ is a Linux command that is used to search the manual page names and descriptions for a given keyword or phrase. The manual pages are a source of information about commands and other software on a Linux system.
The ‘apropos‘ command searches the manual page database and outputs a list of manual pages that match the search term. The output includes the name of the manual page, a brief description, and the path to the manual page file.
For example, if you wanted to find information about the ‘ls’ command, you could run the following command:
$ apropos ls
This would give you a list of manual pages that contain the keyword ‘ls’ in their names or descriptions, allowing you to quickly find the manual page for the ‘ls’ command.
‘apropos‘ is a useful tool for finding information about commands and other software on a Linux system. By searching the manual pages, you can get detailed information about how a command works, what options it provides, and how to use it effectively.
aptitude Command
‘aptitude’ is a package manager for Debian-based systems, similar to apt-get. It provides a terminal-based interface for managing packages and is widely used in many popular Linux distributions, including Debian and Ubuntu.
‘aptitude’ offers several advantages over apt-get, including a more user-friendly interface, the ability to resolve package dependencies automatically, and support for tasks such as package installation, removal, and upgrades.
The syntax for using ‘aptitude’ is similar to that of apt-get, with some additional features. For example, to install a package, you can use the following command:
$ sudo aptitude install
To upgrade all installed packages, you can use the following command:
$ sudo aptitude update && sudo aptitude upgrade
‘aptitude’ also provides the ability to search for packages based on keywords, view package information, and perform other advanced package management tasks.
arch Command
arch is a simple command for displaying machine architecture or hardware name (similar to uname -m):
$ arch
arp Command
The ‘arp’ command is a network utility used to view and manage the Address Resolution Protocol (ARP) cache on a computer. ARP is a protocol that maps an IP address to a physical (MAC) address on a network.
The ARP cache is a table that stores the mapping between IP addresses and MAC addresses for a specific period of time, so that the computer can quickly look up the MAC address of a device it wants to communicate with.
The ‘arp’ command can be used in a number of ways to view and manage the ARP cache. Some common uses of the ‘arp’ command include:
Displaying the current ARP cache: ‘arp -a’
Adding a static ARP entry: ‘arp -s’ <IP-Address> <MAC-address>
Deleting an ARP entry: ‘arp -d’ <IP-Address>
For example, to view the current ARP cache on a system, you can run the following command:
$ arp -a
This will output a list of IP addresses and their corresponding MAC addresses that are stored in the ARP cache.
Below command will find all alive hosts on a network:
$ sudo arp-scan --interface=enp2s0 --localnet
at Command
at command is used to schedule tasks to run in a future time. It’s an alternative to cron and anacron, however, it runs a task once at a given future time without editing any config files:
For example, to shutdown the system at 23:55 today, run:
$ sudo echo "shutdown -h now" | at -m 23:55
atq Command
atq command is used to view jobs in at command queue:
$ atq
atrm Command
atrm command is used to remove/deletes jobs (identified by their job number) from at command queue:
$ atrm 2
awk Command
Awk is a powerful programming language created for text processing and is generally used as a data extraction and reporting tool.
$ awk '//{print}'/etc/hosts
batch Command
In Linux, the “batch” command is used to execute commands or scripts in the background, without the need for user intervention.
Syntax
$ batch [options] [file]
Here, “options” are the various options that can be used with the batch command, and “file” is the name of the file or script that you want to execute.
An example usage of the batch command is as follows:
$ batch myscript.sh
This command will execute the script “myscript.sh” in the background, without any user intervention.
The output of the script will be saved to a file named “batch.n” in the current working directory. The user will be notified via email when the script has been completed.
basename Command
In Linux, the “basename” command is used to extract the filename from a given path or file name. It removes the path and returns only the base name of the file.
Syntax:
$ basename [option] filename
Here, “option” is an optional argument that can be used to modify the behaviour of the command, and “filename” is the name of the file whose base name you want to extract.
Some commonly used options are:
-a : returns all the base names of the given file paths, separated by a newline character.
-s suffix : removes the specified suffix from the base name of the file.
Some examples of using the basename command are:
1. To extract the base name of a file:
basename /home/user/docs/myfile.txt
Output:
myfile.txt
2. To remove the .txt extension from the file name:
basename -s .txt /home/user/docs/myfile.txt
Output:
myfile
To extract the base name of multiple file paths:
basename -a /home/user/docs/myfile.txt /home/user/pictures/photo.jpg
Output:
myfile.txt
photo.jpg
Note that the basename command only extracts the base name of the file, and does not modify the actual file in any way.
bc Command
bc is a simple yet powerful and arbitrary precision CLI calculator language which can be used like this:
$ echo 20.05 + 15.00 | bc
bg Command
bg is a command used to send a process to the background.
$ tar -czf home.tar.gz .
$ bg
$ jobs
bzip2 Command
bzip2 command is used to compress or decompress the file(s).
$ bzip2 -z filename #Compress
$ bzip2 -d filename.bz2 #Decompress
To learn more examples on bzip2, read: How to Compress and Decompress a .bz2 File in Linux
cal Command
The cal command prints a calendar on the standard output.
$ cal
cat Command
‘cat’ command is used to view the contents of a file or concatenate files, or data provided on standard input, and display it on the standard output.
$ cat file.txt
chgrp Command
chgrp command is used to change the group ownership of a file. Provide the new group name as its first argument and the name of the file as the second argument like this:
$ chgrp aditya users.txt
chmod Command
chmod command is used to change/update file access permissions like this.
$ chmod +x sysinfo.sh
chown Command
chown command changes/updates the user and group ownership of a file/directory like this.
$ chmod -R www-data:www-data /var/www/html
cksum Command
cksum command is used to display the CRC checksum and byte count of an input file.
$ cksum README.txt
clear Command
clear command lets you clear the terminal screen, simply type.
$ clear
cmp Command
cmp performs a byte-by-byte comparison of two files like this.
$ cmp file1 file2
comm Command
comm command is used to compare two sorted files line-by-line as shown below.
$ comm file1 file2
cp Command
cp command is used for copying files and directories from one location to another.
$ cp /home/aditya/file1 /home/aditya/Personal/
date Command
date command displays the system date and time like this.
$ date
$ date --set="8 JUN 2017 13:00:00"
dd Command
dd command is used for copying files, converting and formatting according to flags provided on the command line. It can strip headers, extract parts of binary files and so on.
The example below shows creating a boot-able USB device:
$ dd if=/home/aditya/kali-linux-1.0.4-i386.iso of=/dev/sdc1 bs=512M; sync
df Command
‘df’ command is used to show file system disk space usage as follows.
$ df -h
diff Command
diff command is used to compare two files line by line. It can also be used to find the difference between two directories in Linux like this:
$ diff file1 file2
dir Command
dir command works like Linux ls command, it lists the contents of a directory.
$ dir
dmidecode Command
‘dmidecode’ command is a tool for retrieving hardware information of any Linux system. It dumps a computer’s DMI (a.k.a SMBIOS) table contents in a human-readable format for easy retrieval.
To view your system hardware info, you can type:
$ sudo dmidecode --type system
du Command
‘du’ command is used to show disk space usage of files present in a directory as well as its sub-directories as follows.
$ du /home/aaronkilik
echo Command
‘echo’ command prints the text of the line provided to it.
$ echo “This is adityapandey.org"
eject Command
eject command is used to eject removable media such as DVD/CD ROM or floppy disk from the system.
$ eject /dev/cdrom
$ eject /mnt/cdrom/
$ eject /dev/sda
env Command
env command lists all the current environment variables and is used to set them as well.
$ env
exit Command
exit command is used to exit a shell like so.
$ exit
expr Command
expr command is used to calculate an expression as shown below.
$ expr 20 + 30
factor Command
factor command is used to show the prime factors of a number.
$ factor 10
find Command
‘find’ command lets you search for files in a directory as well as its sub-directories. It searches for files by attributes such as permissions, users, groups, file type, date, size and other possible criteria.
$ find /home/aditya/ -name aditya.txt
free Command
free command shows the system memory usage (free, used, swapped, cached, etc.) in the system including swap space. Use the -h option to display output in a human-friendly format.
$ free -h
grep Command
grep command searches for a specified pattern in a file (or files) and displays in output lines containing that pattern as follows.
$ grep ‘adityapandey’ domain-list.txt
groups Command
groups command displays all the names of groups a user is a part of like this.
$ groups
$ groups adityapandey.org
gzip Command
Gzip helps to compress a file, replace it with one having a .gz extension as shown below:
$ gzip passwds.txt
$ cat file1 file2 | gzip > foo.gz
gunzip Command
gunzip expands or restores files compressed with gzip command like this.
$ gunzip foo.gz
head Command
head command is used to show first lines (10 lines by default) of the specified file or stdin to the screen:
# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
history Command
history command is used to show previously used commands or to get info about commands executed by a user.
$ history
hostname Command
hostname command is used to print or set the system hostname in Linux.
$ hostname
$ hostname your_HOSTNAME
hostnamectl Command
hostnamectl command controls the system hostname under systemd. It is used to print or modify the system hostname and any related settings:
$ hostnamectl
$ sudo hostnamectl set-hostname NEW_HOSTNAME
hwclock
hwclock is a tool for managing the system hardware clock; read or set the hardware clock (RTC).
$ sudo hwclock
$ sudo hwclock --set --date 8/06/2017
hwinfo Command
hwinfo is used to probe for the hardware present in a Linux system like this.
$ hwinfo
id Command
id command shows user and group information for the current user or specified username as shown below.
$ id adityapandey
ifconfig Command
ifconfig command is used to configure a Linux systems network interface. It is used to configure, view and control network interfaces.
$ ifconfig
$ sudo ifconfig eth0 up
$ sudo ifconfig eth0 down
$ sudo ifconfig eth0 172.16.25.125
ionice Command
ionice command is used to set or view process I/O scheduling class and priority of the specified process.
If invoked without any options, it will query the current I/O scheduling class and priority for that process:
$ ionice -c 3 rm /var/logs/syslog
iostat Command
iostat is used to show CPU and input/output statistics for devices and partitions. It produces useful reports for updating system configurations to help balance the input/output load between physical disks.
$ iostat
ip Command
ip command is used to display or manage routing, devices, policy routing and tunnels. It also works as a replacement for well known ifconfig command.
This command will assign an IP address to a specific interface (eth1 in this case).
$ sudo ip addr add 192.168.56.10 dev eth1
iptables Command
iptables is a terminal based firewall for managing incoming and outgoing traffic via a set of configurable table rules.
The command below is used to check existing rules on a system (using it may require root privileges).
$ sudo iptables -L -n -v
iw Command
iw command is used to manage wireless devices and their configuration.
$ iw list
iwlist Command
iwlist command displays detailed wireless information from a wireless interface. The command below enables you to get detailed information about the wlp1s0 interface.
$ iwlist wlp1s0 scanning
kill Command
kill command is used to kill a process using its PID by sending a signal to it (default signal for kill is TERM).
$ kill -p 2300
$ kill -SIGTERM -p 2300
killall Command
killall command is used to kill a process by its name.
$ killall chrome
kmod Command
kmod command is used to manage Linux kernel modules. To list all currently loaded modules, type.
$ kmod list
last Command
last command display a listing of last logged in users.
$ last
ln Command
ln command is used to create a soft link between files using the -s flag like this.
$ ln -s /usr/bin/lscpu cpuinfo
locate Command
locate command is used to find a file by name. The locate utility works better and faster than it’s find counterpart.
The command below will search for a file by its exact name (not *name*):
$ locate -b '\domain-list.txt'
login Command
login command is used to create a new session with the system. You’ll be asked to provide a username and a password to login as below.
$ sudo login
ls Command
ls command is used to list contents of a directory. It works more or less like dir command.
The -l option enables long listing format like this.
$ ls -l filename
lshw Command
lshw command is a minimal tool to get detailed information on the hardware configuration of the machine and invoke it with superuser privileges to get comprehensive information.
$ sudo lshw
lscpu Command
lscpu command displays the system’s CPU architecture information (such as the number of CPUs, threads, cores, sockets, and more).
$ lscpu
lsof Command
lsof command displays information related to files opened by processes. Files can be of any type, including regular files, directories, block special files, character special files, executing text reference, libraries, and stream/network files.
To view files opened by a specific user’s processes, type the command below.
$ lsof -u adityapandey
lsusb Command
lsusb command shows information about USB buses in the system and the devices connected to them like this.
$ lsusb
man Command
man command is used to view the on-line reference manual pages for commands or programs like so.
$ man du
$ man df
md5sum Command
md5sum command is used to compute and print the MD5 message digest of a file. If run without arguments, debsums checks every file on your system against the stock md5sum files:
$ sudo debsums
mkdir Command
mkdir command is used to create single or more directories if they do not already exist (this can be overridden with the -p option).
$ mkdir adityapandey
more Command
more command enables you to view through relatively lengthy text files one screenful at a time.
$ more aditya.txt
mv Command
mv command is used to rename files or directories. It also moves a file or directory to another location in the directory structure.
$ mv myfile.sh aditya.sh
nano Command
nano is a popular small, free and friendly text editor for Linux; a clone of Pico, the default editor included in the non-free Pine package.
To open a file using nano, type:
$ nano myfile.txt
nc/netcat Command
nc (or netcat) is used for performing any operation relating to TCP, UDP, or UNIX-domain sockets. It can handle both IPv4 and IPv6 for opening TCP connections, sending UDP packets, listening on arbitrary TCP and UDP ports, and performing port scanning.
The command below will help us see if port 22 is open on host 192.168.6.1.
$ nc -zv 192.168.6.1 22
netstat Command
netstat command displays useful information concerning the Linux networking subsystem (network connections, routing tables, interface statistics, masquerade connections, and multicast memberships).
This command will display all open ports on the local system:
$ netstat -a | more
nice Command
‘nice’ command is used to show or change the nice value of a running program. It runs the specified command with an adjusted niceness. When run without any command specified, it prints the current niceness.
The following command starts the process “tar command” setting the “nice” value to 12.
$ nice -12 tar -czf backup.tar.bz2 /home/*
nmap Command
nmap is a popular and powerful open-source tool for network scanning and security auditing. It was intended to quickly scan large networks, but it also works fine against single hosts.
The command below will probe open ports on all live hosts on the specified network.
$ nmap -sV 192.168.56.0/24
nproc Command
nproc command shows the number of processing units present in the current process. Its output may be less than the number of online processors on a system.
$ nproc
openssl Command
The openssl is a command line tool for using the different cryptography operations of OpenSSL’s crypto library from the shell. The command below will create an archive of all files in the current directory and encrypt the contents of the archive file:
$ tar -czf - * | openssl enc -e -aes256 -out backup.tar.gz
passwd Command
passwd command is used to create/update passwords for user accounts, it can also change the account or associated password validity period. Note that normal system users may only change the password of their own account, while root may modify the password for any account.
$ passwd aditya
pidof Command
pidof displays the process ID of a running program/command.
$ pidof init
$ pidof server.sh
ping Command
ping command is used to determine connectivity between hosts on a network (or the Internet):
$ ping adityapandey.org
ps Command
ps shows useful information about active processes running on a system. The example below shows the top running processes by highest memory and CPU usage.
# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
pstree Command
pstree displays running processes as a tree which is rooted at either PID or init if PID is omitted.
$ pstree
pwd Command
pwd command displays the name of the current/working directory as below.
$ pwd
rdiff-backup Command
‘rdiff-backup’ is a powerful local/remote incremental backup script written in Python. It works on any POSIX operating system such as Linux, Mac OS X.
Note that for remote backups, you must install the same version of ‘rdiff-backup’ on both the local and remote machines. Below is an example of a local backup command:
$ sudo rdiff-backup /etc /media/adityapandey/Backup/server_etc.backup
reboot Command
reboot command may be used to halt, power off or reboot a system as follows.
$ reboot
rename Command
rename command is used to rename many files at once. If you have a collection of files with “.html” extension and you want to rename all of them with the “.php” extension, you can type the command below.
$ rename 's/\.html$/\.php/' *.html
rm command
rm command is used to remove files or directories as shown below.
$ rm file1
$ rm -rf myfiles
rmdir Command
rmdir command helps to delete/remove empty directories as follows.
$ rmdir /backup/aditya
scp Command
scp command enables you to securely copy files between hosts on a network, for example.
$ scp ~/names.txt [email protected]:/root/names.txt
shutdown Command
shutdown command schedules a time for the system to be powered down. It may be used to halt, power off or reboot the machine like this.
$ shutdown --poweroff
sleep Command
sleep command is used to delay or pause (specific execution of a command) for a specified amount of time.
$ check.sh; sleep 5; sudo apt update
sort Command
The “sort” command is a command-line utility that sorts the lines of a text file or the output of a command in a specified order.
It is commonly used in Unix-based operating systems such as Linux and macOS, as well as in Windows through the use of the Unix-like environment provided by the Windows Subsystem for Linux (WSL) or through third-party software such as Cygwin.
Here is the basic syntax of the sort command:
$ sort [OPTION]… [FILE]…
where ‘[OPTION]’ is one or more optional arguments that control the sort order, and ‘[FILE]‘ is the name of the input file. If no file is specified, the sort command will sort the input from the standard input (the keyboard).
For example, to sort the contents of a file named “file.txt” in ascending order, you would run the following command:
$ sort file.txt
To sort the contents of the file in reverse (descending) order, you would use the -r option:
$ sort -r file.txt
For more information on the sort command and its options, you can consult the manual page (man page) on your system by running the following command:
$ man sort
split Command
The “split” command is a Unix utility that is used to split a large file into smaller files. It reads the input file and divides it into several output files of a specified size, or based on a specified number of lines.
Here’s the basic syntax of the split command:
split [OPTIONS] [INPUT_FILE [PREFIX]]
‘OPTIONS’: There are several options available for the split command, including options to specify the size of the output files, the number of lines in each output file, and the prefix for the output files.
‘INPUT_FILE‘: The name of the input file that you want to split. If this argument is not specified, the split command will read from the standard input.
‘PREFIX’: The prefix that will be used for the output files. The default prefix is “x”.
Example
Let’s say you have a file named “largefile.txt” that is 50 MB in size, and you want to split it into smaller files of 10 MB each. You can use the following command:
split -b 10m largefile.txt output_
This will create multiple files named output_aa, output_ab, output_ac, etc., each with a size of 10 MB. The “-b” option specifies the size of the output files, and “10m” means 10 MB. The “output_” prefix is used for the output files.
Here’s another example where you want to split a file named “largefile.txt” into files of 1000 lines each:
split -l 1000 largefile.txt output_
This will create multiple files named output_aa, output_ab, output_ac, etc., each containing 1000 lines of the original file. The “-l” option specifies the number of lines in each output file.
ssh Command
ssh (SSH client) is an application for remotely accessing and running commands on a remote machine. It is designed to offer secure encrypted communications between two untrusted hosts over an insecure network such as the Internet.
$ ssh [email protected]
stat Command
‘stat’ is used to show a file or file system status like this (-f is used to specify a filesystem).
$ stat file1
su Command
su command is used to switch to another user ID or become root during a login session. Note that when su is invoked without a username, it defaults to becoming root.
$su
$ su root
sudo Command
sudo command allows a permitted system user to run a command as root or another user, as defined by the security policy such as sudoers.
In this case, the real (not effective) user ID of the user running sudo is used to determine the user name with which to query the security policy.
$ sudo apt update
$ sudo useradd aditya
$ sudo passwd pandey
sum Command
sum command is used to show the checksum and block counts for each specified file on the command line.
$ sum output file.txt
tac Command
tac command concatenates and displays files in reverse. It simply prints each file to standard output, showing the last line first.
$tac file.txt
tail Command
tail command is used to display the last lines (10 lines by default) of each file to standard output.
If there is more than one file, precede each with a header giving the file name. Use it as follow (specify more lines to display using the -n option).
$ tail long-file
OR
$ tail -n 15 long-file
talk Command
talk command is used to talk to another system/network user. To talk to a user on the same machine, use their login name, however, to talk to a user on another machine use ‘[email protected]’.
$ talk person [ttyname]
OR
$ talk‘[email protected]’ [ttyname]
tar Command
tar command is a most powerful utility for archiving files in Linux.
$ tar -czf home.tar.gz .
tee Command
The tee command is a Unix utility that is used to redirect output from one command to multiple places. The tee command reads the standard input and writes it to both the standard output and one or more files.
Here’s the basic syntax of the tee command:
$ tee [OPTIONS] [FILE...]
OPTIONS: There are several options available for the tee command, including options to specify the behaviour of the tee command when a file already exists, and options to control the file permissions of the output files.
FILE: One or more files that will receive the output from the tee command. If no file is specified, tee writes to the standard output.
Here’s an example of how you could use the tee command to redirect the output of the ls command to both the screen and a file named “ls_output.txt”:
$ ls | tee ls_output.txt
This command will list the contents of the current directory, and the output will be displayed on the screen as well as saved to a file named “ls_output.txt“. The “|” symbol is used to pipe the output of the ls command to the tee command.
You can also use the tee command with multiple files to redirect output to multiple places:
$ ls | tee ls_output1.txt ls_output2.txt
This command will save the output of the ls command to two files: “ls_output1.txt” and “ls_output2.txt”.
tree Command
The tree command is a Unix utility that is used to display the directory structure of a file system in a graphical format.
The tree command displays the contents of a directory and all its subdirectories in a tree-like structure, making it easier to understand the organization of a complex directory structure.
Here’s the basic syntax of the tree command:
$ tree [OPTIONS] [DIRECTORY]
OPTIONS: There are several options available for the tree command, including options to display information such as file sizes, permissions, timestamps, and file type.
DIRECTORY: The directory whose structure you want to display. If this argument is not specified, the tree command will display the structure of the current directory.
Here’s an example of how you could use the tree command to display the directory structure of the current directory:
$ tree
This will display a tree-like structure of the current directory and all its subdirectories, showing the names of files and directories and the relationships between them.
Here’s another example where you want to display the directory structure of a directory named “example_directory”:
$ tree example_directory
This will display a tree-like structure of the “example_directory” directory and all its subdirectories, showing the names of files and directories and the relationships between them.
time Command
time command runs programs and summarizes system resource usage.
$ time wc /etc/hosts
top Command
top program displays all processes on a Linux system in regards to memory and CPU usage and provides a dynamic real-time view of a running system.
$ top
$ top -c
touch Command
touch command changes file timestamps, it can also be used to create a file as follows.
$ touch myfile.txt
tr Command
tr command is a useful utility used to translate (change) or delete characters from stdin, and write the result to stdout or send it to a file as follows.
$ cat domain-list.txt | tr [:lower:] [:upper:]
uname Command
uname command displays system information such as operating system, network node hostname kernel name, version and release etc.
Use the -a option to show all the system information:
$ uname
uniq Command
uniq command displays or omits repeated lines from input (or standard input). To indicate the number of occurrences of a line, use the -c option.
$ cat domain-list.txt
uptime Command
uptime command shows how long the system has been running, the number of logged-on users and the system load averages as follows.
$ uptime
users Command
users command shows the user names of users currently logged in to the current host like this.
$ users
vim/vi Command
vim (Vi Improved) popular text editor on Unix-like operating systems. It can be used to edit all kinds of plain text and program files.
$ vim file_name
w Command
w command displays system uptime, load averages and information about the users currently on the machine, and what they are doing (their processes) like this.
$ w
wall Command
wall command is used to send/display a message to all users on the system as follows.
$ wall “This is Adityapandey.org– Learn Linux”
watch Command
watch command runs a program repeatedly while displaying its output on fullscreen. It can also be used to watch changes to a file/directory. The example below shows how to watch the contents of a directory change.
$ watch -d ls -l
wc Command
wc command is used to display newline, word, and byte counts for each file specified, and a total for many files.
$ wc file_name
wget Command
wget command is a simple utility used to download files from the Web in a non-interactive (can work in the background) way.
$ wget -c http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
whatis Command
whatis command searches and shows a short or one-line manual page description of the provided command name(s) as follows.
$ whatis ls

which Command
which command displays the absolute path (pathnames) of the files (or possibly links) which would be executed in the current environment.
$ which who

who Command
who command shows information about users who are currently logged in like this.
$ who
whereis Command
whereis command helps us locate the binary, source and manual files for commands.
$ whereis cat
xargs Command
xargs command is a useful utility for reading items from the standard input, delimited by blanks (protected with double or single quotes or a backslash) or newlines, and executes the entered command.
The example below show xargs being used to copy a file to multiple directories in Linux.
$ echo /home/aditya/test/ /home/aditya/tmp | xargs -n 1 cp -v /home/aditya/bin/sys_info.sh
yes Command
yes command is used to display a string repeatedly until when terminated or killed using [Ctrl + C] as follows.
$ yes "This is adityapandey.org"
youtube-dl Command
youtube-dl is a lightweight command-line program to download videos and also extract MP3 tracks from YouTube.com and a few more sites.
The command below will list available formats for the video in the provided link.
$ youtube-dl --list-formats https://www.youtube.com/watch?v=iR
zcmp/zdiff Command
zcmp and zdiff minimal utilities used to compare compressed files as shown in the examples below.
$ zcmp domain-list.txt.zip basic_passwords.txt.zip
$ zdiff domain-list.txt.zip basic_passwords.txt.zip
zip Command
zip is a simple and easy-to-use utility used to package and compress (archive) files.
Here’s an example of how you could use the zip command to compress a single file named “file.txt”:
$ zip file.zip file.txt
This will create a new file named “file.zip” that contains the compressed version of “file.txt”.
Here’s another example where you want to compress multiple files named “file1.txt”, “file2.txt”, and “file3.txt”:
$ zip files.zip file1.txt file2.txt file3.txt
This will create a new file named “files.zip” that contains the compressed versions of “file1.txt”, “file2.txt”, and “file3.txt”.
In conclusion, these commands are just a few of the many powerful and useful tools that are available in Linux.
Whether you are a beginner or an experienced user, these commands can help you automate tasks, streamline your workflow, and make your experience with Unix more efficient and enjoyable.
I hope that this information has been helpful and that you will find these commands as useful as I have. Please feel free to share this list with your friends and colleagues, and let them know about the many benefits of using Unix.
You can contact us if we missed any important command in the list.
FAQ’s
What is the most used Linux command?
ls: used to list the contents of a directory.
cd: used to change the current working directory.
pwd: used to display the current working directory.
mkdir: used to create a new directory.
rm: used to remove files or directories.
mv: used to move or rename files or directories.
cp: used to copy files or directories.
echo: used to display a message or the contents of a file.
grep: used to search for a pattern in a file or a set of files.
find: used to search for files or directories based on specified criteria.
How do you list all used commands in Linux?
1. Using the history command: You can use the history command to view the entire list of commands or a specific range of commands.
2. Using the ~/.bash_history file: This file is located in your home directory and contains a list of all commands that have been executed in the current user’s shell session.
3. Using the zsh_history file: This file works similarly to the ~/.bash_history file, but is used by the Zsh shell.
4. Using the fc command: This command is used to display and edit a range of commands from the history list. For example, fc -l -10 will display the last 10 commands that were executed.
What 5 commands a Linux admin should know?
1. ps: The ps command is used to display information about the currently running processes on the system. This information includes the process ID, status, start time, and command name.
2. top: The top command is used to display real-time information about the system, including CPU usage, memory usage, and the processes that are currently running.
3. df: The df command is used to display information about the available disk space on the system. This information includes the total size, used space, available space, and utilization percentage for each file system.
4. du: The du command is used to display the size of a directory and its subdirectories. This information can be useful for identifying which directories are consuming the most disk space.
5. netstat: The netstat command is used to display information about the current network connections and statistics. This information includes the protocol, local and remote addresses, state, and process ID for each connection.
What is Z used for in Linux?
z is a shell function or alias used to quickly navigate to frequently visited directories in the command line.