-bash:/usr/sbin/mail:没有此文件或目录

-bash:/usr/sbin/mail:没有此文件或目录

一段时间以来,我一直遇到邮件问题,我决定今天就解决它们!现在我陷入困境。问题是,当我输入时,mail它不会显示我的邮件,查看邮件链接到的符号链接msmtp。我尝试将符号链接更新为postfix,但这不起作用,运行strace告诉我它正在工作:

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 +++

但是,当我查看符号链接时:

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

我决定msmtp使用 彻底卸载sudo apt-get remove msmtp --purge,这很有效。然后我尝试使用 再次创建符号链接sudo ln -sf /usr/sbin/mail /usr/sbin/postfix。现在,每当我输入邮件时,都会出现以下错误:

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

然而:

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

是什么导致了我的命令出现问题mail?我该如何成功修复它?


输出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

答案1

您的命令已使用链接-f覆盖了二进制文件。/usr/sbin/postfix

当您随后反转顺序时,没有二进制文件可以链接,尽管我预计会出现错误。

您需要/usr/sbin/postfix从备份或重新安装中重新安装二进制文件;正确的顺序ln -sf /usr/sbin/postfix /usr/sbin/mail现在将为您提供所需的链接。

在 Ubuntu 16.04 中,常规mail程序位于 中/usr/bin/,但默认情况下/usr/sbin/位于PATH列表的较早位置。

相关内容