212 votes

SSH Key Permissions chmod settings?

chmod 600 ~/.ssh/id_rsa; chmod 600 ~/.ssh/id_rsa.pub (i.e. chmod u=rw,go= ~/.ssh/id_rsa ~/.ssh/id_rsa.pub) are correct. chmod 644 ~/.ssh/id_rsa.pub (i.e. chmod a=r,u+w ~/.ssh/id_rsa.pub) would also ...
Gilles 'SO- stop being evil''s user avatar
103 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,271
96 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
  • 68.4k
89 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
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
  • 89.8k
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
  • 138k
74 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
71 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
  • 809
68 votes
Accepted

Difference between sudo user and root user

Executive summary: "root" is the actual name of the administrator account. "sudo" is a command which allows ordinary users to perform administrative tasks. "Sudo" is not ...
Edward Falk's user avatar
  • 1,953
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
58 votes

Why does Bash's source not need the execution bit?

source or the equivalent but standard dot . do not execute the script, but read the commands from script file, then execute them, line by line, in current shell environment. There's nothing against ...
cuonglm's user avatar
  • 153k
58 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,600
56 votes
Accepted

usermod -a -G group user not work

When changing a user's groups, the changes don't take effect until the next time the user logs in. So, you can either log out and log back in again or start a new login shell as gefalko: $ groups sys ...
terdon's user avatar
  • 241k
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

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
  • 35.5k
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,628
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
  • 331k
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
  • 138k
49 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,085
47 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
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
  • 241k
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
  • 331k
44 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
  • 691
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
  • 75.6k
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
  • 75.6k
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
  • 94.7k
42 votes
Accepted

Why does Bash's source not need the execution bit?

Bash is an interpreter; it accepts input and does whatever it wants to. It doesn't need to heed the executable bit. In fact, Bash is portable, and can run on operating systems and filesystems that ...
200_success's user avatar
  • 5,505

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