Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [permissions]

Permissions are the Unix way of controlling access to resources such as files, directories and devices and may be specified for an owner, group, or all users.

108
votes
7answers
16k views

Redirecting stdout to a file you don't have write permission on

When you attempt to modify a file without having write permissions on it, you get an error: > touch /tmp/foo && sudo chown root /tmp/foo > echo test > /tmp/foo zsh: permission denied:...
364
votes
7answers
251k views

Execute vs Read bit. How do directory permissions in Linux work?

In my CMS, I noticed that directories need the executable bit (+x) set for the user to open them. Why is the execute permission required to read a directory, and how do directory permissions in Linux ...
16
votes
4answers
15k views

I added a user to a group, but group permissions on files still have no effect

I changed permissions of a file (chmod g+w testfile) and running ls -l testfile gives: -rwxrwxr-x 1 user1 user1 0 2011-01-24 20:36 testfile I then added a user to that group ("/etc/group" has user1:...
31
votes
4answers
27k views

Wrongly set chmod / 777. Problems?

I was trying to run chmod -R 777 ./ but ended up typing chmod -R 777 / and set 777 on my entire machine. What can go wrong? How can I fix it?
66
votes
5answers
55k views

Understanding UNIX permissions and file types

I've never really got how chmod worked up until today. I followed a tutorial that explained a big deal to me. For example, I've read that you've got three different permission groups: owner (u) ...
14
votes
1answer
6k views

What are the different ways to set file permissions etc on gnu/linux

On Unix, a long time back, I learned about chmod: the traditional way to set permissions, on Unix (and to allow programs to gain privileges, using setuid, setgid). I have recently discovered some ...
125
votes
3answers
181k views

Make all new files in a directory accessible to a group

Suppose I have two users A and B and a group G and a folder foo, both users are members of G (using linux and ext3). If I save as user A a file under foo, the permissions are: -rw-r--r-- A A. ...
69
votes
3answers
65k views

Why can't a normal user `chown` a file?

Why is the chown command root-only? Why can't non-root users use chown to give away files they own?
249
votes
4answers
395k views

How to set default file permissions for all folders/files in a directory?

I want to set a folder such that anything created within it (directories, files) inherit default permissions and group. Lets call the group "media". And also, the folders/files created within the ...
144
votes
4answers
255k views

How does the sticky bit work?

SUID The sticky bit applied to executable programs flagging the system to keep an image of the program in memory after the program finished running. But I don't know that what it's stored in memory....
88
votes
3answers
69k views

Why can rm remove read-only files?

If I create a file and then change its permissions to 444 (read-only), how come rm can remove it? If I do this: echo test > test.txt chmod 444 test.txt rm test.txt ...rm will ask if I want to ...
155
votes
4answers
92k views

Do the parent directory's permissions matter when accessing a subdirectory?

If I have a root folder with some restrictive permission, let's say 600, and if the child folders/files have 777 permission will everybody be able to read/write/execute the child file even though the ...
18
votes
4answers
10k views

Precedence of user and group owner in file permissions

I just ran into something unexpected (for me) regarding file permissions on Linux (Arch Linux). Basically I have: userX in groupX fileX userX:groupX ---rwx---- What puzzles me: I cannot perform any ...
80
votes
3answers
175k views

Getting new files to inherit group permissions on Linux

I am having a problem with permissions on a Linux server. I am used to BSD. When a directory is owned by a group the user who owns it isn't in such as www-data, files created in it will be owned by ...
11
votes
4answers
3k views

sudo permission denied but su grants permission

this is the first occurrence where su was required for me. I read an article about changing the value in /sys/devices/virtual/backlight/acpi_video0/brightness to alter my laptop's screen brightness. ...
40
votes
3answers
48k views

How to apply changes of newly added user groups without needing to reboot? [duplicate]

Assume I'm logged in with user takpar: takpar@skyspace:/$ As root, I've added takpar as a member of group webdev using: # usermod -a -G webdev takpar But it seems it has not been applied, because ...
5
votes
1answer
5k views

Difference between systemd and terminal starting program

I am curious as to what this difference is between programs that are; started with systemd when enabled through systemctl, vs those started by means of /etc/rc.local or through the CLI. For example, ...
174
votes
4answers
79k views

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
14
votes
8answers
26k views

Convert ls -l output format to chmod format

Say I have the following output from ls -l: drwxr-xr-x 2 root root 4096 Apr 7 17:21 foo How can I automatically convert this to the format used by chmod? For example: $ echo drwxr-xr-x | chmod-...
50
votes
2answers
88k views

SSH and home directory permissions

It took me hours to solve this SSH problem with one of my class accounts on my school's servers. I couldn't ssh into one particular class account without entering my password, while passwordless ...
7
votes
4answers
1k views

facl ignoring the “x” permission but only on files

When I use setfacl to manage on what permissions should the children files / directories have, for some reason the files have all the permissions except the execute ("x") one. someuser@someuser-MS-...
13
votes
4answers
23k views

How to restore default group/user ownership of all files under /var?

I accidentally changed /var owner/group to my username and then changed it back to root, but not all the /var folders' owners are root, so is there anyway to change back owner/group of files/folders ...
8
votes
1answer
1k views

How to allow to run su instantly after I added the user to the appropriate group

I have the su executable with the following permissions: bash-4.2# ls -la /bin/su -rws--s--- 1 root wheel 59930 Sep 14 2012 ./su When I am logged in as a user, not in the wheel group and try to run ...
2
votes
1answer
2k views

Symbolic link not working as expected when changes user

Symbolic link not working, using standard UBUNTU 16 LTS... It shows "Permission denied" where I expected to get access, not working even after chown. Full example: sudo rm /tmp/file.txt # if exist, ...
155
votes
9answers
44k views

How to chmod without /usr/bin/chmod? [duplicate]

Today I was told a tale by a Unix trainer where the root password got leaked to the students, and one of the fellas removed the execute permission from /usr/bin/chmod itself. How do you recover chmod ...
62
votes
8answers
51k views

Can a script be executable but not readable?

Is it possible to execute a script if there is no permission to read it? In root mode, I made a script and I want the other user to execute this script but not read it. I did chmod to forbid read and ...
34
votes
7answers
38k views

Can root/superuser read my read-protected files?

On shared unix hosting, if I have a file sensitive-data.txt and I issue: chmod 600 sensitive-data.txt Can root user still read my file? Specifically I'm wondering if it's safe to store my password ...
9
votes
3answers
55k views

Allow a user to read some other users' home directories

I am new to system administration and I have a permission related query. I have a group called administration. Inside the administration group, I have the users user1, user2, user3, superuser. All the ...
6
votes
1answer
12k views

Why do I get “Permission denied” when redirecting the output of sudo echo “xyz” to a file? [duplicate]

Why do I get -bash: test: Permission denied when I run sudo echo "xyz" > test The directory permissions are: drwxr-xr-x 3 root root 4096 2014-08-05 16:26 I have no problem creating a file ...
14
votes
1answer
23k views

In Linux, is “write” permission equivalent to “execute” for directories?

The execute permission makes sense for files (which include scripts etc.), but when it comes to directories, the write (w) permission works the same way as execute (x), right? Which means, if we are ...
14
votes
3answers
13k views

Why doesn't umask change execute permissions on files? [duplicate]

If I change the umask to 0000, I'd expect a text file to be created with rwxrwxrwx permissions (based on my understanding of the umask, as described in the "possible duplicate" question) However, when ...
15
votes
5answers
31k views

How to revert chown command?

If I run: sudo chown -R user:user / Can I revert it to what it was before I ran it?
354
votes
8answers
602k views

How do I copy a folder keeping owners and permissions intact?

So I was going to back up my home folder by copying it to an external drive as follows: sudo cp -r /home/my_home /media/backup/my_home With the result that all folders on the external drives are now ...
86
votes
2answers
235k views

Mount cifs Network Drive: write permissions and chown

I have access to a cifs network drive. When I mount it under my OSX machine, I can read and write from and to it. When I mount the drive in ubuntu, using: sudo mount -t cifs -o username=${USER},...
40
votes
4answers
60k views

Is there any way to prevent deletion of certain files from user owned directory?

Let's say user has Directory1 and it contains File1 File2 CantBeDeletedFile How to make so the user would never be allowed to delete the CantBeDeletedFile? If I change the ownership of Directory1 and ...
36
votes
4answers
15k views

How to recover from a chmod -R 000 /bin?

And now I am unable to chmod it back.. or use any of my other system programs. Luckily this is on a VM I've been toying with, but is there any way to resolve this? The system is Ubuntu Server 12.10. ...
56
votes
8answers
9k views

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

With Bash's source it is possible to execute a script without an execution bit set. This is documented and expected behaviour, but isn't this against the use of an execution bit? I know, that source ...
32
votes
4answers
63k views

Why cannot find read /run/user/1000/gvfs even though it is running as root?

Can someone tell me what I'm doing wrong, what this is, or how to fix it? I'm running Fedora 18 and getting the error shown [root@servername /]# find . -name ngirc find: `./run/user/1000/gvfs': ...
21
votes
4answers
2k views

Is there a reason why 'owner' permissions exist? Aren't group permissions enough?

I think I rather understand how file permissions work in linux. However, I don't really understand why they are split into three levels and not into two. I'd like the following issues answered: Is ...
29
votes
3answers
87k views

“rsync: failed to set permissions on …” error with rsync -a or -p option

When I use the -a option as is asked and answered in Preserve the permissions with rsync, I got a lot of "rsync: failed to set permissions on" errors. rsync: failed to set permissions on "/ata/text/...
18
votes
1answer
47k views

Allow certain guests to execute certain commands

I would like to create a new user on some of my Debian/Ubuntu hosts that is able to update the server using the commands apt-get update and apt-get dist-upgrade, but I do not wan't to give them full ...
16
votes
4answers
34k views

Permission denied to change gid(group) of a file I own

It appears I still miss some things about the way permissions work. I am on a debian 7 system btw. just now I have this file of which I downloaded and it belongs to myuser:myuser, that is both user ...
11
votes
2answers
15k views

Group member cannot write even with write permission

The logged in user is a member of a group that has a write permission on a folder. But when this user is trying to write something, "permission is denied". The log below summarizes the question: ...
17
votes
1answer
9k views

Why can't sudo redirect stdout to /etc/file, but sudo 'nano' or 'cp' can? [duplicate]

Why does redirection, using sudo give me an error for the following commands? $ sudo printf "foo" >/etc/file bash: /etc/file: Permission denied $ sudo printf "foo" ~/file; cat ~file >/etc/...
5
votes
2answers
3k views

Configure SELinux to allow daemons to use files in non-default locations

I have a daemon (apache/samba/vsftpd/...) running on SELinux enabled system and I need to allow it to use files in a non-default location. The standard file permissions are configured to allow access. ...
3
votes
1answer
931 views

What is the exact purpose of `mask` in file system ACL?

When I apply default ACL in a directory I see default:mask or just mask in the following two scenario. Scenario 1 -bash-4.2$ ls -ld test/ drwxr-x---. 2 test test 4096 Oct 15 19:12 test/ -bash-4.2$...
121
votes
5answers
100k views

Clone ownership and permissions from another file?

Is there a command or flag to clone the user/group ownership and permissions on a file from another file? To make the perms and ownership exactly those of another file?
62
votes
3answers
65k views

What's the difference between “s” and “S” in ls -la?

When I ls -la, it prints many attributes. Something like this: -rwSrwSr-- 1 www-data www-data 45 2012-01-04 05:17 README Shamefully, I have to confess I don't know the exact meaning of each ...
16
votes
2answers
54k views

How to add a ssh user who only has permissions to access specific folder?

How to add an ssh user who only has permissions to access specific folder? useradd -d /var/www/xyz.com.tr/musteri -s /bin/bash -g sshd musteri I created a user called musteri. I set its home folder ...
53
votes
2answers
13k views

Why is rm allowed to delete a file under ownership of a different user?

From the post Why can rm remove read-only files? I understand that rm just needs write permission on directory to remove the file. But I find it hard to digest the behaviour where we can easily delete ...