1-shell简介 /bash/type

1. 简介
bash,csh,ksh,.... //多个版本
[root@localhost ~]# cat /etc/shells   //查看系统支持的shell
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh

[root@localhost ~]# echo $SHELL   //当前shell
/bin/bash
 
[root@localhost ~]# cat /etc/passwd    //查看系统为每个用户分配的默认shell
root:x:0:0:amao99:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
 
[root@localhost ~]# ll /bin/sh       //查看sh指向哪个shell
lrwxrwxrwx 1 root root 4 Nov  7 15:23 /bin/sh -> bash
2. bash
(1) 命令记忆:可以通过上下箭头来翻看
[root@localhost ~]# cat .bash_history | more
(2) 命令和文件名补全
tab键补全
tab tab可以查看所有的命令
c[tab][tab]可以查看所有以c开头的命令
(3) 命令别名alias
alias lm = ‘ls -al’
(4) 作业前台后台运行设置,防止前台的作业被误用ctrl+c中止
(5) 强大的shell脚本script
(6) 通用匹配字符
ls /usr/x1186/bin/xt*
3. type 判断命令是否shell builtin命令
[root@linux ~]# type [-tpa] name  // //查看name是外部指令还是bash内置指令
参数
-t  :当加入 -t 参数时,type 会将 name 以底下这些字眼显示出他的意义:
       file    :表示为外部指令;
       alias   :表示该指令为命令别名所设定的名称;
       builtin :表示该指令为 bash 内建的指令功能;
-p  :如果后面接的 name 为指令时,会显示完整档名(外部指令)或显示为内建指令;
-a  :会将由 PATH 变数定义的路径中,将所有含有 name 的指令都列出来,包含 alias
 
[root@localhost ~]# type ls
ls is aliased to `ls --color=tty'
[root@localhost ~]# type -p touch
/bin/touch
[root@localhost ~]# type cd
cd is a shell builtin
4. shell指令格式
[root@localhost ~]# command [-options] parameter1 parameter2  <CR>//回车
若指令太长,可以用 \[Enter]转入下一行
shell指令是大小写敏感

你可能感兴趣的:(shell,职场,休闲)