When to work as root & When to Work as a System User

Discussion in 'Beginner Tutorials' started by Rob, Jul 9, 2013.

  1. Rob

    Rob Administrator Staff Member

    Messages:
    573
    Likes Received:
    187
    Trophy Points:
    43
    When you should work as root

    You have now installed Linux and the first thing you did was login as 'root'. Then you provided a password so that you and ONLY you could login to the system as 'root'. When you decide to work as root, you had better go into a phone booth first and change into a blue suit with a big 'S' on the front because 'root' is known as the 'superuser' (you can skip the red tights if you want).

    That's really not meant to be just a witty reference to the Man of Steel. Actually, it is much more glamorous to be 'Superman' but root is actually more like the 'janitor' of the Linux system. Root has the keys to everything. He can shut off the lights, shut off the heat, lock you out of the building; he has to clean up the system and in the end make sure everything runs. And the most important thing about being a janitor - he sees everything.

    'root' is not for routine work

    As I mentioned, Linux makes your computer a true multi-user system, which means that besides root, you can and should work as another person. I say 'should' because doing routine work as 'root' could be hazardous to your health. When I first started using Linux myself, information was not all that readily available and I still had that 'one computer- one user' concept in my brain. It was after I had trashed all of the files and programs that make Linux run that I realized that working regularly as root wasn't a good idea.

    Working as another user

    Well, then how do you do your day to day work with Linux? That's easy. You do it by working as a user other than root. You may pick the name you like. Try your name. If your name is "Bob" then you could create a user account for 'bob'. By the way, if Prince Charles is reading this, Charles Philip Arthur George is a bit too long and has spaces, which Linux doesn't like - he should try 'charlie'. One thing I find EXTREMELY helpful is that with Linux, I can work as different people. It should not be inferred here that I have split-personality disorder. I am just a guy with a couple of different jobs. This way I can organize my work a lot better and backups are easier this way too.

    Adding a new user

    Well, Bob, now it's time to create your account. If your name is Hrothgar, use 'Hrothgar' or 'Hrothie' instead of 'bob' for the remainder of the lesson.

    Now 'root' has to do this stuff. Yes, I know I just warned you about working as root, but this is where you have to exert your authority. Most major distributions have tools to do this. SuSE, for example, has a nice tool called YAST which lets you add users painlessly. You just fill in the correct information. Consult your Linux version for information on their tools. There is also the get-your-hands-dirty way of doing this. Actually you won't get your hands dirty unless you're eating barbecued ribs at the same time.

    Using 'useradd' and 'passwd'

    To add a new user, you can also use the command 'useradd'. Kind of a logical name, isn't it?

    Try this:
    Code:
    useradd bob
    You probably won't see any fireworks go off. You might not see anything. That doesn't matter. Linux has been told that there's a new user and his name's 'bob'.

    Now you should give yourself a password.

    Do this:
    Code:
    passwd bob
    Linux will ask you for your password. Follow the same advice I gave previously about passwords. Also, don't use your 'root' password. Like 'one man, one vote' it's 'one user - one password'. You will be asked to repeat it.

    What's in your user directory

    When you create a new user, there is a directory created for that user in /home. To see what's in this new directory, you have to do the following.

    Go to the /home directory. - typing:
    Code:
    cd /home
    you can make sure you're in the /home directory by typing:
    pwd
    You'll see this: /home.


    Now you need to type:
    Code:
    cd bob
    You can type:
    Code:
    ls -a
    to see what's in the directory. We'll go into more detail with the ls command later. With the -a option, you'll see some files that begin with a '.' (period/dot). Those would normally be hidden from you if you didn't use the -a.

    Now you can go to work as 'bob', 'pcharles' or whoever you happen to be.
    Amit_*nix and bkay like this.
  2. Abhishek Solanki

    Abhishek Solanki New Member

    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    Actually if you are configuring system or installing new packages or software than use 'root' .

    System user is used when you want to access the applications that are already available .

    Once i tried to install Chrome in Fedora it asked to login in root after installing it when i tried to open it says Chrome can run in root use System users.

    So its up to the Application as well as your requirement in which mode you want to log in !!!
    David Thorp likes this.
  3. JeanhuaJia

    JeanhuaJia New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
  4. DiLiGENT

    DiLiGENT New Member

    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    1
  5. Saptarshi Nag

    Saptarshi Nag Member

    Messages:
    39
    Likes Received:
    25
    Trophy Points:
    8
    I am using ubuntu 12.04.By giving the command 'useradd',it is not creating any directory in the new user,so I can't login there.But the command 'adduser' is doing the job correctly.So what is the need of 'useradd' then?
    DevynCJohnson likes this.
  6. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,220
    Likes Received:
    1,021
    Trophy Points:
    113
    Read the man pages (man useradd).

    Haider92 likes this.
  7. Kovax

    Kovax Member

    Messages:
    34
    Likes Received:
    17
    Trophy Points:
    8
    I totally agree. Also sudo could be used
    Amit_*nix likes this.
  8. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,220
    Likes Received:
    1,021
    Trophy Points:
    113
    Piece of advice, never use Root's name in vain. By that, I mean, only use sudo or su when needed for real. Also, do not use the Root account unless needed. Some users use Root and sudo just to use it and that is a no-no not a yes-yes.
    Amit_*nix and Haider92 like this.
  9. Nay Lin

    Nay Lin New Member

    Messages:
    16
    Likes Received:
    2
    Trophy Points:
    3
    I created a guest user "x" by typing useradd x and I gave any password for that user "x".But Linux ask password when I log in.How can I solve for that problem.Help me plz.My Linux is Ubuntu 14.04.
  10. Saptarshi Nag

    Saptarshi Nag Member

    Messages:
    39
    Likes Received:
    25
    Trophy Points:
    8
    What do you mean?If you give a new user-password then while logging in into that account any system requires the password given to it.
  11. Nay Lin

    Nay Lin New Member

    Messages:
    16
    Likes Received:
    2
    Trophy Points:
    3
    I log in as root (admin) and change password for guest acc x in user accounts setting.But I can't log in although I type a new passwd.How can I remove guest acc "x"?
  12. Saptarshi Nag

    Saptarshi Nag Member

    Messages:
    39
    Likes Received:
    25
    Trophy Points:
    8
    Use 'deluser' to remove the account as following
    Code:
    sudo deluser x
    :)
    DevynCJohnson likes this.

Share This Page