Questions tagged [chmod]

chmod (short for change mode) is a Linux / Unix command used to change permissions of files and directories.

chmod accepts either human readable notation of the octal bitwise mask. The bitwise mask often has the three digits, specifying (from left to right) permissions for the world, group and the owner of the file. The bits (left to right) are read, write, and execute. For instance,

chmod 740 x.sh

makes x.sh viewable, editable and executable for the current owner. The group can view but not change or execute, and the world has no access. This can be verified with ls -l x.sh:

-rw-r--r-- 1 me 11 2013-01-25 09:53 x.sh

Permission flags can also be specified as letters (r - read, w - write, x - execute), using + or - sign to turn them on or off, for all users. For instance

chmod +r-x x.sh

with make x.sh readable for possible users but no longer executable, even for the owner. The write permission that has not been mentioned in the command, will not be revoked form the owner:

-rw-r--r-- 1 me 11 2013-01-25 09:53 x.sh

Chmod also accepts the forth (actually first) digit that sets (left to right) setUID, setGUI and sticky flags. If not specified, it is assumed 0 (no such flags).

If chmod parameter is less than 3 digits, the first owner and then group permissions are assumed zero. The following example sets (probably in an unexpected way) full permissions for the world and no permissions for the user or group:

chmod 7 x.sh
cat x.sh
cat: x.sh: Permission denied
326 questions
13
votes
7 answers

chown -R exclude some directory

I want to exclude some large content directory I'm Using it to chown Directory chown -R admin /home/admin/web/public_html is there anyway to exclude a subdirectory under html Like: chown -R admin exclude=/home/admin/web/public_html/content…
Mitra
  • 231
12
votes
1 answer

How to read ls -l permissions

I've been trying to understand Linux permissions. I know that I could download one file via CyberDuck from a remote Linux machine and the other one I was not able to. Here is the output of ls -l : -rw-r--r-- 1 root root 5360 Jul 26 17:31…
12
votes
2 answers

Vi can write to file despite file being read-only

The following example show how to create a file with only read permissions. As we can see, when I try to write to this file using the echo command I get, Permission denied . But why, in the case that we use vi, do we not get Permission denied ? As…
12
votes
3 answers

difference between chmod 777 and chmod 007

What is the difference between chmod 777 and chmod 007? if 'others' means everyone, doesn't that strongly suggest the truth that chmod 777 = chmod 007?
adhg
  • 225
12
votes
1 answer

How to tell chmod to follow symbolic links?

chown has an option -L which tells chown to traverse symbolic links. It seems this option is missing for chmod . Any idea how to tell chmod to follow symlinks as well? EDIT: I'm on Debian.
Aley
  • 326
11
votes
2 answers

How do I change permissions on a directory

I'm using CentOS and I would like to know how to change permissions on a folder with multiple files in it. I have used the following commands on the folder as root (Let's say folder =A) : chmod 777 (home/directory/A) chmod g+r (A) If I view the…
11
votes
4 answers

Git chmod problem: Checkout screws exec bit

Under Ubuntu and Debian the last committed files are getting the execution bit set, when I try a checkout afterwards. It's quite strange and driving me nuts: $ ls -l file -rw-r--r-- ... file # on branch master: $ git commit -m 'mode is 644' file…
Boldewyn
  • 4,496
11
votes
2 answers

Bash File/Folder Permission Issue on Windows 10

mkdir creates folders with 777 permission by default. How can I make 755 default? Also when I clone a git repository all the files and folders are downloaded with 777 permission! How can I correct this problem? Thanks.
misaligar
  • 223
  • 1
  • 2
  • 6
10
votes
2 answers

icacls is giving access denied on remote file system

I am working on remote drive mounted on my system where i created some file i need to set some permission for that file. I used icacls but its not working. When i am trying to access file permission its working fine. Z:\test_permission>icacls…
Abhishek
  • 103
10
votes
5 answers

sudo chmod -R 777 /

sudo chmod -R 777 / I did this. It was a mistake. Is there any way to undo it? Basically it's messed up more things than I can list. I don't have time-machine enabled on my mac.
10
votes
3 answers

How to set default permissions for files moved or copied to a directory?

My question is similar to How to set the default file permissions on ALL newly created files in linux - but differs in important ways: I want all files created in (or copied to or moved to) a certain directory to inherit a set of default permissions…
Rob
  • 101
  • 1
  • 1
  • 3
10
votes
4 answers

Setting permissions for specific user and groups in Linux

How can I grant permission for files to a specific user or a specific group? We have three groups: "g12" ("u1" and "u2), "g34" and "g56". g12 - should only read the file. g34 - should write and read it. g56 - should have all permissions (rwx). And…
AntonAL
  • 755
9
votes
3 answers

How to chmod +x a file in Windows, for use in Linux?

I have a file that needs to be executable in Linux, which I'd do by using chmod +x when using Linux. My problem is: this file is compiled in Windows, and it's a pain to have to open my Ubuntu VM to just chmod it. Is there a tool, or a method in…
9
votes
7 answers

"chown -R root /" how screwed am I?

I accidentally performed the command chown -R root / while trying to change the permissions to the public folder of my rails app. I believed this changed the permissions to all my folders on the / directory. So my question is, how dangerous is this,…
9
votes
0 answers

what is the @ after the permissions for in ls -l on a mac?

Possible Duplicate: ls -la symbolics… what does that last symbol mean? Consider the following output from ls -l on OS X 10.5.8 drwxr-xr-x 3 user staff 102 Aug 26 20:21 downloads drwxrwxrwx@ 10 user staff 340 Aug 26 20:12 images Can anybody tell me…
Constant M
1 2
3
…
21 22