linux初探-linux常用命令

1. ls 查看文件命令
linux初探-linux常用命令

如pwd命令查看當前目錄所在地爲根目錄下在ls下可以看到當前目錄的文件夾,ls - ll
爲查看目錄的各屬性、權限,也可以後跟路徑查看相關路徑下的文件

linux初探-linux常用命令

**2.pwd 查看當時的目錄所在地上圖已示

3.cd 移動路徑**

cd / cd.. cd ~ cd
移動到根目錄 移動到上個目錄 進入用戶主目錄 移動到想去的目錄

cd /
linux初探-linux常用命令

cd..

linux初探-linux常用命令

cd ~

linux初探-linux常用命令

4.mkdir 新建文件夾

linux初探-linux常用命令

5.rm rmdir 刪除、刪除文件夾
rm -rf 強制刪除命令,不帶任何提示,請謹慎使用

linux初探-linux常用命令

6.touch 新建文件
linux初探-linux常用命令

7.echo、重定向、cat

linux初探-linux常用命令

覆蓋數據
追加數據
echo加重定向文件寫入數據 不加直接打印
cat 查看文件內容

cat>>2.txt<<Dchen (以Dchen字符爲結束追加)
linux初探-linux常用命令

cho hello world >1.txt 2>&1 (錯誤和正確的放一個文件)

cho hello world &>1.txt (同理)

8.find 查找文件

linux初探-linux常用命令

find /data -type f -name 'print.txt' 查找文件名

find /data -type f -name 'p*.txt' 模糊查找文件

find /data -type f -name "a.txt" -exec rm {} \; 排序查刪
9.cp 拷貝
linux初探-linux常用命令

10.mv移動

linux初探-linux常用命令

11.|管道

find -type f (-f爲文件 -d爲目錄)-name '*.log' -mtime +15|xargs rm -f

12.grep篩選查找文件
linux初探-linux常用命令

13.head讀取文件頭內容
linux初探-linux常用命令
head -number file (number數不加默認10行)

轉載於:https://blog.51cto.com/12741079/2130601