Creating a file inside 0766 directory fails [closed] - linux

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

Related

How to protect a file under a writable directory [closed]

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

What is the operand in ls -LA do? [closed]

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 6 years ago.
Improve this question
As the title says what does -LA do in a ls command?
I tried reading the manual for ls and this what it said:
-A List all entries except for . and ... Always set for the super-user.
-L Follow all symbolic links to final target and list the file or directory the link references rather than the link itself. This option cancels the -P
option.
But I'm not quite sure what those mean.
the ls command prints a list of files and folders in the current directory.
When using ls -A, the command prints out ALL files and folders in the current directory. This includes hidden files and folders (like files/folders starting witch a dot). However, . (current directory) and .. (parent directory) will be ignored.
When using ls -L the command will follow symbolic links and print out the location of the reference too.
When combining this 2 options you get ls -LA which prints out a list of ALL files and folders, and also prints out the references to symbolic links in the folder.
Just try it out in the terminal. You'll see the difference.

What does cd // means (change directory to //) [closed]

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 6 years ago.
Improve this question
I'm still a Linux newbie and I'm wondering: What is the Linux directory // ?
I can change dir (cd) to the root dir using cd /
~> cd /
/>
Using pwd (print name of working directory) tells me I'm in root (/)
/> pwd
/
Using ls (list directory contents) I see the following (using Raspbian Jessie)
/> ls
bin boot dev etc home include lib lost+found media mnt opt proc root run sbin share srv sys tmp usr var
By mistake I changed dir to // and found that it was valid:
~> cd //
//>
Also using pwd tells me I'm in a directory called // :
//> pwd
//
But using ls I see the that I'm probably still in 'something' looking like root.
//> ls
bin boot dev etc home include lib lost+found media mnt opt proc root run sbin share srv sys tmp usr var
... but telling me it's called // (rootroot ;-)
So what is directory // ?
In Linux (and most other platforms), multiple slashes in a path are interpreted the same as a single slash. However, the POSIX specification states that:
A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
// may be reserved for a special purpose (e.g: accessing a network drive in Cygwin). However, if you check ls in / and // on Linux you should see the same content.

Will the program installed in a folder function properly if I remove the write permission in linux? [closed]

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 9 years ago.
Improve this question
I have a user account on a cluster( a server), and can only install program like python on the home folder. In case I might accidentally delete the bin, lib, share,include folders coming with the installation of python on the home folder. I change the permissions of the above folder like this
chmod -w folder
but I am worried when the program need to write/delete some files of the folders, it might not function because the removal of write permission. Am I right? or I the run, including write files in the folder, of a program have permissions different than the permission of user.
BTW, is there a way to hide the folders without changing the names?
Wouldn't this stop python from running all together? For example:
$ cd ~
$ mkdir -p python/bin/
$ echo "echo 'hi'" > python/bin/python
$ python/bin/python
hi
$ chmod -x python
$ python/bin/python
bash: python/bin/python: Permission denied
As for your second question, no, there is no other way to selectively hide one folder without changing the name.
Edit: re-reading, I may have mis read what you were saying about the folders. You could always apply a "chmod -r folder" and nothing inside will be visable. This is not hiding it, just turning off permissions to view it.

What does the 'x' mean in rwx on a directory? [closed]

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/

Resources