Šta je novo?

bash history

orange47

Slavan
Učlanjen(a)
25.12.2007
Poruke
3,083
Poena
455
jel ima jos neki nacin da se vidi koje su sve komande koriscene (recimo kao root), sem .bash_history?
 
Ne razumem baš najbolje pitanje. Pa mislim, strelica na gore... :d Imaš li ti uopšte root privilegije na tom sistemu?
 
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.
 
Evo šta Apress Ubuntu Server Guide kaže na ovu temu.

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.
 
Poslednja izmena:
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.
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".

Da li ti podrazumevana ljuska uopšte ima opciju "istorijata"? Šta koristiš, C?
 
pa.. ovaj.. ne znam.. pise samo:
#
(ispred komandi, nakon sto otkucam su i password)
sistem je Solaris.

Inace, da li bash cuva istoriju posebno za svakog korisnika ili sve u jednom?
Ako je posebno, u kom direktorijumu se nalazi .bash_history za root-a?
 
.bash_history se nalazi u home (~) folderu svakog usera.

Pošto je na Solarisu home folder root-a root folder (/), a ne kao na Linuxima (/root) samo otkucaj:

cat /.bash_history

Naravno tu će ti biti samo one komande kucane u bashu. Ono šta si kucao u sh-u (kada imaš samo #) se ne beleži nigde.
 
Poslednja izmena:
Ne mora da se lista .bash_history kao fajl, pošto bash ima ugrađenu history komandu (man je takođe fenomenalna komanda). Kako će se history pamtiti može da se reguliše sa više environment varijabli - $HISTSIZE recimo definiše koliko komandi unazad će se pamtiti (default je valjda 1000 za aktuelne verzije). $HISTFILE može da specifikuje i u koji fajl će se history dampovati po zatvaranju sesije, tako da stvari ne moraju obavezno da leže u .bash_history fajlu (dok će komanda "history" uvek prikazati istoriju ma u kom fajlu se istorija snimala).
 
Poslednja izmena:
Nazad
Vrh Dno