關(guān)鍵字:linux文件屬性和目錄配置
1.命令 ls -al
表示列出所有文件的屬性 包括隱藏文件(就是文件名前面第一個(gè)字符為.的文件)
-rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 10758 06-17 01:05 command.txt
文件屬性 連接數 所屬用戶(hù) 所屬組 大小 最新修改時(shí)間 文件名
其中文件屬性 - rw- rw- r--
文件類(lèi)型 所屬用戶(hù)的權限 所屬組的權限 其他非本用戶(hù)組的權限
文件類(lèi)型:
-:文件
d:目錄
l:鏈接文件
b:
設備文件中可供存儲的接口設備
c:設備文件中的串行端口設備,如鍵盤(pán),鼠標
2.更改所屬用戶(hù)組:chgrp [-R] 用戶(hù)組名 文件
更改所屬用戶(hù):chown [-R] 用戶(hù):用戶(hù)組 文件
更改九個(gè)屬性: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:將特殊字符也顯示出來(lái)(換行符是$,[t
ab]鍵是^I)
cat >1.txt (ctrl+c退出):將文件值空
cat 1.txt 2.txt:同時(shí)顯示倆個(gè)文件內容
cat 1.txt 2.txt >3.txt:將兩個(gè)文件的內容添加到3.txt中并覆蓋
cat 1.txt 2.txt >>3.txt:將兩個(gè)文件的內容添加到3.txt中,追加在末尾
less -10(每頁(yè)顯示的行數) command.txt
([pageup],[pagedown]向上向下翻動(dòng)頁(yè);/字符串:向下搜索字符串;?字符串:向上搜索字符串;n:重復前一個(gè)搜索;q:退出)
6.文件與目錄的默認權限
r,w,x分別是4,2,1
文件的默認權限是- rw- rw- rw-(666)
目錄的默認權限是- rwx rwx rwx(777)
命令umask:指的是默認值需要減掉的權限
例如:
[wuxiaoxiao@localhost linux]$ umask
0
002[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 w