How to become root? [duplicate]
Possible Duplicate:
How to know my root password?
I have been trying for a week and a half trying to become root so I can change the motd for an assignment and I have had no luck. Can someone break it down into linux for dummies style please. I have done every update for ubuntu 12.04 do not know if this why it is giving me a hard time? Thank you in advance for your help.
Solution 1:
I would recommend trying it through command line.
First, open up terminal. Then enter this command sudo su
and press enter. It will prompt for your password. After entering the password, everything that you are doing WITHIN THE TERMINAL is being done as you as root. I emphasized that to show that anything you do outside of the terminal will NOT be root.
So, to edit the motd, type this into terminal: gedit /etc/motd
and edit your file accordingly.
Solution 2:
In order to use root privileges, you need to use sudo
, and your user has to belong to the sudo group.
to find out if you're user is a member of the sudo group, you can just run the groups
command:
nathwill@ragnarok:~$ groups
nathwill adm cdrom sudo dip plugdev lpadmin sambashare libvirtd
Then, to run a single command "as root", you just do sudo command arg
To assume root privileges indefinitely, or "sign in as root", you can use sudo -i
to obtain a root prompt.
Solution 3:
Ubuntu's security policy does not allow anyone to become root (see here and here).
Instead preface every command with sudo
and then use your password to gain root privileges for that command.
SUDO Examples:
Copy a file to a directory owned by root:
sudo cp ~/example.txt /etc/example.txt
instead of
cp ~/example.txt /etc/example.txt
To change the privileges of a file owned by root:
sudo chmod 775 example.file
instead of
chmod 775 example.file
You don't actually ever need to become root; you can always use sudo to preface commands that require root privileges.
For applications that have a GUI, use gksudo
.
GKSUDO Examples:
To edit a text file owned by root:
gksudo gedit example.txt
instead of
gedit example.txt
If your want to browse/copy/paste/etc. files using a GUI you can run
gksudo nautilus
instead of
nautilus
All of these commands can be entered into a terminal, or, if you'd prefer to not use a terminal, you can just press alt-F2
and enter the commands there.
Hope this helps!