Jump to content

Secret commands - hide or delete


sunrat

Recommended Posts

Here's something I didn't know. You can delete single commands from bash history or not log them in the first place.

 

Say you have a command you want to delete from history:

1145  su
1146  rsnapshot -t hourly
1147  rsnapshot hourly
1148  kill-infidels
1149  history

Use the -d option to delete:

history -d 1148

It's gone:

1145  su
1146  rsnapshot -t hourly
1147  rsnapshot hourly
1148  history
1149  history -d 1148
1150  history

 

Precede a command with a space and it won't appear in history at all. You need this in .bashrc for this to work but it's probably there by default:

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

Link to comment
Share on other sites

securitybreach

Yeah, you can do the same with any history. Bash or Zsh etc. I have never needed to remove a single entry though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...