Chinaunix

标题: RHEL5进不了root身份 [打印本页]

作者: vierisusu    时间: 2007-04-27 14:34
标题: RHEL5进不了root身份
在虚拟机VMware-workstation-6.0.0-44426里装RHEL5
在文本方式下 我输入  #ifconfig     bash:command not found
                                #/sbin/ifconfig     可以
我记得以前笔记里记了一段可以在/etc/profile添加这个命令:
#chmod 755 /etc/profile
#vim /etc/profile     <添加的部分>
/sbin/ifconfig
export PATH=/sbin:$PATH
#source  /etc/profile

我记得以前在RHEL4里面添加之后没有问题,现在添加后输入其它的命令都显示 command not find ,也进不了root身份,应该怎么解决呢?我试了好半天了,都没用

我截图了,怎么上传图片啊,以前不是可以吗


我照着maluyao先生的指示,后来把我乱改的文件重新改回来了
/usr/bin/vim /etc/profile

重新启动后就正常了,谢谢maluyao先生,也谢谢其他回答问题的各位,你们的指示我都记到本子上了,以后我会慢慢试试,多多学习的,谢谢你们

[ 本帖最后由 vierisusu 于 2007-4-27 23:21 编辑 ]
作者: maluyao    时间: 2007-04-27 14:34

  1. /usr/bin/vim /root/.bash_profile
复制代码
原帖由 vierisusu 于 2007-4-27 19:39 发表于 9楼  


#cd /root/.bash_profile
-bash: cd: /root/.bash_profile:Not a directory
#vi /root/.bash_profile
-bash: vi:command not found
#vim /root/.bash_profile
-bash: vim:command not found

作者: vierisusu    时间: 2007-04-27 16:53

作者: maluyao    时间: 2007-04-27 17:02
你应该也是先以普通用户的身份登陆,然后切换成root用户的吧。
直接用su 命令不好。

切换的时候执行:

  1. su -
复制代码

加一个减号应该就可以解决你的问题了。
作者: vierisusu    时间: 2007-04-27 17:13
我刚才试了一下,还是不行,显示的是

-bash: su: command not found


是不是因为我改 /etc/profile的原因啊?我改权限了啊
chmod 755 /etc/profile

作者: maluyao    时间: 2007-04-27 17:31
对,把/etc/profile 恢复回去。

原帖由 vierisusu 于 2007-4-27 17:13 发表于 4楼  
我刚才试了一下,还是不行,显示的是

-bash: su: command not found

是不是因为我改 /etc/profile的原因啊?我改权限了啊
chmod 755 /etc/profile

作者: maluyao    时间: 2007-04-27 17:33
直接用我这个profile大概就行,是Fedora core 5 上的

  1. # /etc/profile
  2. #echo start_of_etc_profile
  3. # System wide environment and startup programs, for login setup
  4. # Functions and aliases go in /etc/bashrc

  5. pathmunge () {
  6.         if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
  7.            if [ "$2" = "after" ] ; then
  8.               PATH=$PATH:$1
  9.            else
  10.               PATH=$1:$PATH
  11.            fi
  12.         fi
  13. }

  14. # ksh workaround
  15. if [ -z "$EUID" -a -x /usr/bin/id ]; then
  16.         EUID=`id -u`
  17.         UID=`id -ru`
  18. fi

  19. # Path manipulation
  20. if [ "$EUID" = "0" ]; then
  21.         pathmunge /sbin
  22.         pathmunge /usr/sbin
  23.         pathmunge /usr/local/sbin
  24. fi
  25. #pathmunge /jdk/bin
  26. #pathmunge /jdk/jre/bin
  27. # No core files by default
  28. ulimit -S -c 0 > /dev/null 2>&1

  29. if [ -x /usr/bin/id ]; then
  30.         USER="`id -un`"
  31.         LOGNAME=$USER
  32.         MAIL="/var/spool/mail/$USER"
  33. fi

  34. HOSTNAME=`/bin/hostname`
  35. HISTSIZE=1000

  36. if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
  37.     INPUTRC=/etc/inputrc
  38. fi

  39. export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

  40. for i in /etc/profile.d/*.sh ; do
  41.     if [ -r "$i" ]; then
  42.             . $i
  43.     fi
  44. done

  45. unset i
  46. unset pathmunge
  47. #echo end_of_etc_profile


复制代码

[ 本帖最后由 maluyao 于 2007-4-27 17:35 编辑 ]
作者: vierisusu    时间: 2007-04-27 17:40
我没法恢复啊,我现在输入什么命令都是

-bash: su: command not found

输入 cd  pwd  可以,其他的就不行
现在没法进入root下改啊
作者: maluyao    时间: 2007-04-27 19:17
手工把这句话加入到
/root/.bash_profile  文件里,注销后重新登录。也能对付用

  1. export PATH =/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
复制代码
原帖由 vierisusu 于 2007-4-27 17:40 发表于 7楼  
我没法恢复啊,我现在输入什么命令都是

-bash: su: command not found

输入 cd  pwd  可以,其他的就不行
现在没法进入root下改啊

作者: vierisusu    时间: 2007-04-27 19:39
手工把这句话加入到
/root/.bash_profile  文件里,注销后重新登录。也能对付用


#cd /root/.bash_profile
-bash: cd: /root/.bash_profile:Not a directory
#vi /root/.bash_profile
-bash: vi:command not found
#vim /root/.bash_profile
-bash: vim:command not found

[ 本帖最后由 vierisusu 于 2007-4-27 19:52 编辑 ]
作者: vierisusu    时间: 2007-04-27 20:19
localhost login:root
Password:
Last login:Fri Apr 27 14:29:05 on tty1
shutdown: you must be root to do that!
-bash: export:'/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin':not a valid identifier
-bash: id:command not found
-bash: id:command not found
[vierisusu@localhost `]$ su
-bash: su: command not found


现在这样是啥情况,好像还是不对
作者: maluyao    时间: 2007-04-27 20:34
export  那句话(我在8楼写的) 要放在一行里,中间没有任何空格。后边的东西是引号而不是分号。
作者: vierisusu    时间: 2007-04-27 21:02
怎么不能上传图片吗?还是不行

[ 本帖最后由 vierisusu 于 2007-4-27 21:47 编辑 ]
作者: xinyv    时间: 2007-04-27 21:57
去看看论坛里以前的帖子,好多进root的方法。
楼主先id一个贴结果。
知道root密码吗?
作者: bosomfriend    时间: 2007-04-27 22:01
登陆时候通过grub更改运行级别 进入text界面改,应该可以。
作者: jansonwang    时间: 2007-04-27 22:02
我好像没出现这个问题
作者: vierisusu    时间: 2007-04-27 22:04
好 我去找找 好像能进到
# 是输入一些命令的时候老师显示 command not find
作者: xinyv    时间: 2007-04-27 22:11
请楼主验证一下你系统的完整性
rpm -qaV
看看是不是你误删啥文件了。
作者: vierisusu    时间: 2007-04-27 22:14
我啥都没删,我就是改了个东西 我改了 /etc/profile  你看看1楼
作者: xinyv    时间: 2007-04-27 22:22
set
贴结果出来
作者: vierisusu    时间: 2007-04-27 22:33
截图勒 怎么贴上来啊
作者: xinyv    时间: 2007-04-27 22:35
复制粘贴,贴文字。主要贴
PATH=
这行
作者: vierisusu    时间: 2007-04-27 22:40
PATH=/sbin::/root/bin
作者: tanyear    时间: 2007-04-28 07:27
原帖由 vierisusu 于 2007-4-27 14:34 发表于 1楼  
在虚拟机VMware-workstation-6.0.0-44426里装RHEL5
在文本方式下 我输入  #ifconfig     bash:command not found
                                #/sbin/ifconfig     可以
我记得以前笔记里记了一段可以在 ...

感觉你这样学习用处不大。知其然不知其所以然
作者: vierisusu    时间: 2007-04-28 09:11
那些我的确不晓得,翻了翻书,原来书上都有,我都没有仔细看,真是惭愧
/etc 该目录存放了系统管理时要用到的各种配置文件和子目录
/usr/ 很多应用程序和文件都存放在这个目录下
/usr/bin 系统用户使用的应用程序
/usr/sbin 超级用户使用得比较高级的管理程序和系统守护程序
/usr/src 内河源码默认的放置目录
对吧
作者: sirluolin    时间: 2007-04-28 10:05
国人还真是爱当"官"啊,一个ROOT也要操"纵"一下.
作者: fandy    时间: 2007-04-29 09:44
原帖由 vierisusu 于 2007-4-27 19:39 发表于 10楼  


#cd /root/.bash_profile
-bash: cd: /root/.bash_profile:Not a directory
#vi /root/.bash_profile
-bash: vi:command not found
#vim /root/.bash_profile
-bash: vim:command not found



你可能不是修改权限那样的简单,是不是还做了什么东西您记不起啊!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2