###############
####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 #0與7都代表週日
###黑名單與白名單###
與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 ##強行格式化vdb1爲xfs格式
.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 ##查看掃描情況
acl權限設置,延時定時命令,磁盤分區,swap分區設置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.