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
323 questions
225
votes
5 answers

Linux - How to recursively chmod a folder?

How can I recursively chmod everything inside of a folder? e.g. I have a folder called var which contains many subfolders and files. How can I apply chmod 755 recursively to this folder and all its contents?
Black
  • 7,901
103
votes
4 answers

How to remove executable bit recursively from files (not directories)

When I plug-in an USB stick (FAT) into my Mac or Ubuntu machine, all files have the executable bits set. After having copied the directory structure to my hard disk how do I remove the executable bits recursively just from the files and keep those…
Mike L.
  • 5,747
  • 16
  • 51
  • 69
20
votes
4 answers

Chmod files to recursively give group same permissions as user

Is there a unix command to give the group the same permissions as the user currently has on a file-by-file basis recursively for a directory tree? I.e. if a file is user writeable it should become group writeable, otherwise it should not be group…
Alokito
4
votes
2 answers

chmod: removing "x" permission recursively totally borks the permissions

I have a folder with some contents (three files and a folder) that look like this: -rwxr-xr-x 1 max max 14504 2011-05-31 16:55 main.css -rwxr-xr-x 1 max max 2504 2011-05-31 16:55 reset.css -rwxr-xr-x 1 max max 916 2011-05-31 16:55…
Max Williams
  • 3,009
2
votes
2 answers

Clone permissions for all files in a folder

I have a question. So I have 2 folders, both of which have the same files in them, but some with different content, but the same names. What I want to do is clone all of the file permissions from one folder, into the permissions for another folder.…
2
votes
1 answer

chmod does not change file permissions

I am trying to create an executable "Hello World" ruby file and I copied an existing, working executable "Hello World" ruby file and renamed it, but the new file does not have any executable permissions. The original file had the following…
Scott
0
votes
1 answer

Is setting CHMOD to 777 Dangerous?

I am trying to install Prestashop and spoke with the technical support representative from BlueHost regarding questions I had on setting the file permissions to 777 as stated in the following installation instructions:
0
votes
0 answers

recursive chmod on current directory

I was in a directory I wanted to recursively chmod all of its contents (make writable by the group). I did (with sudo): chmod -R g+w . And something weird happened (I lost all permission to the directory I was in, until I fixed that) I ended up…
mwal
  • 121
-1
votes
2 answers

The case of special permission on Linux

I am a beginner in the Linux system and when I learned the commands, I learned to study the permissions and the owners. I understood all the commands but did not understand the special permission. I am referring to chmod u+s, chmod g+s, and chmod…
robert
  • 11