0% found this document useful (0 votes)
117 views4 pages

Essential Linux Commands Cheat Sheet

This document provides a cheat sheet of common Linux commands organized by category such as system, file permissions, hardware, network, users, installation and more. It lists commands like uname, date, df, du, grep, tar, gzip, rpm, useradd, kill and their brief descriptions. The cheat sheet is a quick reference guide for Linux users to lookup basic command syntax and examples.

Uploaded by

Priya Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views4 pages

Essential Linux Commands Cheat Sheet

This document provides a cheat sheet of common Linux commands organized by category such as system, file permissions, hardware, network, users, installation and more. It lists commands like uname, date, df, du, grep, tar, gzip, rpm, useradd, kill and their brief descriptions. The cheat sheet is a quick reference guide for Linux users to lookup basic command syntax and examples.

Uploaded by

Priya Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

LINUX COMMANDS ​CHEAT ​SHEET

SYSTEM
FILE ​PERMISSION ​RELATED

uname ​-​a ​uname ​-​r ​uptime ​hostname ​hostname ​- ​l​ast ​reboot ​date ​cal
=​>​Displaylinux ​system ​information ​=​>​Display ​kernel ​release ​information ​=​>​Show ​how ​long
the ​system ​has ​been ​running ​+ ​load ​=​>​Show ​system ​host ​name ​=​>​Dis​play ​the ​IP ​address
of ​the ​host ​=​>​Show ​system ​reboot ​history ​=​>​Show ​the ​current ​date and ​time ​=​>​Show ​this
month ​calendar ​=​>​Display ​who ​is ​online ​=​>​Who ​you ​are ​logged ​in ​as ​=​>​Display
information about ​user
chmod ​octal ​file​-​nam​e ​=​>​Change t​ he ​permissions ​of ​file ​to ​octal ​Example
chmod ​7​77 /​ ​d​ata​/​tes​t​.​c ​=​>​Set ​rwx ​permission ​for ​owner​,​group​, ​world c​ hmod
7​55 ​/d​ ata​/t​ es​t​.​c ​=​>​Set ​rwx ​permission ​for ​owner​,​rx ​for ​group ​and ​world ​chown
o​wn ​ er​-​user ​file ​=​>​Change ​owner ​of ​the ​file ​chown ​owner​-​user​:​owner​-​group
file​-​name ​=​>​Change ​owner ​and ​group
owner ​of ​the ​file ​chown ​owner​-​user​:​owner​-​group ​directory ​=​>​Change ​o​w​ner
and ​group
o​w​ner ​of ​the ​directory
whoami
finger ​user
NETWORK

HARDWARE

​ essa​ge​s ​ca​t
dmesg ​=​>​Detected ​hardware ​and ​boot m ​/​proc​/​cpuin​fo ​=​>C
​ PU ​model
​cat ​/​pro​c​/​meminfo ​=​>​Hard​w​are ​memory
ca​t​/​proc​/​interrupts ​=​> ​Lists ​the ​numbe​r ​of ​interrupts ​per ​CPU ​per ​1​/​0 ​device
Ishw ​=​>​Displays ​information ​on ​hardware c ​ onfiguration ​of
the ​system
Isblk ​=​> ​Displays ​block ​device ​related ​information ​in ​Linux
f​ree​-​m
=​>​Used ​and ​free ​memory ​(​-​m ​for M
​ B​)
Ispci ​-​tv
=​>​Show ​PCI ​devices

