Useful Linux Commands

This post is a live post and shall contain some useful commands that come in handy in daily work. Rather than keeping it on Google drive, post is more useful.

Getting top 10 files using most disk space

$ du -a /usr/local | sort -n -r | head -n 10

This command returns top 10 files using most disk space. Replace /usr/local to specific directory and replace 10 at the end of command to get the desired number of files.

Getting File Name from tar.gz extension


This command shall return a string minus .tar.gz. I had used it while writing automation script for installing software. $ is part of the command and is not the shell prompt.

If you know of better solutions for these, please do comment and I shall update/add them to the list.

Replacing properties using sed

Let’s see an example of updating tickTime property in Zookeeper’s zoo.cfg

sed -i -r s/tickTime=.*/tickTime=$TICK_TIME/ ${zookeeperbase}/conf/zoo.cfg

This command updates tickTime property with whatever value you provide with TICK_TIME variable.
I found it very useful while updating properties files during installations.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.