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
36
votes
5 answers

Trying to get Postgres setup in my environment but can't seem to get permissions to intidb

I'm following the recent RailsCast on setting up PostgreSQL, but I'm unable to run the initdb /usr/local/var/postgres command. Each time I run it, I get this error: The files belonging to this database system will be owned by user "Construct". This…
Jimmy Odom
  • 395
  • 1
  • 3
  • 5
35
votes
3 answers

Copy file permissions, but not files

I have two copies of the same directory tree. They almost have the same files in both (one version may have a couple extra or missing files). However, most of the files are in common to both directories (have the same relative paths and…
user788171
  • 16,753
  • 40
  • 98
  • 125
32
votes
3 answers

chmod - protect users' file being accessed so only owner can access?

How to set chmod, so that ONLY owner of the file can read, write and execute? (other users cannot read, write, and execute)
user21
  • 1,261
  • 5
  • 20
  • 41
31
votes
2 answers

chmod: cannot read directory `.': Permission denied

I am trying to recursively change the permission of directories and sub-directories for "data" directory and running into following error..can someone provide inputs on the below error? chmod -R 0644 . chmod:…
carte blanche
  • 10,796
  • 14
  • 46
  • 65
30
votes
1 answer

rsync deploy and file/directories permissions

I'm trying to use rsync to deploy my website that resides on a shared web host. Phpsuexec is running on it and that caused me problems with permissions on files and directories I've transfered via rsync. Actually files should be set to 644 and…
Granze
  • 497
  • 1
  • 4
  • 10
29
votes
5 answers

How will a server become vulnerable with chmod 777?

I often read articles saying something along the lines of chmod 777 is bad! I was wondering: How do I become vulnerable when I execute chmod 777 on a file? What is a real world example of this that I can reproduce?
Jürgen Paul
  • 14,299
  • 26
  • 93
  • 133
28
votes
2 answers

Why Docker COPY doesn't change file permissions? (--chmod)

Given this Dockerfile: FROM docker.io/alpine RUN mkdir test # RUN umask 0022 COPY README /test/README COPY --chmod=777 README /test/README-777 COPY --chmod=755 README /test/README-755 COPY FORALL /test/FORALL COPY --chmod=777 FORALL…
Kamafeather
  • 8,663
  • 14
  • 69
  • 99
27
votes
4 answers

Changing permissions via chmod at runtime errors with "Operation not permitted"

When I use chmod() to change permissions at run time, it gives me the below message: Warning: chmod() [function.chmod]: Operation not permitted in /home/loud/public_html/readalbum.php How can I remove this error and make the chmod function work?
Deepak
  • 1,055
  • 4
  • 13
  • 22
24
votes
5 answers

set permissions for all files and folders recursively

I want to recursively set the folder and file permissions. Folders should get 750 and files 644. I found this and made some adaptions. Would this one work?
testing
  • 19,681
  • 50
  • 236
  • 417
24
votes
3 answers

How do you add chmod +x permission to an AWS Elastic Beanstalk platform hook?

Context I am using Elastic Beanstalk to deploy a very simple test application. I have several packages I want to install using apt. I have included a 01_installations.sh script with the installations in the .platform/hooks/prebuild directory. When I…
22
votes
2 answers

What is the difference between `chmod go-rwx` and `chmod 700`

My goal is to prevent modify/read permission of other users except the owner. On ubuntu forums as solutions both approach is given. sudo useradd -d /home/newuser -m newuser chmod 700 /home/newuser # or # chmod go-rwx /home/newuser [Q] Is there…
alper
  • 2,919
  • 9
  • 53
  • 102
22
votes
5 answers

Access GPIO (/sys/class/gpio) as non-root

The /sys/class/gpio can only be accessed as root by default. So I like that a new group gpio can use the files and directories under /sys/class/gpio. To achieve that I added the following lines to /etc/rc.local (I'm on Debian): sudo chown root:gpio…
TiMESPLiNTER
  • 5,741
  • 2
  • 28
  • 64
21
votes
3 answers

Wordpress on Docker: Could not create directory on mounted volume

Here is are the original files in the Wordpress Docker container on path /var/www/html: $ docker exec 5b957c7b9c5ad054883694afbfb80d3c9df6707458d55011f471be0701f3890c ls -l total 192 -rw-r--r-- 1 www-data www-data 418 Sep 25 2013…
Peter G.
  • 7,816
  • 20
  • 80
  • 154
21
votes
2 answers

Linux change group permission to match owner permissions

Suppose I have a directory on Linux with a bunch of files and subdirectories. This is that root directory: drwxr-xr-x 13 user1 group1 4096 May 7 15:58 apps Now, I only want to alter the group portion of those permissions. I want to alter it in…
Dave L.
  • 9,595
  • 7
  • 43
  • 69
21
votes
1 answer

PHP: get_current_user() vs. exec('whoami')

Short version of the question: What's the difference between get_current_user(); and exec('whoami'); ? Long version of the question: I'm on a XAMPP Localhost on a Mac. I'm using Apache, building a PHP based website in a folder (let's call it…
thanks_in_advance
  • 2,603
  • 6
  • 28
  • 44
1 2
3
88 89