Delete historical past with no hint in Linux

0 1

This educational explains methods to delete your bash historical past with out leaving strains in Linux.

Your bash historical past can also be observed the usage of the historical past command. If you happen to run it, the entire consumer historical past can be displayed as proven beneath.

Via default, the bash historical past is situated within the record .bash_history record situated within the consumer’s house listing.  In my case, the consumer is linuxhint, to peer the historical past the usage of cat I run:

cat /house/linuxhint/.bash_history

Word: you’ll be informed your historical past record location via operating the command beneath.

Deleting your historical past with no hint in Linux

 Deleting the command line process historical past is modest, and there are few techniques to succeed in it. The primary way makes use of the historical past command proven above, adopted via the -c (transparent) choice, as proven within the screenshot beneath.

As you’ll see, after operating historical past -c, if we run the historical past command with out choices once more, there is probably not output aside from for the present command.

In a different way to take away your bash historical past is to take away the hidden .bash_history record situated within the consumer house listing.

Since we wish to take away the command line historical past with out leaving a hint, let’s do it in order that convalescing the historical past record is unimaginable. To do it, we want to set up the wipe device.

To put in wipe on Debian primarily based Linux distributions, run:

Now wipe used to be put in, you’ll securely take away the .bash_history record with out the risk it’s going to be recovered.

Now your .bash_history record used to be totally wiped however can be robotically generated once more to report long run instructions while you sign off and log in again as the similar consumer. On the finish of this educational, you are going to in finding directions to stop the .bash_history record from recording instructions.

Casting off a selected line from the .bash_history record

 Let’s assume, like maximum Linux customers, you utilize the .bash_history when repeating instructions, however you wish to have to take away a selected mistake. In some instances, some customers would possibly sort a password of their terminal; that is extraordinarily insecure.

Within the following screenshot, we will be able to see 7 instructions.

Let’s say you best wish to take away the 6th command (wipe .bash_history). To do it, you’ll use the historical past -d command adopted via the road you wish to have to take away, as proven beneath.

As you’ll see, the command used to be got rid of, however you want to put in writing the adjustments the usage of the historical past command adopted via the -w flag, as proven beneath.

Now the precise line you sought after to delete used to be got rid of.

You can also take away line levels. The next instance displays how to take away a selected collection of traces ranging from a selected line. The command beneath will take away 10 traces ranging from line 40. If you wish to take away a bunch rather then 10 traces, substitute the quantity 10 with the collection of traces you wish to have to get deleted. Exchange the quantity 40 with the road you wish to have the road vary to start out.

for i in {1..10}; do historical past -d 40; achieved

Turning off the bash historical past

 This educational segment explains other how you can disable the bash historical past.

If you wish to disable the bash historical past for the present shell best, run the command beneath.

As you’ll see, after operating set+o historical past, that command used to be the ultimate recorded, this means that no instructions typed after that have been recorded, together with the historical past command used to test the end result.

You’ll see if the historical past is enabled via operating the command beneath.

Word: You’ll permit the bash historical past again via operating the command beneath.

To disable the bash historical past completely, run the command beneath so as to add the rule of thumb set +o historical past in your .bashrc record. The .bashrc record retail outlets the configuration in your terminal periods, together with the shell historical past, amongst different options.

echo ‘set +o historical past’ >> ~/.bashrc

As you’ll see, on the backside of your .bashrc record, now you’ll see the set+o historical past rule added.

Observe the adjustments via operating the .bashrc record as proven beneath.

To disable the historical past for the entire gadget, run the command beneath with root privileges to unset the HISTFILE variable.

echo ‘unset HISTFILE’ >> /and so on/profile.d/nohistory.sh

Word: If you wish to get well the shell process historical past, you’ll take away the record you simply created underneath /and so on/profile.d.

You can also disable the bash historical past for brand spanking new or long run customers, preserving it for current customers. To reach it, run the command beneath.

echo ‘set +o historical past’ >> /and so on/profile

To undo the former command and repair the bash historical past, you want to take away the set+o historical past from the /and so on/profile record

Take away the highlighted line (the ultimate one containing the set+o historical past command).

 Exchange it to:

Proscribing the bash historical past measurement

 There are 2 variables restricting the bash historical past measurement, the $HISTFILESIZE and $HISTSIZE variables. The variation between them is that $HISTFILESIZE defines the collection of traces that can be stored to disk and stay after the consultation ends. The second one variable, $HISTSIZE, defines the collection of traces that can be stored within the historical past however gained’t stay after you shut the consultation.

To peer the collection of traces stored on your historical past, run the instructions beneath even after you shut the consultation.

As you’ll see, after last and logging again, my historical past will stay my ultimate 100 instructions.

To switch the collection of traces stored to disk, run the command beneath.

Word: 50 is the collection of traces you wish to have to stay on your historical past even after the closed consultation. Exchange it with the collection of traces you wish to have.

As you’ll see, now your historical past saves your ultimate 50 instructions to disk.

Run the command beneath to peer the collection of traces stored whilst in the similar consultation till logging out.

As you’ll see, your consultation historical past data your ultimate 500 instructions.

To switch the $HISTSIZE run:

Now your periods will stay your ultimate 50 instructions.

Conclusion

As you’ll see, putting off your bash historical past or particular content material inside it’s lovely simple, together with for brand spanking new Linux customers. Understanding how to take away your historical past is particularly vital while you paintings remotely and want to stay process protected. In some instances, customers would possibly sort their passwords via mistake at the terminal, leaving good knowledge. In some instances, some directors would possibly go for disabling this option in any respect. But, the bash historical past is a superb function that is helping us repeat instructions very simply via urgent a key.

I am hoping this educational explaining methods to delete the historical past in Linux with no hint used to be helpful. Stay following Linux Trace for extra Linux guidelines and tutorials.

Leave A Reply

Your email address will not be published.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.