Working with Bash History
Another useful feature of the Bash shell is the history feature, which remembers and lets
you reuse commands you have recently used. By default, the last 1,000 commands are
remembered. This feature is useful for sessions beyond even the current one. A file, named
.bash_history, is created in the home directory of every user, and this file records the last
1,000 commands that that user has entered. You can see an overview of these commands by
typing history at the Bash prompt. Listing 2-2 is an example of this list.
■Note In addition to the history command, you can also use the up/down arrow keys, page up/down
keys, and Ctrl+p/Ctrl+n to browse the history.
Listing 2-2. The history Command Shows a List of All Commands That You Recently Used.
sander@RNA:~$ history
1 clear
2 dpkg -l "*" | grep ^un
3 aptitude search xen
4 aptitude show xen-source
5 aptitude show xen-source-2.6.16
6 exit
7 apt-get install xen
8 sudo apt-get install xen
This is where the history feature becomes especially useful because you can reissue any
command from this list without typing it all over again. If you want to run any of the listed
(and numbered) commands again, simply type its number preceded by an exclamation mark.
In this example, typing !5 would run aptitude show xen-source-2.6.16 again.
A user can also erase his or her history by using the history command. The most important
option offered by this Bash internal command is the option -c, which clears the history list
for that user. This is especially useful because everything that a user types at the command
line—such as passwords—is recorded. So use history -c to make sure your history is cleared if
you’d rather not have others knowing what you’ve been up to. Once using this option, however,
you can’t use the arrow up key to access previous commands, because those are all erased.
Because everything you enter from the command line is saved, I recommend never typing a
plain-text password in the first place, even if you regularly erase the history. The commands that
do require you to enter a password will prompt you anyway if you don't enter one right away.
History je "feature" svake ljuske ponaosob, tako da ako si traženu komandu kucao u nekoj drugoj ljusci bash je neće imati u svojoj "istoriji".ma da imam, ali trebaju mi stare komande koje sam kucao pre nekoliko meseci npr. (nadam se da se to belezi negde).
inace kad se ulogujem kao root, komandom 'su', nije mi odmah ukljucen bash, pa sam neke komande kucao van njega.
Follow along with the video below to see how to install our site as a web app on your home screen.
Napomena: this_feature_currently_requires_accessing_site_using_safari