How to Clear History in Ubuntu
Clearing your Linux mechanism’s history logs is invaluable to retaining a nutritious equipment. It permits you to save beloved disk elbowroom and preserve your digital openings from spying eyes. Here, we underscore you how to legible the history documents on your Commemoration vessel, record supervisor, and text editor on Ubuntu Linux.
- Clearing the Command History in Commemoration
- Clearing the Current File History in Nautilus
- Debilitating the Current Contingencies in Gedit
Clearing the Command History in Commemoration
Linux is a command chatter-driven operating mechanism. From record administration to putting up regimens, practically every feedback inside Linux confiscates some kind of a terminal command. Over time, these commands agglomeration upwards on your Commemoration mechanism vessel, which can confiscate upwards most disk elbowroom.
The simplest means to legible your Commemoration command history in Ubuntu is to usage a UNIX hose to reroute an vacant string to your “.bash_history” record:
echo "" > ~/.bash_history
That claimed, this will most most certainly not legible the history barrier for the current Commemoration session. To execute that, rushed the obeying command:
history -cw
Chit: you demand to rerun this command for every quickly Commemoration vessel on your current desktop computer session.
Authenticate that your current Commemoration history is legible by running the history
command without any arguments.

Debilitating History Logs in Commemoration
You can brunt Commemoration to not save any command history from any of your future sessions. This can be worthwhile if you’re arranging a mutual computer system and you wear’t twinge the opposite other borrowers to recognize the commands that you’re running on your account.
Overture by making certain that your current history barrier in Ubuntu is faultlessly legible:
history -cw
Responsive your .bashrc record gaining manipulate of your favourite text editor:
nano ~/.bashrc
Paste the obeying queues of code at the run out of your .bashrc record:
export HISTSIZE=0 export HISTFILESIZE=0
Chit: the HISTSIZE
variable pinpoints the amount of queues that Commemoration will most most certainly hold during an quickly session. At unmodified time, HISTFILESIZE
caboodles the amount of queues that the history log record will most most certainly back over time.
Conserve your .bashrc record, then rushed the obeying command to apply your brand name-new-fashioned arrangements to your current vessel session:
source ~/.bashrc
Test your brand name-new-fashioned arrangements by running an ls
command on the current brochure, then re-running the history
command:
ls && history

Great to recognize: learn nonessential around vessel scripting by analysis upwards on the most invaluable Commemoration momentous individualities.
Obliterating Capricious Commemoration History Entries
The history
command can in addition fetch rid of respective entries from its cache and history log. This can be worthwhile if you lone twinge to run away out a handful of commands instead of clearing up the entire history of your vessel.
Gain manipulate of the history
command to detect the index digit of the command that you twinge to legible. In my vessel, I twinge to fetch rid of the 7th command in my vessel history.

Chit: you can lookout for the respective command that you twinge to fetch rid of by piping the history command to grep: history | grep my-history-command
.
Rushed the obeying command along putting on the index digit of the entry that you twinge to fetch rid of:
history -d 7
Authenticate that the history entry is gone by rerunning the history
command.

Clearing the Current File History in Nautilus
Aside from clearing up the history of commands on your terminal session, you can delete the current history of your mechanism’s default record supervisor. To execute this, amenable your record supervisor from your mechanism’s application launcher.
Click the Current style on the supervisor’s abandoned sidebar.

Press Ctrl + A to pick all the lately opened upwards documents in Nautilus.
Press Right Click, then pick Separate from Current to delete the record supervisor’s current history.

Responsive the Tool Nutrients selection on the desktop computer’s upper abandoned side, then click the Contrivance symbol on the popup panel.

Pick Seclusion and Coverage under the abode window’s abandoned sidebar.

This will most most certainly lug upwards a brand name-new-fashioned subcategory on the abode window’s proper panel. Click the File History & Fiasco style.

Cripple the File History button, then click the Translucent History button.

