Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was trying to remove some old history from my .bash_history file, but I was receiving this message:

[john ~] /home/john $ mv .bash_history .bas
mv: impossible to move `.bash_history' to `.bas': Operation not permited

I suspected the file/directory permission:

[john ~] /home/john $ ls -ld .bash_history .
drwxrwx--T+ 5 root       john 4096 Out 11 19:45 .
-rw-r--r--  1 john john 2977 Out 10 14:36 .bash_history
[john ~] /home/john $

Then I tried:

[john ~] /home/john $ lsattr .bash*
-----a------- .bash_history
------------- .bash_logout
------------- .bash_profile
------------- .bashrc
[john ~] /home/john $

Probably it is this a attribute; what does it mean?

share|improve this question
add comment

1 Answer

up vote 12 down vote accepted

The a attribute means that the file is append-only: you can't overwrite it or delete it, only append data to it. This is explained in the chattr man page. Only root can remove the attribute.

The practical consequence is that you can't erase your old history lines. This is presumably intended as a security measure by your system administrator. I'm not completely convinced it's secure, but off the top of my head I can't think of a way to remove some of the file's contents. (It is however easy to bypass the file and run commands without their showing in the history, which is why it's not a particularly useful security measure against competent users — an obvious way being to run the commands from something other than bash.).

share|improve this answer
    
Got it... thanks Gilles –  jyzuz Oct 12 '10 at 16:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.