Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Ubuntu Help > Using sudo in place of root login in Ubuntu

Forgot Password?
 Ubuntu Help   Discussion and help about Ubuntu, Kubuntu, Xubuntu, and all the Ubuntu family

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Closed Thread
 
Thread Tools Display Modes
Old 11-05-2007   #1 (permalink)
/etc/init.d/moderator
 
bigtomrodney's Avatar
 
Join Date: Nov 2004
Location: Sunny South-East of Ireland
Posts: 6,031
Exclamation Using sudo in place of root login in Ubuntu

root / sudo
If you are reading this you are likely aware that the administrator on Linux/Unix systems is referred to as root. The root account is the account on which all system processes run and should be the only account that can write to the main filesystem.

Because most of us started our computing lives out using Microsoft Windows there has always been a notion that it is better to be the administrator of the system. Unfortunately this is one of the major causes of insecurity in computing and opens up your system to instability. As most Linux users will tell you, only log in as root to perform maintenance on your system and never log in to a graphical or desktop session using root.

Ubuntu takes this one step further. Rather than asking users not to login as root, they have locked the root account and default to using sudo. As a side effect users have /sbin, /usr/sbin and /usr/local/sbin as part of their $PATH environmental variable, meaning they can see commands that users can not normally see.

What is sudo?
It is a tool to allow you to execute a command as root, without logging in as root. Its name is derived from a related command su "do". su is the command to switch user and is most frequently used to run commands as root. So in essence, sudo is 'switch user do <command>.

It provides several key benefits;
  • It logs all commands run using it
  • It logs failed attempts to authenticate using it
  • It can be restricted in a much more detailed way than simply using root, i.e. per user permissions
  • It can be used with the user's login password rather than distributing the root password
The latter is the case with Ubuntu so that users are prevented from logging in permanently as root but can temporarily elevate themselves to root to run the required system command. Ubuntu is configured to allow members of the admin group have access to commands via sudo. Anyone else attempting to run a command in this manner will have their attempt logged and mailed to the system administrator(s).

How is it used?
When running certain commands in a terminal you will notice that they will either not work or will return no information. Try running
Code:
fdisk -l
The above command will have run as your own regular user and should not have returned a value. Now try running it with sudo, to run it with root privilege
Code:
sudo fdisk -l
This time you should be prompted for your password and on entering it you will see a listing of all of your hard disk partitions, something only possible with root privilege.

What about graphical applications?
Although it isn't a great idea to run any old application as root, there are some that need to such as package managers and system configuration tools. Synaptic Package Manager for example. You can run the command 'synaptic' but you will receive errors about starting without administrative privileges. But if you were to prefix this with gksu (for Gnome) or kdesu (for KDE) you will first be prompted for your root password and then the application would run correctly.

So there you have it. That little prefix to your commands lets you run just what needs to be run as root and keeps your system secure and stable. And even for distributions that do not require the use of sudo, it can't be a bad habit to get into

Further reading:
sudo
Wikipedia entry on sudo
Ubuntu article on sudo
__________________
Registered Linux user #378740
New members read here / Forum Rules
#linuxforums on irc.freenode.net

Last edited by bigtomrodney; 11-09-2007 at 08:55 PM..
bigtomrodney is offline  


Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 11:15 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2