Why am I not able to use chmod 000 for a folder?
Solution 1
There is a manual page for chmod
here.
Basically, look at this table on that page:
You can change the tick boxes, so that different people have different permissions.
Owner is the permissions on that file of the owner of the folder - usually the user that has created them - can be changed with chown
.
Group is the permissions on that file of the group of the folder - can be changed with the chown
or the chgrp
commands.
Other is the permissions on that file of everyone who does not fall into the above two categories.
So running chmod 600 /PATH/TO/FILE
will change the permissions so that only the owner can read the file, and write to it.
You can also do the same for folders, but by using chmod -R 600 /PATH/TO/FILE
so the contents of the folder is the same as well.
The thing is, if you try entering it as 000:
Then no one can access or write to the file, except root, and the owner if they change the permissions again. This can work, but there is not much point to it as:
- Anyone who is logged in as the owner could remove the file.
- They could change the permissions back again, either by
chmod
, or by & Properties - If they are not the owner of the file, you do not need to
chmod 000 ..
, just usechmod 600 ..
So if you want to stop people accessing the file, encrypting the file with a password would be the better idea. So to stop people accessing a file or folder, open Archive Manager, and click New - create one that you can encrypt (under Other Options) - I use .7z, as then you can encrypt the file list to. Then type the password you want to use.
Then you can add files:
Then you have an encrypted archive with your files secure inside - though it can still be deleted...
Solution 2
The owner of the folder will always have to have access.
Solution 3
But I am able to do this in my SLES Box
user@DemoBox:/export/home/n/user : ls -l test
ls: cannot access test: No such file or directory
user@DemoBox:/export/home/n/user : mkdir test
user@DemoBox:/export/home/n/user : ls -ld $_
drwx------ 2 user EDC_EOO_OS 6 Dec 10 04:35 test
user@DemoBox:/export/home/n/user : chmod 0000 $_
user@DemoBox:/export/home/n/user : ls -ld $_
d--------- 2 user EDC_EOO_OS 6 Dec 10 04:35 test
user@DemoBox:/export/home/n/user : lsb_release -a
LSB Version: core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch
Distributor ID: SUSE LINUX
Description: SUSE Linux Enterprise Server 11 (x86_64)
Release: 11
Codename: n/a
Related videos on Youtube
Muddassir Nazir
I am a Linux sysadmin and a tech enthusiast. I love working with Linux. Ubuntu and CentOS are my favorite distros. I started my career as a Sysadmin and would like to see myself contributing to Open Source Community in as many ways possible and helping people. I am interested in working with Cloud, Automation, and Devops.
Updated on September 18, 2022Comments
-
Muddassir Nazir over 1 year
I can't
chmod 000
for a folder in Ubuntu 13.10 -
Muddassir Nazir over 10 yearsYeah..i want people to stop accessing a particular folder. How to encrypt it with a password?
-
Muddassir Nazir over 10 years@Nischay.. is this a bug with Ubuntu or Suse?? Any way to do that in Ubntu??
-
Wilf over 10 yearsUpdated ridiculously long answer... :-)
-
Nischay over 10 yearsCurrently I have no access to any ubuntu box and I never tried it on my ubuntu.I am just curious why you need this permission for any folder, This permission is going to make your folder unusable for everyone.
-
Nischay over 10 yearsIf you have sudo(root) access on that box and everyone using same account to access machine, just change ownership to root and removed all permissions for group and other.After doing this folder is not going to accessible by anyone except root.You can also rename folder to a leading . like pics to .pics, by this folder is not visible in file manager until someone press ctrl+h.
-
psusi over 10 yearsThe owner does not have to have access,
chmod 000 somedir
works just fine. As the owner, you can stillchmod
it back later, or delete it regardless of the permissions. -
psusi over 10 yearsThis is incorrect.
chmod 000 somedir
works just fine. -
Oli over 10 years@psusi but it doesn't stop you doing things to the directory. The same user can re-establish permissions or
rm
the directory, without issue. -
Wilf over 10 years@psusi for the purpose of preventing access to the file, it is better to encrypt it anyway - without permissions you can still see the contents...
-
psusi over 10 years@wilf, sure, that's true... if you edit your answer I'll switch my vote.
-
Wilf over 10 years@Oli - you don't even need to change the permissions -
rm -f...
(orrm -rf
for a directory). -
Wilf over 10 yearsSlightly happier now, @psusi?
-
psusi over 10 years@wilf, one more nit: not anyone can remove the file, only the owner of the file or someone with write access to the directory ( unless it has the sticky bit set ).
-
Wilf over 10 yearsIf they are not the owner of the file, there is no need to
chmod 000 ...
then @psusi.