Isusb​-​tv ​=​>​Show ​USB ​de​v​ices ​dmidecode ​=​>​Sho​w ​hardware ​info ​from ​the ​BIOS
hdparm ​-​i​/​de​v​/​sda ​=​>​Show ​info ​about ​disk ​sda ​hdparm​-​T ​/​dev/​ ​sd​a ​=​>​Do ​a ​read ​speed
tes​t ​on ​disk ​sda ​badbl​ocks ​-​s ​/​dev/​ ​sd​a =
​ ​> ​T​es​t ​fo​r ​unreadable ​blocks ​on ​disk ​sda
ip ​addr show ​=​>​Display ​all ​network ​interfaces ​and ​ip ​address
(​a ​iproute2 ​command​, ​powerful ​than ​ifconfig​) ​ip ​address ​add ​192​.​16​8​.​0​.​1 ​dev ​etho
=​>​Set ​ip ​address e​ thtool ​etho ​=​> ​Linux ​tool ​to ​show ​ethernet ​status ​mii​-​tool ​etho =
​ ​>​Linux
tool ​to ​show ​ethernet ​status ​ping ​host
=​>​Se​nd ​echo ​request ​to ​test c​ ​o​nnection ​whois ​domain ​=​>​Get ​who ​is ​information ​for
domain ​dig ​domain ​=​>​Get ​DNS ​information ​for ​domain ​dig ​-​x ​host ​=​> ​Reverse
lookup ​host ​host ​google​.​com ​=​>​Lookup ​DNS ​ip ​address ​for ​the ​name
​hostname​-​i ​=​>​Lookup ​local ​ip address
wget ​file =
​ ​>​Download ​fi​le ​netstat ​-​tupl ​=​>​Listing ​all ​active ​listening ​ports

CO​MPRESSION ​/ ​ARCHIVES

USERS
​ zf ​file​.​tar​.​gz ​files ​g​zip ​file
tar ​cf ​home​.​tar ​home ​tar ​xf f​ ile​.​tar ​tar c
=​>​C​rea​te ​tar ​named ​home​.​tar ​containing h
​ ome​/ ​=​>​Extract ​the ​files ​from ​file​.​tar
=​>​Create ​a ​tar ​with ​gzip ​compression ​=>​Compress ​file ​and ​renames ​it ​to ​file​.​gz

INSTALL ​PACKAGE
id ​=​>​Show the ​active ​user ​id ​with ​login ​and ​group
last ​=​>​Show ​last ​logins ​on t​ he ​system
​ ho ​=​>​Sho​w ​wh
w ​ o ​is ​logged ​on t​ he ​system ​groupadd ​admi​n ​=​> ​Add ​group
"​admin​" ​useradd ​-​c ​"​Sam ​Toms​hi​" ​=​>​g ​admin ​-​m ​sa​m ​#​Create ​user ​"​sam​" ​userdel
s​am ​=​>​Delete ​user ​sam a​ dduser ​sam ​=​> ​Add ​user ​"​sam​"
usermod ​=​>Modify ​user ​information
rpm ​-​ipkgname​.​rpm ​rpm ​-​e ​pkgname
=​>​Install ​rpm ​based ​package ​=​>​Remove ​package

INSTALL ​FROM ​SOURCE

FILE ​COMMANDS
Jc​ onfigure ​make ​make ​install
pwd
SEARCH

grep ​pattern ​files


=​>​Search ​for ​pattern ​in ​files ​grep ​-​r ​pattern ​dir
=​>​Search ​recursively ​for ​pattern ​in ​dir ​locate ​file
=​>​Find ​all ​instances ​of ​f​ile ​find ​/​home​/​tom ​-​name ​'​ind​ex​* ​=​>​Find ​files ​names ​that
start ​wi​t​h ​"​index​" ​find ​/h
​ ome​-​size ​+​10000k ​=​> ​Find ​files ​la​r​ger ​than ​100​00​k ​in ​/​home

LOGIN ​(SSH ​AND ​TELNET​)


​ irectories
Is​-​al ​=​>​Display ​all ​information ​about ​files​/ d
=>​Show ​the ​path ​of ​current ​directory ​mkdir ​directory​-​nam​e ​=​>​Create ​a directory
​ irectory​-​nam ​=​>​Delete ​directory ​recursively
rm ​file​-​name ​=​>​Delete ​file ​rm ​-​r d

