Nano edit, permission denied

11,351

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>

Share:
11,351

Related videos on Youtube

Kristin Kohler
Author by

Kristin Kohler

Updated on September 18, 2022

Comments

  • Kristin Kohler
    Kristin Kohler over 1 year

    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?

  • chili555
    chili555 over 9 years
    I suggest you edit your answer to include the steps to chown and chmod.
  • becko
    becko over 7 years
    the OP says he used sudo. Why is chown/chmod necessary?