Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used ls -l to find file permissions in a shell and found this:

File 1: -rw-r--r-- 1 root root 451 Mar 9 15:25 file.class.php

File 2: -rw-rw-r-- 1 andy dev 872 Mar 9 15:43 file.class.php

I want file 1's permissions to be changed to file 2's permissions. I have root access and am cd'd to the proper directories. I have never used chmod before and am having some trouble. When I try to do this:

chmod 872 file.clas.php

I get the error: chmod: invalid mode: '872'

share|improve this question

migrated from Mar 10 '13 at 1:12

This question came from our site for professional and enthusiast programmers.

0664, or just chmod g+w – Wrikken Mar 9 '13 at 21:06
up vote 3 down vote accepted

That 5th column is the filesize, not the permissions. The permissions are listed on the left in expanded form. The permissions on the first file are 644 in octal (add up the contributions from each bit: r-- = 4, -w- = 2, --x = 1, so rw- = 6), and the permissions on the second file are 664. Therefore, you want

chmod 664 file.class.php

Alternately, remember that the three permission groups are user, group and other, so rw-rw-r-- is "user rw, group rw, other r". Then, to change rw-r--r-- into rw-rw-r--, you need to add group-write permissions, i.e.

chmod g+w file.class.php

This lets you update the permissions individually.

share|improve this answer
Hmm. The permissions changed successfully but I still can't seem to save the file while connected to the server in Notepad++. It's located on a server and I created it with a root account instead of a user account and even with the different permissions the upload is failing. Any idea what it might be? Are there other permissions I could change? – John Smith Mar 9 '13 at 21:10
The 3rd and 4th columns are the user and group who own the file. The first file is owned by root:root and the second file by andy:dev. So, you want to change the owner of the first file to andy:dev: chown andy:dev file.class.php – nneonneo Mar 9 '13 at 21:12
Thanks that did it! – John Smith Mar 9 '13 at 21:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .