Q. How do I view command line history? I am using Cent OS Linux system.
A. BASH is the default shell for Linux computers. Bash has history command. It display the history list with line numbers i.e. it lists everything you have entered on the command line. You can recall commands from history so that you can save the time.
Task: View your command Line History
Type the following command:
$ history
Output:
911 man 7 signal 912 man ps 913 man 7 signal 914 man killall 915 killall -l 916 man killall 917 su - 918 su - lighttpd 919 su - lighttpd 920 cd /tmp/ 921 ncftpget -u 'vivek@lan.server.gite.in' lan.server.gite.in
So whenever you type a command, that command is saved is a file called .bash_history. Type following commands to get more info:
$ help history
$ man bash (look for Event Designators for more info).
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 21 comments… read them below or add one }
How we can increase the size of History in Unix/Linux
Currently mine history command showing only 500 entries i want it to show atleast 2000 entries.
Thanks in advance
Set HISTSIZE variable by editing ~/.bash_profile or other shell startup file.
HISTSIZE defines the number of commands to remember in the command history. The default value is 500. Set it to 2000
export HISTSIZE=2000Not everyone uses bash, my friend.
Most people do, my friend.
What is he supposed to do, spell out how to increase the size of your history in every single possible shell?
Well said Jacob.. Besides vivek clearly said “or other shell startup file”
At the least one shoudl know which shell one is using…
How do I determine the the size of my history file on the command line and how many commands that can be stored?
echo $HISTSIZE
will print to screen how long your history is.
How do we clear the history? Do we set HUSTSIZE to ZERO and then back again to 2000 or so?
Hi Bingo,
use the following to clear the history:
history -c
hi guys i am in need of a tutorial shat show how to automatically save history in a file every 1 second .
can any one assist me ..
nishu, you shat?
Display with data and time.
#export HISTTIMEFORMAT=’%F %T’
#history | more
Hi Natraj,
Can you explain more about this command. I tried executing but there was no output.
Thanks & Regards
Be sure you don’t type the “#”‘s at the start of each line. That will turn them into comments!
i want to know how to see the particular user “s history when we lodin as a root
Hi friends, how can i get the complete info about a job that was running 10 days back?
pl Reply me…
How can i start a job after some time automatically?
Pl reply me…….
hello!
my history is delete when i log in. what i can do to keep the history?
What is the command for pulling a specific line from history and running it again (without typing the whole command again)?
by using bang. !254
Hi I want to display history of only 2 hours , How can I do it??