window计算的chk在linux下可以读,Linux系统命令从入门到完全忘记(四)
系統安全相關命令
chmod
概要:
用于改變文件或目錄的訪問權限,用它控制文件或目錄的訪問權限。
語法格式:
chmod [-cfvR] [–help] [–version] mode file
參數:
參數
說明
-c
當發生改變時,報告處理信息
-f
錯誤信息不輸出
-R
處理指定目錄以及其子目錄下的所有文件
-v
運行時顯示詳細處理信息
使用示例:
增加文件file所有用戶組可執行權限
1
2
3
4
5
[root@ansheng ~]# ll file
-rw-r--r-- 1 root root 0 Apr 25 21:02 file
[root@ansheng ~]# chmod a+x file
[root@ansheng ~]# ll file
-rwxr-xr-x 1 root root 0 Apr 25 21:02 file
更改文件ansheng.txt擁有者和所屬組擁有讀寫執行權限,其他用戶沒有任何權限
1
2
3
4
5
6
[root@ansheng ~]# ll
total 0
-rw-r--r-- 1 root root 0 Apr 25 21:03 ansheng.txt
[root@ansheng ~]# chmod 770 ansheng.txt
[root@ansheng ~]# ll ansheng.txt
-rwxrwx--- 1 root root 0 Apr 25 21:03 ansheng.txt
chown
概要:
通過chown改變文件的擁有者和群組。在更改文件的所有者或所屬群組時,可以使用用戶名稱和用戶識別碼設置。普通用戶不能將自己的文件改變成其他的擁有者。其操作權限一般為管理員。
語法格式:
chown [選項]… [所有者][:[組]] 文件…
參數:
參數
選項
-c
顯示更改的部分的信息
-f
忽略錯誤信息
-h
修復符號鏈接
-R
處理指定目錄以及其子目錄下的所有文件
使用示例:
更改文件group的擁有者和組
1
2
3
4
5
6
[root@ansheng ~]# touch abc
[root@ansheng ~]# ll abc
-rw-r--r-- 1 root root 0 Apr 25 21:06 abc
[root@ansheng ~]# chown ansheng.ansheng abc
[root@ansheng ~]# ll abc
-rw-r--r-- 1 ansheng ansheng 0 Apr 25 21:06 abc
chattr
概要:
用于改變文件屬性
語法格式:
chattr [-RV][-v][+/-/=][文件或目錄…]
參數:
參數
說明
-R
遞歸處理,將指定目錄下的所有文件及子目錄一并處理
-v
設置文件或目錄版本
-V
顯示指令執行過程
+
開啟文件或目錄的該項屬性
-
關閉文件或目錄的該項屬性
=
指定文件或目錄的該項屬性
使用示例:
用chattr命令防止系統中某個關鍵文件被修改:
1
2
3
[root@ansheng ~]# chattr +i /etc/resolv.conf
[root@ansheng ~]# ll /etc/resolv.conf
-rw-r--r--. 1 root root 53 Apr 9 17:58 /etc/resolv.conf
lsattr
概要:
用chattr執行改變文件或目錄的屬性,可執行lsattr指令查詢其屬性。
語法格式:
lsattr [-adlRvV][文件或目錄…]
參數:
參數
說明
-a
顯示所有文件和目錄,包括以”.”為名稱開頭字符的額外內建,現行目錄”.”與上層目錄”..”
-d
顯示,目錄名稱,而非其內容
-l
此參數目前沒有任何作用
-R
遞歸處理,將指定目錄下的所有文件及子目錄一并處理
-v
顯示文件或目錄版本
使用示例:
查看文件/etc/resolv.conf狀態
1
2
[root@ansheng ~]# lsattr /etc/resolv.conf
----i--------e- /etc/resolv.conf
系統相關命令
shutdown
概要:
該命令可以安全關閉或者重新啟動系統。你沒有看錯,shutdown命令不僅可以關閉系統、也可以重啟Linux系統。
語法格式:
shutdown [-t sec] [-arkhncfFHP] time [warning-message]
參數:
參數
說明
-a
Use /etc/shutdown.allow.
-c
中斷關機:當執行”shutdown -h 12:00”指令時,只要按+鍵就可以中斷關機的指令
-f
重新啟動時不進行磁盤檢測(fsck)
-F
重新啟動時進行磁盤檢測(fsck)
-h
關閉電源
-k
模擬關機(不是真的關機),只是向登錄者發送警告信息出去!
-n
不調用init進程進行關機,而是強行關機
-r
關閉系統然后重新啟動,類似于Windows平臺restart
-t
延遲關機的時間
-w
僅做測試,并不真的將系統重新開機,只會把重開機的數據寫入/var/log目錄下的wtmp記錄文件
使用示例:
馬上關閉Linux系統,其中 now 相當于時間為 0 的狀態
1
2
3
[root@ansheng ~]# shutdown -h now
Broadcast message from root (pts/1) (Sat Jan 10 18:51:34 2015):
The system is going down for system halt NOW!
系統2分鐘后重新啟動,其中+m表示幾分鐘后關機或開機。
1
2
3
[root@ansheng ~]# shutdown -r +2
Broadcast message from root (pts/2) (Sat Jan 10 19:56:00 2015):
The system is going DOWN for reboot in 2 minutes!
設置系統在那個時間點關機
1
2
3
4
[root@ansheng ~]# shutdown -h 12:30
或
[root@ansheng ~]# shutdown -h 12:30 &
[1] 4578
向所有登錄的用戶發出信息
1
2
3
4
[root@ansheng ~]# shutdown -k "now"
Broadcast message from root (pts/2) (Sat Jan 10 20:09:14 2015):
The system is going down to maintenance mode NOW!
Shutdown cancelled.
reboot
概要:
立即重啟系統
使用示例:
系統重啟
1
2
3
4
5
6
[root@ansheng ~]# reboot
Broadcast message from root@ansheng
(/dev/pts/0) at 21:19 ...
The system is going down for reboot NOW!
halt
概要:
立刻關機
使用示例:
關機
1
2
3
4
5
6
[root@ansheng ~]# halt
Broadcast message from root@ansheng
(/dev/pts/0) at 21:19 ...
The system is going down for halt NOW!
mii-tool
概要:
查看網卡接口的狀態
使用示例:
查看eth0是否啟用
1
2
[root@ansheng ~]# mii-tool eth0
eth0: negotiated 100baseTx-FD, link ok
eject
概要:
用于退出抽取式設備。
語法格式:
eject [-dfhnqrstv][-a ][-c ][設備]
參數:
參數
說明
-r
退出光盤
使用示例:
彈出光驅
1
[root@ansheng ~]# eject -r /dev/cdrom
chkconfig
概要:
查看設置開機自啟動服務
語法格式:
chkconfig [服務名] [–type type][name]
參數:
參數
概述
–list
查看所有服務狀態
–add
添加一個服務
–del
刪除一個服務
–level
啟動級別
–type
off/on
使用示例:
關閉iptables在所有模式下的自啟動
1
2
3
[root@ansheng ~]# chkconfig iptables off
[root@ansheng ~]# chkconfig --list|grep iptables
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
開啟iptables在2模式下啟動
1
2
3
[root@ansheng ~]# chkconfig --level 5 iptables on
[root@ansheng ~]# chkconfig --list|grep iptables
iptables 0:off 1:off 2:off 3:off 4:off 5:on 6:off
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的window计算的chk在linux下可以读,Linux系统命令从入门到完全忘记(四)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: login控件authenticate_
- 下一篇: 如何将对象中的内容按照一定的顺序进行排序