Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I got a testdir by mkdir testdir, and created a file in it by touch testdir/a.
drwxr-xr-x 2 jermaine jermaine 4096 Mar 12 22:57 testdir
If I remove the 'x' by chmod -x testdir
Then I won't be able to
cd testdir
touch testdir/b
ls -l testdir
cat testdir/a
So my question is why can't I list the file hierarchy under a directory with a 'r' but without an 'x'? What exactly does the 'x' mean on directory?
I knew some explanations like "x means entering the direcotry, you have to enter before read and write". But what does 'enter' mean? I really appreciate answers on inode or dentry level. Thanks a lot.
"Execute" is the traversal permission on a directory. It allows you to access files and folders within the directory.
If you can read a directory, you can list the contents.
If you can write a directory, you can make new files and folders within it.
If you can "execute" a directory, you can move through the hierarchy, even if you don't know what's inside.
When applying permissions to directories on Linux, the permission bits have different meanings than on regular files.
The write bit allows the affected user to create, rename, or delete files within the directory, and modify the directory's attributes
The read bit allows the affected user to list the files within the directory
The execute bit allows the affected user to enter the directory, and access files and directories inside
Execute permission on a directory means you can access files in that directory.
Check this link out for more information about Unix permissions:
http://www.cyberciti.biz/faq/how-linux-file-permissions-work/
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Created a directory as root and changed its permissions to 0766:
drwxrw-rw- 2 root root 4096 Aug 2 13:33 test/
When running touch test/test.txt as a user, I get error: touch: cannot touch 'test/test.txt': Permission denied.
$getfacl /test
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: root
user::rwx
group::rw-
other::rw-
The directory is set with write permission to all users, what am I missing?
For directories the bits of the access rights have a different meaning than for files:
x means that files inside the directory may be accessed.
r means that you can list the names of the files inside directory. If r is set but x is not set, ls can list the names of the files and sub-directories inside the directory; however, ls cannot show you more information if x is not set; not even if some file it is a regular file or a sub-directory.
w is required to rename or to delete files or to create files or sub-directories inside the directory. However, w has no effect if x is not set!
0766 directory
Because x is not set for group and others, this is the same as a 0744 directory:
Other users may list the names of files and sub-directories inside the directory, but they cannot do more: They cannot even see if some file inside the directory is a regular file or a sub-directory.
You might have an Access Control List (ACL), which permits the access to your folder.
I don't know very much about those lists, but this link should explain them https://www.redhat.com/sysadmin/linux-access-control-lists
You can view the ACL using the getfacl command
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am coming across some problem with file permission and acl.
I've got a writable directory name "dir" with the permission 777 (dir rwxrwxrwx)
Under dir I create a file tmp.txt (dir/tmp.txt)
I was wondering how can I stop other/group members to edit/delete the file while not changing the permission of "dir". Everyone is free take any action as they like to the other file/directory under "dir".
I was wondering maybe "setfacl" or what.
Whoever owns the directory can delete the files within it, even if they are owned by root.
There are two ways to get you to almost where you want.
Idea 1 - Sticky Bit
$ ls -ld /tmp
drwxrwxrwt 33 root root 1020 2020-03-14 14:06 /tmp/
This is the common permissions for Unix /tmp directory. That t there at the end of the permissions denotes the sticky bit, you can set it by running:
chmod +t /tmp
The sticky bit says that even though everyone has write permission on the directory, the only ones who can delete a file under that directory are root, the directory owner, and the file's owner.
Idea 2 - Extra Directory
A directory cannot be deleted if it's not empty. If you put your files in a directory that's owned by you, where only you (and root) can delete files, then nobody else can delete it:
root#playground# tree -up
.
`-- [drwxrwxrwx root ] box
|-- [-rw-r--r-- test1 ] f1
`-- [drwxr-xr-x test2 ] hello
`-- [-rw-r--r-- test2 ] f2
2 directories, 2 files
root#playground# su test1
test1#playground$ rm box/hello
rm: cannot remove ‘box/hello’: Is a directory
test1#playground$ rm -rf box/hello/
rm: cannot remove ‘box/hello/f2’: Permission denied
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
The explanation is:
"-R, --recursive
operate on files and directories recursively"
What does "recursive" mean here?
"Recursive" implies that the operation will be performed for all files and directories (and all files and directories within any directory). So
chown -R foo /some/path
would change file owner to foo for all files and directories in /some/path
p.s. You might have even seen the dictionary entry for recursive:
recursive, n: See recursive
In some Linux commands, if you run the command on a folder with -R, the command will operate on all files and folders in that folder's tree. If you run the command on a file, -R has no effect.
The command will operate on given folder, and recursively operates on files and folders within it. It is based on recursion.
For example, you can remove a folder and its contents with
rm -R folder-name
Or you can find all occurrences of a specific string in all files within current folder tree with
grep -R -n the-string .
In this example -n is for displaying line numbers.
It means apply it to sub-directories and their contents, that is, recurse chown() when a directory is encountered.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
1. drwxr-xr-x 10 tester test 100 Sep 8 09:30 hello
2. -rwsrwsrwt 2 tester test 100 Sep 8 09:35 program
I want to know the permissions of the folder "hello" and the file "program", the following is my interpretation, am i right?
About the directory “hello”, the tester user has read, write and execute permission, the test group and others have read and execute permission but no write permission.
About the file "program", the tester user, test group and others have full permissions.
Yes, but your program also has the setuid, setguid and sticky bits set. Read here and here about what they mean. Sticky bit use on executables is very rare these days and normally only on directories such as /tmp
With unix directories x means access not execute, but yes for the directory "home":
user "tester" can read the contents of the directory, change the contents of the directory and change into the directory via the cd command
the group "test" may read the contents of the directory and change into the directory via the cd command
every other user may the contents of the directory and change into the directory via the cd command
For the file "program":
the user "tester", the group "test" and anybody else have the full set of rights and the programm will be executed under the uid of user "tester" (SUID-bit) and the group "test" (SGID-bit) and the sticky bit is also thrown in. This is not used on files any longer, only on directories like /tmp to prevent users from beeing able to delete some other users files.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
when trying to delete file, I got the rm command on ubuntu page at https://help.ubuntu.com/community/DeletingFiles. And on, this page I got the term read-only files. I have tried to google read-only file linux, but cannot find any definition about this. Could you tell me what read-only mean? Does it mean all owner, group and other have only read permission? Thank you!
Does it mean all owner, group and other have only read permission?
They may have different permissions. But you (the current user) have only read permission.
Linux has three kind of permission for user, group and others.
r: read permission
w: write permission
x: execute permission
If the file is read-only, it means you (the user) don't have the w permission on it and so you cannot delete the file.
Use:
chmod +w FILE
To add that permission. You can change files permission only if you're the owner of the file.
Otherwise, you can remove the file using sudo, gaining super user privilege.
sudo rm FILE
It will prompt you for a password and it will works only if you're in the /etc/sudoers/ file (and you're likely to be there if you're the only user, since you're using Ubuntu).
A read-only file is a file that you don't have permission to alter its content. To see detailed info about your permissions use ls -l; if you want to change the permissions, use chmod. Also see this example for better understanding.
Change the Permissions with chmod or try with sudu:
sudo rm file.xxx