LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-12-2009, 03:37 PM   #1
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Rep: Reputation: 30
Ubuntu use root without sudo


I have been using Fedora and just got an opportunity to use Ubuntu.
For Fedora, I can just sudo, then can continue working as root without re-sudo.

However, for Ubutuntu, I have to use sudo every time I want to perform task as the root. If the task is short, it will not ask for the password. It becomes problem when I wrote scripts that each task take a long time to complete. The second task will not continue unless I enter the root password again. Is there a way to skip entering the root password?

Here is example of my script:

Code:
# each disk is 1 TB. so it takes a long time to finish.

sudo mkfs -t ext3 /dev/sdb1
sudo mkfs -t ext /dev/sdc1
 
Old 09-12-2009, 03:59 PM   #2
29t88
Member
 
Registered: Jan 2009
Distribution: CentOS 5.3
Posts: 62

Rep: Reputation: 17
Try using this command,
Sudo passwd passwordhere
then enable the root account to be able to log on from the log on screen,
thats the only thing i could think of> Enabling the root account or making a Database with variables to import the sudo variables after typing it once. (Witch im not sure is even possible)
 
Old 09-12-2009, 04:00 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
if you run sudo -i then you'll get a login session, alternatively just run the entire script as sudo, e.g. "sudo my_admin_script.sh"
 
Old 09-12-2009, 04:00 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Ugh, no don't do that. Breaking the authentication model really isn't a good move.
 
Old 09-12-2009, 04:49 PM   #5
elisee
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
Just use "sudo -s" to start a shell as root.
 
Old 09-12-2009, 06:33 PM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,539

Rep: Reputation: 462Reputation: 462Reputation: 462Reputation: 462Reputation: 462
if you need to do something as root, then login as root and forget about sudo. this way you do not get lazy and treat Linux like Windows. please remember that Linux is NOT Windows.
 
Old 09-12-2009, 09:04 PM   #7
louieb
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu 8.04
Posts: 94

Rep: Reputation: 17
Quote:
Originally Posted by elisee View Post
Just use "sudo -s" to start a shell as root.
its a little safer to use
Code:
sudo -i
Difference being -i gets you roots environment too. and -s keeps the current environment. - can easily accidentally give root ownership of the users configuration files.

Last edited by louieb; 09-12-2009 at 09:06 PM.
 
Old 09-12-2009, 09:25 PM   #8
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: /root
Distribution: Slackware & BSD
Posts: 1,215

Rep: Reputation: 231Reputation: 231Reputation: 231
ufmale,
Quote:
However, for Ubutuntu, I have to use sudo every time I want to perform task as the root.
This is the very purpose to minimize running an entire session as root. Unix experience teaches that root account should only be used for essential system works.

Quote:
If the task is short, it will not ask for the password.
Ubuntu and similar flavors default at 15 minutes, then the sudo root expires, after this short period sudo is again required.

Quote:
It becomes problem when I wrote scripts that each task take a long time to complete. The second task will not continue unless I enter the root password again. Is there a way to skip entering the root password?
Use gksudo within your script, or if you are sure script is safe run it as being owned by root. Since we do not understand what your script is doing we cannot say any further help other than general concepts.

Hope it helps.
 
Old 09-12-2009, 11:24 PM   #9
Smartpatrol
Member
 
Registered: Sep 2009
Posts: 196

Rep: Reputation: 38
Old School

...

Last edited by Smartpatrol; 03-11-2010 at 09:23 PM.
 
Old 09-12-2009, 11:43 PM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,397

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
As above though, sudo =i will give a functional equivalent of su - without breaking the ubuntu model.
 
Old 09-13-2009, 03:59 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by Smartpatrol View Post
Being old school in Ubuntu i sudo to root once and set a root password then su - when i need root(which is the majority of the time). Keep in mind that over the 11 years i have been a Unix/Linux Systems Admin i have conditioned myself to work in the root shell acutely aware of the power of root at all times.
Me too. I have a launcher on the panel that runs
Code:
gnome-terminal --window-with-profile=MyRootGTProfile --geometry=1028x768+0+0 -x su -
It is one of the most heavily used panel launchers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry, sudo must be setuid root kurtdriver Fedora 6 10-22-2008 07:47 PM
aftr sudo cmd and pswd i get this E: Type 'http://archive.ubuntu.com/ubuntu' is not k turoblaztr Linux - General 1 01-14-2007 10:29 AM
sudo is junk in ubuntu. thinking about adding a root user. fakie_flip Linux - Newbie 21 08-09-2006 03:35 PM
How to hack sudo to become root lewkh Linux - Security 5 01-08-2005 06:20 AM
Sudo, su and root lesleyb Linux - Security 3 10-18-2004 01:36 PM


All times are GMT -5. The time now is 12:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration