history:获取关于shell会话的更多信息
输入history命令来查看本次会话的历史:
history
示例输出:
9 ls10 vi advanced-cache.php11 cd ..12 ls13 w14 cd ..15 ls16 pwd17 ls.........91 hddtemp /dev/sda92 yum install hddtemp93 hddtemp /dev/sda94 hddtemp /dev/sg095 hddtemp /dev/sg196 smartctl -d ata -A /dev/sda | grep -i temperature97 smartctl -d ata -A /dev/sg1 | grep -i temperature98 smartctl -A /dev/sg1 | grep -i temperature99 sensors
输入history 20来查看命令历史的后20条:
history 20
示例输出:
图6:在bash shell中使用history命令查看会话历史
你可以重复使用之前的命令。简单地按下[上]或[下]方向键就可以查看之前的命令。在shell提示符下按下[CTRL-R]可以向后搜索历史缓存或文件来查找命令。重复最后一次命令,只需要在shell提示符下输入!!就好了:
ls -l /foo/bar!!
在以上的历史记录中找到命令#93 (hddtemp /dev/sda),输入:
!93
使用sudo或su改变用户
下面是语法:
su userName## 登录为tom用户 ##su tom## 为用户tom打开一个新的shell会话 ##su tom## 登录为root用户 ##su -## sudo命令语法(必须在系统中配置有这个命令) ##sudo -ssudo tom

