Monday, December 13, 2010

Linux Amazing Keypresses & Commands : Set 5

  • Finding the top 20 processing in consuming the RAM.
$ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 20
This command will list the top 20 process in decreasing order of their RAM consumption. It will be more helpful if you add a alias this command. Another solution for it is htop.
Install htop. For Fedora/RedHat users.
$yum install htop
For Ubuntu users.
$sudo apt-get install htop
For sorting the processes run htop & type
M for RAM
P for CPU
T for TIME
To invert the processes type I.



  • Command chaining.
You can chain a number a commands so the you can fetch a burger while your linux box is busy executing them.
In order to execute a series of commands regardless of any error, we have to chain them with ';'. For example,
#cd /home/rom/; ls ; cd /home/guest/ ; ls
In order to execute them only if preceding one executed successfully, we will chain them using '&&'.
#cd test && cp -f -R * /home/ron/new && rm -f -R *
In order to execute them only if preceding one fails, we will chain them using '||'.
#cd new || mkdir new

  • Deleting files using their inode value. Use ls -l to list the inode value.
#find . -inum 123456 -exec rm -i {} \;


References:
http://htop.sourceforge.net/
http://bashshell.net/
http://www.linuxaria.com/

No comments:

Post a Comment