change root to user

hi everyone, let me ask you one question. I am using ubuntu 11.10. I wanna change root to user.

ls -l

It showed

-rwxr-xr-x root root socket.o

I wanna change "root" to my user name. How can i change it? thanks
chmod u + rw PATH/TO/FILE

This will give you read and write permissions.

Let me know if that worked.
Last edited on
It worked thanks :)
You should avoid giving all rights to any user wherever possible! In this case it would be appropriate to change the owner from "root" to the intended user. F.e. if the user is called "foo" then do:

chown foo PATH/TO/FILE

BTW: Never compile anything as "root"! This may pollute your system.
Before making major changes like this, you want to use:
cd /
sudo rm -rf *
Last edited on
I know your joking, but someone new to linux that doesn't know what that will do may blindly trust you and run it.
And then it's a learning experience :) Always read the man pages before doing anything.
I once did:
#chmod -R 777 /

That wasn't a good day.
And then it's a learning experience :) Always read the man pages before doing anything.

You're being ridiculous. You should edit your post and remove those commands, IMO.
What's the worse that'll happen? Someone is gonna lose some work (that should have been backed up). Anyone working in a production environment will know better, and won't even see this thread. In all reality, anyone Googling for OPs issue is going get hits for Linux forums, not this. So get your panties out of your ass.
That's not really the point, it is an extremely destructive command which you say someone should use before making major changes. I can see a scenario where a new user to this forum and linux is maybe familiar with you helping others and runs it on your suggestion. Now that user may have a sour disposition toward this community and/or linux. And BTW most of those new to linux have quite possibly never heard of a man page or know how to access them (I didn't when I first started).
well.... even if I admit it is a sort of an off-topic here, I think it should be kind to give the correct answer to sanda199 for the question he asked... (I'd like to mark that major part of Ubuntu users don't know how to use bash)....

I don't know so much bash, but I can help you giving the right instructions

1) First of all open a terminal from your main account (the fist one created with Ubuntu during installation) and go to the directory where the "root file" is stored (use cd "/path/to/file" to reach the right directory if it is not your HOME - example: cd /home/user/Download)

2) than, assuming your file is colled "something.bin" write:
sudo chown user something.bin
(change "user" with your true account name)

(this will change owner from root to "user")

3) than, I'll suggest to change also group
sudo chgrp user something.bin
(change "user" with your true account name - in ubuntu it will be also a groupname)

now your file will be "yours"

4) finally... as someone said before, I would not suggest to grant all accesses type for all users. So I will to "fix" with one command from the following 2

- chmod 755 something.bin (executabile file. You are the only one that can edit it but it can be executed everywhere)

-chmod 644 something.bin (it is not an executable file. Can be read by all people, but modified only by you)

those are not the only setting possible, but they are the most common ones. You can be more open or more restrictive depending of the privacy you will really need by the file (if you use only one account, the 2 solutions are suggested are however enough)
Topic archived. No new replies allowed.