Questions tagged [chmod]

chmod is a linux/unix command. It stands for "change mode". This command is used change the permissions of directories and files.

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
1322 questions
81
votes
5 answers

changing chmod for files but not directories

I need to use chmod to change all files recursivly to 664. I would like to skip the folders. I was thinking of doing something like this ls -lR | grep ^-r | chmod 664 This doesn't work, I'm assuming because I can't pipe into chmod Anyone know of an…
Ori
  • 4,961
  • 10
  • 40
  • 39
73
votes
3 answers

find . -type f -exec chmod 644 {} ;

why doesn't this work I am trying to change all files to 644 abd all -d to 755: find . -type f -exec chmod 644 {} ; i get: find: missing argument to `-exec' thanks
user1920187
  • 802
  • 1
  • 7
  • 15
64
votes
1 answer

changing the owner of folder in linux

I have a folder in my subdomain which is created through WHM so the owner of that subdomain is not the owner of main domain. I want to change the owner of one of the folders of subdomain to domain owner. I tried this, but when I check with winscp…
sachin
  • 727
  • 1
  • 5
  • 11
59
votes
7 answers

Cannot change permissions of folders within vagrant home folder

When I ssh in to my vagrant vm, I can change permissions of files and folders above and outside the vagrant user folder, and for files within the vagrant user folder. But cannot change permissions for folders under the vagrant user folder. I have…
kayaker243
  • 2,580
  • 3
  • 22
  • 30
57
votes
3 answers

How do I use chmod with Node.js

How do I use chmod with Node.js? There is a method in the package fs, which should do this, but I don't know what it takes as the second argument. fs.chmod(path, mode, [callback]) Asynchronous chmod(2). No arguments other than a possible exception…
pvorb
  • 7,157
  • 7
  • 47
  • 74
57
votes
1 answer

preserving file permissions for samba shares when file is edited

The code bases I work with are checked out from Git repositories onto my Linux machine. Since our production code is written to be deployed on Linux, I do all the testing on my Linux machine but like to use Windows for everyday usage, including code…
recognosco
  • 1,506
  • 1
  • 10
  • 10
49
votes
4 answers

In a PHP / Apache / Linux context, why exactly is chmod 777 dangerous?

Inspired by the discussion in this question. We have all been taught that leaving directories or files on Linux-based web hosting with the permission level of 777 is a bad thing, and to set always as little permissions as necessary. I am now curious…
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
46
votes
3 answers

How to change permissions to certain file pattern/extension?

Using chmod, I do chmod +x *.sh in the current directory but what if I want to change all files including files within subfolders that has an sh file extension?. chmod +x -R * will work but I need something more like chmod +x -R *.sh
ivanceras
  • 1,415
  • 3
  • 17
  • 28
45
votes
6 answers

What is the normal chmod?

On my web server, my file permissions are all over the place and I want to 'reset' everything back to how it originally was. I don't want any users to be able to come in and delete things off my web server! I just want them to be able to look at php…
James
45
votes
3 answers

How to make all files under a directory world readable on linux?

I want to make all files (and directories) under a certain directory world readable without having to chmod each file on its own. it would be great if there is an option to also do this recursively (look under folders and chmod 666 all files under…
Rorchackh
  • 2,113
  • 5
  • 22
  • 38
43
votes
5 answers

Creating executable files in Linux

One thing I plan to be doing is writing (painfully simple) Perl scripts, and I'd like to be able to run them without explicitly calling Perl from the terminal. I appreciate that, to do this, I need to grant them execute permissions. Doing this with…
user100246
40
votes
1 answer

Differences between CHMOD 755 vs 750 permissions set

I have some files with 755 and I need to change them to 750, but I am not sure if this can affect some process. I am changing JARs, XMLs, LOGs, and properties files. Can someone explain to me the difference between these two permission sets? Thanks!
Israelm
  • 1,607
  • 3
  • 23
  • 28
39
votes
1 answer

svn: how to set the executable bit on a file?

How do I set the executable bit on a file in an svn repository? I've tried: chmod +x sync.py svn commit sync.py -m "Make sync.py executable" But the change was not propagated. How do I set the executable bit in the svn repository?
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
38
votes
7 answers

Linux: Set permission only to directories

I have to change the permissions of the htdocs directory in apache to a certain group and with certain read/write/execute. The directories need to have 775 permissions and the files need to have 664. If I do a recursive 664 to the htdocs, then all…
radicaled
  • 2,369
  • 5
  • 30
  • 44
37
votes
3 answers

How do I make git accept mode changes without accepting all text changes?

I've got the opposite problem from "How do I make git ignore mode changes (chmod)?" I've got a file that I've changed executable permission on, but there are also some text changes, and I want to commit the former but not the latter. Is this…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
1
2
3
88 89