Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to copy a folder to the directory /user/src and I can't do it because its owner is set to "root" and it says I am not the root. But I am in the administrator group.

How to change the owner of that folder and/or give me permission to access and modify it? Or how to login as root if this is easier?

share|improve this question
    
Why do you want to copy things into one of root's directories? This is potentially harmful and almost certainly unnecessary, so it would be better to find another way to achieve your end goal, whatever it is. –  Paul Jun 15 '13 at 14:36

3 Answers 3

if you open terminal (press cntrl+atl+t)

type cp --help it will display all instructions you need to copy files from the terminal

the reason to do it from the terminal is if you type sudo before any command it will execute the command as root


just realised another method (may be easier)

  1. close all file browsers in ubuntu.
  2. run command: gksudo nautilus
  3. a file browser will be opened as root.
  4. you can use this windows you browse and copy the file you wish.

Note if you cant find your ubuntu files, click file system on the right, then home, then your username

share|improve this answer

Root owns /usr/src for security reasons. You should never, ever change the owner to someone else, it will create drastic security holes. Instead, just run your commands as root:

sudo cp myfile /usr/scr/someDestination  

The prefix sudo gives the command root privileges.

Another way, but less recommended, is to run Nautilus, Ubuntu's default file manager, as the root user:

gksu nautilus 

(note: If you are running 13.04 you might need to install gksu before you can use it.)

share|improve this answer

Sure thing. Don't tell us what you are trying to achieve. After all we are not trustworthy, aren't we? (Why are you asking us then?) And you have a right to shoot yourself in the foot.

Go ahead, here is your solution:

sudo ln -s /usr /user
sudo chown $USER -R /user/src   # Like a BOSS!

Next time when the package manager wants to put new files into that directory or modify existing ones, well...

drwxr-xr-x   6 _BOSS_ root  4096 Jun 14 09:27 src/

booyah... permission denied

Why this is a bad idea

That directory is really named usr, it's not a typo and its permissions are not set like this to annoy you. This is all defined by a standard (FHS - Filesystem Hierarchy Standard) and the entire system with its programs and services relies on this structure to function properly. Therefore you do not change permissions and ownership or blindly copy stuff into there because some guide tells you to do so.

If you really need to copy source code manually to a location where the tools can pick it up, it is recommended to copy the source code to /usr/local/src. This way non-packaged source code can be easily distinguished from packaged and system managed source code.

Caution: You can still not be safe if some malformed custom built kernel module breaks your kernel.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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