鸟哥私房菜Shell基础(1/3)

2018-06-03  本文已影响0人  any_young

何为shell

应用程序操作操作系统的顺序是

linux系统使用的shell

使用者什么时候可以获得操作的shell?

[root@young ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown

如上,当我们登录的时候,在/etc/passwd中就保存了对应用户使用的shell,而root用户使用的就是/bin/bash

常用的shell,bash

bash有何好处?以下几点为使用bash的好处:

[root@young ~]# history
    1  ls
    2  cd /opt
    3  cd /
    4  ls
    5  wget http://download.redis.io/releases/redis-4.0.7.tar.gz
    6  ls
    7  cd /redis
    8  cd /opt/redis
    9  ls
   10  tar xvf redis-2.8.8.tar.gz 
   11  ls
   12  cd /opt/
   13  ls
   14  cd redis/
[root@young ~]# alias la='ls -alh'
[root@young ~]# la
总用量 48K
dr-xr-x---.  3 root root  206 3月  10 21:18 .
dr-xr-xr-x. 17 root root  224 1月  25 23:34 ..
-rw-------.  1 root root 1.2K 1月  25 23:35 anaconda-ks.cfg
-rw-------.  1 root root 3.1K 5月  27 17:18 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwxr-xr-x.  2 root root   40 2月   3 15:59 .oracle_jre_usage
-rw-r--r--.  1 root root   37 1月  26 00:01 .rediscli_history
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
-rw-r--r--.  1 root root  14K 3月  11 17:38 zookeeper.out

使用后的效果和ll一样,可以直接使用别名

如何查看bash的联机帮助文件呢?

直接使用man后加bash是全部bash的帮助文件,而后面如果跟上命令的话则是这个命令的帮助文件

[root@young ~]# man cd
BASH_BUILTINS(1)      General Commands Manual     BASH_BUILTINS(1)

NAME
       bash, :, ., [, alias, bg, bind, break, builtin, caller, cd,
       command, compgen,  complete,  compopt,  continue,  declare,
       dirs,  disown,  echo,  enable,  eval,  exec,  exit, export,
       false, fc, fg, getopts, hash, help,  history,  jobs,  kill,
       let,  local,  logout,  mapfile,  popd,  printf, pushd, pwd,
       read, readonly, return, set, shift, shopt, source, suspend,
       test, times, trap, true, type, typeset, ulimit, umask, una‐
       lias, unset, wait - bash built-in commands, see bash(1)

而type则是查看是否是bash内的命令和命令所处的位置

上一篇 下一篇

猜你喜欢

热点阅读