CMD attrib命令詳解

2022-07-18 22:24:17 字數 993 閱讀 3101

主要說明怎樣用attrib命令設定檔案唯讀、隱藏屬性。

attrib.exe為cmd下的乙個小程式,可以用來設定檔案的基本屬性(唯讀、隱藏、系統、存檔和無內容索引)。

我們大家先來看看它都有哪些引數。

c:\users\administrator>help attrib

顯示或更改檔案屬性。

attrib [+r | -r] [+a | -a ] [+s | -s] [+h | -h] [+i | -i]

[drive:][path][filename] [/s [/d] [/l]]

+ 設定屬性。

- 清除屬性。

r 唯讀檔案屬性。

a 存檔檔案屬性。

s 系統檔案屬性。

h 隱藏檔案屬性。

i 無內容索引檔案屬性。

[drive:][path][filename]

指定 attrib 要處理的檔案。

/s 處理當前資料夾及其所有子資料夾中的匹配檔案。

/d 也處理資料夾。

/l 處理符號鏈結和符號鏈結目標的屬性。

然後我們用例項來具體驗證。 

第一步,先建立乙個檔案:d:\2.txt

第二步,為d:\2.txt檔案新增乙個隱藏屬性和乙個唯讀屬性。

c:\users\administrator>attrib +r +h d:\2.txt

設定檔案屬性成功後,也不會有任何提示。

第三步,顯示d:\2.txt的檔案屬性。

c:\users\administrator>attrib d:\2.txt

a hr d:\2.txt

可以看到當前檔案中有存檔(a)、隱藏(h)、r(唯讀)三種屬性。可能想問,為什麼會有存檔(a)屬性呢?這個我也不太清楚,估計在使用建立檔案時,預設就有存檔(a)屬性了吧。

iptable 詳解 iptable命令詳解1

p protocal protocol 協議 j jump target i in inte ce name 入口 o out inte ce name 出口 f,fragment 分片 指定 p tcp時 source port port port 原埠 也作 sport destionation...

UNIX crontab命令詳解

crontab命令的功能是在一定的時間間隔排程一些命令的執行。在 etc目錄下有乙個crontab檔案,這裡存放有系統執行的一些排程程式。每個使用者可以建立自己的排程crontab。crontab命令有三種形式的命令列結構 crontab u user file crontab u user e l...

mount命令詳解

名稱 mount 使用許可權 系統管理者或 etc fstab中允許的使用者 使用方式 mount hv mount a ffnrsvw t vfstype mount fnrsvw o options device dir mount fnrsvw t vfstype o options devi...