Chinaunix首页 | 论坛 | 博客
  • 博客访问: 44198
  • 博文数量: 18
  • 博客积分: 474
  • 博客等级: 下士
  • 技术积分: 260
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-20 10:08
文章分类

全部博文(18)

文章存档

2011年(18)

分类: LINUX

2011-06-20 15:10:18

基本命令
# users
root root root

# w

# who

# ps

# wall "messages ... "
# mesg  <--  mesg n  , 管理员的广播必须收到

# write tom tty2
hey,tom. welcome to upl
    <--- ctrl + D 结束消息编写

简单的文本处理命令
    wc
    sort
    uniq
    cut

# wc s2.txt
 2  4 13 s2.txt
行,单词,字符数量

# wc -l  s2.txt

uniq 去掉连续行的重复

# uniq  -c s2.txt

# sort  默认按字典(ASCII)排序

# sort -n s2.txt  《-- -n 把数字当成数值比较

# sort -t" " -k1,1  /var/log/httpd/access_log
    <---以“ ”作为分割符号,然后对第一列进行排序


# sort -t":" -k3,3n s1.txt
# sort -t":" -k1,1   -k3,3n s1.txt

统计出单个IP的访问情况
# cut -d" " -f1 access_log | sort | uniq -c | sort -n -r

统计web服务当个IP的访问量
# cut -d" " -f1 access_log | sort | uniq -c | wc -l

=================================
文件访问控制列表
    
    test.txt   tom:mary     rwx,r-x,r--

tom    rwx
mary    r-x
bean    r--
moto    ---

为了使用acl,需要满足:
    1、acl的软件包
    2、文件所在的分区的文件系统支持acl , 例如: ext2/3/4
        挂载选项:acl

命令:
    getfacl
    setfacl


# id tom
uid=519(tom) gid=519(tom) groups=519(tom)
# id mary
uid=520(mary) gid=520(mary) groups=520(mary)
# id bean
uid=521(bean) gid=521(bean) groups=521(bean)
# id moto
uid=512(moto) gid=515(moto) groups=515(moto)

需要添加访问控制列表的文件
-rw-r--r-- 1 root root 952 05-22 13:53 hosts

例子1: 在不更改文件的拥有者属性的前提下完成

tom    rwx
mary    r-x
bean    r--
moto    rx-
 

设定之前
shell> getfacl /tmp/test/hosts
# file: tmp/test/hosts
# owner: root
# group: root
user::rw-
group::r--
other::r--

shell> setfacl -m user:tom:rwx,user:mary:rx,user:bean:r,user:moto:rx /tmp/test/hosts


# getfacl hosts
# file: hosts
# owner: root
# group: root
user::rw-
user:moto:r-x  ##
user:tom:rwx   ##
user:mary:r-x  ##
user:bean:r--  ##
group::r--
mask::rwx
other::r--

        


例子2:

# id tom
uid=519(tom) gid=519(tom) groups=519(tom)
# id mary
uid=520(mary) gid=520(mary) groups=520(mary)
# id bean
uid=521(bean) gid=521(bean) groups=521(bean),520(mary) ###<----
# id moto
uid=512(moto) gid=515(moto) groups=515(moto),520(mary) ###<----

-rw-r--r-- 1 tom mary 39 05-22 14:04 hosts

清空文件的原有的所有acl
# setfacl -b ./hosts

进行以下acl设定:
    tom    rwx
    mary    r-x
    mary组  rw-
    bean    r-x

思考:
    1、mary属于mary组,根据acl的设定,是否会出现权限的冲突?
    2、bean属于mary组,而acl中既有mary组的设定,也有针对bean用户的acl设定,权限是否会出现冲突还是堆叠?
    3、moto用户到底什么权限?


shell> setfacl -m user::rwx,user:mary:rx,user:bean:rx,group::rw ./hosts


shell>  getfacl ./hosts
# file: hosts
# owner: tom
# group: mary
user::rwx
user:mary:r-x  ###用户mary权限,不会受到其它设定影响
user:bean:r-x  ###用户bean权限,不会受到其它设定影响
group::rw-    ### 由于moto属于mary组,而文件属于mary组,这是moto的权限
mask::rwx
other::r--


例子3:在上面已经设定好的acl的基础上,对文件添加一个针对moto组的acl设定


uid=512(moto) gid=515(moto) groups=515(moto),520(mary) ###<----

-rw-r--r-- 1 tom mary 39 05-22 14:04 hosts


    moto组: r-x权限

    moto用户到底什么权限? rw + r-x == rwx

shell> setfacl  -m group:moto:rx /tmp/test/hosts

shell> getfacl /tmp/test/hosts
getfacl: Removing leading '/' from absolute path names
# file: tmp/test/hosts
# owner: tom
# group: mary
user::rwx
user:mary:r-x
user:bean:r-x
group::rw-
group:moto:r-x  ##比上一个例子增加了该行,
mask::rwx
other::r--

访问控制列表怎么去工作?
    1、判断是否为文件拥有者
        是,就更具owner进行授权
        否,继续下一步判断
    2、是否有专门属于该用户的acl条目
        有,根据具体acl进行授权
        没有,继续下一步判断
    3、判断是否为该文件的拥有组
        是,就根据文件拥有组的权限进行授权
        否,继续判断
    4、是否有专门属于该用户所在组的acl条目
        有,根据acl进行授权
        没有,继续判断
    补充:如果3,4步都满足,也就是该用户既文件拥有组的成员,也存在针对该用户所在另外的组的设定,那么就进行权限的堆叠,去并集。
        
    5、按照其他人的权限进行授权。


例子4: mask值的影响。
一般不用去修改。

shell> setfacl  -m mask::-w- ./hosts

# getfacl ./hosts
# file: hosts
# owner: tom
# group: mary
user::rwx    <---不受mask影响
user:mary:r-x                   #effective:--- 与mask取交集
user:bean:r-x                   #effective:--- 与mask取交集
group::rw-                      #effective:-w- 与mask取交集
group:moto:r-x                  #effective:--- 与mask取交集
mask::-w-
other::r--    <---不受mask影响

删除某条acl
# setfacl -x group:moto ./hosts

针对目录设定默认访问控制列表
    作用:所有在该目录下建立的子文件都会受到该目录的默认acl影响(自动继承acl)。这些acl设定对该目录不生效

    # setfacl -d -m user:tom:rwx /tmp/test/

================================



系统启动流程
    开机--bois硬件自检--int 19中断---加载引导设备的MBR中的bootloader--->grub 读取grub.conf --> 根据设定,引导自定的系统--->加载内核镜像(vmlinuz-xxxx)和 初始化内存盘镜像(initrd)---> 内核执行第一个进程/sbin/init ---> 读取/etc/inittab ---> 或者系统将要启动的级别---->执行/etc/rc.d/rc.sysinit脚本进行系统的初始化(设定主机名,挂载分区,selinux设定,udev生成设备文件)----> 根据启动级别启动对应的服务(读取/etc/rc.d/rcX.d/下的服务脚本软连接)---> /etc/rc.d/rc.local----> 根据initab文件产生对应的终端(tty1~tty6)---> 各个终端会调用login程序,产生登录界面,如果启动级别是5(图形界面),还会产生图形登录界面。



下周:
    服务管理
    磁盘配额






================================================================
修复grub
root 登录帐号
让系统支持yum,支持挂载nfs资源
    showmount -e 10.1.1.22


nfs服务都要以来portmap


手工安装图形界面
 GNOME 桌面环境     , X 窗口系统

# yum groupinstall  "X Window System"  "GNOME Desktop Environment"

阅读(609) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~