20 Advanced Commands For Middle Level Linux Users
20 Advanced Commands For Middle Level Linux Users
By Avishek Under: Linux Commands On: May 23, 2013 You migh have !ound he !irs ar i"#e very mu"h use!u#, his ar i"#e is an ex ension o! he 20 Use!u# Commands !or Linux $e%&ies' (he !irs ar i"#e %as in ended !or ne%&ies and his ar i"#e is !or Middle-Level-User and Advanced Users' )ere you %i## !ind ho% o "us omise sear"h, kno% he *ro"esses running guide o ki## hem, ho% o make your Linux ermina# *rodu" ive is an im*or an as*e" and ho% o "om*i#e c, c++, java *rograms in nix' 20 Linux Advan"ed + ,x*er Commands
No e: (he /-name0 o* ion makes he sear"h "ase sensi ive' You "an use he /-iname0 o* ion o !ind some hing regard#ess o! "ase' 1! is a %i#d"ard and sear"hes a## he !i#e having ex ension 0.s"0 you "an use !i#ename or a *ar o! !i#e name o "us omise he ou *u 2'
root@tecmint:~# find -iname *.() * find -iname *.(h / find -iname *.s)+
./Desktop/load.sh ./Desktop/test.sh ./Desktop/shutdown.sh ./Binary/firefox/run-mo illa.sh ./Downloads/kdewe!de"-#.$.%/&uanta/scripts/externalpre"iew.sh ./Downloads/kdewe!de"-#.$.%/admin/doxy'en.sh ./Downloads/kdewe!de"-#.$.%/admin/c"s.sh ./Downloads/kdewe!de"-#.$.%/admin/ltmain.sh ./Downloads/whee y-n"-install.sh root@tecmint:~# find -name *.tar.' /"ar/www/modules/update/tests/aaa,update,test.tar.' ./"ar/cache/flashplu'in-nonfree/install,flash,player,--,linux.i#%..tar.' ./home/ser"er/Downloads/drupal-/.00.tar.' ./home/ser"er/Downloads/smtp-/.x--.1.tar.' ./home/ser"er/Downloads/nore&newpass-/.x--.0.tar.' ./usr/share/'ettext/archi"e.'it.tar.' ./usr/share/doc/ap'/php.tar.' ./usr/share/doc/festi"al/examples/speech,pm,-.1.tar.' ./usr/share/doc/ar'yll/examples/spyder0.tar.' ./usr/share/us!,modeswitch/confi'2ack.tar.'
Page1
No e: (he a&ove "ommand sear"hes !or a## he !i#e having ex ension 0 ar.#$0 in roo dire" ory and a## he su&.dire" ories in"#uding moun ed devi"es' 3ead more exam*#es o! Linux 0find0 "ommand a 34 5ind Command ,xam*#es in Linux
6gnore %ord "ase and a## o her "om&ina ion %i h 0-i0 o* ion'
root@tecmint:~# 'rep -i 3567893 /etc/passwd tecmint:x:-111:-111:3ecmint444:/home/tecmint:/!in/!ash
-ear"h re"ursive#y 1-r2 i.e. read a## !i#es under ea"h dire" ory !or a s ring 712(.0.0.17'
root@tecmint:~# 'rep -r :-0/.1.1.-: /etc/ /etc/"lc/lua/http/.hosts:-0/.1.1./etc/speech-dispatcher/modules/i"ona.conf:#8"ona(er"er)ost :-0/.1.1.-: /etc/mys&l/my.cnf:!ind-address ; -0/.1.1./etc/apache0/mods-a"aila!le/status.conf: <llow from -0/.1.1.- ::/etc/apache0/mods-a"aila!le/ldap.conf: <llow from -0/.1.1.- ::/etc/apache0/mods-a"aila!le/info.conf: <llow from -0/.1.1.- ::/etc/apache0/mods-a"aila!le/proxy,!alancer.conf:# <llow from -0/.1.1.- ::/etc/security/access.conf:#= : root : -0/.1.1./etc/dhcp/dhclient.conf:#prepend domain-name-ser"ers -0/.1.1.-> /etc/dhcp/dhclient.conf:# option domain-name-ser"ers -0/.1.1.-> /etc/init/network-interface.conf: ifconfi' lo -0/.1.1.- up ?? true /etc/@a"a-.-open@dk/net.properties:# localhost A -0/.1.1.-+. /etc/@a"a-.-open@dk/net.properties:# http.non2roxy)osts;localhost?-0/.1.1./etc/@a"a-.-open@dk/net.properties:# localhost A -0/.1.1.-+. /etc/@a"a-.-open@dk/net.properties:# ftp.non2roxy)osts;localhost?-0/.1.1./etc/hosts:-0/.1.1.localhost
No e: You "an use hese !o##o%ing o* ions a#ong %i h #re%' 1' -' !or %ord 1egre* .% 0'ord18'ord20 9*a h9 o9!i#e2' 2' -c !or "oun 1i'e', o a# num&er o! imes he *a ern ma "hed2 1gre* ." 0'ord0 9*a h9 o9!i#e2' 3' )color !or "o#oured ou *u 1gre* )color server 9e "9*ass%d2'
7<9*-+ pa'er utils 9<75 man - an interface to the on-line reference manuals
7anual 7<9*-+
(B9C2(8( man D-6 fileE D-dE D-DE D--warnin'sD;warnin'sEE D-F encodin'E D-G localeE D-m systemD4...EE D-7 pathE D-( listE D-e extensionE D-i?-8E D--re'ex?--wildcardE D--names-onlyE D-aE D-uE D--no-su!pa'esE D-2 pa'erE D-r promptE D-/E D-5 encodin'E D--no-hyphenationE D--no-@ustificationE D-p strin'E D-tE D-3Dde"iceEE D-)D!rowserEE D-HDdpiEE D-IE DDsectionE pa'e ...E ... man -k Dapropos optionsE re'exp ... man -J D-w?-KE D-( listE D-i?-8E D--re'exE DsectionE term ... man -f Dwhatis optionsE pa'e ... man -l D-6 fileE D-dE D-DE D--warnin'sD;warnin'sEE D-F encodin'E D-G localeE D-2 pa'erE D-r promptE D-/E D-5 encodin'E D-p strin'E D-tE D-3Dde"iceEE D-)D!rowserEE D-HDdpiEE D-IE file ... man -w?-K D-6 fileE D-dE D-DE pa'e ... man -c D-6 fileE D-dE D-DE pa'e ... man D-hLE
Manua# *age !or man *age i se#!, simi#ar#y 0man ca 0 1Manua# *age !or "a "ommand2 and 0man ls0 1Manua# *age !or "ommand #s2' No e: man *age is in ended !or "ommand re!eren"e and #earning'
2+. Command: %s
%s 1,rocess2 gives he s a us o! running *ro"esses %i h a uni;ue -d "a##ed ,-.'
root@tecmint:~# ps 28D 33B M-/1 pts/N.0% pts/3875 67D 11:11:11 !ash 11:11:11 ps
(o #is s a us o! a## he *ro"esses a#ong %i h *ro"ess id and ,-., use o* ion 0-A0'
root@tecmint:~# ps -< 28D 33B - O 0 O # O $ O / O % O N O .... 3875 67D 11:11:1- init 11:11:11 kthreadd 11:11:1- ksoftir&d/1 11:11:11 kworker/1:1) 11:11:11 kworker/u:1) 11:11:11 mi'ration/1 11:11:11 rcu,!h
No e: (his "ommand is very use!u# %hen you %an o kno% %hi"h *ro"esses are running or may need ,-. some imes, !or *ro"ess o &e ki##ed' You "an use i %i h 0#re%0 "ommand o !ind "us omised ou *u ' 5or exam*#e,
root@tecmint:~# ps -< ? 'rep -i ssh -$11 O 11:1N:$% sshd
Page1
M#-/ O
11:11:11 sshd
)ere 0%s0 is *i*e#ined %i h 0#re%0 "ommand o !ind "us omised and re#evan ou *u o! our need'
5ind *ro"ess 0a%ac"e20, no e i s %id and 0ill i ' 5or exam*#e, in my "ase 0a%ac"e20 *id is 0121/0'
root@tecmint:~# kill -0%$ *to kill the process apache0+
No e: ,very ime you re.run a *ro"ess or s ar a sys em, a ne% %id is genera ed !or ea"h *ro"ess and you "an kno% a&ou he "urren running *ro"esses and i s %id using "ommand 0%s0' Ano her %ay o ki## he same *ro"ess is'
root@tecmint:~# pkill apache0
No e: <i## re;uires jo2 id 9 %rocess id !or sending signa#s, %here as in %0ill3 you have an o* ion o! using *a ern, s*e"i!ying *ro"ess o%ner, e "'
No e: (his is use!u# o kno% %here he &inaries are ins a##ed !or manua# edi ing some imes'
Page1
(he 0service0 "ommand "on ro#s he 7 ar in#, 7 o%%in# or 8es ar in# o! a 0service0' (his "ommand make i *ossi&#e o s ar , res ar or s o% a servi"e %i hou res ar ing he sys em, !or he "hanges o &e aken in o e!!e" ' 7 ar in# an a%ac"e2 server on U2un u
root@tecmint:~# ser"ice apache0 start * (tartin' we! ser"er apache0 apache0: 6ould not relia!ly determine the ser"erPs fully &ualified domain name4 usin' -0/.1.-.- for (er"er9ame httpd *pid -0%$+ already runnin' D CJ E
No e: A## he *ro"ess s"ri* #ies in 0&e c&ini .d0, and he *a h migh needs o &e in"#uded on "er ain sys em, i'e', in s*i e o! running 7service a%ac"e2 s ar = you %ou#d &e asked o run 7service &e c&ini .d&a%ac"e2 s ar ='
Page1
0 0 0 0 0
7ay / -.:$% 7usic 7ay 01 -.:-/ 2ictures 7ay / -.:$% 2u!lic 7ay / -.:$% 3emplates 7ay / -.:$% Lideos
Making a #i #e !un ou o! his "ommand' Make a#ias o! "er ain im*or an "ommand o some o her im*or an "ommand'
alias cd;Pls -lP *set alias of ls -l to cd+ alias su;PpwdP *set alias of pwd to su+ .... *Bou can create your own+ ....
$o% %hen your !riend y*es 0cd0, >us hink ho% !unny i %ou#d &e %hen he ge s dire" ory #is ing and no dire" ory "hanging' And %hen he ries o &e 0su0 he a## he ge s is he #o"a ion o! %orking dire" ory' You "an remove he a#ias #a er using "ommand 0unalias0 as ex*#ained a&ove'
29. Command: df
3e*or disk usages o! !i#e sys em' Use!u# !or user as %e## as -ys em Adminis ra or o kee* ra"k o! heir disk usages' 0df0 %orks &y examining dire" ory en ries, %hi"h genera##y are u*da ed on#y %hen a !i#e is "#osed'
root@tecmint:~# df Qilesystem /de"/sdanone ude" tmpfs none none none /de"/sda$ /de"/sda/ /de"/sda% -J-!locks Rsed <"aila!le RseS 7ounted on M/N0N00M /%--N1% #/./$NM% -%S / M 1 M 1S /sys/fs/c'roup -11$N-. M -11$N-0 -S /de" 010%0M %-. 01011% -S /run $-01 1 $-01 1S /run/lock -1-M-01 .0% -1-#MN0 -S /run/shm -10M11 MM -10#$. -S /run/user -%M#1/ /N%$0 NM/0/ M.S /!oot N$N%N$-. .--1M N-1M$./. -S /data N-N$#-N0 $/1#0 %/0-%$0% -S /personal
5or more exam*#es o! 0df0 "ommand, read he ar i"#e 12 d! Command ,xam*#es in Linux'
*0. Command: du
,s ima e !i#e s*a"e usage' Ou *u he summary o! disk usages &y ever !i#e hierar"hi"a##y, i'e', in re"ursive manner'
root@tecmint:~# du
Page1
./Daily 2ics/wp-polls/ima'es/default,'radient ./Daily 2ics/wp-polls/ima'es/default ./Daily 2ics/wp-polls/ima'es ./Daily 2ics/wp-polls/tinymce/plu'ins/polls/lan's ./Daily 2ics/wp-polls/tinymce/plu'ins/polls/im' ./Daily 2ics/wp-polls/tinymce/plu'ins/polls ./Daily 2ics/wp-polls/tinymce/plu'ins ./Daily 2ics/wp-polls/tinymce ./Daily 2ics/wp-polls ./Daily 2ics ./2lu'ins/wordpress-author-!ox ./2lu'ins ./7ay <rticles 01-#/Htreme Download 7ana'er ./7ay <rticles 01-#/H6ache
No e: 0df0 on#y re*or s usage s a is i"s on !i#e sys ems, %hi#e 0du0, on he o her hand, measures dire" ory "on en s' 5or more 0du0 "ommand exam*#es and usage, read 10 du 1?isk Usage2 Commands'
*1. Command: rm
(he "ommand 0rm0 s ands !or remove' rm is used o remove !i#es 1s2 and dire" ories' 8emovin# a direc or6
root@tecmint:~# rm 2assport<pplicationQorm,7ain,5n'lish,L-.1 rm: cannot remo"e T2assport<pplicationQorm,7ain,5n'lish,L-.1P: 8s a directory
(he dire" ory "an: &e removed sim*#y &y 0rm0 "ommand, you have o use 0-rf0 s%i "h a#ong %i h 0rm0'
root@tecmint:~# rm -rf 2assport<pplicationQorm,7ain,5n'lish,L-.1
:arnin#: 7rm -rf= "ommand is a des ru" ive "ommand i! a""iden #y you make i o he %rong dire" ory' On"e you 0rm -rf0 a dire" ory a## he !i#es and he dire" ory i se#! is #os !orever, a## o! a sudden' Use i %i h "au ion'
1' "rea e a !i#e, named 0in erac ive;s"ell.s"0 on desk o*' 13emem&er 0.s"0 ex ension is mus 2' 2' "o*y and *as e he &e#o% s"ri* , exa" #y same, as &e#o%'
#U/!in/!ash
Page1
echo :2lease enter your name:: read name echo :Kelcome to Ginux Vname:
No e: 0<=&2in&2as"0 e##s he she## ha i is an s"ri* an i is a#%ays a good idea o in"#ude i a he o* o! s"ri* ' 0read0 reads he given in*u '
No e: (he 0l%>0 "ommand #e s you vie% he s a us o! a *rin er 1%he her i :s u* or no 2, and he >o&s 1!i#es2 %ai ing o &e *rin ed'
Page1
Page1
sd! ^]sd!-
%:-. %:-/
#./[ #./[
1 disk 1 part
5rom his s"reen i %as "#ear ha 6 *#ugged in a + A5 *endrive hus 0sd210 is my !i#esys em o &e moun ed' Be"ome a roo o *er!orm his o*era ion and "hange o &dev dire" ory %here a## he !i#e sys em is moun ed'
root@tecmint:~# su 2assword: root@tecmint:~# cd /de"
Crea e a dire" ory named any hing &u shou#d &e re#even !or re!eren"e'
root@tecmint:~# mkdir us!
$o% you "an naviga e o &dev&us2 !rom ermina# or B-'indo's sys em and a"ess !i#e !rom he moun ed dire" ory'
No e: On "om*i#ing a c *rogram he ou *u is au oma i"a##y genera ed o a ne% !i#e 7a.ou = and every ime you "om*i#e a c *rogram same !i#e 7a.ou = ge s modi!ied' )en"e i is a good advi"e o de!ine a ou *u !i#e during "om*i#e and hus here is no risk o! over%ri e o ou *u !i#e'
Com%ile i "is 'a6 root@tecmint:~# 'cc -o )ello )ello.c
Page1
)ere 0-o0 sends he ou *u o 0?ello0 !i#e and no 0a.ou 0' 3un i again'
root@tecmint:~# ./)ello )ello world
b Com%ile i
root@tecmint:~# '== <dd.cpp 8un i root@tecmint:~# ./a.out 5nter first num!er: ... ...
No e: On "om*i#ing a c++ *rogram he ou *u is au oma i"a##y genera ed o a ne% !i#e 7a.ou = and every ime you "om*i#e a c++ *rogram same !i#e 7a.ou = ge s modi!ied' )en"e i is a good advi"e o de!ine a ou *u !i#e during "om*i#e and hus here is no risk o! over%ri e o ou *u !i#e'
Com%ile i "is 'a6 root@tecmint:~# '== -o <dd <dd.cpp 8un i root@tecmint:~# ./<dd 5nter first num!er: ... ...
Page1
No e: A#mos every dis ri&u ion "omes *a"ked %i h #cc com%iler, ma>or num&er o! dis ros have in&ui# #++ and java com%iler, %hi#e some may no have' You "an a% or 6um he re;uired *a"kage' ?on: !orge o men ion your va#uea&#e "ommen and he y*e o! ar i"#e you %an o see here' 6 %i## soon &e &a"k %i h an in eres ing o*i" a&ou he #esser kno%n !a" s a&ou Linux'
Page1