pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

Using Sudo for Super User Access to Root Privileges in Linux

The Linux super user, or root user, is a special user that has tremendous power, with the ability to access and modify all files on the operating system. This is necessary at times, but there is a potential for accidental errors to cause a great deal of destruction, so you have to be careful. (Like Spiderman says, with great power comes great responsibility.) Fot the times when the super user’s power is necessary, we’ll look at safer ways to be the super user on your Linux dedicated server.

Super User and Sudo

A really important feature of Linux is privileges. It’s part of the security, and controls which users can access, manipulate or even be aware of what files. Logged in with the user account we’ve created will allow safe usage of the operating system, but there are times when the privileges of the root, or super user are required.

There are two ways to access super user privileges. The first is with the su command.

$ su –

If you enter this command, and note the hyphen, then you will be prompted for the root user’s password. Enter it correctly, and you will be logged in as the super user. You can then perform what tasks you need to, but with care! When you’ve finished, log out immediately using the exit command.

The second way to get super user privileges is to use sudo. This is a method by which a regular user can gain a temporary privilege boost. It takes a little setting up, but once done it is probably safer than the su command method.

First, log in to your server. Then, log in as root using the su command. Then, enter the following.

$ visudo

This will open up a text file that contains information for sudo. A little way down the file you’ll see the following text.

# User privilege specification

root ALL=(ALL) ALL

You need to add yourself to the file in order to get your privileges. To do this, you need to do a little editing. Use the arrow keys to move the cursor to this line, then press i on the keyboard. You’re now editing the file, so enter the following line:

YourUserName ALL=(ALL) ALL

Of course substitute your user name for YourUserName, then press escape, and type ZZ (capital Z twice). This will save the file, and that’s it. If you’ve done it right, you can now use sudo. To test this, log out as the root user (type exit, hit return), then try the following.

$ ls /root

You should receive an error message telling you that permission is denied. So, try it with sudo.

$ sudo ls /root

Now you will be asked for a password. Enter your own password at this point (not the root password) and hey presto, you’ll be presented with a listing of the root user’s directory. So, any time that you wish to do something that requires root user privileges, remember that you can use the sudo command, saving you from logging in as the root user.

Logging out

To log out of your ssh session, and so your server, at any time, type:

$ exit

If you are logged in as the super user having used the su command, remember that you may need to type this twice.


Now we know how to log in and out we want to do something constructive with the server, but before we get to the commands we should take a look at the Linux directory structure.

  • Advantage to Shared Web Hosting
  • Shared Hosting Issues – Shared Bandwidth and Server Resources
  • The Ins and Outs of Dedicated Web Hosting
  • When To Move To A Dedicated Server
  • Choosing a Dedicated Server for your Website
  • Managing and Operating a Dedicated Server Over the Internet Using Online Control Panels
  • Accessing the Linux Operating System on Dedicated Servers with PuTTY or SSH
  • How to Create a Secure Password
  • Using Sudo for Super User Access to Root Privileges in Linux
  • The Linux Directory Structure
  • Linux Commands for Navigating and Viewing Directories
  • Creating, Moving, Renaming and Copying Files and Directories in Linux
  • Find, View and Delete Files and Directories Using Linux Commands
  • Using vi to Edit Text Files on A Linux Dedicated Server

Filed Under: Moving from Shared to Dedicated Web Hosting Tagged With: linux and super users, super user access, using sudo in linux

Latest Articles

Avast! Pro Antivirus Review

Avast! Pro Antivirus Review

PROS: Shields for all user computing sessions CONS: The shareware reputation may prevent serious consideration. OVERVIEW: Avast! Pro Antivirus is a great piece of software to use to keep your computer safe. With most of us up and running around on the internet everyday, we all need to protect … [Read More...]

Why Cross-Chain Trading Is the Future of Crypto Investing?

The rapid growth and evolution of the cryptocurrency market have opened up exciting opportunities for investors. Within this dynamic landscape, cross-chain trading has emerged as a game-changing trend that is shaping the future of crypto investing. It’s believed that cross-chain trading is poised to … [Read More...]

Audio Sampling and Recording Techniques Explained

When a sound card records analogue audio, it is converting the sound waveform into digital information and then copying this in real time onto the hard disk. Essentially, it is using the disk as a digital tapeless … [Read More...]

Comments

  1. Misssypi says

    February 26, 2012 at 8:51 pm

    a question about
    sudo su
    does this command enable root without asking for the account password ?
    therefore is it safer to enable root just to set a password so that if someone who knows your account password cannot perform sudo commands ?
    or …if the ‘sudo su’ command doesnt ask for a password does it even make a difference ?

Gaming Laptop Security Guide: Protecting Your High-End Hardware Investment in 2025

Since Jacob took over PC Tech Guide, we’ve looked at how tech intersects with personal well-being and digital safety. Gaming laptops are now … [Read More...]

20 Cool Creative Commons Photographs About the Future of AI

AI technology is starting to have a huge impact on our lives. The market value for AI is estimated to have been worth $279.22 billion in 2024 and it … [Read More...]

13 Impressive Stats on the Future of AI

AI technology is starting to become much more important in our everyday lives. Many businesses are using it as well. While he has created a lot of … [Read More...]

Graphic Designers on Reddit Share their Views of AI

There are clearly a lot of positive things about AI. However, it is not a good thing for everyone. One of the things that many people are worried … [Read More...]

Redditors Talk About the Impact of AI on Freelance Writers

AI technology has had a huge impact on our lives. A 2023 survey by Pew Research found that 56% of people use AI at least once a day or once a week. … [Read More...]

11 Most Popular Books on Perl Programming

Perl is not the most popular programming language. It has only one million users, compared to 12 million that use Python. However, it has a lot of … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

Understanding the Interface with Etsy

Have you ever thought about opening your Etsy store but you haven't done it yet? Do you think it's complicated? Are you afraid that you won't know … [Read More...]

xDSL Variants

RADSL, like ADSL, operates faster in one direction than in the other and has the same transmission limits as ADSL. But as … [Read More...]

SCSI Internal Mounting

Identify an available 5.25in drive bay into which to mount the drive. If you must use mounting rails, screw the rails into the lower pair of … [Read More...]

[footer_backtotop]

Copyright © 2025 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors