0

I've been having mail issues for a little while now and decided that today I was going to fix them! Well now I'm stuck. The issue was, when I type mail it doesn't display my mail, looking at my symlinks mail was linked to msmtp. I tried to update the symlink to postfix instead, but that isn't working and a strace run is telling me that it is working:

sudo strace ln -sf /usr/sbin/mail /usr/sbin/postfix
execve("/bin/ln", ["ln", "-sf", "/usr/sbin/mail", "/usr/sbin/postfix"], [/* 13 vars */]) = 0
brk(NULL)                               = 0x136f000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=62599, ...}) = 0
mmap(NULL, 62599, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9edbd88000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9edbd87000
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9edb7a9000
mprotect(0x7f9edb969000, 2097152, PROT_NONE) = 0
mmap(0x7f9edbb69000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f9edbb69000
mmap(0x7f9edbb6f000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9edbb6f000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9edbd86000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9edbd85000
arch_prctl(ARCH_SET_FS, 0x7f9edbd86700) = 0
mprotect(0x7f9edbb69000, 16384, PROT_READ) = 0
mprotect(0x60c000, 4096, PROT_READ)     = 0
mprotect(0x7f9edbd98000, 4096, PROT_READ) = 0
munmap(0x7f9edbd88000, 62599)           = 0
brk(NULL)                               = 0x136f000
brk(0x1390000)                          = 0x1390000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2981280, ...}) = 0
mmap(NULL, 2981280, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9edb4d1000
close(3)                                = 0
stat("/usr/sbin/postfix", 0x7fff872ed280) = -1 ENOENT (No such file or directory)
lstat("/usr/sbin/postfix", {st_mode=S_IFLNK|0777, st_size=14, ...}) = 0
stat("/usr/sbin/mail", 0x7fff872ed0d0)  = -1 ENOENT (No such file or directory)
symlink("/usr/sbin/mail", "/usr/sbin/postfix") = -1 EEXIST (File exists)
unlink("/usr/sbin/postfix")             = 0
symlink("/usr/sbin/mail", "/usr/sbin/postfix") = 0
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

However, when I look at the symlink:

ls -l /usr/sbin | grep "\->"
...
lrwxrwxrwx  1 root root           14 Jul 18 09:28 mail -> /usr/bin/msmtp
...

I decided to uninstall msmtp for good using sudo apt-get remove msmtp --purge which worked. I then attempted to create the symlink once more using sudo ln -sf /usr/sbin/mail /usr/sbin/postfix. Now whenever I type mail it gives me the following error:

 mail
-bash: /usr/sbin/mail: No such file or directory

However:

sudo find / -iname "mail"
...
/usr/sbin/mail
...

What is causing the issue with my mail command, and how can I fix it successfully?


Output of sudo find / -iname "postfix":

sudo find / -iname "postfix"
/etc/ufw/applications.d/postfix
/etc/resolvconf/update-libc.d/postfix
/etc/network/if-up.d/postfix
/etc/network/if-down.d/postfix
/etc/ppp/ip-up.d/postfix
/etc/ppp/ip-down.d/postfix
/etc/insserv.conf.d/postfix
/etc/init.d/postfix
/etc/postfix
/usr/share/doc/postfix
/usr/share/bash-completion/completions/postfix
/usr/share/lintian/overrides/postfix
/usr/share/postfix
/usr/sbin/postfix   #<=
/usr/lib/python3/dist-packages/fail2ban/tests/files/logs/postfix
/usr/lib/postfix
/var/spool/postfix
/var/lib/postfix
You have new mail in /home/serveradmin/Maildir
  • Can you post result of sudo find / -iname "postfix"? – Fanatique Jul 24 '18 at 13:44
  • @Fanatique yeah one second – CertifcateJunky Jul 24 '18 at 13:51
  • 1
    First thing first: with sudo ln -sf /usr/sbin/mail /usr/sbin/postfix you made postfix a symlink to mail, not the other way around. – Kamil Maciorowski Jul 24 '18 at 13:53
  • @KamilMaciorowski Even if I do it the other way around, it still prodices the same results, I thought about that – CertifcateJunky Jul 24 '18 at 13:54
  • As a side note, what is the actual point of symlinking mail to postfix? They do completely different things! You won't find an interactive mail client in Postfix. (Nor in msmtp, for that matter. They're both commonly symlinked to /usr/sbin/*send*mail instead.) – grawity Jul 24 '18 at 14:01
2

The -f in your command has overwritten the binary /usr/sbin/postfix with a link.

When you subsequently reverse the order there is no binary to link to, though I would have expected an error.

You need to reinstall the binary /usr/sbin/postfix from a back-up or a reinstall; the correctly ordered ln -sf /usr/sbin/postfix /usr/sbin/mail will now give you the link you want.

On Ubuntu 16.04 the normal mail program is in /usr/bin/, though by default /usr/sbin/ is earlier in the PATH list.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.