![启动 ubuntu14.04 时出错](https://linux22.com/image/987748/%E5%90%AF%E5%8A%A8%20ubuntu14.04%20%E6%97%B6%E5%87%BA%E9%94%99.png)
每次启动系统时我都会收到此消息:
Error found when loading /etc/profile:
/etc/profile: line 1: syntax error near unexpected token ('
/etc/profile: line 1:iamgreat# /etc/profile: system-wide.profile file for the Bourne shell(sh(1))'
As a result the session will not be configured correctly You should fix the problem as soon as feasible.
有人能帮我解决这个问题吗?这些是我当前的内容/etc/profile
:
iamgreat# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
答案1
你/etc/profile
的一团糟。即使iamgreat
一开始就去除杂散,sh -n
仍然抱怨语法错误。重新缩进并清理空格后,错误消失了。结果如下:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
将您的内容替换/etc/profile
为上面列出的代码(例如gksu gedit /etc/profile
),然后您就应该再次变得好起来。
PS:比全局环境变量/etc/environment
更好的地方(见最后一行)。/etc/profile
JAVA_HOME
答案2
iamgreat# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
你不应该iamgreat
在那里有它。删除它。你可以使用以下命令来执行此操作:
sudo sed -i '1s/^iamgreat//' /etc/profile
或者使用编辑器。