LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-10-2011, 05:58 AM   #1
brownflamigo1
Member
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 90

Rep: Reputation: 15
'sudo -i' and resolve host


I tried searching online, but that did not produce any results.
Could anyone please explain to me, why does a machine try to resolve host when I issue 'sudo -i' or some other command prefixed with sudo.
What is happening in the background?

Thanks.
 
Old 03-10-2011, 11:40 AM   #2
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
Can you explain more of what exactly you are doing?
 
Old 03-11-2011, 04:12 AM   #3
brownflamigo1
Member
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
DNS server went down. And when I issue 'sudo -i' I notice that the (Debian) machine tries to resolve it's hostname.
The question is: why would it need to resolve a hostname, when issued a 'sudo -i' command. I miss to see the connection between two events...
 
Old 03-11-2011, 04:23 AM   #4
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
Do you have any output of it? And does it try to resolve when you just issue su - ?
 
Old 03-12-2011, 06:13 AM   #5
brownflamigo1
Member
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
user@host:~$ sudo -i
sudo: unable to resolve host host

su -
requests me to enter root password, but does not display this message.
 
Old 03-12-2011, 09:11 AM   #6
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
Definitely something within your environment variables or something within that nature that is doing this. I would recommend going through them to see what is causing it.

---------- Post added 03-12-11 at 04:12 PM ----------

From the man page -
Quote:
The -i (simulate initial login) option runs the shell specified in
the passwd(5) entry of the user that the command is being run as.
The command name argument given to the shell begins with a - to
tell the shell to run as a login shell. sudo attempts to change to
that user’s home directory before running the shell. It also ini‐
tializes the environment, leaving TERM unchanged, setting HOME,
SHELL, USER, LOGNAME, and PATH, and unsetting all other environment
variables. Note that because the shell to use is determined before
the sudoers file is parsed, a runas_default setting in sudoers will
specify the user to run the shell as but will not affect which
shell is actually run.
 
Old 03-12-2011, 09:13 AM   #7
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,511

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
Please post the output from
Code:
cat /etc/hosts
Kind regards
 
Old 03-13-2011, 08:25 AM   #8
brownflamigo1
Member
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by corp769 View Post
Definitely something within your environment variables or something within that nature that is doing this. I would recommend going through them to see what is causing it.

---------- Post added 03-12-11 at 04:12 PM ----------

From the man page -
I went through the contents of .profile, .login and .bashrc as well as checked the environment variables, but could not find anything that points to the host resolution process.

<user>@<domain>:~$ cat /etc/hosts
# This file is managed by cfengine
127.0.0.1 localhost.localdomain localhost
2001::XX mea.<domain>
2001::XX coo.<domain>
2001::XX kwa.<domain>
2001::XX fru.<domain>
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

And here are the contents of resolv.conf:

<user>@<domain>:~$ cat /etc/resolv.conf
# This file is managed by cfengine
search net.<domain> eec.<domain> <domain>
nameserver 2001::XX
 
Old 03-13-2011, 08:29 AM   #9
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,511

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
try to comment everything out except
Code:
127.0.0.1 localhost.localdomain localhost
in /etc/hosts

comment out
Code:
nameserver 2001::XX
in
/etc/resolv.conf

Kind regards
 
Old 03-13-2011, 08:34 AM   #10
brownflamigo1
Member
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
If I comment out the "nameserver 2001::XX" in resov.conf and comment out everything in hosts, except for the IPv4 localhost, then I get the message again:
Quote:
<user>@<host>:~$ sudo -i
sudo: unable to resolve host <host>
 
Old 03-13-2011, 08:37 AM   #11
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,511

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
and if you comment out
Code:
search net.<domain> eec.<domain> <domain>
Kind regards
 
Old 03-13-2011, 08:43 AM   #12
brownflamigo1
Member
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 90

Original Poster
Rep: Reputation: 15
I get the same message ("Unable to resolve...") if I comment out either just the 'net.<domain> eec.<domain> <domain>' line or both lines in resolv.conf.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
try install host ; bind9-host uninstalled , how to undo sudo apt-get install host? shojaru Linux - Newbie 0 06-11-2009 12:45 AM
host resolve via dns shan_nathan Linux - Server 2 10-01-2008 12:18 AM
sudo works, but says 'unable to resolve host' Daravon Linux - Networking 4 09-08-2008 11:39 AM
Unable to resolve host name MistaT Linux - Server 5 07-16-2007 04:22 PM
DHCP not able to resolve host rmcastil Linux - Newbie 8 08-10-2005 06:31 AM


All times are GMT -5. The time now is 05:21 PM.

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