您的位置:首页 > 运维架构 > Shell

linux shell 编程 之 shell简介

2011-05-27 16:35 387 查看
linux shell 编程 之 shell简介

×什么是shell
×存取权限和安全
×shell简单脚本
×shell特性

#cat /etc/shells

#echo $SHELL

查看当前运行的shell

~~~~~~~

chmod [who] operator [permission] filename

who (u ,g ,o ,a)
operator (+,-,=)
permission (r,w,x,s,t)

ex: chmod u=rwx,g+w,o-x 1.txt

~~~~~~~~

chmod mode file

mode r 4,w 2,x 1

ex: chmod 4744 1.txt 相当于 chmod u+s 1.txt
chmod 6744 1.txt 相当于 chmod g+s 1.txt
chmod 7744 1.txt 相当于 chmod o+T 1.txt

~~~~~~~~~~~~~~~~~~~~~

chown [-R] owner.group myfile 表示-R则myfile目录和目录下面的所有文件权限都要改变

chown owner:group myfile
chown :group myfile
chgrp 用法同chown

~~~~~~~~~~~~~~

umask umask的值是原值(目录满值是7,文件满值是6)的反值。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

符号链接

ln -s

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

shell

注意赋予权限 chmod u+x filename

运行方法 ./filename

~~~~~~~~~~~~~~~`
shell 特性

tar -czf filename.tar.gz filename & 放在后台运行

jobs -l 查看后台运行程序

~~~~~~~~~~~~~~~~~~~~~~~~~

后台 &
变量
管道 ls |sort sort----排序
重定向 sort <myfile.txt>myfile_dort.txt <输入 > 输出

特殊字符
" "
touch qwe qwr
touch "qwe qwr"

; ---------- 一行运行多个命令

$ -----------变量名的开头

本文出自 “初出茅庐” 博客,谢绝转载!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: