0

I have a directory called pub on a Ubuntu 20.04 server, that I wish to protect from deletion, and I found https://askubuntu.com/questions/504151/how-to-prevent-directory-from-being-deleted-by-user so I tried:

$ sudo chattr +i pub

Good enough, now I want to check if that attribute has been set:

$ lsattr pub
--------------e----- pub/__pycache__
--------------e----- pub/file1.py
--------------e----- pub/file2.py
--------------e----- pub/file3.py
--------------e----- pub/file4.py

So, I got the contents of the directory listed, but I did not get the directory listed, which is what I wanted.

I mean, if it at least gave me an entry for pub, I would have been fine - but here I get all the children and NOT what I requested for... it is so amazingly stupid.

Turns out, there is lsattr -R switch for "recursive", which I've expected to provide output like above - but when I run it, it simply also descends into __pycache__ directory.

So, how do you lsattr a directory only, so you can see if you achieved the right thing with chattr?

sdbbs
  • 480

1 Answers1

2

Use -d, which lists directories like other files instead of listing their contents:

lsattr -d pub
Stephen Kitt
  • 434,908