Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
More tar examples: The Ultimate Tar Command Tutorial with 10 ractical Examples
rint the matched line% along with the & lines after it.
$ grep -A 3 -i "example" demo_text
More grep examples: (et a (rip on the (rep) * 1+ ractical (rep Command Examples
More find examples: Momm'% . found it) / 1+ ractical 0inux ,ind Command Examples
rint all lines from :etc:passwd that has the same uid and gid
$a>: -4 7C7 7$3;;$D7 pass>d.txt
More aw9 examples: ; owerful 7w9 2uilt#in Varia-les * ,!% 5,!% 8!% 58!% <8% <,% ,.0E<7ME% ,<8
More diff examples: Top = ,ile 1ifference Tools on U<.> : 0inux * 1iff% Colordiff% 4diff% Vimdiff
5rder ,iles 2ased on 0ast Modified Time ".n 8everse 5rder$ Using ls #ltr
$ ls -ltr
$ gOip -d test.txt.gO
More -@ipF examples: 2G is Ea@') -@ipF% -@grep% -@cmp% -@diff% -@cat% -@less% -@more examples
To view the file names located on the remote server -efore downloading% mls ftp command as shown -elow.
ftpJ mls *.html /ftptest/feat#res.html /ftptest/index.html /ftptest/othertools.html /ftptest/samplereport.html /ftptest/#sage.html
8estart a service.
# service ssh restart
ps command is used to displa' information a-out the processes that are running in the s'stem. 4hile there are lot of arguments that could -e passed to a ps command% following are some of the common ones. To view current running processes.
$ ps -ef < more
To view current running processes in a tree structure. 3 option stands for process hierarch'.
$ ps -ef- < more
.f 'ou want to Iuic9l' chec9 how man' (2 of 87M 'our s'stem has use the #g option. #option displa's in -'tes% #9 in 9ilo -'tes% #m in mega -'tes.
$ free -g total MemC 3 -/E 5#ffers/cacheC ,>apC 3 #sed / 2 2 free / 6 3 shared 2 5#ffers 2 cached 2
.f 'ou want to see a total memor' " including the swap$% use the #t switch% which will displa' a total line as shown -elow.
rameshTramesh-laptopC($ free -t total #sed MemC 3"SSD2Q /".6/DQ -/E 5#ffers/cacheC D3"336 ,>apC D222/3S 2 NotalC 3"SS"QD /".6/DQ free /.3D6S2 32./23S D222/3S ".3DD3S shared 2 5#ffers 62D6S2 cached ./6""S
To displa's onl' the processes that -elong to a particular user use #u option. The following will show onl' the top processes that -elongs to oracle user.
$ top -# oracle
More top examples: Can Jou Top ThisK 1+ ractical 0inux Top Command Examples
df #h displa's output in human reada-le form. i.e si@e will -e displa'ed in (2Ls.
rameshTramesh-laptopC($ df -h 4ilesystem ,iOe Used Avail UseR Mo#nted on /dev/sda/ 6.9 3./9 6D9 /6R / /dev/sda6 //"9 DQ9 S69 DDR /home
More 9ill examples: = 4a's to Aill a rocess * 9ill% 9illall% p9ill% x9ill
.t is ver' useful while giving shell metacharacters in the file name argument. rint the filename and get confirmation -efore removing the file.
$ rm -i file*
,ollowing example recursivel' removes all files and directories under the example director'. This also removes the example director' itself.
$ rm -r example
Cop' file1 to fileF. if fileF exists prompt for confirmation -efore overwritting it.
$ cp -i file/ file6
<ote: mv #f is ?ust the opposite% which will overwrite fileF without prompting. mv #v will print what is happening during file rename% which is useful while specif'ing shell metacharacters in the file name argument.
$ mv -v file/ file6
4hile displa'ing the file% following cat #n command will prepend the line num-er to each line of the output.
$ cat -n /etc/logrotate.conf / /var/log/5tmp $ 6 missingo: 3 monthly D create 2SS2 root #tmp " rotate / S %
Jou can also add this to the fsta- for automatic mounting. i.e 7n'time s'stem is restarted% the files'stem will -e mounted.
/dev/sd5/ /#2/ ext6 defa#lts 2 6
8evo9e all access for the group "i.e read% write and execute $ on a specific file.
$ chmod g-r>x file.txt
7ppl' the file permissions recursivel' to all the files in the su-#directories.
$ chmod -F #gEr>x file.txt
!uper user can use passwd command to reset others password. This will not prompt for current password of the user.
# pass>d U,LF=AML
8emove password for a specific user. 8oot user can disa-le password for a specific user. 5nce the password is disa-led% the user can login without entering the password.
# pass>d -d U,LF=AML
Create nested directories using one m9dir command. .f an' of these directories exist alread'% it will not displa' an' error. .f an' of these directories doesnLt exist% it will create them.
$ m:dir -p dir//dir6/dir3/dirD/
!tart or stop a specific interface using up and down command as shown -elow.
$ ifconfig eth2 #p $ ifconfig eth2 do>n
4hen 'ou want to find out where a specific Unix command exists "for example% where does ls command existsK$% 'ou can execute the following command.
$ >hereis ls lsC /5in/ls /#sr/share/man/man//ls./.gO /#sr/share/man/man/p/ls./p.gO
4hen 'ou want to search an executa-le from a path other than the whereis default path% 'ou can use #2 option and give path as argument to it. This searches for the executa-le lsm9 in the :tmp director'% and displa's it% if it is availa-le.
$ >hereis -# -K /tmp -f lsm: lsm:C /tmp/lsm:
4hen a man page for a command is located under more than one section% 'ou can view the man page for that command from a specific section as shown -elow.
$ man ,L NM+=-=UMKLF commandname
1. (eneral commands F. !'stem calls &. C li-rar' functions =. !pecial files "usuall' devices% those found in :dev$ and drivers +. ,ile formats and conventions D. (ames and screensavers N. Miscellaneous ;. !'stem administration commands and daemons ,or example% when 'ou do whatis cronta-% 'ouLll notice that cronta- has two man pages "section 1 and section +$. To view section + of cronta- man page% do the following.
$ >hatis cronta5 cronta5 ?/@ cronta5 ?"@ $ man " cronta5 - maintain cronta5 files for individ#al #sers ?*3@ - ta5les for driving cron
View the content of the file in real time using tail #f. This is useful to view the log files% that 9eeps growing. The command can -e terminated using CT80#C.
$ tail -f log-file
More tail examples: & Methods To View tail #f output of Multiple 0og ,iles in 5ne Terminal
5ne 'ou open a file using less command% following two 9e's are ver' helpful.
NF1E4 P for>ard one >indo> NF1EK P 5ac:>ard one >indo>
More less examples: Unix 0ess Command: 10 Tips for Effective <avigation
Execute a single command from a different account name. .n the following example% ?ohn can execute the ls command as ra? username. 5nce the command is executed% it will come -ac9 to ?ohnLs account.
A)ohnTdev-serverB$ s# - ra) -c 7ls7 A)ohnTdev-serverB$
0ogin to a specified user account% and execute the specified shell instead of the default shell.
$ s# -s 7,-L11=AML7 U,LF=AML
.f 'ou want to specif' the m'sIl root password in the command line itself% enter it immediatel' after #p "without an' space$.
More rpm examples: 8 M Command: 1+ Examples to .nstall% Uninstall% Upgrade% Ouer' 8 M ac9ages
5nce 'ouLve changed the s'stem date% 'ou should s'ncroni@e the hardware cloc9 with the s'stem date as shown -elow.
# h>cloc: Psystohc # h>cloc: --systohc P#tc
More wget examples: The Ultimate 4get 1ownload (uide 4ith 1+ 7wesome Examples 1id . miss an' freIuentl' used 0inux commandsK 0eave a comment and let me 9now