BASH (Bourne Again SHell) it is the default shell on virtually all Linux based operating systems. All commands, which we write in the terminal, are interpreted by the shell and become part of its history. In this tutorial we will see, where shell history is stored and how to manage it using the built-in "history" command and some environment variables.
In this tutorial you will find out:
Where and how the history of BASH is recorded
How to clear Bash shell history
Where BASH history is stored?
If we are opening a terminal emulator or working in TTY and we want to invoke a command, we have launched in the past, we usually press the up arrow key, To go back or Down arrow key, to move forward in shell history . Have you ever wondered, where and how the history of Bash is recorded? Command list, which we call in the Bash shell, is stored in the so-called. "History file", which is by default ~/.bash_profile.
To visualize the current contents of the shell history, we can use the history command, without passing any argument or options. Each line in the output it generates is preceded by a number:
history
1 echo "serwerweb.pl" 2 cat /etc/hostname 3 ls -l /etc/hostname 4 history
Clearing Bash History
The history command is not only used to display the current history of the shell, but also to perform other operations. To clear all current history of the Bash shell, for example, just invoke it with the -c option.
history -c
We also have the option to remove a specific command from the history, by using the -d option and passing the line offset as an argument. imagine, that we want to delete the row 1 from the current history in memory. We would invoke the history command as follows:
history -d 1
The guide below describes how to install KeePass on Ubuntu. Całość wykonamy za pomocą kilku poleceń…
Master PDF Editor is a comprehensive PDF program, which includes many features. Oprócz tworzenia i edycji…
Iotop jest prostym narzędziem dla systemów Uniksowych umożliwiającym monitorowanie użycia dowolnego nośnika pamięci flash/hdd/ssd w…
You can separate two or more commands with semicolons (;), Semicolon (;): służy do oddzielania…
Poniższy poradnik opisuje w jaki sposób za pomocą konsoli możemy dokonać edycji danych zdjęcia exif.…
The following guide describes how to install Rocket.Chat on Rocky Linux 8 Całość bardzo prosto zainstalujemy…