Tip: learn how you can render Nautilus even nonessential worthwhile putting on plugins and extensions.
Instantaneously Separate the File History in Nautilus
An additional means to legible record history in Ubuntu is to delete the documents that hold the documents for the “Current” style putting on Commemoration.
Overture by inventing a neighborhood binaries folder in your abode brochure:
mkdir -p ~/.local/bin/ && cd ~/.local/bin/
Model a brand name-new-fashioned Commemoration manuscript under your brand name-new-fashioned folder gaining manipulate of your favourite text editor:
nano ./user-clear-history.sh
Paste the obeying block of code inside your manuscript record:
#!/bin/bash rm -f ~/.recently-used.xbel rm -f ~/.recently-used.xbel.* rm -f ~/.local/share/recently-used.xbel rm -f ~/.local/share/recently-used.xbel.*
Conserve your manuscript record, then rushed the obeying command to upgrade its authorization pieces:
chmod +x ./user-clear-history.sh
Responsive your mechanism’s application launcher, then pick Startup Implementations.

Click the Consist of button on the abode window’s upper abandoned side.

Give a tag to the manuscript that you twinge to rushed. In my vessel, I will most most certainly label it as: “Borrower File History Autoclear.”
Click the Peruse… button under the Tag textbox.

Press Ctrl + H on the record picker menu, then surf to your “~/.neighborhood/canister/” brochure.

Pick your vessel manuscript, then click Responsive to add it to your brand name-new-fashioned start-up entry.
Click Consist of to tote out it to your current user session.

On a side note: learn how you can launch your manuscript from the GUI gaining manipulate of .desktop computer documents in Linux.
Clearing the File History for All Users
One of the drawbacks of dispelling the record history through the GUI is that it lone clears it for the current user. This can be a hassle if you’re retaining a equipment that’s mutual in between multiple humans.
To resolve this, amenable a brand name-new-fashioned terminal session then rushed the obeying command to button to the root user:
sudo -s

Go to your root user’s abode brochure, then decor a neighborhood canister folder inside it:
cd ~ && mkdir -p ~/.local/bin/ && cd ~/.local/bin/
Model a brand name-new-fashioned manuscript record gaining manipulate of your favourite text editor:
nano ./system-clear-history.sh
Paste the obeying block of code inside your manuscript record:
#!/bin/bash rm -f /home/*/.recently-used.xbel rm -f /home/*/.recently-used.xbel.* rm -f /home/*/.local/share/recently-used.xbel rm -f /home/*/.local/share/recently-used.xbel.*
Conserve your brand name-new-fashioned manuscript record, then acquired its authorization pieces to execute:
chmod +x ./system-clear-history.sh
Model a brand name-new-fashioned systemd treatment record under “/etc/systemd/mechanism” for your brand name-new-fashioned manuscript:
sudo nano /etc/systemd/system/system-clear-history.service
Paste the obeying block of code inside your brand name-new-fashioned treatment record:
[Unit] Description=Clear File History Before Shutdown DefaultDependencies=no Before=shutdown.target [Service] Type=oneshot ExecStart=/root/.local/bin/system-clear-history.sh [Install] WantedBy=halt.target reboot.target shutdown.target
Conserve your brand name-new-fashioned treatment record, then rushed the obeying commands to heap it to your systemd daemon:
sudo systemctl daemon-reload sudo systemctl enable --now system-clear-history.service
Authenticate that the treatment is running sufficiently by glancing at its current status:
systemctl status system-clear-history.service

Debilitating the Current Contingencies in Gedit
Gedit is a humble text editor that comes by default on some of the current iterations of Ubuntu. In some sheaths, this editor generates a backup of every record that you’ve opened upwards and saved in the mechanism. This can be an defect if you’re glancing to save elbowroom on your equipment.
To immobilize this, click the Remedy menu on the app’s upper proper side, then pick Wills.

Click the Editor tab on Gedit’s Postures abode window, then untick the Model a backup xerox of documents in the past preserving checkbox.

Close the Postures abode window, then reload Gedit to apply your brand name-new-fashioned arrangements.
Responsive a brand name-new-fashioned terminal session, then rushed the obeying command to fetch rid of any backup record that Gedit acquired on your abode brochure:
rm "$(find ~ -regex '.*~$')"
Last but not least, affirm that there’s zero Gedit backup documents abandoned on your abode brochure:
find ~ -regex '.*~$'
Erasing the countless history logs from your mechanism is merely one slide on retaining and straightening out your Linux equipment. Study the impressive planet of mechanism counterclaim by learning how to anonymize your Linux distro putting on Whoami.
Image credit history: Samu Lopez putting on Unsplash. All alterations and screenshots by Ramces Red.