cd /home/tarena 切換到/home/tarena目錄下
cd .. 進入上級目錄
cd ./tarena 進入當前目錄下的tarena目錄里面
cd ~ 進入主目錄
cd / 進入根目錄
顯示目錄內容:ls
ls -a,顯示全部內容,包括隱藏文件
ls -l,顯示詳細信息,包括文件屬性
ls /home/tarenacd 查看/home/tarena目錄下的內容
ls -l /home/tarena 查看/home/tarena目錄里面內容的詳細信息
ls /usr/include/stdio.h 查看此文件是否存在
ls -l /usr/include/stdio.h查看此文件的詳細信息
ls 查看當前目錄下的內容
ls -l 查看當前目錄下內容的詳細信息
ls ..查看上一級目錄里面內容的詳細信息
ls -l .. 查看上一級目錄里面內容的詳細信息
ls stdio.h 查看當前目錄下是否存在stdio.h文件
ls -l stdio.h 查看當前目錄下stdio.h文件的詳細信息
ls ~查看主目錄里面的內容
ls -l ~查看主目錄里面內容的詳細信息
ls / 查看根目錄里面的內容
ls -l / 查看根目錄里面內容的詳細信息
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 //使用管理員權限強制刪除
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
文件詳細信息
- 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:屬主權限,r(讀)/w(寫)/x(執行)/-(無)
C:同組權限,r(讀)/w(寫)/x(執行)/-(無)
D:其他權限,r(讀)/w(寫)/x(執行)/-(無)
E:硬鏈接數,文件的別名
F:屬主的名稱
G:屬組的名稱
H:字節數
I:最后的修改時間
J:文件名
針對目錄的寫權限:在該目錄下增刪字目錄或文件
針對目錄的執行權限:訪問該目錄下的內容
文件通配符
*
通配若干任意字符:ls*.txt
?
通配 一個任意字符:ls file_?.txt
[]
通配一個在特定字符集中的字符: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