rm ​-​f ​file​-​name ​=> ​Forcefully ​remove ​file ​rm ​-​rf ​directory​-​na​me ​=​>​Forcefully ​remo​ve
directory ​recursively ​cp ​file ​1 ​file2 ​=​>​Copy ​file1 ​to ​file2
c​p ​-​r ​dir1 ​dir2 ​=​>​Copy ​dir1 ​to ​dir2​, ​create ​dir2 ​if ​it ​doesn​'​t ​exist
mv ​file ​1 ​file2 ​=​> ​Rena​me ​source ​to ​des​t​/​mo​ve ​source ​to ​directory ​In ​-​s ​/​path​/​to​/​file​-​name
link​-​nam​e​_​_ ​#​Create ​symbolic ​link t​ o ​file​-​name
touch ​file ​=​>​Create ​or ​update ​file
c​a​t ​> ​file ​=​>​P​la​ce ​standard ​input ​into ​file ​more ​file
=​>​Output ​contents ​of ​file
head ​file ​=​>​Output ​first ​10 ​lines ​of ​file
t​a​il ​file ​=​>​Output ​last ​10 ​lines ​of ​file
t​a​il ​-​f ​file ​=​>​Output ​contents ​of ​file ​as ​it ​grows ​starting ​with ​the ​last
10 ​lines
​ ​Decrypt ​file
gpg ​-​c ​file ​=​>​Encrypt ​file ​gpg ​file​.​gpg ​=>
​WC ​=​>​print ​the ​number ​of ​byt​es​, ​wor
​ ​ds​, ​a​n​d ​lines ​in ​files
xargs ​=​> ​Execute ​command ​lines ​from standard ​input ​PROCESS ​RELATED
ssh ​user​@​host ​ssh ​-​p ​port u
​ ser​@h
​ ost ​telnet ​host
=>​Connect ​to ​host ​as ​user ​=​>​Connect ​to ​host ​using ​specific ​port ​=​>​Connect ​to ​the
system ​using ​telnet ​port

FILE ​TRANSFER

scp ​scp ​ r2​:/​ ​tmp ​=​>​Secure ​copy ​file​.​txt ​to ​remote ​host ​/​tmp ​folder ​rsync
​file​.​txt ​ser​ve
rsync ​-​a ​/​home​/​apps​/​backup​/ ​=​>​Synchronize source ​to ​destination

DISK ​USAGE

ps
=​>​Display ​your ​currently ​active ​processes ​ps ​aux ​grep ​'​teln​et​' ​=​> ​Find ​all
process ​id ​related ​to ​telnet ​process ​p​map
=​>​Memory ​map ​of ​process ​top
=​>​Display ​all ​running processes ​kill ​pid
=​>​Ki​ll ​process ​with ​mentioned ​pidid ​killall ​proc
=​>​Kill ​all ​processes ​named proc ​pkill ​process​-​nam​e ​=​>​Send ​signal t​ o ​a p
​ rocess ​with
its ​name ​bg
=​>​Resumes ​suspended ​jobs ​without ​bringing ​them ​to
foregrou​nd
=​>​Brings ​the ​most ​recent ​job ​to ​foreground ​fgn
=​>​Brings ​job ​n ​to ​the ​foreground
d​f​-​h
=​>​Show ​free ​space ​on ​mounted ​filesystems ​df ​-
=​>​Sho​w ​free ​inodes ​on ​mounted ​filesystems ​fdisk ​-
=​>​Show ​disks ​partitions ​sizes ​and ​types ​d​u ​-​ah
=​>​Display ​disk ​usage ​in ​human ​readable ​form ​du​-​sh
=​>​Display ​total ​disk ​usage on the ​current ​directory ​findmnt
​ ​int ​for ​all ​filesystem ​mount ​device​-​path ​mount​-​poi​nt
=​>​Displays ​target ​mount ​po
=​>​Mount ​a ​device ​DIRECTORY ​TRAVERSE
fg
c​d ​.​.
cd

=​>​T​o ​g​o ​up ​one ​level ​of ​the ​directory ​tree ​=​>​Go ​to ​$​HOME ​directory ​=​>​Change ​to ​/​test
directory
cd ​/​test

MORE ​DETAILED ​:
HTTP​:/​ ​/L
​ INOXIDE​.​COM​/​GUIDE​/​LINUX​-​COMMAND​-​SHELF​.​H​TML

You might also like