Friday, March 28, 2014

Very Helpful Linux Command Tips


1. How to automatically correct mistypes directory names.?
 
You have typed mall instead of mail
 
#cd /etc/mall

do the below command

#shopt -s cdspell

If you type  again cd /etc/mall  , it will direct you in the correct directory..


Try it and enjoy.

2. How to convert lower case to upper case in a file ?

if you want to convert from lower to upper

tr a-z A-Z < filename

do vice verca for upper to lower

tr A-Z a-z < filename

3. How to add time stamp in history output ?

This is really very helpful command .

# export HISTTIMEFORMAT=’%F %T ‘

then do history |more

If you don't want to use it , rever it back to original.

# export HISTTIMEFORMAT=’ '

4. How to run a command from history?
If you want to run a particular command {nth command} from history, just try with '!'

Ex:If you want to run 100th command in history, just type # !100  - it will run 100th command in history

5. ac command

ac -d  -  display connect time for the current logged in user
ac -p  - connect time for all users

ac -d utech - connect time for a specific user


6. How to execute commands in background  even after you logged out from the putty session ?

use '&' at the end of command line to run any command in background. If you use 'nohup' option at the beggining of a command line, it will run in background even after you logged out from the session.

For Ex:
#nohup ./yourscript.sh &

7. How can we see multiple log files in one terminal ?

Just type tail -f logfile1 -f logfile2

Please try it and make use of it.




No comments:

Post a Comment

Thank you !!