Monday, 2 May 2016

Useful UNIX /Linux commands.

ls -lart <files starting with>*
ex: ls -lart a*---lists all files with a

grep -i <words to search> *.js
ex: grep -i grarr *.js----lists all files with .jsextension having the words grarr along with the content where the line is present.

 netstat -an|grep <portnumber to check>
ex: netstat -an|grep 111111 ------if the port is not free it ll display the status of the port.If the port is free then it will not display any thing.

grep -il "*<string to search>*" *js
ex:grep -il "grl" *scr -----searches for the string "grl" all files with extension js


find . -name "*<part of file name>*"
ex:find . -name "*report*" ----finds all the subdirectories with the file name having the word "report"

kill -9 <pid name>
ex: kill -9 12344 ------kills the pid with 12344


find . -name "*<part of file name>*" |xargs grep -i "<string to search>*"
ex: find . -name "*report*" |xargs grep -i "grl*"  -----searches all files having the name report having the contents as "grl"


tail -f <file name>
ex: tail -f catalina.out  -----displays last 10 lines in the file. when the file is updated the 10 lines are also updated.



ex:  grep -r "*test*" /data/imp  --search all the the files recursively in all sub folders in "imp" folder for the string test

ex:
du -sh
size of the current directory

No comments:

Post a Comment