MPRASHANT
LINUX
100+ COMMANDS
Get Ready with your Linux
Setup for Practise
MPRASHANT
How to check your current
location?
#pwd
1
MPRASHANT
How to display name of current
logged-in user?
#whoami
2
MPRASHANT
How to check system date or
time?
#date
#date %D
3
MPRASHANT
How to display files and directory
present in current location?
#ls
#ls -lt
4
MPRASHANT
How to clear the linux terminal?
#clear
5
Creating
Deleting
Editing.
MPRASHANT
How to display content of a file
on terminal?
#cat <file>
6
MPRASHANT
How to read a file and Search for a
word?
#less <file>
7
MPRASHANT
How to view content of a file page
by page?
#more <file>
8
MPRASHANT
How to create a file in Linux?
#touch <file_name>
9
MPRASHANT
How to delete a file in Linux?
#rm <file_name>
10
MPRASHANT
How to edit a file in Linux?
#vi <file_name>
#nano <file_name>
11,12
MPRASHANT
How to create a
directory/folder in Linux?
#mkdir <dir_name>
13
MPRASHANT
How to delete a
directory/folder in Linux?
#rmdir <dir_name>
14,15 #rm -rf <dir_name>
MPRASHANT
How to change path or move
to another folder in Linux?
#cd /path/folder
16 #cd ..
MPRASHANT
How to copy and paste a file from
one folder to another in Linux?
#cp <file> /dest/path
17
MPRASHANT
How to copy content of a file to
another file in Linux?
#cp fileA fileB
18
MPRASHANT
How to cut - paste a file from one
folder to another in Linux?
#mv <file> /dest/path
19
MPRASHANT
How to rename a file in Linux?
#mv fileA fileNewName
19
MPRASHANT
How to read or diplay top 5 lines
from a file in Linux?
#head -5 file
20
MPRASHANT
How to read or diplay bottom 5
lines from a file in Linux?
#tail -5 file
21
MPRASHANT
How to SORT the content from a
file in Linux?
#sort file
#sort -r file
22
MPRASHANT
How to display UNIQUE content
from a file in Linux?
#sort file | uniq
23
MPRASHANT
A file has 9 lines.
How to split this file in 3 different
files in Linux?
#split -l 3 file
24
MPRASHANT
How to search a word and display
matching content from a file in
Linux?
#grep "word" file
25
MPRASHANT
How to search multiple words and
display matching content from a
file in Linux?
#egrep "word1|word2" file
26
MPRASHANT
How to use WILDCARDS in Linux?
* [] {}
#ls file*
#touch file{1..5}
27
MPRASHANT
How to SHUFFLE content of file in
Linux?
#shuf file
28
MPRASHANT
How to COUNT no. of lines in a
file in Linux?
#wc -l file
29
MPRASHANT
How to check if two files are
identical or not in Linux?
#cmp fileA fileB
30
MPRASHANT
How to compare and display
difference between two files in
Linux?
#diff -u fileA fileB
31
MPRASHANT
How to find a file in Linux?
#find /path/ -name <file>
32
MPRASHANT
How to find a file in Linux?
#updatedb
#locate <file>
33,34
Utility Commands
MPRASHANT
How to display previously used
commands in past?
#history
35
MPRASHANT
How to check syntax and options
available for a command?
#help
36
MPRASHANT
How to read or get mor info about
a command?
#man
37
MPRASHANT
How to check which executable is
using for a command?
#which
38
MPRASHANT
How to use calculator in Linux?
#bc
39
MPRASHANT
How to check CALENDAR of last
year in Linux?
#cal
40
MPRASHANT
How to check How Long server
has been running in Linux?
#uptime
41
MPRASHANT
How to record your activity on
termial in a file?
#script
42
MPRASHANT
How to create a short-cut of a
long command in Linux?
#alias l="ls -ltr"
43
Zip and Unzip
of Files and
Folders
MPRASHANT
How to compress a file in Linux?
#gzip -k file
44
MPRASHANT
How to decompress a file in
Linux?
#gzip -d file
#gunzip file
45,46
MPRASHANT
How to compress a folder in
Linux?
#tar -czf [Link] myfiles/
47
MPRASHANT
How to decompress a folder in
Linux?
#tar -xzf [Link]
47
MPRASHANT
How to compress multiple files in
one zipped file in Linux?
#zip [Link] file1 file2
48
MPRASHANT
How to list files in zipped file?
#unzip -l [Link]
48
Downloading
Files from
Internet
MPRASHANT
How to download a file from
internet?
#wget URL_of_file
#wget -O opt_file.txt URL_Of_file
49
MPRASHANT
How to call an API on Linux?
#curl [Link]
50
MPRASHANT
How to install an application on
Linux?
#apt or yum/dnf
51
MPRASHANT
How to check if an application is
installed or not on Linux?
#rpm -qa | grep app
#dnf list installed
52
MPRASHANT
How to list available packages to
install on Linux?
#apt search <package_name>
#yum/dnf list available
53
MPRASHANT
How to start/stop a service on
Linux?
#systemctl start/stop service_name
54
MPRASHANT
How to list all services on Linux?
#systemctl list-units --type=service --all
55
MPRASHANT
How to list all existing
Environment Variables on Linux?
#printenv
56
MPRASHANT
How to ADD a new Environment
Variables on Linux?
#export JAVA_HOME="/usr/lib/jvm/java_v"
#export PATH=$JAVA_HOME/bin:$PATH
57
MPRASHANT
How to ADD a new Environment
Variables permanently on Linux?
Add env variable in ./bashrc file
#source ~/.bash_profile
58
MPRASHANT
How to print a specific column
from a CSV file?
#awk -F ,'{print $2}' [Link]
59
MPRASHANT
How to display starting two
characters of all line?
#cut -c1-2 [Link]
60
MPRASHANT
How to display a specific line
from a file?
#sed -n '5p' [Link]
61
MPRASHANT
How to replace a specific word
within a file?
#sed -n 's/from/to/g' [Link]
61
MPRASHANT
How to convert the content to
Uppercase or Lowercase within a
file?
#tr [:lower:] [:upper:] <[Link]
#tr [:punct:] Z <[Link]
62 #tr [:digit:] Z <[Link]
MPRASHANT
How to extend or shrink size of a
file?
#truncate -s 100M [Link]
63
MPRASHANT
How to display following line in
vertical line? ABCDE
#echo "ABCDE" | fold -w1
64
MPRASHANT
How to change user or login as
different user in linux?
#su <user_name>
65
MPRASHANT
How to exit as current user or
close terminal in linux?
#exit
66
MPRASHANT
If you are not root user, how to
execute admin commands like
installing new apps?
#sudo yum install httpd
67
Access
Remote
Servers
MPRASHANT
How to access remote Linux
server?
#ssh user@hostname
68
MPRASHANT
How to copy a file to a remote
Linux server?
#scp file user@hostname:/tmp/
69
Working with Permissions
MPRASHANT
How to check permissions of a
file?
#ls -ltr
rwx rw- r--
user group other
MPRASHANT
How to modify permissions of a
file?
#chmod a+rwx [Link]
u - user, g - group, o - other
70
a - all
MPRASHANT
How to change ownership of a
file?
#chown root [Link]
71
MPRASHANT
How to change group ownership
of a file?
#chgrp paul [Link]
72
Memory Info
MPRASHANT
How to check free RAM space?
#free
73
MPRASHANT
How to check % Memory and CPU
Utilization?
#top
74
MPRASHANT
How to check disk Utilization?
#du
75
MPRASHANT
How to check filesystem available
and disk space allocated?
#df
76
System INFO
MPRASHANT
How to check hostname of your
linux server?
#hostname
77
MPRASHANT
How to check cpu/core/thread
info of your linux server?
#lscpu
78
MPRASHANT
How to check type of architecture
of your linux server?
#arch
79
MPRASHANT
How to see list of storage devices,
disk partition on your linux
server?
#lsblk
80
MPRASHANT
How to see OS name of linux
server?
#uname -a
81
Process Management
MPRASHANT
How to check if a process(java) is
running or not?
#ps -ef | grep java
82
MPRASHANT
How to get PID of a process?
#pgrep chron
83
MPRASHANT
How to stop a process by PID?
#kill -9 PID
84
MPRASHANT
How to stop a process by its
name?
#pkill httpd
85
MPRASHANT
How to see all the active jobs?
#jobs
86
MPRASHANT
How to resume a job in
background?
#bg
87
MPRASHANT
How to resume a job in
foreground?
#fg
88
MPRASHANT
How to run a script in
background?
#nohup ./script >/dev/null &
89
Networking Info
MPRASHANT
How to check IP of your machine?
#ifconfig
90
MPRASHANT
How to check if a server or
website is accesible or not?
#ping [Link]
91
MPRASHANT
How to check if a IP:PORT is
accessible and open or not?
#telnet IP Port
92
MPRASHANT
How to check if port is open or
not on our server?
#netstat -putan | grep 80
93
MPRASHANT
How to check all hubs in network
path to reach a website?
#traceroute
94
MPRASHANT
How to restart our linux server?
#reboot
95
MPRASHANT
How to shutdown our linux
server?
#shutdown
96
User Creation
MPRASHANT
How to create a new user on our
linux server?
#useradd
97
MPRASHANT
How to change password for the
user?
#passwd
98
MPRASHANT
How to create a new group on our
linux server?
#groupadd
99
MPRASHANT
How to check UserID or GroupID
of a user?
#id user
100
MPRASHANT
How to delete a user or group?
#userdel <user>
#groupdel <group>
101,2
MPRASHANT
How to schedule a script to run on
a particular date/time?
#at
#crontab
103,4
MPRASHANT
useradd
groupadd
USER usermod
MANAGEMENT userdel
groupdel
passwd
id
MPRASHANT
ifconfig
ping
NETWORKING netstat
traceroute
telnet
MPRASHANT
sleep
ps
pgrep
PROCESS kill
MANAGEMENT pkill
jobs
bg
fg
nohup
MPRASHANT
hostname
SYSTEM INFO lscpu
arch
lsblk
uname -a
MPRASHANT
top
MEMORY INFO free
du
df
MPRASHANT
su
CHANGE USER sudo
& exit
REMOTE SERVER
ssh
ACCESS
scp
MPRASHANT
chmod
FILE chown
PERMISSIONS
chgrp
MPRASHANT
awk
cut
TEXT sed
PROCESSING tr
truncate
fold
MPRASHANT
printenv
ENV VARIABLES export
source
MPRASHANT
INSTALL & apt or yum/dnf
MANAGE dpkg or rpm
APPLICATIONS systemctl
MPRASHANT
DOWNLOAD wget
FILES curl
MPRASHANT
tar
COMPRESS gzip
DECOMPRESS gunzip
zip
unzip
MPRASHANT
history
cal
help
OTHER USEFUL script
COMMANDS man
uptime
which
alias
bc
MPRASHANT
shuf
wc
FILES & diff
DIRECTORIES cmp
MANAGEMENT
find
locate
MPRASHANT
cd head
cp tail
FILES & mv sort
DIRECTORIES
grep uniq
MANAGEMENT
egrep split
MPRASHANT
cat vi
less nano
FILES &
DIRECTORIES more mkdir
MANAGEMENT touch rmdir
rm
MPRASHANT
pwd
whoami
FIRST TIME
date
ON TERMINAL
ls
clear
Some Useful Utility
Commands
Installing Applications
Environment Variables
String/Text Operations
Working with Permissions
Scripting and
Automating
task
MPRASHANT
at
SCRIPTING &
crontab
AUTOMATION
bash or sh
MPRASHANT
SYSTEM reboot
CONTROL shutdown
MPRASHANT
FIREWALL firewall-cmd --list-all
SETTINGS firewall-cmd --add-port=20201/tcp