3

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.

2
  • 1
    I wouldn't say it's a duplicate. The linked post is a problem related to a 3rd party application not expecting Ubuntu's security policy, whereas this one seems to rather just be the user not understanding Ubuntu's security policy. Still a well documented problem(non-problem) but probably not a duplicate of that specific link in my opinion. May 21, 2012 at 18:54
  • 1
    Not a duplicate whatsoever
    – Insperatus
    Oct 28, 2014 at 8:29

4 Answers 4

4

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.

1
  • 8
    sudo -i works too instead of sudo su. That said, it is not a very good idea to be root in an interactive shell for small jobs like these.
    – jippie
    May 21, 2012 at 18:58
1

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.

1

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!

0

You can turn your terminal into a root session by typing su or you can prefix a command with

sudo <command>

to run that particular command as a superuser/root

To edit motd, the command is

 sudo nano /etc/motd.tail

nano is a terminal text editor.

If you want to use a graphical interface just swap nano out for gedit.

2
  • 1
    If you want to use gedit you should swap gksudo for sudo as well. ie. gksudo gedit /etc/motd.tail May 21, 2012 at 18:36
  • @adempewolff Why? sudo seems to work fine even with GUI apps. Feb 24, 2022 at 7:34

Not the answer you're looking for? Browse other questions tagged .