Search This Blog

Saturday 10 March 2012

Linux Tips


------------------------------------------------------------------------------------
Who is SUPER USER in linux
awk -F: '$3 == 0{print $1,"superuser!"}' /etc/passwd
------------------------------------------------------------------------------------
How to get Environment for a process
If the process id is 920.
(cat /proc/920/environ; echo) : tr "\000" "\n"
------------------------------------------------------------------------------------
How to list files with their complete path
If 'childdir' is the name of directory.
find childdir -type f -printf "%AY%Am%Ad%AH%AM %p\n" : sort -r : gawk
'{print $2}'
------------------------------------------------------------------------------------
How to find open files in linux
find /proc -regex "/proc/[0-9]*/fd/.*" -ls
------------------------------------------------------------------------------------
Formatting man pages
man ls : col -bx > myfile.txt
------------------------------------------------------------------------------------
Finding the biggest files
ls -l : sort +4n
------------------------------------------------------------------------------------
Searching files for content
find / -name "filename" : xargs grep -n content
------------------------------------------------------------------------------------
Largest Directories
du -kx : egrep -v "\./.+/" : sort -n
-----------------------------------------------------------------------------------
List today's files only
ls -al --time-style +%D : grep `date +%D`
------------------------------------------------------------------------------------
Encrypt some plain text
perl -e 'print crypt("ke", "password");'
-----------------------------------------------------------------------------------
Look for unusual SUID root files
find / -uid 0 -perm -4000 -print
-----------------------------------------------------------------------------------
Look for unusual large files (> 10 Mb)
find / -size +10000k -print
-----------------------------------------------------------------------------------

No comments:

Post a Comment