You can't edit the contents of the public directory if you don't have write and execute access.
You indicate you are attempting to create a new file. If the test
file doesn't already exist in public
, touch
will attempt to create a new file. It cannot do this without the write and execute permissions over the parent directory. Execute is required to traverse the directory; write is required to add the inode entry for the new file. Apparently, you don't have one or both of these permissions.
If the test
file does already exist in public
, touch
will, by default, update the modification time of the file. Only write access to the file is required for this, as the modification date/time is stored in the file's inode. If the file already exists, you will need to inspect the file's permissions using a command like ls -l public/test
to determine if you have write access.
The permissions bitmask on the directory, rwxrwxr-x
, means:
- the
root
user, i.e. the owner of the directory, has write privileges to the directory as indicated by the first rwx
block. This user can also read the directory (the r
bit) and traverse it to access its contents (the x
bit).
- members of the
root
group, i.e. the group on the directory, who are not themselves the root
user, also have similar privileges to read, write and traverse the directory as indicated by the second rwx
block
All other users only have read and execute rights, as indicated by the last r-x
block. As noted, for directories, execute permissions allow you to traverse that directory and access its contents. See this question for more clarity on this.
How do I get permissions?
You will need to talk to your system administrator (which might be you!) to do one of the following:
- Make you the owner of the
public/
directory using a command like chown user public/
. This will be suitable if you are the only user who will need to have edit rights.
- Create a new group with a suitable name, perhaps
publiceditors
, and set this as the group on the public/
directory using a command like chgrp publiceditors public/
. Ensure you and any other users who require the ability to modify the directory are listed as members of the group. This approach works where multiple users need edit capability.
- Make your user account a member of the
root
group (not something I would recommend).
- Provide you with access to log in or masquerade as
root
, such as with sudo
or su
with the root
password
- Change the rights on the directory to grant all users write permissions, using a command like
chmod o+w public
. Be aware that this gives everyone on the box the ability to edit and delete files in the public directory.* You may not want this!
*In the absence of other access control enforcement, such as mandatory access control in the kernel.
What do read, write and execute permissions mean in the context of a directory?
Assuming you're on a Linux box, on a directory, a read permission bit allows you to read the directory listing. The write permission bit allows you to update the directory listed, which is required for creating a file*, editing the name of a file, unlinking (deleting) a file. The execute bit allows you to traverse the directory, access its files etc. More information on Linux directory permissions.
* Actually, you're linking a file into the directory. Most times you will do this at the point of file creation, but there are more complex examples. For example, making a hard link to a file which originally existed elsewhere in the file system will require write access to the target directory of the link, despite the fact you're not creating a new file.
Why write access to the directory?
You need to be able to write to the directory to add a reference to the relevant inode for the file you are adding.
The problem is ReiserFS being neglected in Linux: https://bbs.archlinux.org/viewtopic.php?id=197628
ACL is broken in reiserfs from Kernel 4.4.x (Invalid argument error)
4.3.x worked fine for me...
I haven't checked yet how to goes in kernels after 4.4.
One need to reboot to a kernel <4.4 to be able to remove broken ACLs from the filesystem.
Best Answer
In order to delete a file, you must have write permissions on the directory that the file resides in. When you
rm
a file it makes theunlink
system call which removes the name from the directory. This only deletes the file if it is the last remaining link to the inode.You can find more information in unlink(2).