我是Linux操作系统的新手,并且已在centos7上安装了jdk。
现在,每次我登录时,都会收到以下错误消息:
/usr/libexec/grepconf.sh: line 5: grep: command not found
-bash: /home/centos/.bash_profile: line 13: syntax error near unexpected token `newline'
-bash: /home/centos/.bash_profile: line 13: `export PATH=$PATH:/opt/jdk1.8.0_192/bin:/opt/jdk1.8.0_192/jre/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin:/usr/bin/grep>'
“所有命令均未找到”
我找到此信息以更新路径: https://unix.stackexchange.com/questions/302743/centos-7-all-command-not-found-except-cd
然后我用以下命令更新路径:
PATH=/usr/local/bin:/usr/bin:bin
所以现在
sudo nano /home/centos/ .bash_profile
命令在bash_profile文件中具有以下内容:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PATH=$PATH:/opt/jdk1.8.0_192/bin:/opt/jdk1.8.0_192/jre/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin:/usr/bin/grep>
什么是问题?如何解决所描述的错误?
第一次编辑,以回答@航海问题:
.bash_profile文件的内容:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PATH=$PATH:/opt/jdk1.8.0_192/bin:/opt/jdk1.8.0_192/jre/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin:/usr/bin/grep
这里是grepconf的内容:
#!/bin/sh
case "$1" in
-c | --interactive-color)
! grep -qsi "^COLOR.*none" /etc/GREP_COLORS
;;
*)
echo >&2 "Invalid / no option passed, so far only -c | --interactive-color is supported."
exit 1
;;
esac
第二次编辑,以回答评论中的问题:
此处ldd / usr / bin / grep命令输出:
linux-vdso.so.1 => (0x00007fff769b8000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f0454df3000)
libc.so.6 => /lib64/libc.so.6 (0x00007f0454a26000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f0454809000)
/lib64/ld-linux-x86-64.so.2 (0x000055ce09e0c000)
这是ls -l / lib64 / ld *的结果
[centos@serveur-1 ~]$ ls -l /lib64/ld*
-rwxr-xr-x 1 root root 163400 Jan 29 18:55 /lib64/ld-2.17.so
lrwxrwxrwx 1 root root 10 Feb 20 21:51 /lib64/ld-linux-x86-64.so.2 -> ld-2.17.so
每次我注销后,我都会登录, 除了某些命令,我总是得到“找不到命令”:
java -version
因此,每次我必须键入“ PATH = / usr / local / bin:/ usr / bin:bin /”(在此站点上找到的答案),并且每次我键入echo $ PATH时,输出都会越来越复杂:
[centos@serveur-1 ~]$ echo $PATH
$PATH:/opt/jdk1.8.0_192/bin:/opt/jdk1.8.0_192/jre/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin:/opt/jdk1.8.0_192/bin:/opt/jdk1.8.0_192/jre/bin:/usr/local/sbin:/usr/sbin:/home/centos/.local/bin:/home/centos/bin:/usr/bin/grep
我想$ PATH内容刚登录后就坏了。
那我该如何彻底解决呢?
对@tripleee的第三次修改: 这是.bashrc文件的内容:
[centos@serveur-1 ~]$ sudo nano /home/centos/.bashrc
GNU nano 2.3.1 File: /home/centos/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
它谈论/ etc / bashrc,所以这是它的内容:
[centos@serveur-1 ~]$ sudo nano /etc/bashrc
GNU nano 2.3.1 File: /etc/bashrc
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*|vte*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
elif [ "${VTE_VERSION:-0}" -ge 3405 ]; then
PROMPT_COMMAND="__vte_prompt_command"
else
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOM$
fi
;;
screen*)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOM$
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-de$
;;
esac
fi
# Turn on parallel history
shopt -s histappend
history -a
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
# You might want to have e.g. tty in prompt (e.g. more virtual machines)
# and console windows
# If you want to do so, just add e.g.
# if [ "$PS1" ]; then
# PS1="[\u@\h:\l \W]\\$ "
# fi
# to your custom modification shell script in /etc/profile.d/ directory
fi
if ! shopt -q login_shell ; then # We're not a login shell
# Need to redefine pathmunge, it get's undefined at the end of /etc/profile
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
# By default, we want umask to get set. This sets it for non-login shell.
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ];
then
umask 002
else
umask 022
fi
SHELL=/bin/bash
# Only display echos from profile.d scripts if we are no login shell
# and interactive - otherwise just process them to set envvars
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
fi
# vim:ts=4:sw=4
当您来自“ Windows世界”时,很难理解这种机制。
答案 0 :(得分:0)
从此行中删除结尾的>
:
export PATH=$PATH:/opt/jdk.../usr/bin/grep>
它应该可以工作。
答案 1 :(得分:0)
通过更新.bash_profile如下解决:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/bin:/usr/bin:/bin:/opt/jdk1.8.0_192/bin:/opt/jdk1.8.0_192/jre/bin
export PATH
我是Centos的新手,所以我希望我能获得2分(经否决票删除):