Questions tagged [chmod]

The chmod command is used to adjust file permissions to read, write and execute for the owner, group and others.

chmod is an abbreviation of change mode. A file's mode is the set of permissions attached to it that control access:

permissions

Permission settings have different effects on regular files and on directories:

files and directories compared

chmod can also set the special permissions setuid, setgid and sticky bit.

chmod commands may be given in symbolic notation:

u = file owner
g = file group owner
o = everyone else
a = all of the above

Examples:

chmod u+x        #give owner only execute permission
chmod o-w        #remove global write permission
chmod g=r        #set group permission to read only
chmod u+w,go=rx  #give owner write permission & set permissions for group and others to read & execute only
chmod g+s        #add the setgid bit

Octal notation may also be used. An absent digit will be interpreted as a leading zero, so chmod 1 file is the same as chmod 0001 file The last three digits refer to the three sections of the mode and act as follows:

1 = x only
2 = w only
3 = w and x
4 = r only
5 = r and x
6 = r and w
7 = r w and x

The first digit applies special permissions:

1 = sticky bit
2 = setgid
4 = setuid

Examples:

chmod 644   #owner may read and write, group & others only read
chmod 755   #owner may read write and execute, group & others read and execute
chmod 2750  #setgid, owner may read write and execute, group may read and execute, others have no permissions

The command takes multiple file names as arguments:

chmod 744 foo bar baz  #gives the owner rwx and all others r only on the files foo bar and baz

It also has a -R recursive flag, but it is unusual for files and directories to need the same permissions.

588 questions
84
votes
2 answers

chmod files only in all subdirectories

Please someone assist me with chmod, I have the following file structure -dir1 --file1 --file2 --dir1a ---file1a1 ---file1a2 --dir1b ---file1b1 ---file1b2 How do I chmod 655 to all files under dir1 and all subdir? So all files will have 655…
netic
  • 943
56
votes
4 answers

Why does chmod 777 -R / leave the system unusable?

I'm only granting permission to all to do anything but why does the system crash by giving permissions only? I'm only modifying the permission not changing the files.
11
votes
1 answer

What does the final "+" mean after the user/group/others rwx permissions

How do you modify or eliminate the "+" symbol? Example: (directory)rwxr-x---+
goodbyte
  • 113
  • 6
9
votes
2 answers

How can I recover from chmod -R a-wrx / command?

Today I ran sudo chmod -R a-wrx /. Now nothing is working. Can anyone help me recover my system?
8
votes
2 answers

User Rights letters to numbers

I am having Problems converting user rights. I want to assign the following rights to certain files/folders but dont know hat to translate them into a format which chmod will work with like chmod 755. -rwxrwxrwx will be? And drwxr-xr-x will…
Shaeldon
  • 185
8
votes
1 answer

Any recover from sudo chmod 600 /

I was configuring ssl certificate on server and while following documentation I accidentally pasted terminal command without checking. sudo chmod 600 / usr/local/nginx/ssl/my-ssl.key It immediately kicked me out of the server because I guess this…
Roko
  • 183
7
votes
4 answers

What "chmod 777 -R / " does in /var/www/html/.../.../.../?

Unfortunately I was rushing and ran sudo chmod 777 -R / inside one project. Should I worry that it started to add 777 permission for all my folder starting from root (/) ?
πter
  • 179
  • 1
  • 1
  • 3
7
votes
3 answers

What is the difference between chmod and chattr?

Solaris operating system does not have chattr, it uses chmod instead. Also on Windows. Because when you're changing attributes of a file you're changing what you or other users can do with it, thus the meaning of chmod. So do we really need chattr?…
Shayan
  • 1,503
5
votes
1 answer

How to chmod files that have a specific set of permissions

I want to find all files in a folder that have -rw-r----- (640? is that the right code?) permissions, and change them all to have -rw-rw-rw- instead. How do I do this, with chmod? I know I could do the whole folder with sudo chmod -R 666…
Max Williams
  • 227
  • 1
  • 3
  • 12
3
votes
0 answers

chmod: permissions of a directory don't change

I have some issue with chmod: mis@hell:/var/www/blah$ sudo chmod g+w .git -v mode of `.git' changed from 0755 (rwxr-xr-x) to 0775 (rwxrwxr-x) mis@hell:/var/www/blah$ ls -la | grep git$ drwxr-xr-x 1 www-data www-data 442 Mar 6…
2
votes
1 answer

Chmod breaks folder access / file access

My servers are currently running a fresh install of Ubuntu 16.04 server, no direct nor indirect system changes have been made. A folder/file is completely accessible when created, but if I use chmod to make the slightest change, I completely lose…
2
votes
4 answers

How can I limit a user to access just his folder? Not able to view/cd into any other thing?

How do I limit a user to access just his folder? Suppose I don't want the user to be able to cd anywhere else, isit possible? Do I need to chmod the whole system?
Jiew Meng
  • 10,347
2
votes
1 answer

My newly added user cannot write to folder

Suppose I installed ubuntu with the user usr1 then I added usr2. I then create a group grp1 where this 2 users are added. A folder is owned by usr1 and has group grp1. But when I login as usr2 I cannot write. The folder has permissions…
JM at Work
  • 1,965
2
votes
2 answers

Setting directory file permissions in Ubuntu using chmod

whats the equivalent command of this (Fedora command) for Ubuntu: chmod +a "www-data allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs When I try the above with Ubuntu (10.0.4 LTS), I get the error message: chmod: invalid…
2
votes
1 answer

Change only file permissions in a folder NOT RECURSIVELLY

I have a lot of files in one specific folder, and I want to change the permissions only for files and only in this folder (not subfolders), how can I achieve this? Thanks in advance.
lpFranz
  • 123
1
2 3