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
5
votes
1 answer

Why can't my PHP script chmod a file it creates?

I have a php that creates a file that needs to be executable (it's a batch file that needs to be run by the system). For some reason, even though the file is owned by apache and php is running as apache, and the file IS created, the script dies at…
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
5
votes
2 answers

Set pem file permissions for AWS without chmod on Windows

Trying to SSH into our AWS instance, I get "bad permissions" every time. The AWS documentation gives a simple solution, which is to change the pem file permissions using chmod. But my local machine is Windows, and in the Windows world, there is no…
rikuwolf
  • 103
  • 2
  • 10
5
votes
3 answers

How to preserve ownership and permissions when doing an atomic file replace?

So, the normal POSIX way to safely, atomically replace the contents of a file is: fopen(3) a temporary file on the same volume fwrite(3) the new contents to the temporary file fflush(3)/fsync(2) to ensure the contents are written to disk fclose(3)…
Daniel Pryden
  • 59,486
  • 16
  • 97
  • 135
5
votes
3 answers

file/directory permissions trailing + ( drwxr-xr-x+ )

I have a directory with strange permissions ( drwxr-xr-x+ ) - trailing ( + ) as 11th character, which seems to force all the files and subdirectories to assume rwxrwxrwx permissions, Following is the permissions. drwxr-x---+ 3 root root 4096 Dec…
Gurdyal
  • 161
  • 2
  • 2
  • 11
5
votes
3 answers

How to give executable permission to all Python scripts in Linux?

Suppose I have a python script called a.py like this: #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author : Bhishan Poudel # Date : Jul 13, 2016 # Imports # Script print("hello") I can run this scripts in two ways: Using python…
BhishanPoudel
  • 15,974
  • 21
  • 108
  • 169
5
votes
2 answers

Magento2 no CSS after clean install and nothing works

I've got the same problem a lot of people seem to have, I've spent over 20 hours now researching this, and none of the solutions work. - I did a fresh clean install of magento 2 on a VPS server with all the right php extensions, etc. - and install…
M21
  • 343
  • 3
  • 14
5
votes
4 answers

Secure chmod privileges?

The standard chmod privileges are "644" for files and "755" for directories, aren't they? In most cases, PHP doesn't need to write to files or directories. So couldn't I take the write privileges from all groups? I could assign "444" to all files…
caw
  • 30,999
  • 61
  • 181
  • 291
5
votes
2 answers

Unable to run .py file from putty, Syntax error: word unexpected (expecting ")")

I am new to both Python and Linux and as such request simple explanations with minimal assumed knowledge where possible please, however I am more than willing to invest time and effort to learn. I have a Raspberry Pi 2 (Model B V1.1) that is running…
Ruthenium66
  • 63
  • 1
  • 5
5
votes
1 answer

Vagrant, Permission denied @ rb_sysopen - /home/vagrant

When I run rails s on vagrant, I got the following error. It seems that the file "/home/vagrant/Realarts/tmp/pids/server.pid" does not exist, however rails tries to access it.How should I do solve the problem? [vagrant@localhost Realarts]$ rails s…
Toshi
  • 1,293
  • 3
  • 19
  • 37
5
votes
3 answers

Can I set permissions when creating a file or directory?

Can I set permissions when I create a file/directory using a single command or do I have to create the file/directory first and then use chmod to set its permissions? For instance to do something like this // for directories mkdir 755 test // for…
ltdev
  • 4,037
  • 20
  • 69
  • 129
5
votes
1 answer

Linux. Heroku-Django. Collectstatic read-only file system

I need help from someone who understands linux. I can't push my staticfiles to Heroku (I'm trying to use whitenoise and not Amazon S3 or any CDN). The error is rather simple, when I try to push to heroku I get: Preparing static assets …
Alejandro Veintimilla
  • 10,743
  • 23
  • 91
  • 180
5
votes
3 answers

How to perform chmod() in Objective C

What's the equivalent of C's: chmod(MY_FILE, 0777); in Objective C? I am trying to write to an existing locked file without performing chmod +x MY_FILE on the terminal.
newbieMACuser
  • 847
  • 1
  • 11
  • 19
5
votes
0 answers

git ignore permission for everyone

I have a git repo, few of us work on it on different computers, some on windows, some linux. Problem is file permissions get changed, some times for web server configuration. So they show up in git diff. I ignored filemode changes with command git…
Yujin Boby
  • 293
  • 2
  • 10
5
votes
1 answer

Execute permissions on downloaded file

I have made a script for installing a control panel. I've uploaded the script to a server so people can wget it to their machines. The only issue is that you have to chmod it after download. Is there a way to remove this step? How would I go about…
Sharkie
  • 51
  • 1
  • 4
5
votes
3 answers

Renaming not supported across conflicting directory permissions

I get the above error message from dovecot, if I try to rename a IMAP folder (with thunderbird) Renaming not supported across conflicting directory permissions if I try to rename "foo" to "foobar" Here are the…
guettli
  • 25,042
  • 81
  • 346
  • 663