This is a mirror of official site: http://jasper-net.blogspot.com/

Basic command line tips and tricks

| Wednesday, January 12, 2011
This article is a continuation of our previous stone – 40 Basic Command Line Tips and Tricks. The terminal is a really powerful tool when it comes to Linux, anything and almost everything on Linux can be done via the command line. Therefore it is necessary for us to have a basic idea of all the important commands and a few really important options that come along with them.

1. BASH ( Bourne-Again SHell ) is the most common shell in Linux. It’s freeware shell.

cat /etc/shells -> To find the available shells in your system
/bin/shell-name  -> For temporary changing of the shell

/bin/sh :  To change to the sh shell.

To return back to the bash shell : /bin/bash

2. To print your home directory location:

echo $HOME

3. To print colouful text

echo -e ” \ 033[31m Hello  World” Note : There is no space between the \ and 0
Output :
Hello World ( in Red )

Set foreground color:
echo -e ” \ 033[3xm” ( where x = 0 – 7 ) Note : There is no space between the \ and 0
Set background color :
echo -e ” \ 033[4ym” ( where y = 0 – 7 ) Note : There is no space between the \ and 0

4. The sort command can be used to sort lines of text files. It can be used for sorting of both numbers and characters or words.

For example if your file myfile.txt contains the following data :

Raju
Khanal
aayush

If you want to sort it the following command gives you the sorted list

sort myfile.txt
Output :
aayush
Khanal
Raju

5. The cut command is used for removing sections from each line of files. For instance consider a file myfile.txt with the following data


Read more: Fortystones

Posted via email from .NET Info

0 comments: