LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-27-2012, 06:34 AM   #1
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Rep: Reputation: Disabled
How to set the name of a computer for postfix / mail?


The smartmontools daemon (smartd) can send mails to e.g. root, if and when a warning or error for a hard disk occurred. One sets the mail address like "root@linux" in /etc/smartd.conf. When a real mail is sent, the mail agent appends "site" to the above denominator like so root@linux.site and the mail is duly sent and received.

How can I change "linux" to something more meaningful? I know that I set this up (possibly during installation), but I want to change it now.

<edit> It is not set from "/etc/HOSTNAME", remarcably... </edit>

And while we are at it: can I change "site" too?

Last edited by JZL240I-U; 09-27-2012 at 07:12 AM.
 
Old 09-27-2012, 08:07 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,074

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
Take a look at man smartd.conf, particularly the -m and -M options for background and detailed information; I suspect, though, that you can simply edit the e-mail address(es) in /etc/smartd.conf then stop and restart the daemon:
Code:
su -
ps -ef | grep smartd           <to get the PID>
kill -HUP <PID of smartd>      <stop the daemon>
Then you can test your change by starting the daemon with the -M test option (which will send mail). Be sure to read the section on this in man smartd first.

Hope this helps some.
 
Old 09-27-2012, 08:27 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tronayne View Post
Take a look at man smartd.conf, particularly the -m and -M options...
Did that already, but thanks anyhow.

Quote:
Originally Posted by tronayne View Post
...I suspect, though, that you can simply edit the e-mail address(es) in /etc/smartd.conf then stop and restart the daemon....
No, you can't change an addressee arbitrarily. In real life you send your letter either toTom (root) in New York or in Boston and there is a difference. Postfix thinks my machine is called "linux.site" (New York). I want to change that denomination into "netbook" (Boston). I even tried it and get the error "Host or domain name not found. Name service error for name=netbook.site"

I suspect that this is hidden in some .conf file, like HOSTNAME is. That's what I am looking for, to rename my machine in the eyes of postfix.

<edit> In /etc/postfix/main.cf is a line like this: "myhostname = linux.site". Put there probably by the "SuSEconfig.postfix" program. Which is parameterized how? </edit>

Last edited by JZL240I-U; 09-27-2012 at 08:40 AM.
 
Old 09-27-2012, 09:12 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,074

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
Oh. Well, OK...

Just for grins, what does
Code:
uname -n
show you? It ought to be what's in /etc/HOSTNAME without the domain. Are you running fixed IP and, if so, what's in /etc/hosts; if not, what's embedded in your "inet1.conf" (do you have DHCP_HOSTNAME defined)?

This might seem like overkill but you more or less know that linux.site has got to be buried somewhere in some blasted file, so why not
Code:
su -
find / -type f | xargs grep -i 'linux.site' 2>/dev/null
Then, you know, go change 'em all to what you want and reboot the thing.
 
Old 09-27-2012, 09:37 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Code:
uname -n
shows
Code:
netbook
And that is exactly what is in /etc/HOSTNAME without the domain, right.


I am not running fixed IP. In /etc/hosts is
Code:
127.0.0.1.   localhost
192.168.1.69   my.desktop.PC   linux-jdoc
{some IPv6 statements}

DHCP_HOSTNAME is not defined as far as I can see. How to check it outside of YAST?
Code:
su -
find / -type f | xargs grep -i 'linux.site' 2>/dev/null
Is running now.

Last edited by JZL240I-U; 09-27-2012 at 09:43 AM.
 
Old 09-27-2012, 09:40 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Code:
uname -n
shows
Code:
netbook
And that is exactly what is in /etc/HOSTNAME without the domain, right.


I am not running fixed IP. In /etc/hosts is
Code:
127.0.0.1.   localhost
192.168.1.69   my.desktop.PC   linux-jdoc
{some IPv6 statements}

DHCP_HOSTNAME is not defined as far as I can see. How to check it outside of YAST?
Code:
su -
find / -type f | xargs grep -i 'linux.site' 2>/dev/null
Is running now.

<edit> In /var/log/mail I found
Code:
Networkmanager: <info> Setting system hostname to 'linux.site' (from system configuration)
What is that telling us? --- Uups, I clicked on quote instead of edit </edit>

