Linux Unix help !!

"Give respect to Time, One day at right Time, Time will respect You"

Thursday, November 18, 2010

Linux History command tips & Tricks

History Command Tips:

1>Generally # history displays only commands you tiped last Suppose you want time too then...?

# export HISTTIMEFORMAT='%F %T '
# history | more
1  2010-11-11 15:05:20 top
2  2010-11-11 15:05:25 man top
3  2010-11-11 15:05:29 free -m
4  2010-11-11 15:10:05 cat /proc/mdstat

2>Search last hosory by ctl+r and type command you typed in last
when comes just press enter or use arrow to edit and fire you command

#Press Ctrl+R from the command prompt,
(reverse-i-search)`man ': man Top
[Note: Press enter or edit as per your requirement]

3>#Repeat you previou command quick
way 1> use up arroy once
way 2> !!   <- Enter
way 3> !-1  <- Enter
way 4> ctl+p <-Enter

4> quick sortcut
#!5  <- 5th commnds you used from history to check use #history |less
#!man <- latest commnad you used that started with man...
#export HISTCONTROL=ignoredups (ignore duplicates commnds from history)
#export HISTCONTROL=erasedups  (remove duplicates commnds from history)
#export HISTCONTROL=ignorespace (ignore to add cmnds starting with space in history)
eg:
#export HISTCONTROL=ignorespace
#  man dig
#history
1 pwd
2 man top
3 ...
but history does not store any command you start with space

5> Clear your history
# history -c

6> Disable to use of history
# export HISTSIZE=0
# history
no o/p

7> Enable history to not record specifics commnands
# export HISTIGNORE="man:ll:pwd:password:alias amgreat=clear:amgreat"
Now use above commands but history dosent save it.
   
8> control you history size ..
# vi /home/yourhome_dir/.bash_profile
HISTSIZE=450
HISTFILESIZE=450

1 comment:

Write Here .. your comments are always wellcome ..but no spam please !!

Followers

Pls LIKE my Story !!!