Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a server (CentOS 5.3) which won't allow the sudo command to work, and it fails with the following error:
Quote:
sudo: can't get hostname: Success
The issue is probably the hostname, which is quite long - so long, that the hostname command cuts it off.
Is there a way to set sudo to not require a hostname? I've tried putting the hostname in /etc/hosts without any luck. Unfortunately I cannot change the hostname to something shorter due to the system in place so I need to find a workaround.
Are you trying to sudo to a shell, or run a single
specific command?
How long is the hostname, itself, not counting any
characters that make up a domain name, etc. For
example, if the host were on the Internet and it's
complete name was:
"myhost.here.there.everywhere.com"
then the portion of the name that I'm concerned with
would be just "myhost", so it would be only 6
characters. How long is the portion of your hosts
fully qualified name, before the first dot?
If you have a full blown sudoers implementation
then in principle it should allow the use of a
host alias, the value of which can be an IP address.
If the problem is the hostname, that might solve your
problem. However, there's two aspects to hostname
here. I realize you're making substitutions in the
"pattern" of the hostname that you illustrated, so
just in terms of the pattern tokens, if you're
using the pattern you mentioned:
should output the portion of the name represented
by the first token "x", whereas the command
hostname --fqdn
should output the entire name. For the first portion,
some linux facilities only allow it to be as much as
32 characters, whereas some others 64 characters, and
for the full name, 256 characters.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.