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
20
votes
2 answers

ADB Shell giving bad mode when executing chmod (under su)

I'm having an issue related to the Android ADB Shell. When I try to execute the command chmod he gives me a "Bad Mode". I don't get it why. I'm sure I'm executing under "su", as represented by the '#'. Anyone have any idea why this is happening, and…
Comic Sans MS Lover
  • 1,729
  • 5
  • 26
  • 52
19
votes
1 answer

PHP chmod( ):Operation not permitted, safe_mode deprecation involved?

I'm struggling a bit to grasp the concept of chmod() from PHP as the course I'm currently taking is a bit outdated and involves safe_mode. It states that as safe_mode is turned off, the restrictions to modify permissions with chmod() to a file when…
Joel Hernandez
  • 1,817
  • 4
  • 18
  • 27
17
votes
2 answers

How to fix permission denied for .git/ directory when performing git push?

I have set up a git repository on my server. Created a new user 'git'. My repos are located in /srv/git/example.git. I was able to git remote add origin git@domain/srv/git/example.git then I added and committed my changes. However when I tried git…
xylar
  • 7,433
  • 17
  • 55
  • 100
17
votes
1 answer

Linux: command to make folders recursively writable without affecting the permission of files inside them

Is it possible to make the folders writable recursively without affecting the files inside them using Linux command. chmod 777 -R foldername - will make all folders and files inside the folder writable. We've a website where we do not want the core…
Sankar V
  • 4,110
  • 5
  • 28
  • 52
16
votes
2 answers

chmod: How to recursively add execute permissions only to files which already have execute permission

I noticed: chmod -R a+x adds execute permissions to all files, not just those who are currently executable. Is there a way to add execute permissions only to those files who already have an execute set for the user permission?
Clinton
  • 22,361
  • 15
  • 67
  • 163
16
votes
3 answers

File Permissions and CHMOD: How to set 777 in PHP upon file creation?

A question about file permissions when saving a file that when non existent, is created initially as new file. Now, this all goes well, and the saved file appear to have mode 644. What to I have to change here, in order to make the files save as…
Sam
  • 15,254
  • 25
  • 90
  • 145
16
votes
3 answers

How to `chmod -R +w` with Ant, files and folders?

I'd like to do the equivalent of a chmod -R +w foo/ in an Ant build script. So far I'm using this: Is there a neater way to…
Wernight
  • 36,122
  • 25
  • 118
  • 131
16
votes
6 answers

chmod a freshly mounted external drive to set up writing access

I have mounted a external drive at: # mkdir /mnt/external and subsequently: mkdir -p /mnt/external mount /dev/sdb1 /mnt/external Now only the root-user has access to write to these folders. linux-wyee:/home/martin # dir /mnt drwxr-xr-x 2 root root…
zero
  • 1,003
  • 3
  • 20
  • 42
16
votes
2 answers

How to give file permission to a specific user in a Group?

I have a Group 'g1' having 2 users Alice and Bob. I want to share a file 'file1' with both of them with different permissions.(for Alice read only and for Bob Read+write)
Vijay
  • 221
  • 1
  • 2
  • 11
16
votes
3 answers

Git ignoring gitconfig?

It appears Git is ignoring ~/.gitconfig $ git config --global core.filemode false $ git config -l core.filemode=false core.filemode=true So now there are 2 entries for core.filemode and git is still not ignoring filemode changes $ touch…
Zombo
  • 1
  • 62
  • 391
  • 407
15
votes
2 answers

How do i secure a web server's image upload directory?

For my web application, people can upload images from a web form to my web server. What should I set the CHMOD settings for that image upload directory so that people can upload images (from the web server) to that directory but not execute any…
phpneedshelp99
15
votes
5 answers

MySQL LOAD_FILE returns NULL

I want to get SQL LOAD_FILE function to work and have read every single question/answer + documentation about this, but here is what's been happening. When I want to LOAD_FILE from my home directory: mysql> SELECT…
Emir
  • 762
  • 2
  • 8
  • 22
14
votes
1 answer

Granting Access Permission to a file to a specific user

In linux, how can I give access permissions to a file/folder to a specific person. In other words suppose I want to allow only and only user fred to be able to read a file, then how do I do that? Note that I know about chmod and all, but Linux…
Alison Lee
  • 270
  • 1
  • 4
  • 9
14
votes
6 answers

Laravel 5.2 could not open laravel.log

I know there are a lot of questions on this topic but my issues is really weird that's why I decided to post. I have this error in /var/logs/apache/error.log [Tue Mar 01 07:26:51.435312 2016] [:error] [pid 8837] [client 127.0.0.1:37843] PHP Fatal…
Daniel Bejan
  • 1,468
  • 1
  • 15
  • 39
13
votes
1 answer

fopen Creates File, But how to change permissions?

I am creating a new file using fopen. $filename = 'user_data/10.xml'; $openhandle = fopen($filename, 'w+'); Then I check if the file has been created using: file_exists() function. The problem is: The file is being created with some owner, probably…
Arjun Bajaj
  • 1,932
  • 7
  • 24
  • 41