Ubuntu – How to move a file to /usr/local in Ubuntu

directoryfilespermissionsUbuntu

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?

Best Answer

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.

Related Question