acl权限设置,延时定时命令,磁盘分区,swap分区设置

###############
####ACL
权限#####
###############


setfacl  -m u:user:mode    filename ##
授予用户在某个文件上的什么权限
            g:group:mode  filename ##
授予组在某个文件上的什么权限
            m:mode   filname        ##
更改文件的mask权限(在ACL权限开启的前提下)
         -x u:user:mode    filename ##
删除用户在某个文件上的什么权限
            g:group:mode   filename ##
删除组在某个文件上的什么权限
         -b filename                ##
删除此文件的全部ACL权限设定
         -d                         ##
更改默认权限
getfacl  filename                   ##
查看文件的acl权限设定
-------------------------------------------------
[root@desktop12 mnt]# ll
total 0
-rw-r--r--. 1 root root 0 Feb 16 20:17 file  
##-rw-r--r--. 
最后为. 代表此文件没有设置ACL权限 .变为+之后 代表此文件有设置的ACL权限
--------------------------------------------------
[root@desktop12 mnt]# setfacl -m u:student:rx file
[root@desktop12 mnt]# getfacl file
# file: file
# owner: root
# group: root
user::rw-
user:student:r-x
group::r--
mask::r-x              ##
掩码权限(有效权限),用户或组所设置的权限必须在mask权限设置的范围之内
other::r--
----------------------------------------------------
[root@desktop12 mnt]# setfacl -md u:student:rwx westos/    ##
此命令只会对目录/mnt/westos/下的新增的文件的默认权限进行更改,不会更改目录本身与此目录下在此之前就存在的文件的默认权限
# file: westos/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
default:user::rwx
default:user:student:rwx
default:group::r-x
default:mask::rwx
default:other::r-x
************************************************************************************************************

rhel6  新建的分区acl功能被关闭,需要自己开启

测试:

fdisk /dev/vdb               ##
创建分区
[root@desktop12 tmpfiles.d]# partprobe     ##
内核扫描分区
[root@desktop12 tmpfiles.d]# cat /proc/partitions  
mkfs.ext4 /dev/vdb1          ##
格式化分区
tune2fs -l /dev/vdb1         ##
查看分区信息
tune2fs -o ^acl /dev/vdb1    ##
关闭acl
tune2fs -o acl /dev/vdb1     ##
开启acl



##############
###
延时,定期##
##############

1.at
命令

  at  -l        ##
查看当前的延时任务
      
时间       ##定时任务
       now +
时间  ##定时任务

  atrm  job
    ##删除还未执行的延时任务

 -------------------------------------------------
  [root@desktop12 /]# at now +1min
  at> rm -fr /mnt/*      ##
编辑延时任务
  at> <EOT>               ##ctrl+d 
退出编辑
  job 2 at Thu Feb 16 22:15:00 2017   ##job
信息,包括job号以及将要被执行的时间
 -------------------------------------------------

  ********
延时命令的白名单与黑名单************
 
默认情况下,存在黑名单(at.deny),不存在白名单(at.allow)

  vim /etc/at.deny     
编辑黑名单

 
在新建了白名单之后,黑名单失效,系统不会去读取黑名单内容

  touch /etc/at.allow    
  vim /etc/at.allow

2.crontab
定期命令
 

  crontab -r    ##
清空定期任务
          -l    ##
查看定期任务
         -e   ##
编辑定期任务,任务被自动保存在/var/spool/cron/

 
编辑任务:

  * * * * *   commom   ##
每月每天每小时每分钟去执行某个命令(*可以被替换成你想要的日期)
 
  ##
说明

  * * * * *   
分 时 天 月 周

  */2  
2///

 
分钟:0-59
 
小时:0-23
 
  1-31
 
  1-12
 
  0-7      #07都代表周日
 
  ###
黑名单与白名单###
 
 
at命令一致
 
黑名单文件:/etc/cron.deny
 
默认白名单不存在  如果建立了白名单,则黑名单失效  白名单文件:/etc/cron.allow
 
3.
非交互式编辑定期任务
 
 
/etc/cron.d/ 目录下编辑文件(默认情况下只有root能够编写) 编辑格式与 crontab命令编辑任务格式一致
 
通过这种方式编辑的定期任务用crontab命令查不到
 
 
通过crontab命令设置的黑白名单对此方式设置的任务无效
 
-----------------------------------------------------------

**
注意:  以上几种延时命令方式  如果有输出 将以邮件的形式发给命令的编辑者
        
邮件存储在/var/spool/mail/
        
邮件查看命令:mail -u root    ##查看root用户的邮件






##################
###
临时文件的管理##
##################

  cd /usr/lib/tmpfiles.d/
  vim test.conf
  --------------
  d /mnt  1777  root root 6s     ## 6s
代表建立6s之后才能被清除
  --------------

  f ##
普通文件
  d ##
