Skip to main content
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 ...
David's user avatar
  • 1,291
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 ...
JdeBP's user avatar
  • 69.9k
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.
alo Malbarez's user avatar
  • 1,013
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 (...
Hauke Laging's user avatar
  • 90.7k
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 ...
Stephen Kitt's user avatar
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 ...
ilkkachu's user avatar
  • 142k
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.
chris's user avatar
  • 849
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.
ranga.sl's user avatar
  • 731
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 ...
Stephen Kitt's user avatar
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 ...
Ravexina's user avatar
  • 2,678
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 ...
A.B's user avatar
  • 37.5k
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 ...
Stephen Harris's user avatar
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. ...
Toby Speight's user avatar
  • 8,850
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 ...
Taiki Bessho's user avatar
  • 1,105
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 ...
Kusalananda's user avatar
  • 341k
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 ...
Andy's user avatar
  • 591
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 ...
ilkkachu's user avatar
  • 142k
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 ...
thebunnyrules's user avatar
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
ASten's user avatar
  • 711
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 ...
terdon's user avatar
  • 245k
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 ...
Kusalananda's user avatar
  • 341k
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; ...
DopeGhoti's user avatar
  • 77.4k
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 ...
DopeGhoti's user avatar
  • 77.4k
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,...
telcoM's user avatar
  • 103k
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 ...
Stephen Kitt's user avatar
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: ...
Jeff Galbraith's user avatar
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 ...
Pascal's user avatar
  • 499
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 ...
fra-san's user avatar
  • 10.4k
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 ...
Stephen Kitt's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible