1.命令 ls -al
表示列出所有文件的屬性 包括隱藏文件(就是文件名前面第一個字符為.的文件)
-rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 10758 06-17 01:05 command.txt
文件屬性 連接數(shù) 所屬用戶 所屬組 大小 最新修改時間 文件名
其中文件屬性 - rw- rw- r--
文件類型 所屬用戶的權(quán)限 所屬組的權(quán)限 其他非本用戶組的權(quán)限
文件類型:
-:文件
d:目錄
l:鏈接文件
b:設(shè)備文件中可供存儲的接口設(shè)備
c:設(shè)備文件中的串行端口設(shè)備,如鍵盤,鼠標
2.更改所屬用戶組:chgrp [-R] 用戶組名 文件
更改所屬用戶:chown [-R] 用戶:用戶組 文件
更改九個屬性:a:表示all
chmod [-R] u=rwx,go=rx 文件名
chmod a+w 文件名
chmod a-x 文件名
3.查看環(huán)境變量:echo $PATH
增加環(huán)境變量:PATH="$PATH":/sbin
4.通常用在shell腳本里面
[wuxiaoxiao@localhost ~]$ basename linux/command.txt :獲取文件名
command.txt
[wuxiaoxiao@localhost ~]$ dirname linux/command.txt :獲取文件夾名
linux
5.查看文件:
head -3 command.txt:查看文件前三行
tail -3 command.txt:查看文件后3行
cat -n command.txt:顯示行號
cat -A command.txt:將特殊字符也顯示出來(換行符是$,[tab]鍵是^I)
cat >1.txt (ctrl+c退出):將文件值空
cat 1.txt 2.txt:同時顯示倆個文件內(nèi)容
cat 1.txt 2.txt >3.txt:將兩個文件的內(nèi)容添加到3.txt中并覆蓋
cat 1.txt 2.txt >>3.txt:將兩個文件的內(nèi)容添加到3.txt中,追加在末尾
less -10(每頁顯示的行數(shù)) command.txt
([pageup],[pagedown]向上向下翻動頁;/字符串:向下搜索字符串;?字符串:向上搜索字符串;n:重復(fù)前一個搜索;q:退出)
6.文件與目錄的默認權(quán)限
r,w,x分別是4,2,1
文件的默認權(quán)限是- rw- rw- rw-(666)
目錄的默認權(quán)限是- rwx rwx rwx(777)
命令umask:指的是默認值需要減掉的權(quán)限
例如:
[wuxiaoxiao@localhost linux]$ umask
0002
[wuxiaoxiao@localhost linux]$ touch 1.txt
[wuxiaoxiao@localhost linux]$ mkdir xiaoxiao
[wuxiaoxiao@localhost linux]$ ls -l
總計 20
-rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 0 10-13 05:00 1.txt
drwxrwxr-x 2 wuxiaoxiao wuxiaoxiao 4096 10-13 05:00 xiaoxiao
重新設(shè)置:umask 022
7.文件隱藏屬性
設(shè)置文件隱藏屬性:chattr
i:讓一個文件不能被刪除,改名,設(shè)置鏈接,也無法寫入或者增加數(shù)據(jù)
a:文件只能增加數(shù)據(jù),不能刪除
chattr +i command.txt
chattr -i command.txt
查看文件的隱藏屬性
lsattr
8.file 文件名:可以查看文件的類型(二進制,純文本...)
9.which [-a] 執(zhí)行文件:尋找"執(zhí)行文件",根據(jù)PATH環(huán)境變量所規(guī)范的路徑查找
eg:which shutdown
-a:表示將所有找到的命令均列出
whereis 文件名:查找特定文件
eg:whereis passwd
任何與passwd有關(guān)的文件名都會被列出來
locate 文件名
locate command.txt
只要文件名中包含command.txt的都會列出來
表示列出所有文件的屬性 包括隱藏文件(就是文件名前面第一個字符為.的文件)
-rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 10758 06-17 01:05 command.txt
文件屬性 連接數(shù) 所屬用戶 所屬組 大小 最新修改時間 文件名
其中文件屬性 - rw- rw- r--
文件類型 所屬用戶的權(quán)限 所屬組的權(quán)限 其他非本用戶組的權(quán)限
文件類型:
-:文件
d:目錄
l:鏈接文件
b:設(shè)備文件中可供存儲的接口設(shè)備
c:設(shè)備文件中的串行端口設(shè)備,如鍵盤,鼠標
2.更改所屬用戶組:chgrp [-R] 用戶組名 文件
更改所屬用戶:chown [-R] 用戶:用戶組 文件
更改九個屬性:a:表示all
chmod [-R] u=rwx,go=rx 文件名
chmod a+w 文件名
chmod a-x 文件名
3.查看環(huán)境變量:echo $PATH
增加環(huán)境變量:PATH="$PATH":/sbin
4.通常用在shell腳本里面
[wuxiaoxiao@localhost ~]$ basename linux/command.txt :獲取文件名
command.txt
[wuxiaoxiao@localhost ~]$ dirname linux/command.txt :獲取文件夾名
linux
5.查看文件:
head -3 command.txt:查看文件前三行
tail -3 command.txt:查看文件后3行
cat -n command.txt:顯示行號
cat -A command.txt:將特殊字符也顯示出來(換行符是$,[tab]鍵是^I)
cat >1.txt (ctrl+c退出):將文件值空
cat 1.txt 2.txt:同時顯示倆個文件內(nèi)容
cat 1.txt 2.txt >3.txt:將兩個文件的內(nèi)容添加到3.txt中并覆蓋
cat 1.txt 2.txt >>3.txt:將兩個文件的內(nèi)容添加到3.txt中,追加在末尾
less -10(每頁顯示的行數(shù)) command.txt
([pageup],[pagedown]向上向下翻動頁;/字符串:向下搜索字符串;?字符串:向上搜索字符串;n:重復(fù)前一個搜索;q:退出)
6.文件與目錄的默認權(quán)限
r,w,x分別是4,2,1
文件的默認權(quán)限是- rw- rw- rw-(666)
目錄的默認權(quán)限是- rwx rwx rwx(777)
命令umask:指的是默認值需要減掉的權(quán)限
例如:
[wuxiaoxiao@localhost linux]$ umask
0002
[wuxiaoxiao@localhost linux]$ touch 1.txt
[wuxiaoxiao@localhost linux]$ mkdir xiaoxiao
[wuxiaoxiao@localhost linux]$ ls -l
總計 20
-rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 0 10-13 05:00 1.txt
drwxrwxr-x 2 wuxiaoxiao wuxiaoxiao 4096 10-13 05:00 xiaoxiao
重新設(shè)置:umask 022
7.文件隱藏屬性
設(shè)置文件隱藏屬性:chattr
i:讓一個文件不能被刪除,改名,設(shè)置鏈接,也無法寫入或者增加數(shù)據(jù)
a:文件只能增加數(shù)據(jù),不能刪除
chattr +i command.txt
chattr -i command.txt
查看文件的隱藏屬性
lsattr
8.file 文件名:可以查看文件的類型(二進制,純文本...)
9.which [-a] 執(zhí)行文件:尋找"執(zhí)行文件",根據(jù)PATH環(huán)境變量所規(guī)范的路徑查找
eg:which shutdown
-a:表示將所有找到的命令均列出
whereis 文件名:查找特定文件
eg:whereis passwd
任何與passwd有關(guān)的文件名都會被列出來
locate 文件名
locate command.txt
只要文件名中包含command.txt的都會列出來