A - Z Linux Commands - Overview With Examples PDF
A - Z Linux Commands - Overview With Examples PDF
Commands
Linux
A-Z
A – Z LINUX COMMANDS – OVERVIEW WITH EXAMPLES
https://www.tecmint.com/linux-commands-cheat-sheet/ 1/39
10/10/2017 A - Z Linux Commands - Overview with Examples
https://www.tecmint.com/linux-commands-cheat-sheet/ 2/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ arch
arp Command
ARP (Address Resolution Protocol) is a protocol that maps IP network
addresses of a network neighbor with the hardware (MAC) addresses in
an IPv4 network.
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 con g les:
atq Command
atq command is used to view jobs in at command queue:
$ atq
atrm Command
atrm command is used to remove/deletes jobs (identi ed by their job
number) from at command queue:
https://www.tecmint.com/linux-commands-cheat-sheet/ 6/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ atrm 2
For more usage about at command, read: How to Use ‘at’ Command to
Schedule a Task in Linux
awk Command
Awk is a powerful programming language created for text processing and
generally used as a data extraction and reporting tool.
$ awk '//{print}'/etc/hosts
For more Awk concepts (basic and advance) with simple and easy-to-
understand, we’ve created a book that contains 13 chapters with a total of
41 pages, which covers all Awk basic and advance usage with practical
examples: Awk Getting Started Guide for Beginners
batch Command
batch is also used to schedule tasks to run a future time, similar to the at
command.
basename Command
basename command helps to print the name of a le stripping of
directories in the absolute path:
$ basename bin/findhosts.sh
bc Command
bc is a simple yet powerful and arbitrary precision CLI calculator language
which can be used like this:
https://www.tecmint.com/linux-commands-cheat-sheet/ 7/39
10/10/2017 A - Z Linux Commands - Overview with Examples
bg Command
bg is a command used to send a process to the background.
bzip2 Command
bzip2 command is used to compress or decompress le(s).
cal Command
The cal command print a calendar on the standard output.
$ cal
cat Command
cat command is used to view contents of a le or concatenate les, or
data provided on standard input, and display it on the standard output.
$ cat file.txt
https://www.tecmint.com/linux-commands-cheat-sheet/ 8/39
10/10/2017 A - Z Linux Commands - Overview with Examples
chgrp Command
chgrp command is used to change the group ownership of a le. Provide
the new group name as its rst argument and the name of le as the
second argument like this:
chmod Command
chmod command is used to change/update le access permissions like
this.
$ chmod +x sysinfo.sh
chown Command
chown command changes/updates the user and group ownership of a
le/directory like this.
cksum Command
cksum command is used to display the CRC checksum and byte count of
an input le.
$ cksum README.txt
clear Command
clear command lets you clear the terminal screen, simply type.
https://www.tecmint.com/linux-commands-cheat-sheet/ 9/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ clear
cmp Command
cmp performs a byte-by-byte comparison of two les like this.
comm Command
comm command is used to compare two sorted les line-by-line as shown
below.
cp Command
cp command is used for copying les and directories from one location to
another.
$ cp /home/tecmint/file1 /home/tecmint/Personal/
date Command
date command displays/sets the system date and time like this.
$ date
$ date --set="8 JUN 2017 13:00:00"
https://www.tecmint.com/linux-commands-cheat-sheet/ 10/39
10/10/2017 A - Z Linux Commands - Overview with Examples
To learn more about how to set date in Linux, read: How to Set System
Date in Linux
dd Command
dd command is used for copying les, converting and formatting
according to ags provided on the command line. It can strip headers,
extracting parts of binary les and so on.
df Command
df command is used to show le system disk space usage as follows.
$ df -h
diff Command
diff command is used to compare two les line by line. It can also be used
to nd the difference between two directories in Linux like this:
Some useful diff tools for Linux: 8 Best File Comparison and Difference
(Diff) Tools for Linux
dir Command
https://www.tecmint.com/linux-commands-cheat-sheet/ 11/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ 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.
du Command
du command is used to show disk space usage of les present in a
directory as well as its sub-directories as follows.
$ du /home/aaronkilik
echo Command
echo command prints a text of line provided to it.
eject Command
eject command is used to eject removable media such as DVD/CD ROM
or oppy disk from the system.
https://www.tecmint.com/linux-commands-cheat-sheet/ 12/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ eject /dev/cdrom
$ eject /mnt/cdrom/
$ eject /dev/sda
env Command
env command lists all the current environment variables and 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
nd Command
nd command lets you search for les in a directory as well as its sub-
directories. It searches for les by attributes such as permissions, users,
https://www.tecmint.com/linux-commands-cheat-sheet/ 13/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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 human friendly format.
$ free -h
grep Command
grep command searches for a speci ed pattern in a le (or les) and
displays in output lines containing that pattern as follows.
groups Command
groups command displays all the names of groups a user is a part of like
this.
$ groups
$ groups tecmint
gzip Command
Gzip helps to compress a le, replaces 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 les compressed with gzip command like this.
$ gunzip foo.gz
head Command
head command is used to show rst lines (10 lines by default) of the
speci ed le or stdin to the screen:
history Command
https://www.tecmint.com/linux-commands-cheat-sheet/ 15/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ history
hostname Command
hostname command is used to print or set system hostname in Linux.
$ hostname
$ hostname NEW_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
https://www.tecmint.com/linux-commands-cheat-sheet/ 16/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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
speci ed username as shown below.
$ id tecmint
ifcon g Command
ifcon g command is used to con gure a Linux systems network
interfaces. It is used to con gure, 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 speci ed 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
https://www.tecmint.com/linux-commands-cheat-sheet/ 17/39
10/10/2017 A - Z Linux Commands - Overview with Examples
To understand how it works, read this article: How to Delete HUGE (100-
200GB) Files in Linux
iostat Command
iostat is used to show CPU and input/output statistics for devices and
partitions. It produces useful reports for updating system con gurations
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 ifcon g
command.
iptables Command
iptables is a terminal based rewall for managing incoming and outgoing
tra c via a set of con gurable table rules.
$ sudo iptables -L -n -v
iw Command
iw command is used to manage wireless devices and their con guration.
$ 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.
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 firefox
https://www.tecmint.com/linux-commands-cheat-sheet/ 19/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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 les using the -s ag
like this.
$ ln -s /usr/bin/lscpu cpuinfo
locate Command
locate command is used to nd a le by name. The locate utility works
better and faster than it’s nd counterpart.
The command below will search for a le 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.
https://www.tecmint.com/linux-commands-cheat-sheet/ 20/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ sudo login
ls Command
ls command is used to list contents of a directory. It works more or less
like dir command.
$ ls -l file1
lshw Command
lshw command is a minimal tool to get detailed information on the
hardware con guration of the machine, invoke it with superuser privileges
to get a comprehensive information.
$ sudo lshw
lscpu Command
lscpu command displays system’s CPU architecture information (such as SHARE
number of CPUs, threads, cores, sockets, and more).
+
$ lscpu
+
lsof Command
https://www.tecmint.com/linux-commands-cheat-sheet/
0 21/39
10/10/2017 A - Z Linux Commands - Overview with Examples
0
lsof command displays information related to les opened by processes.
Files can be of any type, including regular les, directories, block special
les, character special les, executing text reference, libraries, and
158
stream/network les.
$ lsof -u tecmint
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/programs like so.
$ man du
$ man df
md5sum Command
md5sum command is used to compute and print the MD5 message
digest of a le. If run without arguments, debsums checks every le on
your system against the stock md5sum les:
$ sudo debsums
mkdir Command
https://www.tecmint.com/linux-commands-cheat-sheet/ 22/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ mkdir tecmint-files
OR
$ mkdir -p tecmint-files
more Command
more command enables you to view through relatively lengthy text les
one screenful at a time.
$ more file.txt
Check difference between more and less command and Learn Why ‘less’
is Faster Than ‘more’ Command
mv Command
mv command is used to rename les or directories. It also moves a le or
directory to another location in the directory structure.
$ mv test.sh sysinfo.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.
$ nano file.txt
nc/netcat Command
https://www.tecmint.com/linux-commands-cheat-sheet/ 23/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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, performing port scanning.
The command below will help us see if the port 22 is open on the host
192.168.56.5.
$ nc -zv 192.168.1.5 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 speci ed command with an adjusted niceness. When run
without any command speci ed, it prints the current niceness.
The following command starts the process “tar command” setting the
“nice” value to 12.
nmap Command
https://www.tecmint.com/linux-commands-cheat-sheet/ 24/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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 ne against single hosts.
The command below will probe open ports on all live hosts on the
speci ed network.
nproc Command
nproc command shows the number of processing units present to the
current process. It’s 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 les in the current directory and encrypt the
contents of the archive le:
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 tecmint
https://www.tecmint.com/linux-commands-cheat-sheet/ 25/39
10/10/2017 A - Z Linux Commands - Overview with Examples
pidof Command
pidof displays the process ID of a running program/command.
$ pidof init
$ pidof cinnamon
ping Command
ping command is used to determine connectivity between hosts on a
network (or the Internet):
$ ping google.com
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.
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 current/working directory as below.
$ pwd
https://www.tecmint.com/linux-commands-cheat-sheet/ 26/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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:
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 les at once. If you’ve a
collection of les with “.html” extension and you want to rename all of
them with “.php” extension, you can type the command below.
rm command
rm command is used to remove les or directories as shown below.
$ rm file1
$ rm -rf my-files
https://www.tecmint.com/linux-commands-cheat-sheet/ 27/39
10/10/2017 A - Z Linux Commands - Overview with Examples
rmdir Command
rmdir command helps to delete/remove empty directories as follows.
$ rmdir /backup/all
scp Command
scp command enables you to securely copy les between hosts on a
network, for example.
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 (speci cally execution of a
command) for a speci ed amount of time.
sort Command
sort command is used to sort lines of text in the speci ed le(s) or from
stdin as shown below
https://www.tecmint.com/linux-commands-cheat-sheet/ 28/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ cat words.txt
split Command
split as the name suggests, is used to split a large le into small parts.
ssh Command
ssh (SSH client) is an application for remotely accessing and running
commands on a remote machine. It is designed to offer a secure
encrypted communications between two untrusted hosts over an insecure
network such as the Internet.
$ ssh tecmint@192.168.56.10
stat Command
stat is used to show a le or le system status like this ( -f is used to
specify a lesystem).
$ stat file1
https://www.tecmint.com/linux-commands-cheat-sheet/ 29/39
10/10/2017 A - Z Linux Commands - Overview with Examples
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 tecmint
sudo Command
sudo command allows a permitted system user to run a command as root
or another user, as de ned 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.
sum Command
sum command is used to show the checksum and block counts for each
each speci ed le on the command line.
tac Command
https://www.tecmint.com/linux-commands-cheat-sheet/ 30/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$tac file.txt
tail Command
tail command is used to display the last lines (10 lines by default) of each
le to standard output.
If there more than one le, precede each with a header giving the le
name. Use it as follow (specify more lines to display using -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 ‘user@host’.
tar Command
tar command is a most powerful utility for archiving les in Linux.
tee Command
tee command is used to read from standard input and prints to standard
output and les as shown below.
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
touch Command
touch command changes le timestamps, it can also be used to create a
le as follows.
$ touch file.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 to a le as
follows.
https://www.tecmint.com/linux-commands-cheat-sheet/ 32/39
10/10/2017 A - Z Linux Commands - Overview with Examples
uname Command
uname command displays system information such as operating system,
network node hostname kernel name, version and release etc.
$ 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, 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
https://www.tecmint.com/linux-commands-cheat-sheet/ 33/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ vim file
Learn how to use vi/vim editor in Linux along with some tips and tricks.
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.
watch Command
watch command runs a program repeatedly while displaying its output on
fullscreen. It can also be used to watch changes to a le/directory. The
example below shows how to watch the contents of a directory change.
https://www.tecmint.com/linux-commands-cheat-sheet/ 34/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ watch -d ls -l
wc Command
wc command is used to display newline, word, and byte counts for each
le speci ed, and a total for many les.
$ wc filename
wget Command
wget command is a simple utility used to download les 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
descriptions of the provided command name(s) as follows.
$ whatis wget
which Command
which command displays the absolute path (pathnames) of the les (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.
https://www.tecmint.com/linux-commands-cheat-sheet/ 35/39
10/10/2017 A - Z Linux Commands - Overview with Examples
$ who
whereis Command
whereis command helps us locate the binary, source and manual les 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.
yes Command
yes command is used to display a string repeatedly until when terminated
or killed using [ Ctrl + C ] as follows.
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.
https://www.tecmint.com/linux-commands-cheat-sheet/ 36/39
10/10/2017 A - Z Linux Commands - Overview with Examples
zcmp/zdiff Command
zcmp and zdiff minimal utilities used to compare compressed les as
shown in the examples below.
zip Command
zip is a simple and easy-to-use utility used to package and compress
(archive) les.
zz Command
zz command is an alias of the fasd commandline tool that offers quick
access to les and directories in Linux. It is used to quickly and
interactively cd into a previously accessed directory by selecting the
directory number from the rst eld as follows.
$ zz
1 RESPONSE
Comments 1 Pingbacks 0
https://www.tecmint.com/linux-commands-cheat-sheet/ 37/39
10/10/2017 A - Z Linux Commands - Overview with Examples
Comment
Name * Email *
Website
Notify me of followup comments via e-mail. You can also subscribe without commenting.
Post Comment
QUESTIONS
How to Monitor Apache 5 Best Modern Linux ‘init’
Web Server Load and Page Systems (1992-2015)
Statistics Basic Linux Interview
Questions and Answers –
https://www.tecmint.com/linux-commands-cheat-sheet/ 38/39
10/10/2017 A - Z Linux Commands - Overview with Examples
Tecmint: Linux Howtos, Tutorials & Guides ©
2017. All Rights Reserved.
This work is licensed under a (cc) BY-NC
The material in this site cannot be republished
either online or o ine, without our permission.
https://www.tecmint.com/linux-commands-cheat-sheet/ 39/39