Useful Commands for Linux Users – Episode 5

The Command-line is more powerful because you can do lots with them. Yyou can tell your computer exactly what you want and get the appropriate answer, while GUI application can only tell your computer what the GUI programmer has defined.

Recently, CLI is mostly used by Linux/Unix administrators since most popular Linux distributions come with a complete set of GUI applications that make the user interact less with the command-line.

In this post we will see 10 commands that can be useful for any Linux user.

1 Find corrupted JPG image files

This command line allow you to find all corrupted JPG files in current directory and its subdirectories and displays any error or warning found:

$ find . -name "*jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR"

2 Get all possible problems from any log files

Using the grep command, retrieve all lines from any log files in /var/log/ that have one of the problem states:

$ grep -2 -iIr "err\|warn\|fail\|crit" /var/log/*

3 Combine mkdir & cd into single command

This command allow you to create and cd the new directory in a single command:


 4 Measure, explain and minimize a computer’s electrical power consumption

Run this command as root to get enough stats. It works on AMD and Intel machines including desktops. If you run on a laptop it’ll give you suggestions on extending your battery life.

You’ll need to install PowerTOP if you don’t have, via ‘apt-get install powertop‘ etc.

To grep the output use:

$ sudo powertop -d | grep ...


5 Convert lowercase letters to upper case and vice versa

The following command is used to convert the letters from lower case to upper case and vice versa. It will be used mainly when creating scripts:

$ echo unixmen | tr '[a-z]' '[A-Z]'
$ echo UNIXMEN | tr '[A-Z]' '[a-z]'

6 Record your desktop using ffmpeg command

Using the following command we can record our desktop and save as a video file:

$ ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 25 -i :0.0 -vcodec mpeg2video -ar 44100 -s wvga -y -sameq desktop.mpg

The above command will record all your desktop activities and store it in your current working folder.

7 Execute a command at a particular time

It’s similar to cronjob command. It will execute the users command at a given time:

$ echo "cat > sk.txt" | at 15.04
warning: commands will be executed using /bin/sh
job 1 at Wed May 29 15:04:00 2013

The above command will create a new file called sk.txt at 3:04pm.

8 Display top ten running processes sorted by memory usage

$ ps aux | sort -nk +4 | tail

The above command will display the top ten processes which are sorted by their memory usage.

9 Check your system type whether it is 32 or 64bit

The below command will display if the system is 32 or 64 bit. Run the following command in your terminal and verify your system version:

$ getconf LONG_BIT

10 Display current Internet usage of applications

The below command will show you which applications are using the internet at present:

$ lsof -P -i -n