View Your Command-Line History


history

Every time you type a command in your shell, that command is saved in a file named .bash_history in your home directory (the dot in front of the filename means that it's hidden unless you use ls -a). By default, that file holds the last 500 lines entered on the command line. If you want to view that list of commands, just enter the history command.

$ history   496  ls   497  cd rsync_ssh   498  ls   499  cat linux   500  exit 


Because you're looking at 500 results, they're going to stream by so fast that you can't see any until you get to the end. Want to step through the results one screen at a time? Turn to your old friend less:

$ history | less 


Now you can jump through your results much more easily.

Caution

Now you understand why you need to be careful typing passwords and other sensitive information on the command line: Anyone who can view your .bash_history file is able to see those passwords. Be careful and think about what you enter directly on the command line!




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net