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

62,227

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.

Share:
62,227

Related videos on Youtube

ahmed
Author by

ahmed

Walking pumpkin pie. You're helping in SO by answering questions or by posing thoughtful questions. Remember, others (or you later on) will be looking at them for help.

Updated on September 18, 2022

Comments

  • ahmed
    ahmed over 1 year

    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?

  • Michael Mrozek
    Michael Mrozek almost 13 years
    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
  • tcoolspy
    tcoolspy almost 13 years
    @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 :)
  • tcoolspy
    tcoolspy almost 13 years
    @Michael: Is that better?
  • ahmed
    ahmed almost 13 years
    I am the only person using this machine though. By the way, you spell "dying" wrong.
  • tcoolspy
    tcoolspy almost 13 years
    @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.
  • ahmed
    ahmed almost 13 years
    I am looking at the setup instructions. How do I edit ~/ .bashrc?
  • tcoolspy
    tcoolspy almost 13 years
    @GTyler: With any text editor. On Ubuntu try gedit ~/.bashrc for a graphical editor or lean your way around a terminal based editor like vim.