The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [chmod]

chmod is used to change the commonly used read, write, and execute permissions on files. It can change these permission bits for the file owner, the file's group owner, and everyone else. It can also change the more esoteric ‘permissions’ (attributes, reall) like set-user-ID, set-group-ID, and sticky bits.

Filter by
Sorted by
Tagged with
156
votes
9answers
46k 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 ...
100
votes
4answers
143k views

Get the chmod numerical value for a file

In FreeBSD and also in Linux, how can I get the numerical chmod value of a file? For example, 644 instead of -rw-r--r--? I need an automatic way for a Bash script.
68
votes
5answers
58k 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) ...
63
votes
2answers
164k views

SSH Key Permissions Chmod settings?

I need to use SSH on my machine to access my website and its databases (setting up a symbolic link- but I digress). Following problem: I enter the command: ssh-keygen -t dsa To generate public/...
53
votes
7answers
215k views

How to get permission number by string : -rw-r--r--

I need to set the same chmod, how to get number for -rw-r--r-- ?
44
votes
4answers
124k views

'chmod g+s' command

Hello I want to understand the role of the chmod g+s command in Unix. I also would like to know what it does in this particular context: cd /home/canard; touch un; chgrp canard .; chmod g+s .; touch ...
40
votes
1answer
27k views

What is the first chmod octal digit in a four-digit value for?

Sometimes I see chmod commands that use four octal digits instead of three -- what is the optional first digit for? For example, chmod 777 is equivalent to chmod a+rwx; what's the same command for ...
38
votes
9answers
81k views

Why use `chmod 644` instead of `chmod u=rw,go=r,…`?

I've been working on *nix for a few years now, and one of the things I just can't get used to is octal permissions in code. Is there some other reason than line length to prefer chmod 644 ... over ...
37
votes
3answers
39k views

chmod + silent mode + how force exit code 0 in spite of error

Is it possible execute chmod and ignore error from command Example ( remark file.txt not exsist to show the example ) When I type chmod 777 file.txt I get error on the output chmod: cannot ...
37
votes
4answers
142k views

Change permissions for a symbolic link

I have a symlink with these permissions: lrwxrwxrwx 1 myuser myuser 38 Aug 18 00:36 npm -> ../lib/node_modules/npm/bin/npm-cli.js* The symlink is located in a .tar.gz archive. Now when I ...
37
votes
3answers
455k views

Create file in folder: permission denied

I have a problem copying files to a directory on Ubuntu 12.04. I create a directory in the home directory so that the path where I want to copy to is: /home/sixven/camp_sms/inputs But when ini run ...
36
votes
4answers
16k 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. ...
33
votes
4answers
29k 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?
32
votes
3answers
170k views

How to create a Samba share that is writable from Windows without 777 permissions?

I have a path on a Linux machine (Debian 8) which I want to share with Samba 4 to Windows computers (Win7 and 8 in a domain). In my smb.conf I did the following: [myshare] path = /path/to/share ...
27
votes
6answers
27k views

Is there a web based converter between rwx and the octal version?

I can never remember what the conversion is from something like rw-r--r-- to 644. Is there a simple web based converter between the 2?
25
votes
1answer
6k views

Make group permissions same as user permissions

I want to set the group permissions for all files and subdirectories within a certain parent directory to whatever the user permission setting for that specific file or directory is. For example, ...
21
votes
2answers
211k views

How to set the permission drwxr-xr-x to other folders?

I have few directores inside a folder like below - teckapp@machineA:/opt/keeper$ ls -ltrh total 8.0K drwxr-xr-x 10 teckapp cloudmgr 4.0K Feb 9 10:22 keeper-3.4.6 drwxr-xr-x 3 teckapp cloudmgr 4....
20
votes
4answers
2k views

What is a valid use case for an “execute only” file permission?

I was reading up on chmod and its octal modes. I saw that 1 is execute only. What is a valid use case for an execute only permission? To execute a file, one typically would want read and execute ...
20
votes
3answers
12k views

I accidentally chmod -R +x on a directory. How do I restore the correct permissions?

Well, to be specific, it was chmod -R 755. Now every file is executable, which I don't want. I am thinking that I should look at the first two bytes of each file for the #!, but will this cover ...
19
votes
2answers
1k views

What does chmod -u do?

By accident I ran chmod -u filename and it removed all of the permissions I had on filename. The man page does not reference a -u option. Experimenting I was able to conclude that it removes not all ...
19
votes
1answer
903 views

Why does chmod require disk space? Not-in-place algorithm?

I try to chmod some files and I get the error "disk quota exceeded": It's true that I don't have that much space remaining in the filesystem where I use chmod, namelynfs.mit.edu:/export/evodesign/...
18
votes
5answers
47k views

Can't apply chmod to a file

I have a file on my HDD, cd /media/celebisait/5AC69788C6976355 There is my file called myFile.tar.gz. I do als -l, -rw------- 2 celebisait celebisait 1387745311 Jun 6 2013 myFile.tar.gz ...
18
votes
2answers
7k views

How to apply recursively chmod directories without affecting files?

After I apply chmod -R to a directory, permissions are changed for everything within (files and directories). How can I add execute/search (x) permissions to directories without modifying the files?
17
votes
3answers
5k views

Purpose of permissions such as 0111 or 0333

What is the purpose of Linux permissions such as 111 or 333 (i.e. the user can execute, but cannot read the file), if the ability to execute does not automatically imply the ability to read?
16
votes
8answers
27k 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-...
16
votes
3answers
9k views

Why does chmod +w not give write permission to other(o)

