This question already has an answer here:

I have run into this problem too many times. Sometimes when I'm trying to run a command on the terminal it will say "Permission Denied." How can I get that permission??

marked as duplicate by thomasrutter, Eric Carvalho, karel, bain, LnxSlck Jul 2 '14 at 14:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    @AvinashRaj chmod 777 serves debugging purposes, no more. Don't end up with a full-777 system. – John WH Smith Jul 1 '14 at 2:54
  • 1
    It would be helpful if you specified which commands caused this error, because the cause (and most appropriate solution) will be quite different depending on what it was that caused this error. The best solution is probably not to change file permissions. – thomasrutter Jul 1 '14 at 3:20
  • 1
    To echo what @JohnWHSmith said, DO NOT set all files to chmod 777. This will only end up with a hopelessly insecure system and (if it was done system-wide) there is no way to un-do it except to wipe and reinstall. I repeat, the appropriate solution is most likely not to change file permissions. – thomasrutter Jul 1 '14 at 3:22
  • chmod +x <filename> will give execution permission to file. And use sudo <command> to run as root user – Pandya Jul 1 '14 at 5:25

@Avinash Raj is useful but , I think what user meant without realizing it is how to run a script ./script you need to change the mode and get the permission you can achieve that with

chmod +x script_name.extension

which makes the script executable and let you run it !

or you can right click the file go to properties and then permissions and check the executable checkbox

and then back to terminal to actually run it .

after if you double click it you get options to open in text editor or run in terminal etc..

  • In addition to this, you can't add executable mode (+x) to a file inside a non-linux (ext) filesystem since they don't support that functionality (like in windows NTFS or FAT32). So ensure that the file you are trying to execute is in the Linux filesystem/directory. – Camicri Jul 1 '14 at 3:28

The permission denied error (code 13) warns you that your request cannot be carried out by the system, since your user/group IDs do not give you the required privileges. For instance, consider this file in my home directory :

$ ls -l test.txt
-rw-r----- 1 me mygroup 0 Jul  1 03:54 test.txt

The rw-r----- part states that the owner (me) can perform read/write operations on the file, while members of the mygroup group can read it. Others can't do anything.

In order to read this file, you'll type :

$ cat test.txt

Yet, if you're not me, and don't belong to the mygroup group, you'll get a beautiful Permission denied (13) error.

If you want to know more about the UNIX permissions system, have a look here, here or here. Note that this system applies to all programs (commands) on your system. Any program trying to read test.txt must be running as me, or someone in the mygroup group in order to succeed (otherwise, the same error will occur).

When performing administration tasks such as package management or system configuration, it is usually necessary to have root privileges. These tasks require access to files owned by root, or the execution of kernel-tasks that can only be carried out with super-user privileges. On Ubuntu, you can run a command as root using sudo :

$ sudo mycommand

However, this requires you to be registered as a sudoer, which will probably be the case if you're the first or only user on that machine. More about sudo.

Not the answer you're looking for? Browse other questions tagged or ask your own question.