我已经使用命令安装了 LAMP 服务器sudo apt-get install lamp-server^
。此后,每当我打开终端时,就会出现以下错误:
bash: /home/gaja/.bashrccu: No such file or directory
bash: /home/gaja/.bashrc: line 4: syntax error near unexpected token ('
bash: /home/gaja/.bashrc: line 4: see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)'
我可以摆脱这个问题使用这里给出的答案。
但是,现在的问题是我无法使用该sudo apt-get
命令安装任何东西。
我正在尝试重新root
运行该sudo apt-get install lamp-server^
命令,但出现以下错误输出:
dpkg: warning: 'tar' not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)
以下是运行命令的完整输出:
gaja@gaja-System-Product-Name:~$ sudo su
[sudo] password for gaja:
root@gaja-System-Product-Name:/home/gaja# sudo apt-get install lamp-server^
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libdbi-perl' for task 'lamp-server'
Note, selecting 'perl-modules' for task 'lamp-server'
Note, selecting 'libaprutil1-dbd-sqlite3' for task 'lamp-server'
Note, selecting 'perl' for task 'lamp-server'
Note, selecting 'apache2-bin' for task 'lamp-server'
Note, selecting 'libapache2-mod-php5' for task 'lamp-server'
Note, selecting 'ssl-cert' for task 'lamp-server'
Note, selecting 'mysql-server-5.5' for task 'lamp-server'
Note, selecting 'mysql-client-core-5.5' for task 'lamp-server'
Note, selecting 'libclass-isa-perl' for task 'lamp-server'
Note, selecting 'mysql-server' for task 'lamp-server'
Note, selecting 'libapr1' for task 'lamp-server'
Note, selecting 'php5-readline' for task 'lamp-server'
Note, selecting 'libaprutil1' for task 'lamp-server'
Note, selecting 'libwrap0' for task 'lamp-server'
Note, selecting 'libdbd-mysql-perl' for task 'lamp-server'
Note, selecting 'apache2-mpm-prefork' for task 'lamp-server'
Note, selecting 'libhtml-template-perl' for task 'lamp-server'
Note, selecting 'mysql-client-5.5' for task 'lamp-server'
Note, selecting 'libaio1' for task 'lamp-server'
Note, selecting 'mysql-common' for task 'lamp-server'
Note, selecting 'libmysqlclient18' for task 'lamp-server'
Note, selecting 'mysql-server-core-5.5' for task 'lamp-server'
Note, selecting 'libterm-readkey-perl' for task 'lamp-server'
Note, selecting 'php5-mysql' for task 'lamp-server'
Note, selecting 'apache2-data' for task 'lamp-server'
Note, selecting 'apache2' for task 'lamp-server'
Note, selecting 'php5-common' for task 'lamp-server'
Note, selecting 'php5-cli' for task 'lamp-server'
Note, selecting 'libswitch-perl' for task 'lamp-server'
Note, selecting 'libaprutil1-ldap' for task 'lamp-server'
Note, selecting 'tcpd' for task 'lamp-server'
libaio1 is already the newest version.
libapr1 is already the newest version.
libaprutil1 is already the newest version.
libaprutil1-dbd-sqlite3 is already the newest version.
libaprutil1-ldap is already the newest version.
libclass-isa-perl is already the newest version.
libdbd-mysql-perl is already the newest version.
libdbi-perl is already the newest version.
libhtml-template-perl is already the newest version.
libswitch-perl is already the newest version.
libterm-readkey-perl is already the newest version.
libwrap0 is already the newest version.
perl is already the newest version.
perl-modules is already the newest version.
ssl-cert is already the newest version.
tcpd is already the newest version.
apache2 is already the newest version.
apache2-bin is already the newest version.
apache2-data is already the newest version.
apache2-mpm-prefork is already the newest version.
libapache2-mod-php5 is already the newest version.
libmysqlclient18 is already the newest version.
mysql-client-5.5 is already the newest version.
mysql-client-core-5.5 is already the newest version.
mysql-common is already the newest version.
mysql-server is already the newest version.
mysql-server-5.5 is already the newest version.
mysql-server-core-5.5 is already the newest version.
php5-cli is already the newest version.
php5-common is already the newest version.
php5-mysql is already the newest version.
php5-readline is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 230 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
dpkg: warning: 'tar' not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)
root@gaja-System-Product-Name:/home/gaja# sudo apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
apache2 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 230 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
dpkg: warning: 'tar' not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)
root@gaja-System-Product-Name:/home/gaja#
根据其他成员的建议,我采取了一些故障排除步骤:
$ ls -l /bin/tar
ls: cannot access /bin/tar: No such file or directory
$ apt-cache policy tar
tar: Installed: 1.26+dfsg-8 Candidate: 1.26+dfsg-8 Version table: *** 1.26+dfsg-8 0 500 in.archive.ubuntu.com/ubuntu saucy/main i386 Packages 100 /var/lib/dpkg/status
切换到后,我也尝试运行以下命令root
,但这也无济于事:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
答案1
根的$PATH
环境变量未正确设置,因此dpkg
无法找到tar
提取的软件包。
切换到 root 权限后尝试以下操作:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
然后apt-get
再次运行该命令。
答案2
从您的问题和以下评论中可以清楚地看出tar
已安装但缺少可执行文件/bin/tar
。您需要手动添加它,因为dpkg
没有 您的程序将无法工作tar
。
首先检查以下文件是否已经存在,
ls -l /etc/rmt
ls -l /usr/lib/mime/packages/tar
ls -l /usr/sbin/rmt-tar
ls -l /usr/sbin/tarcat
我没有列出 doc 和 man 文件。完整列表可以找到这里。
您可以从以下位置手动下载.deb
软件包tar
packages.ubuntu.com. 下载适合您的架构的精确软件包。
.deb
接下来,在有存档管理器的系统中提取文件。如果您提取文件,主目录下.deb
将有一个名为的目录。您需要将可执行文件从提取的目录复制到。bin
tar
bin
/bin/
您可以先将可执行文件tar
放到您的主目录中。接下来在终端中使用以下命令将其复制到/bin
,
sudo cp tar /bin/
sudo chmod 755 /bin/tar
只需检查的所有者/bin/tar
是 root。并且它必须对所有人都具有执行权限。的输出ls -l /bin/tar
应如下所示,
-rwxr-xr-x 1 root root ...
这应该可以工作。你可能需要安装建议的套餐如果尚未安装。
答案3
我在尝试将发行版从 Debian Squeeze 升级到 Wheezy 时遇到了类似的错误(我知道这是一个 Ubuntu Stack Exchange,但我的解决方案可能对你有用)。这是我收到错误时执行的命令:
sudo apt-get dist-upgrade
以下是部分错误:
dpkg: 3 expected programs not found in PATH or not executable.
我使用以下命令更改为 root 用户并再次尝试:
su root
apt-get dist-upgrade
并且安装成功,没有错误。