When I run chmod +w filename it doesn't give write permission to other, it just gives write permission to user and group. After executing this command chmod +w testfile.txt running ls -l testfile....
16
votes
2answers
12k views

execute bit on directories, but not files [duplicate]

Possible Duplicate: How to apply recursively chmod directories without affecting files? What is the command to apply execute permission for directories (for traversal), but leave the execute bit ...
16
votes
5answers
20k views

chmod recursive permission on thousands of files

This is a more general question about 'chmoding' recursively. I have this script which at some point needs to change the permissions recursively in a folder which has a few hundred thousand files. ...
16
votes
2answers
39k views

chmod: What does the `+a` parameter mean?

I was following a tutorial and it told me to run sudo chmod +a "SOME_PARAMS" some/dir I was surprised to see that fail telling me chmod: invalid mode: `+a' So I wonder: What does the +a mode mean? ...
15
votes
2answers
45k views

Why does “chmod 1777” and “chmod 3777” both set the sticky bit?

To set the sticky bit on a directory, why do the commands chmod 1777 and chmod 3777 both work?
15
votes
1answer
19k views

Why does setuid not work? [duplicate]

I want to ensure that my program can only be run by user xyz using root privilege. To do this, I set the setuid bit with: chmod u+s program1.sh ls -l program1.sh rwsr-x--- 1 root house 1299 May 15 23:...
14
votes
2answers
81k views

How to Change Owner of a Directory

EDIT: The problem was that Apple uses permissions to mark backups and prevents you from modifying them (probably a security feature). By using chmod -RN <dir> I removed ACL data from all the ...
14
votes
4answers
51k views

permissions 755 on /home/<user>/

I am wondering why by default my directory /home/<user>/ has permissions set to 755. This allows other users to enter into directories and read files in my home. Is there any legitimate reason ...
13
votes
3answers
22k views

Write access without read access

Is it possible for a user to have a write access to a file and not be able to read it? How is it possible? I tried the following commands: debianbox@debian:~/posix/io$ touch filetest debianbox@...
13
votes
4answers
4k views

vim: create file with +x bit

Is there any way to set +x bit on script while creating? For example I run: vim -some_option_to_make_file_executable script.sh and after saving I can run file without any additional movings. ps. I ...
13
votes
3answers
52k views

How to check which Apache group I can use for the web server to write?

I'm trying to make Wordpress work. I currently have this error message: Could not create directory. /var/www/html/wp-content/upgrade/theme_name when trying to upload a theme. This is the permissions ...
13
votes
2answers
8k views

recursively change file permission but not directories?

I was doing a mass recursive change of permissions of some files that I had migrated to a unix system. I changed them to ug+rw, but then I found that I could not traverse subdirectories. I looked at ...
12
votes
1answer
1k views

Would chmod 000 /dev/stdin disable terminal forever?

I'm working through questions from Unix The Textbook (chapter 8, #16, page 207): Give chmod command lines that perform the same tasks that the mesg n and mesg y commands do. (Hint: Every hardware ...
12
votes
1answer
3k views

Root can't chmod?

In my department we have a small file server with CentOS and samba. I have root access to be able to perform some basic maintenance. Today I was making some folders read-only, so I went ahead and did ...
12
votes
1answer
25k views

Difference between “chmod 775” and “chmod 2755”

What is the difference between chmod 775 and chmod 2755?
12
votes
1answer
6k views

Symbolic link permissions don't change with chmod

I have access to a remote Linux machine where every time I create a symbolic link, it is created by default with the following permissions: lrwxrwxrwx If I try to change the permissions of the ...
11
votes
2answers
1k views

Use chmod command selectively

I want to set 755 permission on all files and sub-directories under a specific directory, but I want to execute chmod 755 only for those components which does not have 755 permission. find /...
11
votes
3answers
12k views

How do Linux permissions work when a process is running as a specific group?

This is something I haven't been able to find much info on so any help would be appreciated. My understanding is thus. Take the following file: -rw-r----- 1 root adm 69524 May 21 17:31 ...
11
votes
2answers
12k views

Difference between chmod vs ACL

I understand chmod and chown and how the permission bits work, but there is another permission system inside Linux, ACL with setfacl and getfacl, so this makes me wonder. What's the difference ...
9
votes
1answer
26k views

What does “execute” permission mean on a folder? [duplicate]

I have read this topic, which gave me some info but I feel I am not fully getting it. What does the execute permission actually mean on a folder? I fully understand what it means on a file, but on a ...
9
votes
3answers
40k views

How can I revert a chmod on the etc directory?

I accidentally executed the following command on the etc directory: sudo chmod -R 700 /etc I know that I have done something very wrong. My terminal now prints: I have no name!@ubuntu: /$ How can ...
9
votes
3answers
84k views

Giving PHP permission to write to files and folders

UPDATED FOR FURTHER CLARITY: According to http://expressionengine.com/user_guide/installation/installation.html, it says: For most Unix hosts the following is typical, but you may check with your ...
9
votes
1answer
5k views

What permissions one needs to run chmod, chown command on a folder/item?

I've always been running chmod/chown commands as a sudo user. But today I wondered if I don't use sudo, what permissions do I need to actually execute chmod/chown command on a folder/file? I've tried ...
9
votes
7answers
8k views

How to change the permission and group-owner of a file at the same time

For changing file permission, I know I could use chmod. For changing group-owner, I could use chgrp. However, if I want to change both permission and owner at the same time, any command I could use on ...
9
votes
3answers
300 views

Permissions on Files:

I would like to give 755 permissions to a directory, so I use: # chmod -R 755 /my/folder/ It works for all files inside my folder, but the problem is that I use scripts that create new files in this ...