104
votes
Execute vs Read bit. How do directory permissions in Linux work?
I have prepared this table with all the possible permissions and their practical effects.
dirpermissions
Octal
delrenamecreatefiles
dir list
readfilecontents
writefilecontents
cd dir
cdsubdir
...
97
votes
What did the sticky bit originally do when applied to files?
No, the sticky bit was not like the set-UID or set-GID flags. It didn't effect any changes to process credentials.
What the sticky bit did was make the program text "sticky". It wasn't a ...
91
votes
Getting new files to inherit group permissions on Linux
TL:DR; to make new files inherit the group of the container folder do:
$ chmod g+s somefolder
Note: its implied in the accepted answer, this is just a snippet.
84
votes
Accepted
Can I create a *super* super-user so that I can actually have a user that can deny permission to root?
The "user" you want is called LSM: Linux security module. The most well known are SELinux and AppArmor.
By this you can prevent certain binaries (and their child processes) from doing certain stuff (...
76
votes
Accepted
File permission with six octal digits in git. What does it mean?
The values shown are the 16-bit file modes as stored by Git, following the layout of POSIX types and modes:
32-bit mode, split into (high to low bits)
4-bit object type
valid values in ...
76
votes
Why is the "ls" command showing permissions of files in a FAT32 partition?
The filesystem as stored on disk doesn't store all file permissions, but the filesystem driver has to provide them to the operating system since they are an integral part of the Unix filesystem ...
75
votes
Why do I get permission denied when using mv although directory rights are correct?
I was using Windows Subsystem for Linux. I had the directory open in a different bash instance. Closing it let me move the directory.
63
votes
Run ./script.sh vs bash script.sh - permission denied
Try chmod +rx script.sh, this will give read and execute permissions to user, group and others.
Then try, ./script.sh.
63
votes
Accepted
gpg: WARNING: unsafe ownership on homedir '/home/user/.gnupg'
This is the result of running gpg with sudo: gpg then runs as root, but its home directory is still the user’s. This explains both the warning (gpg is running as root but another user owns the ...
60
votes
Accepted
Getting "permission denied" when trying to append text onto a file using sudo
You have to use tee utility to redirect or append streams to a file which needs some permissions, like:
echo something | sudo tee /etc/file
or for append
echo something | sudo tee -a /etc/file
...
52
votes
Accepted
root cannot write to file that is owned by regular user
This is a new behavior available on Linux kernels since version 4.19 to prevent attacks using /tmp/ tricks. The default value of the option might have been enabled later or be different depending on ...
51
votes
Accepted
One file wants to belong to two users. How? Hard linking fails
You can use ACLs so the file can be read by people in both groups.
chgrp bar file
chmod 640 file
setfacl -m g:baz:r-- file
Now both bar and baz groups can read the file.
For example, here's a file ...
51
votes
Accepted
What is the reason for having or restricting file owner's permissions?
There are various reasons to reduce the owner's permissions (though rarely to less than that of the group).
The most common is not having execute permission on files not intended to be executed. ...
50
votes
Accepted
How to remove ACL from a directory and back to usual access control?
Our problem was resolved by using:
setfacl -bn foobar
The point was we also had to remove the aclMask from the directory with an option -n... The man page of setfacl says as follows:
-n Do ...
50
votes
Accepted
Why are executables in e.g. /usr/sbin writable by root?
It doesn't really matter if the files in /bin (or any other standard directory where executables are kept) are writable by root or not. On a Linux server I'm using, they are writable by root, but on ...
50
votes
Can I create a *super* super-user so that I can actually have a user that can deny permission to root?
You're misunderstanding the concept of the root user.
In plain English, root is at the "top of the tree".
What if you decide one day to have a "super super user", and then next month, a "super ...
50
votes
Accepted
How do file permissions work for the "root" user?
Privileged access to files and directories is actually determined by capabilities, not just by being root or not. In practice, root usually has all possible capabilities, but there are situations ...
48
votes
How to set default file permissions for all folders/files in a directory?
This is an addition to Chris' answer, it's based on my experience on my Arch Linux rig.
Using the default switch (-d) and the modify switch (-m) will only modify the default permissions but leave the ...
46
votes
VERR_ACCESS_DENIED when trying to add a raw disk to virtual box
User should be in a disk group to access raw partitions (as Gilles mentioned by last reference in his answer).
sudo usermod -a -G disk $USER
46
votes
Accepted
Regular user is able to modify a file owned by root
This is happening because of two things:
vim (at least in this case) and sed, when doing in place editing, actually delete the original file and then create a new one with the same name.
the ability ...
45
votes
Accepted
Unable to delete this file as root
The file has the i ("immutable") attribute, according to the output from lsattr that you show.
From the chattr(1) manual (on Ubuntu):
A file with the i attribute cannot be modified: it ...
44
votes
Accepted
What is a valid use case for an "execute only" file permission?
Shell scripts require the read permission to be executed, but binary files do not:
$ cat hello.cpp
#include<iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
...
43
votes
Give myself permissions for all files in / without bricking my computer?
Changing the ownership of all files on the system is a very very very bad idea. Consider just for starters that the first command you propose will change the owner of sudo, which means it will no ...
43
votes
Accepted
How to make an ext4 formatted usb drive with full RW permissions for any linux machine?
Like any unix-style filesystem, ext4 includes standard Unix file ownership and permission conventions. That is, the user is identified by an UID number, and each user will belong to one or more groups,...
42
votes
Accepted
/etc/shadow permissions security best practice (000 vs. 600 vs. 640)
The idea behind setting /etc/shadow permissions to 000 is to protect that file from being accessed by daemons, even when running as root, by ensuring that access is controlled by the DAC_OVERRIDE ...
40
votes
Accepted
GitKraken does not start anymore on Ubuntu 18.04
SOLVED:
Had to install libgnome-keyring:
sudo apt install libgnome-keyring0
The UI now comes up and works for me.
Still get the following warnings, but it's working:
Gtk-Message: 11:19:31.343: ...
39
votes
VERR_ACCESS_DENIED when trying to add a raw disk to virtual box
The poster used linux on the host machine. If you came here and use Windows as a host (like me) there is an easy solution to this error. Windows doesn't allow raw disk access if you don't start ...
39
votes
Accepted
Group permissions for root not working in /tmp
The behavior you are showing seems to depend on the fs.protected_regular Linux kernel parameter, introduced along with fs.protected_fifos by this commit (converged in version 4.19, I believe), with ...
39
votes
Accepted
Is there any reason why /proc/*/cmdline is world-readable?
I suspect the main, and perhaps only, reason is historical — /proc/.../cmdline was initially world-readable, so it remains that way for backwards compatibility. cmdline was added in 0.98.6, released ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
permissions × 4549linux × 842
files × 458
chmod × 356
users × 270
sudo × 262
ubuntu × 249
acl × 227
group × 214
filesystems × 200
directory × 194
mount × 187
root × 180
debian × 169
security × 169
centos × 160
ssh × 133
bash × 131
apache-httpd × 126
samba × 119
chown × 112
umask × 100
shell-script × 94
nfs × 91
rsync × 89