目录
  c ##
字符设备
  s ##
套接字
  p ##
管道
  b ##
块设备
  l ##
连接
 

  systemd-tmpfiles --creat/usr/lib/tmpfiles.d/*     ##
读取全部的配置文件
  systemd-tmpfiles --clean/usr/lib/tmpfiles.d/*     ##
执行全部的配置文件




##################
####
磁盘分区#######
##################

  fdisk /dev/vdb    ##
/dev/vdb/进行分区
  /proc/partitions   ##
这个文件里记录了内核所记录的分区情况
  partprobe          ##
让内核去重新读取分区情况
 
 
分区要经过格式化  与挂载 才能被使用
  mkfs.xfs   /dev/vdb1 -f  ##
强行格式化vdb1xfs格式
      .ext4
  mount /dev/vdb1  /mnt    ##
挂载到/mnt
 
永久挂载:  vim /etc/fstab 
  /dev/vdb1   /mnt  xfs  defaults   0     0
 
分区         挂载点  格式          不检测 不备份

  mount -a        ##
重新读取fstab里的内容,执行挂载
 --------------------------------------------------
 [root@desktop12 tmpfiles.d]# fdisk/dev/vdb
 Welcome to fdisk (util-linux 2.23.2).

 Changes will remain in memory only,until you decide to write them.
 Be careful before using the writecommand.


 Command (m foR help): n 
 Partition type:
   p  primary (1 primary, 0 extended, 3 free)
   e  extended
 Select (default p): p
 Partition number (2-4, default 2):2
 First sector (206848-20971519, default206848):
 Using default value 206848
 Last sector, +sectors or +size{K,M,G}(206848-20971519, default 20971519): +1G
 Partition 2 of type Linux and of size 1GiB is set

 Command (m foR help): wq
 The partition table has beenaltered!

 Calling ioctl() to re-read partitiontable.

 WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.
 The kernel still uses the old table. Thenew table will be used at
 the next reboot or after you runpartprobe(8) or kpartx(8)
 Syncing disks.                ##
当前进行的分区不能被内核识别   执行partprobe或者kpartx就可以被识别
 -------------------------------------------------------------

  Command (m  help): m
  Command action
   a  toggle a bootable flag
   b  edit bsd disklabel
   c  toggle the dos compatibility flag
   d  delete a partition                            ##
删除分区
   g  create a new empty GPT partition table        ##
建立GPT分区
   G  create an IRIX (SGI) partition table
   l  list known partition types                    ##
将分区列出来
   m  print this menu
   n  add a new partition                           ##
新建分区
   o  create a new empty DOS partition table
   p  print the partition table
   q  quit without saving changes                   ##
退出
   s  create a new empty Sun disklabel
   t  change a partitions system id                ##
更改分区的性质
   u  change display/entry units
   v  verify the partition table
   w  write table to disk and exit                  ##
保存设定
   x  extra functionality (experts only)
 

#################
#####swap
分区
#################


fdisk /dev/vdb.


---------------------------------
.
.
Select (default p): p
Partition number (2-4, default 2): 2
First sector (206848-20971519, default 206848):
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-20971519, default 20971519):+1G
Partition 2 of type Linux and of size 1 GiB is set

Command (m foR help): t
Partition number (1,2, default 2):
Hex code (type L to list all codes): 82     ## 82
代表swap类型
.
.
----------------------------------
 
mkswap /dev/vdb3     ##
格式化为swap类型
swapon -s            ##
查看swap类型的分区


 -1 -2 
代表优先级
[root@desktop12 tmpfiles.d]# partprobe
[root@desktop12 tmpfiles.d]# cat /proc/partitions

可以调整优先级:

先停止分区使用  再调整:
[root@desktop12 tmpfiles.d]# swapon -p 0 /dev/vdb3
swapon: /dev/vdb3: swapon failed: Device or resource busy     ##
没有停止分区 报错


正确做法:  swapoff/dev/vdb3
          swapon -a -p 0 /dev/vdb3   ##
将优先级改为0



删除分区:  先查看分区使用情况再进行关闭/卸载操作 最后进行删除   执行partprobe  
     
[root@desktop12 tmpfiles.d]# fuser -vm /dev/vdb3        ##
查看分区使用情况
                     USER        PID ACCESS COMMAND
/dev/vdb3:           root     kernel swap  /dev/vdb3
[root@desktop12 tmpfiles.d]# swapoff /dev/vdb3         ##
停止使用

[root@desktop12 tmpfiles.d]# fdisk /dev/vdb
-------------------
.
.
Command (m foR help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted

Command (m foR help): wq
.
.
--------------------
[root@desktop12 tmpfiles.d]# partprobe                ##
内核重新扫描分区情况
[root@desktop12 tmpfiles.d]# cat /proc/partitions     ##
查看扫描情况


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值