第2章 Shell 程序设计
主要内容
Shell Overview
What is Shell? Why Shell?
创建和执行Shell程序
Shell程序设计的语法
变量、条件测试、条件语句、重复语句、命令表和语句块、函数…
实例
基本命令(1)
文件操作
列出目录内容: ls
创建特殊文件: mkdir, mknod, mkfifo
文件操作: cp, mv, rm
修改文件属性: chmod, chown, chgrp
查找文件: find
字符串匹配: grep
其它: pwd, cd, file, more, less, head, tail, cat, gzip,zip,tar
http://linux./special//
基本命令(2)
进程操作
ps, kill
用户和组账号操作
useradd, userdel, groupdel,passwd
网络命令
ifconfig, ping, netstat,
其他
who, whoami, su, sudo,uname, …
man
mount unmount
du,df
文件权限
% ls -l
total 161
-rwxr-xr-x 1 mingming group1 17878
-rw-r--r-- 1 mingming group1 5053 test
drw-r-xr-x 1 mingming group1 512 dsa
...
- rwx rwx rwx a file
user
(owner)
group
other
(world)
file
u
g
o
161 blocks in disk are occupied by these files
文件权限(续)
- rw- r-- r--
user
(you)
group
other
(world)
file
a file you create
r - read
w - write
x - execute
A file does not have executable permission
by default, not even for the owner
目录权限
d rwx r-x r-x
user
(you)
group
other
(world)
directory
a directory you create
目录权限(续)
目录权限
读–可以列出存储在该目录下的文件
写–允许从目录中删除或添加新的文件
执行–允许在目录中查找,并能用cd命令将工作目录改到该目录:
cat /u/mingming/emails/
chmod: 改变文件或目录的存取权限
chmod u+x
x permission for owner
chmod ugo+x
x permission for all
chmod a+x
x permission for all
chmod a-x
remove x permission for all
chmod a-rwx
remove all permissions for all
(文件的权限只能被创建者或超级用户修改)
chmod命令(续)
chmod a+r, u+w
chmod a=r
chmod u=rwx
Linux课件:CH02 shell程序设计 来自淘豆网m.daumloan.com转载请标明出处.