Ubuntu – Get root access for copying files to /usr/share/…

command linepermissionsrootSecurity

To be short, I want to copy a folder to a location /usr/share/screenlets/.... in Ubuntu 10.04 system. I tried by logging in as root from terminal giving su.

I even changed my user account type to ADMINISTRATOR; Yet, no use. PASTE option in the context menu's list in the folder /usr/share/... is INACTIVE.

How can I copy those files?

Best Answer

First, however tempted you might ever get, never "log in with root". It's far too easy to break things beyond repair. Anyway, this is disabled by default so you'd have to do a whole lot more to get to that point.

/usr/ is owned by the root account so to write files in there you need to write them as root. Two methods (there are undoubtedly more but here are the two main ways for most users):

  1. Press Alt+F2 to get a run dialogue and in that type gksu nautilus. This will open up a file browser window running as root. Copy your files across but be careful, you can nuke the system like this.

  2. A much more direct method is just loading up a terminal and writing:

    sudo cp -R /path/to/files/you/want/copied/ /copy/to/this/path/
    

    (the -R is just there to recursively copy directories)

If you ever want to fire off multiple commands as root without prepending them all with sudo you can run sudo -i or sudo su and you'll get a root terminal. But again, be careful what you do.

Related Question