Last edited by JZL240I-U; 09-27-2012 at 09:43 AM.
 
Old 09-27-2012, 10:46 AM   #7
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,074

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
Are you running KDE? Maybe take a look at the system configuration options? Probably need to be root when you do anything with it (I'm running Xfce but I can look at the KDE System Settings from it).

Other place to look is /etc/mail, maybe in local-host-names and helpfile.

Gotta be there someplace
 
Old 09-27-2012, 05:53 PM   #8
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,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
One solution which I have used with both postfix and sendmail (but I think it is picked up by the mail-generating program, not the MTA) is to change root's line in /etc/paswd, setting the 5th field to root@<hostname> (where <hostname> is the hostname you want).
 
Old 09-28-2012, 01:44 AM   #9
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tronayne View Post
Are you running KDE? Maybe take a look at the system configuration options?
I am and I did that, but didn't find anything. Probably looked at the wrong places.

Quote:
Originally Posted by tronayne View Post
Other place to look is /etc/mail, maybe in local-host-names and helpfile.
/etc/mail and /local-hos-names don't exist in openSuSE .

Quote:
Originally Posted by tronayne View Post
Gotta be there someplace
Indeed. That b@stard.

P.S.: I had to break off the systemwide search yesterday. It's just restarted (after I umounted all unnecessary partitions ). But
Code:
ps ax | grep find
results in
Code:
2361 pts/0   S+   0:00  find / -type f
Does that mean the job sleeps??? Or has it stopped (abnormally)? <edit> Spleeps. Lazy guy. When and how will it wake?</edit>

Last edited by JZL240I-U; 09-28-2012 at 02:09 AM.
 
Old 09-28-2012, 01:54 AM   #10
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
...change root's line in /etc/paswd, setting the 5th field to root@<hostname> (where <hostname> is the hostname you want).
Ummf. My root entry in /etc/passwd reads
Code:
root:x:0:0:root:/root:/bin/bash
Should that be
Code:
root:x:0:0:root@netbook:/root:/bin/bash
??? But where stems the current "linux" from?

Last edited by JZL240I-U; 09-28-2012 at 02:12 AM.
 
Old 09-28-2012, 06:49 AM   #11
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,074

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
You should probably try to kill that find (if it's still running)
Code:
su -
ps -ef | grep find
kill -9 2361         <the PID of the running find>
Kinda looks like a zombie, maybe.

Trying to remember where the mail files used to be, I think in /var somewhere, maybe in /var/spool; if you've got sendmail those configuration files are someplace. Look for aliases, aliases.db, sendmail.cf; e.g.,
Code:
find /var -type f -name 'aliases*'
 
Old 10-08-2012, 11:33 AM   #12
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Been away for a week, back to work now .

I already killed the "find", no problem there.

"/etc/aliases" in SuSE systems holds mappings for users like lp: root or postgres: root. There are no machine names in there, I checked. There is also an aliases.db, with what would I open that? "sendmail*" does not exist, though. Any more ideas?
 
Old 10-08-2012, 01:50 PM   #13
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,074

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
No sendmail, huh? Well, who knew.

Anyway, have you tried simply setting the system name and domain in /etc/HOSTNAME and reboot the thing?

Take a look at the manual page for hostname; simply typing
Code:
hostname
should tell you what it is (sans domain name). You can set the name of the system with hostname with
Code:
hostname sysname
where sysname is the name you want set. You typically can't set the domain name that way (see the hostname manual page).

It's usual that you can set the host and domain in /etc/rc.d/rc.inet1 or /etc/init.d/boot and look at /etc/host.conf (if you don't have one or more of those files; e.g., in /etc/rc.d, look for a file of that name somewhere in the /etc directory). Note that, if the system name is not set in one of those you probably don't want to mess with it; if the system name is set in one of those files and it's the wrong one, change it and reboot.

Most every system I've ever worked with, both Unix and Linux, takes the system name setting from /etc/HOSTNAME (or some variant of that). Whatever is overriding your system name is going to be found in some configuration file somewhere and you should find that and either comment out the "wrong" name or simply change it with an editor.

Whatever file that network manager uses for configuration (and I have no idea what that might be) is probably where you'll find the problem; might be worth a look-see at the manual page for the network manager? I dunno.

Hope this helps some.
 
Old 10-09-2012, 06:47 AM   #14
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,674

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tronayne View Post
...Anyway, have you tried simply setting the system name and domain in /etc/HOSTNAME and reboot the thing?
That doesn't work, as this is not the HOSTNAME (see the <edit> in my thread starting post #1 ).

I tried
Code:
hostname test
after which a simple "hostname" returns "test" (not anymore "netbook"). /etc/HOSTNAME was not changed and the system variable "$HOSTNAME" still is "netbook".

There is no /etc/rc.d/rc.inet1.

There is an /etc/init.d/boot.localnet which loads the system variable $HOSTNAME with the content of /etc/HOSTNAME (i.e. "netbook").

/etc/host.conf is the "resolver conofiguration file" with two lines
Code:
order hosts, bind
multi on
Quote:
Originally Posted by tronayne View Post
...Most every system I've ever worked with, both Unix and Linux, takes the system name setting from /etc/HOSTNAME (or some variant of that). Whatever is overriding your system name is going to be found in some configuration file somewhere and you should find that and either comment out the "wrong" name or simply change it with an editor...
Yes. YES. But I can't find that blasted configuration file responsible for this.

I used
Code:
find / -type f -newer /root/timestamp > op
with "timestamp created immediately before a "hostname test" command. 1.8 MB output but no luck. Nor did I find anything in the network manager connected files . The man page says, that network manager uses the same "gethostname(2)" to get the hostname ...
 
Old 10-09-2012, 08:31 AM   #15
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,074

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
I don't know if this will help but here's an example program that will print your host and domain name using the gethostname() and getdomainname() functions.
Code:
/*********************************************************************** 
 * File     :   gethostname.c 
 * Author   :   Saurabh Gupta 
 * Desc     :   Demonstrate gethostname(2) 
 *              gethostname example 
 *              gethostname example c 
 *              gethostname example linux 
 *              gethostname function linux 
 * Source   :   http://saurabhgupta0527.blogspot.com/2011/07/socket.html 
 * Created  :   AM 10:27 22 August 2011 
 * Note     : 
 ************************************************************************/  
 #include <stdio.h>  
 #include <unistd.h>  
 #include <stdlib.h>  
 #include <errno.h>  
 #include <string.h>  
 #include <sys/types.h>  
 #include <sys/stat.h>  
 #include <sys/socket.h>  
 #include <sys/un.h>  
 #include <netinet/in.h>  
 #include <arpa/inet.h>  
  
  int main(int argc,char **argv) {  
     int z;  
     char buf[32];  
  
     z = gethostname(buf,sizeof buf);  
  
     if ( z == -1 ) {  
        fprintf(stderr, "%s: gethostname(2)\n",  
        strerror(errno));  
        exit(1);  
     }  
  
     printf("host name = '%s'\n",buf);  
  
     z = getdomainname(buf,sizeof buf);  
  
     if ( z == -1 ) {  
        fprintf(stderr,"%s: getdomainname(2)\n",  
        strerror(errno));  
        exit(1);  
     }   
  
     printf("domain name = '%s'\n",buf);  
  
     return 0;  
  }
If you save the above as gethostname.c in a convenient directory then enter
Code:
make gethostname
you should be able to execute the program and see what your system name and domain are set to; might help chase something down.

The above example comes from http://www.ccplusplus.com/2011/11/ge...example-c.html.

Note that (from the getdomainname manual page):
Quote:
Since Linux 1.0, the limit on the length of a domain name, including the terminating
null byte, is 64 bytes. In older kernels, it was 8 bytes.

On most Linux architectures (including x86), there is no getdomainname() system
call; instead, glibc implements getdomainname() as a library function that returns a
copy of the domainname field returned from a call to uname(2).
See what this tells you, eh?
 
  


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
Postfix Mail Queue set to manual wademac Linux - Server 2 06-21-2012 09:00 AM
How do I set Quota for mail boxes in postfix cj_cheema Linux - Server 7 08-02-2010 01:45 PM
Set-up postfix just for sending mail harald25 Linux - Software 1 04-06-2009 08:53 AM
Postfix mail server set up nakayiza Linux - Server 1 10-12-2006 05:38 AM
set squirrel mail to use postfix paul_mat Linux - Networking 1 01-20-2006 04:52 AM


All times are GMT -5. The time now is 07:11 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