I am trying to edit a index.php by using sudo nano index.php
.
Nano opens me into index.php
, then i add the code into the file, save and try to exit but it says permission denied
. I am using ssh
session in terminal and also Amazon web services... I am signed in on an ubuntu@IPADDRESS. any help?
Add a comment
|
1 Answer
While your user may have permission to read the file, your user doesn't have permission to write the file.
Use ls -l <filename>
to list permissions, owner and group of the file.
If appropriate, change permissions or owner so you can write to the file.
How to use the chown
command
chown
changes the user and/or group ownership of for given file. The syntax is:
chown owner-user file
chown owner-user:owner-group file
chown owner-user:owner-group directory
chown options owner-user:owner-group file
How to use the chmod
command
To setup file permission you need to use chmod
, its syntax is chmod <mode> <filename>
-
2I suggest you edit your answer to include the steps to chown and chmod.– chili555Sep 9, 2014 at 16:41
-