【2014/09/16】linux笔记文件权限 脚本

来源:互联网 发布:webservice和json区别 编辑:程序博客网 时间:2024/06/05 19:08

文件权限

ll


- 表示是一个文件
d 表示一个目录
x 执行
r 读
w 写
文件基本权限


 
可以出现 -w-权限

设置权限
  cd /tmp/ 打开文件
  touch file1 穿件一个file1文件
更改权限
chmod 
chmod u=rwx file1 设置拥有人的权限
chmod u=rwx,g=rwx,o=rwx 设置权限
chmod 777 file1  和上一行等效
chmod u+x file1 添加权限
chmod u-x file1 去掉权限
chmod a+w file1 给所有人添加写权限


脚本
(外信息
可执行的文件 脚本
linux下 bash语言 文件以.sh结尾  perl  后缀名为.pl
弱变量
echo 打印出来
用$取出变量
echo $a 打印出来a的值
|管道符 例如 echo "redhat"|passwd user1 --stdin


创建文件并写入脚本
touch user.sh

第一行声明shell
#!/bin/bash   (which bash 命令找出这个路径)
for x in 1 2 3(其中要有空格) 或者写为 $(seq 1 100)
 do
 useradd user$x
 echo "redhat" | passwd user$x --stdin
 done
执行的两种方式:
bash user.sh  执行
./user.sh  执行
再写入:
!#/bin/bash
for x in $(seq 1 100)
do
userdel user$x -r
done
./user.sh 
结束。。。
0 0