cd /home/tarena 切換到/home/tarena目錄下
cd .. 進(jìn)入上級(jí)目錄
cd ./tarena 進(jìn)入當(dāng)前目錄下的tarena目錄里面
cd ~ 進(jìn)入主目錄
cd / 進(jìn)入根目錄
顯示目錄內(nèi)容:ls
ls -a,顯示全部?jī)?nèi)容,包括隱藏文件
ls -l,顯示詳細(xì)信息,包括文件屬性
ls /home/tarenacd 查看/home/tarena目錄下的內(nèi)容
ls -l /home/tarena 查看/home/tarena目錄里面內(nèi)容的詳細(xì)信息
ls /usr/include/stdio.h 查看此文件是否存在
ls -l /usr/include/stdio.h查看此文件的詳細(xì)信息
ls 查看當(dāng)前目錄下的內(nèi)容
ls -l 查看當(dāng)前目錄下內(nèi)容的詳細(xì)信息
ls ..查看上一級(jí)目錄里面內(nèi)容的詳細(xì)信息
ls -l .. 查看上一級(jí)目錄里面內(nèi)容的詳細(xì)信息
ls stdio.h 查看當(dāng)前目錄下是否存在stdio.h文件
ls -l stdio.h 查看當(dāng)前目錄下stdio.h文件的詳細(xì)信息
ls ~查看主目錄里面的內(nèi)容
ls -l ~查看主目錄里面內(nèi)容的詳細(xì)信息
ls / 查看根目錄里面的內(nèi)容
ls -l / 查看根目錄里面內(nèi)容的詳細(xì)信息
mkdir /home/tarena/mvtest
cd /home/tarena/mvtest
touch hello.txt
mkdir hello
ls
mv hello.txt hello.txt
ls
mv hello.txt hello1
ls
ls hello1
mkdir hello2
ls
mv hello2 hello1
ls
ls hello1
刪除:rm
刪除文件:rm 文件1 文件2 ……文件n
刪除目錄:rm -fr 目錄1 目錄2 ……目錄n
rm /home/tarenacd/hello.txt
cd /home/tarena
rm -fr mvtest
ls /home/tarena/hello.txt
ls /home/tarena/cptest
sudo rm -fr //使用管理員權(quán)限強(qiáng)制刪除
mkdir -p /home/tarena/tartest/hello
cd /home/tarena/tartest/hello
touch hello.txt
echo 1234>> hello.txt
cd ..
ls
tar -jcvf hello.tar.bz2 hello
tar -zcvf hello.tar.gz hello
ls
rm -fr hello
tar -xvf hello.tar.bz2
rm -fr hello
tar -xvf hello.tar.gz
cat hello/hello.txt
文件詳細(xì)信息
- rwx rw- r-- 1 root root 6 jul 25 11:48 myfile
- --- --- --- - ---- ---- - ----------- -----
A B. C. D. E. F. G. H I. J
A:文件類型,d(目錄)/-(普通)/1(軟鏈接)
B:屬主權(quán)限,r(讀)/w(寫(xiě))/x(執(zhí)行)/-(無(wú))
C:同組權(quán)限,r(讀)/w(寫(xiě))/x(執(zhí)行)/-(無(wú))
D:其他權(quán)限,r(讀)/w(寫(xiě))/x(執(zhí)行)/-(無(wú))
E:硬鏈接數(shù),文件的別名
F:屬主的名稱
G:屬組的名稱
H:字節(jié)數(shù)
I:最后的修改時(shí)間
J:文件名
針對(duì)目錄的寫(xiě)權(quán)限:在該目錄下增刪字目錄或文件
針對(duì)目錄的執(zhí)行權(quán)限:訪問(wèn)該目錄下的內(nèi)容
文件通配符
*
通配若干任意字符:ls*.txt
?
通配 一個(gè)任意字符:ls file_?.txt
[]
通配一個(gè)在特定字符集中的字符:ls file_[a-c].txt
mdkir /home/tarena/file
cd /home/tarena/file
touch file_1.txt
touch file_2.txt
touch file_a.txt
touch file_11.txt
touch file_b.txt
touch file_aa.txt
ls *.txt
ls file_?.txt
ls file_[a-z].txt
ls file_[0-9][0-9].txt