Header Ads

Make the Linux Terminal More Productive


Today GNU/Linux has come a long way and you don’t need to touch the command-line for performing everyday tasks, but if GUI is a little too n00b for you, here are a few tricks to make you a command-line ninja.

Watch videos

If static ASCII art is too boring for you try and watch a video in command line. Not only is it possible, it is very simple too. Install mplayer on a debianbased system. To do this, type sudo apt-get install mplayer

Then to watch the video, fire up a terminal and type mplayer -vo caca filename. avi.

The screenshot doesn’t do justice to the geeky glory of watching video in text

If the above is not retro enough for you, you can watch it in black and white too mplayer -vo aa filaname. avi. Works best for simple 2D animated content such as SouthPark.

Change your MAC address

So your university insists on infringing your privacy by tracking you via your MAC address, you can always be a step ahead by changing it to whatever you fancy. All you have to do is bring the interface down then use the hw ether switch to change it and then pull up the interface back again.

$ ifconfig eth0 down
$ ifconfig eth0 hw ether ff:ff:ff:ff:ff:ff
$ ifconfig eth0 up

Remember the MAC address will always be in HEX format.

Easy filesharing

Ever wanted to share a directory and its content quickly over the network? If yes, simply type cd in the directory you want to share and issue the following command:

$ python -c “import SimpleHTTPServer;SimpleHTTPS erver.test()”

and everything under this directory will be served at the port 8000 via a new web server. So your friends can point at http://YourIP:8000/ to access the content. When done, simply close the terminal window or press [Ctrl] + [C] to terminate the process.

Long commands


If you think you will never be able to remember the long command given in the above tip, you are right. This is where the role of “alias” comes in alias short_name= ‘command_ name arg1 arg2 arg3’ For example you can first form the following alias, by issuing the command in the terminal

$ alias share_dir=’python -c “import SimpleHTTPServer;SimpleHTTPServer. test()”’

and from now you can just type share_dir to share your current directory over the internet.

Alias are generally stored in your ~/.bashrc file, so you don’t have to manually make them for each terminal session. If you ever want to use alias without its expansion you can use the \ mark before it. For example, if you have an alias like the following

alias ls=’ls --color=auto’

and want use ls without that --color option the you can issue the following: $ \ls.

Editing your .bashrc

The .bashrc file located in your home directory is the configuration file for your bash shell. It is executed every time you open a terminal window or invoke the shell. Therefore it is a great place to store your “alias”. To open it, type the following and hit return: $ gedit ~/.bashrc

You can use it for fun stuff such as displaying a message every time your shell is started or for more useful stuff as making your default startup directory as your Desktop folder instead of your home directory when you invoke the shell. Both of these can be achieved simply by typing the following in your .bashrc. echo “message you want to display” cd Desktop.

Customise your shell experience

You can edit this file to include whatever fancies your, there are also some default alias present over there, especially related to the ls command that you can enable/ disable by simply uncommenting/ commenting them.

Type less do more

This one is self-explanatory and a huge timesaver, just look at the example below.

$ cd /digit/long/path/ pain/to/type/again
cd: /digit/long/path/ pain/to/type/again: No such file or directory
$ mkdir !*
mkdir /digit/long/path/ pain/to/type/again

!* works with any command and not just mkdir to run it with same arguments as the command before it.

Killing applications

On issue of kill -9 Process_id the application with that particular process_id (pid) will get killed no matter how badly it is hung. To find the PID of any application type the following $ ps –e | grep app_name

You don’t even need to type in the full application name, for example typing just fire for Firefox would do. If you find the above process too tedious you can also use the less powerful but more convenient killall command $ killall application_name

A word of caution if you type the following command $ kill -9 -1, it will kill all processes that you have the privileges to kill.

System monitor

If you’re not satisfied with merely killing an application from the command line and want to see where your system resources are going in detail, then Htop is a neat little application for that.

Since it is universally present in the default repositories it can be easily installed. On a Debian-based distribution (include Ubuntu) this can be done by issuing the following sudo apt-get install htop. You can view processor/memory usage of all application, change their processing priority, kill them and much more with Htop.

R for remember

Finally we had reserved the best for the last. All of us have found ourselves looking for that awesome command we typed two days or two minutes back by continuously pressing the up arrow key, but not finding it. Press [Ctrl] + [R] in your bash shell. Type in the first few letters of the command you’re looking for it will immediately match the command you are looking for from your history (which you can view by issuing the history command) and you can execute it by pressing [Enter].