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
6
votes
4 answers

Change '0777' string to 0777 octal LITERALLY

My code is like $perm = "0777"; //this is fetch from the database chmod("myFolder/", $perm); but the value of $perm is not in octal, how can I change the data type of the variable to octal? even an alternative method will do
Xelakz
  • 175
  • 3
  • 11
6
votes
3 answers

Can't use ansible inventory file because it is executable

I am trying to run an Ansible inventory file ansible -i hosts-prod all -u root -m ping and it is failing with this message: ERROR: The file hosts-prod is marked as executable, but failed to execute correctly. If this is not supposed to be an…
Steve Midgley
  • 2,226
  • 2
  • 18
  • 20
6
votes
5 answers

Chmod, php and imageupload

How should I handle image uploading using PHP? How should I handle the chmod settings? Example; I have a dir called /image/ where i want to upload all my images. Should I set this dir to chmod 777 and leave it like that? Or should i change chmod on…
lejahmie
  • 17,938
  • 16
  • 54
  • 77
6
votes
1 answer

Why use int() in a Perl chmod?

Why would you need to use the int() function when setting the perms on a file in Perl? die "blab, blah" if (! chmod(int(0664), $tmp_file)); I can understand the use of oct() as in the following perldoc example: $mode = "0644"; chmod(oct($mode),…
Rob Wells
  • 36,220
  • 13
  • 81
  • 146
6
votes
1 answer

How to change file permission for all users in R

When I use Sys.chmod(file,'777') it looks like the permission is changed only for the owner and not for all users, how can I do this ?
statquant
  • 13,672
  • 21
  • 91
  • 162
6
votes
3 answers

I stupidly ran "chmod 400 chmod" and now it appears forever broken

I'm "hacking" an ARM-base quadcopter running a stripped down Linux as part of a class assignment, and after getting into it using telnet and getting access to the bash terminal, and then messing around the file system I wanted to see what commands…
Robert Caldwell
  • 89
  • 1
  • 1
  • 5
6
votes
3 answers

Image permissions after uploading for resize

I am having a user's profile page in which user uploads his profile picture from file dialog.. when the file is moved to my local server's folder it gets permission as 0644 only.. but I want to resize this image before getting uploaded into…
shruti
  • 780
  • 9
  • 25
6
votes
2 answers

Why in PHP if you use Mkdir recursive flag do the nest directories not chmod?

I am using mkdir to create normally 2 nested directories for a file structure. The directories it creates are always set to 0755. The code I am using however is. mkdir('path_one/path_two', 0777, true); I have tried then doing …
Case
  • 4,244
  • 5
  • 35
  • 53
6
votes
2 answers

Codeigniter - setting up directories and files permissions (chmod settings)

Since i don't think i got right permissions all over my application folders and files is there anyway to check the right permissions allover them? I mean, does anyone knows/has a standard/tutorial/link to follow for Codeigniter to set chmod…
itsme
  • 48,972
  • 96
  • 224
  • 345
6
votes
3 answers

/usr/bin/ssh-copy-id: line 1: ucgi:: command not found

I followed instructions at http://www.devthought.com/2009/09/19/get-ssh-copy-id-in-mac-os-x/ in order to get ssh-copy-id to work on my mac. Now I am getting an error when running: ssh-copy-id /usr/bin/ssh-copy-id: line 1: ucgi:: command not…
Benjamin Bakhshi
  • 663
  • 2
  • 9
  • 22
6
votes
2 answers

You don't have permission error in Apache in CentOS

I have installed apache 2.2 in centos 6. Everything worked fine when the apache folder was at its default location /var/www/html. Then I configured a Virtual host inside my users home folder. After that apache started showing Forbidden You don't…
th1rdey3
  • 4,176
  • 7
  • 30
  • 66
5
votes
3 answers

Netbeans remote file permissions. chmod from within Netbeans?

When working with a project, a'la "PHP application from remote server" The file properties I am offered, when I right-click->properties on files, relate only to the local properties. Is it possible to modify file permissions on the remote files from…
DM8
  • 214
  • 2
  • 10
5
votes
1 answer

Retrieve multiple information by a single number?

I was wondering how they did come up with the way of setting permissions using chmod by just using numbers. For example: 1 is for execute 2 is for write 4 is for read Any sum of those give a unique permission: 2+4 = 6 lets you write and read. 1+4…
Pithikos
  • 18,827
  • 15
  • 113
  • 136
5
votes
4 answers

How to set permissions for every directory along a directory path

I'm creating a remote directory path on a webserver that I'd like to be executable. I create it remotely with a command like: ssh user@machine mkdir -p a/b/c/d/e/f Next, I'd like to be able to chmod directories a-f but avoid doing a chmod -r on the…
Rich
  • 12,068
  • 9
  • 62
  • 94
5
votes
1 answer

logrotate says permission denied when rotating log / re-creating log file

I'm new to logrotate on linux machines... here's what I have set up in my app's logrotate.d file: /var/log/myapp.log { daily missingok create 0660 root utmp rotate 1 } I set owner permissions on the myapp.log file for the account that runs the app…
Derick Bailey
  • 72,004
  • 22
  • 206
  • 219