●umask --查看当前用户创建文件或文件夹时的默认权限
eg:
[test@szbirdora 1]$umask
0002
[test@szbirdora 1]$ls -lh
-rw-rw-r-- test test myfile
drwxrwxr-x test test 1
上面的例子中我们看到由test默认创建的文件myfile和文件夹1的权限分别为664,775.而通过umask查到的默认权限为002.所以可以推断出umask的计算算法为:
umask file directory
0 6 7
1 5 6
2 4 5
3 3 4
4 2 3
5 1 2
6 0 1
7 0 0
●连接ln
硬连接 ln sourcefile targetfile 连接后的target文件大小和source文件一样
软连接 ln -s sourcefile targetfile 类似于windows的快捷方式
●shell script 基本结构
#!/bin/bash --------bash shell开头必须部分
# description --------注释部分(可有可无,为了阅读方便最好加以说明)
variable name=value ---------变量部分,声明变量,赋值
control segment ---------流程控制结构,如判断、循环、顺序
eg.
helloworld.sh
#! /bin/bash
# This is a helloworld shell script
printchar = "hello world"
echo $printchar
[test@szbirdora 1]$sh helloworld.sh
hello world
●shell 特性
①别名 alias eg. alias ll = “ls -l”
②管道 a |b 将a命令的输出作为b命令的输入 eg. ls |sort 将ls列举的项排序
③命令替换 a`b` 将b命令的输出作为a命令的输入 eg. ls `cat myfile` 列举出cat myfile的输出项
④后台运行 nohup command& 可通过jobs -l查看后台运行的脚本
⑤重定向 >,< 可以改变程序运行的输出来源和输入来源
⑥变量 可以用$varname 来调用变量
⑦特殊字符 `用来替换命令 \用来使shell无法认出其后的特殊字符,使其失去特殊含义;允许一行放多个命令 () 创建成组的命令?? {} 创建命令块 ??