Useful Linux Commands: Part I

04 Feb

List of Linux commands which I use regularly.

  1. Remove .svn directories from current and sub directories under it:
    This command is useful when a SVN deliverable is to be given to a client.

    find   .   -name   “*.svn”   |   xargs   rm   -rf

  2. List file system content in human readable form:
    When you want to find out exact status of your disk quickly, you can use this command.

    df     -h

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1             125G  109G  9.7G  92% /
    none                  741M  260K  741M   1% /dev
    none                  750M   12M  738M   2% /dev/shm
    none                  750M  128K  749M   1% /var/run
    none                  750M     0  750M   0% /var/lock
    none                  750M     0  750M   0% /lib/init/rw
  3. List the details of all the processes running which have ‘keyword’ in its command
    When you want to find out more details of the process/es which are executing a particular command.

    ps    aux    |    grep    “keyword”

    ps aux | grep terminal
    user 11005 5.9 42.2 3055624 647596 ? Rl Feb03 178:48 /usr/bin/xfce4-terminal

  4. Kill a process with a hydrogen bomb:
    When a process is taking too long to proceed further or load and you want to restart it but before that you want to kill this existing one!

    kill    -9    process_id   

    Note: Be careful about the process_id you are supplying, else you may end up crashing your system!


  6. Insert/Remove (load/unload) a LKM (Loadable Kernel Module) :
    LKMs are normally developed to test a new file system or interface. Below commands come very handy while debugging or to try out quickly some changes to the module. Ensure you have removed the previously installed module before trying the new version.

    sudo    insmod    my_kernel_module.ko   

    sudo    rmmod    my_kernel_module.ko   

    modprobe is another intelligent option to do the same!   

  7. Copying files intelligently:
    I used this option during Android/Angstrom kernel/driver development on BeagleBoard where I wanted to copy the updated Device images and other files to a SD card. -l option copies symlinks as symlinks.

    rsync    -l    source    destination   

  8. Watch output of a command on a periodic basis:
    Following command-set executes ‘ls -l *.mp4’ command every five seconds and shows its output.

    watch    -n    5    ls    -l    *.mp4

    If you want to watch syslog content (last 5 lines) after every one minute, you can use following command-set.

    watch    -n    60    tail    -5    /var/log/syslog

  9. Find number of times a word/pharase appears in a file:
    During my previous project I needed this command-set to get an idea of refactoring effort.

    cat  my_file | grep -o ‘phrase’ | wc -l

    If you need to count number of times ‘device’ appears in syslog.

    cat  /var/log/syslog  | grep -o ‘device’ | wc -l

    For more Linux command reference please visit:


Posted by on February 4, 2011 in Linux, Technical


Tags: , , , , , , , , , , , , , ,

3 responses to “Useful Linux Commands: Part I

  1. Karl Jeanphilippe

    February 10, 2011 at 4:22 am

    I simply want to mention I am beginner to blogs and actually enjoyed your web page. Probably I’m going to bookmark your blog post . You certainly come with exceptional articles and reviews. Regards for revealing your website.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: