HB Computer Security | Aide Memoire
  • Introduction
  • Core Technical Skills
    • Core Skills
      • Linux
        • Getting to Know Linux
          • Using the Shell
            • Shells, Terminals, and Virtual Consoles
            • Choose your Shell
            • Shell Commands
              • Non-PATH Commands
              • Command History
                • Command Line Editing
                  • Keystrokes for Navigating Command Lines
                  • Keystrokes for Editing Command Lines
                  • Keystrokes for Cutting and Pasting Text from within Command Lines
                • Command Line Recall
                  • Keystrokes for Command Line Recall
              • Connecting and Expanding Commands
                • Piping Between Commands
                • Sequential Commands
                • Expanding Commands
            • Shell Variables
              • Common Shell Variables
            • Aliases
            • Create your Own Shell Environment
              • Modification Ideas
          • Navigating the Linux File System (LFS)
            • Filesystem Commands
            • Listing Files and Directories
            • File Permissions and Ownership
              • Modifying Permissions with chmod
              • Modifying Default Permissions with umask
              • Change File Ownership with chown
            • Copying, Moving, and Removing Files
            • Finding Files
              • locate
              • find
              • grep
            • Downloading Files
              • axel
              • wget
              • curl
                • User-Agent: Googlebot
          • Working with Text Files
            • Using vim and vi to Edit Text Files
              • Starting with vi
              • Adding Text
              • Moving Around in the Text
            • Text Manipulation
        • System Administration
          • Installing Linux
            • Installing from Live Media
            • Installing in the Enterprise
            • Partitioning Hard Disks
              • Tips for Creating Partitions
          • Account Administration
            • The root Account
              • Becoming root with su
              • sudo
                • The /etc/sudoers File
                • Granting sudo privileges
                  • visudo Guidance
                • Useful sudo Hints
            • Other Administrative Accounts
            • Standard User Accounts
              • Risks of userdel: Orphaned Files
          • Graphical Remote Administration
            • Cockpit
              • Installation Guide
            • Remote Desktop Protocol with xrdp
              • Installation and Configuration
            • Remote Desktop with vnc
              • Installation and Configuration
              • Running VNC as a System Service
          • Managing Running Processes
            • Listing Processes
              • ps
              • top
              • htop
            • Backgrounding and Foregrounding
              • Starting a Background Process
              • Using Foreground and Background Commands
            • Killing and Recining Processes
              • kill and killall
          • Managing Software
            • Managing Software from the Desktop
            • Going Beyond the Limitations of Software Center
              • Debian Packages
                • Advanced Package Tool (apt)
                • Repositories
                • dpkg
        • Shell Scripting
          • Variables
            • Command Substitution
            • Arguments
          • Reading User Input
          • if, else, and elif
          • BOOLEAN Logic
          • Loops
            • for Loops
            • while Loops
          • Functions
          • Local Vs Global Variables
          • Summary
        • Securing Linux
      • Windows
        • Security Hardening
Powered by GitBook
On this page
  • Exercise - Log In as root

Was this helpful?

  1. Core Technical Skills
  2. Core Skills
  3. Linux
  4. System Administration
  5. Account Administration

The root Account

PreviousAccount AdministrationNextBecoming root with su

Last updated 1 year ago

Was this helpful?

Every Linux setup begins with the all-powerful root account – the top dog of user accounts. It's the admin with unrestricted access to everything on the system. This user can access any file, start up any program; basically anything goes. On top of that, the root account is in charge of key tasks like installing new software and creating user accounts for others who need to use the computer.

For day-to-day use, you'd ordinarily log in with a regular user account, one that's got your own chosen username or the one your Linux flavour has set up for you. Then, if you need to do something that needs admin powers, you switch hats and become the root user just for that task. It's a bit like having a regular key for the staff entrance and a master key for the entire building – you only use the master key when you really need to.

If you are coming from a Windows background, it can be helpful to think of the root account as similar to the Administrator in Windows

When you first install most Linux systems (although not all systems), you add a password for the root user. You must remember and protect this password; you need it to log in as root, or to switch user to root while you are logged in as some other user.

Exercise - Log In as root

To become familiar with the root user account, you can simply log in as the root user. I recommend trying this from a virtual console. To do so, press Ctrl + Alt + F3, then when you see the login prompt, type root, press Enter, and enter the password. A login session for root will open.

At this point, any command that you run from your shell is run with root privilege. So be careful. You have much more power to change (and damage) the system than you did as a regular user.

After you have logged in as root, the home directory for the root user is typically /root. The home directory, and other information associated with the root user account, are located in the /etc/passwd file.

When you are finished, type exit, and then press Ctrl + Alt + F1 to return to the regular desktop login.

Here’s what the root entry looks like in the /etc/passwd file:

cat /etc/passwd | grep root

This shows that for the user named root, the user ID is set to 0 (root user), the group ID is set to 0 (root group), the home directory is /root, and the shell for that user is /bin/bash.

You can change the home directory or the shell used by editing the values in this file. A better way to change these values, however, is to use the usermod command, which we will cover shortly.

By default, the root account has no password set in Ubuntu. This means that even though the account exists, you cannot log in using it, or use su to become the root user. This adds an additional level of security to Ubuntu, and requires you to use sudo before each command that you want to execute as the root user

The entry for the root account in /etc/passwd