-1

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?

1 Answer 1

2

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>

2
  • 2
    I suggest you edit your answer to include the steps to chown and chmod.
    – chili555
    Sep 9, 2014 at 16:41
  • the OP says he used sudo. Why is chown/chmod necessary?
    – a06e
    Oct 31, 2016 at 16:42

You must log in to answer this question.

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