I am working in the most recent Ubuntu in a 64 bit machine. I am currently on the Gnome command prompt and I am trying to move a file under the Downloads directory to /usr/local. However, it gives me a permission denied message even though I typed in chmod 777 filename and I am the administrator. What should I do?


Don't run chmod 777 on anything! That will make it writable AND executable by anybody, and you realy don't want that. Trust me on this one and never do that. You don't want to be responsible for kittens dying, planets of foreign stars exploding and other destructive chaos. The only thing you ever need the 7 for is the first digit, which means the owner of the file can write, edit and execute the file. The second digit is for the group owner, and in rare cases 7 might be acceptable. For everybody else you should restrict the permissions to only what they need.

If you knew the original permissions for the file, now would be a good time to change them back. If you don't here is how to figure it out:

  1. If the file is executable, try 755 so that you can rwx, but everybody else can only rx:
    $ chmod 755 filename
  2. If the file is just a data file and needs to be readable, try 644 so that you can rw and everybody else can only read:
    $ chmod 644 filename

Now about moving that file :) To move it to /usr/bin, you need to run the move command as the superuser. You may own the file in question but you don't own the directory you are moving it to so you don't have write permissions there. You can use the command 'sudo' to run a command with root permissions like this:

$ sudo mv filename /usr/local

This will likely prompt you for your user password.

  • 2
    He probably doesn't need to screw with filename's permissions at all. I think he was setting it 777 to try and get around the mv permission problem, not realizing it was /usr/local that he needed to mess with -- setting /usr/local 777 would've fixed it, but isn't the right way – Michael Mrozek Jun 23 '11 at 21:02
  • @Michael: I realize that, and I probably could explain better, but since I knew he had messed with permissions I was hoping to get him to set them back to something sane before moving the file into /usr/local :) – Caleb Jun 23 '11 at 21:07
  • @Michael: Is that better? – Caleb Jun 23 '11 at 21:15
  • I am the only person using this machine though. By the way, you spell "dying" wrong. – GTyler Jun 23 '11 at 21:23
  • 1
    @CTyler: That actually doesn't matter, you still need to head the warning. There are other things on a unix system besides users ... for example non privileged daemons. Having a file on your system with 777 permissions would allow any rogue process to write commands to it. The next time YOU innocently executed it, your account (and since you are an administrator user, the whole machine at root level) would be compromised. – Caleb Jun 23 '11 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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