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
7
votes
3 answers

NSFileManager & NSFilePosixPermissions

I want to use the octal permissions (used for chmod) for NSFilePosixPermissions. Here is what I did now: NSFileManager *manager = [NSFileManager defaultManager]; NSDictionary *attributes; [attributes setValue:[NSString stringWithFormat:@"%d", 0777]…
qwertz
  • 14,614
  • 10
  • 34
  • 46
7
votes
3 answers

Recursively chmod/chown/chgrp all files and folder within a directory

I am working on a site which builds other sites. Some if it I use copy() to create the files and directories, other times I'm building XML files in php and using DOMDocument::save to save them. The end result is a root folder with all sorts of…
Steve Robbins
  • 13,672
  • 12
  • 76
  • 124
7
votes
1 answer

Is chmod 757 safe?

As i am on a shared host , i want to add a image hosting script and it seems that with 755 it doesnt allow me to upload images, so i changed the folder to 757 , is it safe to chmod to 757?
stergosz
  • 5,754
  • 13
  • 62
  • 133
7
votes
2 answers

Making executable all PHP files (recursively)

I just downloaded MediaWiki software on my server for installation. After decompressing it, I noticed that PHP files were not executable. I ran chmod +x *.php* (there are also .php5 files) but it didn't work in subdirectories. How can I add the…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
7
votes
1 answer

asyncio version of `os.chmod` in Python

I have some Python3 code running inside an asyncio event loop. I want to use the functionality of os.chmod(...), but would ideally like a non-blocking version of this, so that I can use await os.chmod(...), and avoid making a blocking system call. I…
Tom Christie
  • 33,394
  • 7
  • 101
  • 86
7
votes
3 answers

PHP mkdir 0777 fail chmod 0777 works

using PHP 5.2.14, this is what happens [user@VE213 public_html]$ php -r "mkdir('directory', 0777);" [user@VE213 public_html]$ ls -lt drwxrwxr-x 2 rankranger rankranger 4096 Dec 8 17:28 directory [user@VE213 public_html]$ php -r…
meow
  • 71
  • 1
  • 2
7
votes
1 answer

GitLab's Shell executor, no privileges

I have GitLab platform in 8.7.0 version and I am currently working on setting up CI part. I have created new gitlab-runner that uses shell as an executor. The problem is that before the runner is invoked to do own jobs the system is not able to…
Roland
  • 189
  • 3
  • 7
7
votes
1 answer

How to set permissions recursively, 700 for folders and 600 for files, without using find

I'm trying to figure out a way to set permissions recursively 700 for dirs and subdirs on a specific path and 600 for files. I would use these commands: find /path -type d -print0 | xargs -0 chmod 700 find /path -type f -print0 | xargs -0 chmod…
Ichundu
  • 173
  • 1
  • 10
7
votes
5 answers

Why does recursive mode on chmod do everything but recursion?

chmod -R 775 *.cgi only changes permissions on the files in the current directory, the files in the subdirectory don't get modified at all. This is the exact same functionality as simply doing chmod 775 *.cgi. I have seen people use solutions such…
Razor Storm
  • 12,167
  • 20
  • 88
  • 148
7
votes
1 answer

Why do my setuid root bash shell scripts not work?

I created this simple script to allow the user to remove files created by the web server in his home directory without giving him "su". Both scripts are set with "chmod 4750". The craziest thing is that they DID work and now they don't. Here's the…
Bob
  • 71
  • 1
  • 1
  • 3
7
votes
1 answer

How to control file access in Windows?

Go provides os.Chmod() for setting file and directory permissions. For example, if I want to ensure a file is accessible only to the current user, I can do the following: os.Chmod("somefile.txt", 0600) This works great on Linux but does absolutely…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
7
votes
3 answers

Chmod issue to change file permission using python

I am looking to change the file permission to all files to read write and execute for all the users in a directory using a python script. However, after running the script when I check the file permission doing the right click, it only shows the…
Chaos
  • 415
  • 1
  • 3
  • 12
7
votes
1 answer

Using nodejs chmod 777 and 0777

Using fs.chmod(path, mode, callback) I set the mode to 777. It didn't work properly. But when I set it to 0777, it worked. So I want to know what the difference is between chmod 777 and chmod 0777?
Yofine
  • 273
  • 1
  • 3
  • 8
7
votes
2 answers

Recursive mkdir() and chmod()?

When using mkdir() with the recursive flag set to true do all the created directories get the specified chmod or just the last one? For example: mkdir('/doesnotExist1/doesnotExist2/doesnotExist3/', 0755, true); Will the newly created directories…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
7
votes
1 answer

PHPUnit & Git: How to test with unreadable file?

Short version: For unit testing, I need an unreadable file to make sure the correct exception is thrown. Obviously, that unreadable file can't be stored by Git, so I chmod 000 at testing time and use git update-index --assume-unchanged so that Git…
jchamberlain
  • 1,038
  • 8
  • 26