Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot move or delete files even after chown and chmod

I can't seem to be able to move or delete files in my home directory even after chmod and chown.

At first glance it seems like the permissions are set up correctly.

user@f9195084fbf8:~$ ls -lah
total 32K
drwxr-xr-x 18 user user 4.0K Oct  8 17:35 .
drwxr-xr-x 16 root root 4.0K Oct  8 04:57 ..
-rwxr-xr-x  1 user user  220 Apr  3  2012 .bash_logout
-rwxr-xr-x  1 user user 3.5K Apr  3  2012 .bashrc
drwxr-xr-x  2 user user 4.0K Oct  8 05:43 .matplotlib
drwxr-xr-x  2 user user 4.0K Oct  8 17:19 .pip
-rwxr-xr-x  1 user user  675 Apr  3  2012 .profile
drwxr-xr-x 15 user user 4.0K Oct  8 04:58 .virtualenvs

But I can't remove existing files.

user@f9195084fbf8:~$ rm .bashrc
rm: cannot remove `.bashrc': Operation not permitted

So I try chown and chmod but it still doesn't work.

user@f9195084fbf8:~$ sudo chown -R $USER:$GROUP .
user@f9195084fbf8:~$ sudo chmod -R 755 .          
user@f9195084fbf8:~$ rm .bashrc
rm: cannot remove `.bashrc': Operation not permitted
user@f9195084fbf8:~$ mv .bashrc .virtualenvs/
mv: cannot move `.bashrc' to `.virtualenvs/.bashrc': Operation not permitted

However, I can write and remove newly created files just fine.

user@f9195084fbf8:~$ echo 'hello' > test.txt
user@f9195084fbf8:~$ ls  
test.txt
user@f9195084fbf8:~$ rm test.txt
like image 959
user1027169 Avatar asked Oct 16 '25 14:10

user1027169


1 Answers

Any immutable attribute has been set on the file?

lsattr .bashrc

If so, you may fix it by:

chattr -i -a .bashrc

Run man chattr to see the flags, or check the wiki page.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!