[ubuntu-uk] Help needed with ssh
Alan Lord (News)
alanslists at gmail.com
Fri Jul 17 07:16:21 BST 2009
On 17/07/09 06:45, John Matthews wrote:
> Ok, this is some good news, I have a question to ask, I need to change
> the permissions of a file in one of my folders, on my site, it has to be
> read only, as it is its 777.
> I have gotten into the folder and have the list of files and their
> permissions, and I can see the file I need to change, but I am not sure
> of the command.
> I know you have to chmod to something but I cannot work it out.
> Can somebody help please?
chmod is the right command but, depending on who *owns* the file you
might not have permissions to do so straight away.
man chmod will help you. There are several ways to achieve the same thing.
essentially the command is:
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
Personally I prefer the octal method.
Your file has three sets of permissions
-rw-r--r-- 1 alord alord 49 2009-05-13 19:43 temp
(BTW, this information is well documented in several of the links we
Ignoring the very first (from the left) "-" you should see three groups
of "---" Which in my case show
rw- (The File Owner: The first alord you see)
r-- (The Group Owner: The 2nd alord)
r-- (Anyone/Everyone: Also referred to as World)
So, who do you want to have read only access? Everyone but you? Everyone
but you and the group? Or Everyone?
chmod 444 filename
Will set all three sets of permissions to Read only.
chmod 666 filename
Will set all three sets of perms to Read/Write.
chmod 555 filename
Will set all three perms to Read/Execute
You add up three numbers to get the right one:
If you want the file to be read only for everyone else, but *you* (The
file's owner) needs read/write then do:
chmod 644 filename
You do not say what or who owns the file. If it on your webserver, it
might be owned by the web-server perhaps? Sometimes called www-data,
apache, nobody or httpd. The name is [almost] arbitrary but if it isn't
the same as your username you do not own it.
If you are not the owner you might not be able to change it without
becoming root or assuming root privileges by using sudo (if available on
This page (of the link I have referred you to on several occasions) will
explain all this far better than I can in a text-mode email.
More information about the ubuntu-uk