Linux 基本命令

2021-08-29 02:34:43 字數 2596 閱讀 1032

pwd -p 返回鏈結的真實路徑

ls -a 顯示所有目錄

ls -l

ls -ld /root 檢視當前目錄的自身資訊

ls -lh 個性顯示資訊

ls -lc 檢視檔案的屬性變更時間

ls -lu 最後訪問時間

ls -lt 安裝修改時間排序

建立檔案 如果檔案存在,更新檔案修改時間

mkdir -p /tmp/test/joer/book/computer
cp + 原始檔 + 目標檔案

cp -r 遞迴 複製子檔案及子目錄

rm -f 強制刪除

rm -r 刪除所有的內容

mv hello.txt hello.doc 重新命名

mv hello.txt /temp/ 放到目錄下

find -name 按名稱查詢

find -iname 按名稱查詢 不區分大小寫

find -mtime 按修改時間查詢

find -size 按容量大小查詢

find -type 按型別查詢 檔案(f型別),目錄(d型別),裝置(b,c型別),鏈結(l型別)

find -user 按使用者查詢

find -exec 查詢過程中執行的命令

find -a 並且

find -o 或

find /size +10m -a type f

find /size +10m -exec ls -l {} ;

查詢所有三天內被修改過的檔案:

find / -mtime -3
查詢/root目錄下所有。txt結尾的檔案

find /root -name "*.txt"
du -sh /root

檢視/root 所佔磁碟空間容量

-n 顯示檔案末尾的n行

-f 動態顯示檔案內容

tail -f /var/log/messages 檢視日誌

head -n

grep th hello.txt

grep -i 忽略大小寫

grep -v 取反

gerp -w 匹配單詞的

例子:

將/etc/passwd,有出現root的行取出來(兩種方法)

1.grep root /etc/passwd

2.cat /etc/passwd | grep root

將/etc/passwd,將沒有出現root的行取出來

grep -v root /etc/passwd
將/etc/passwd,將沒有出現root和nologin的行取出來

grep -v root /etc/passwd | grep -v nologin
將/etc/passwd,我想要搜尋test和taste 這兩個單曲

grep -n 't[ae]st' test.txt

這個表裡面無論有多少個字元,都僅代表乙個字元

將/test.txt,想要搜尋有oo的字元,但是oo前面不能有g

grep -n '[^g]oo' test.txt
將/test.txt,前面不能有英文本元行

grep -n '^[^a-za-z]' test.txt
將/test.txt,我只想要讓the只在行首的行

grep -n '^the' test.txt
^ 行首

$ 行尾

請找出test.txt檔案中空白行

grep -n '^$' test.txt
.代表的任意乙個字元

*重複前乙個字元

-c 建立壓縮檔案

-r 追加至壓縮檔案

-t 列出壓縮檔案的內容

-x 解包檔案

–delete 從打包文件中刪除檔案

選項:-c 指定解壓的路徑

-f 指定打包後的檔名稱

-j 通過bzip2格式壓縮

-z 通過gzip格式壓縮

將/etc/目錄打包並儲存為etc.tar檔案

tar -cf etc.tar /etc
將boot目錄打包並壓縮為boot.tar.gz

tar -czf boot.tar.gz /boot/
追加檔案至已經打包好的檔案中

tar -f 檔名 -r /root/hello.txt
tar -xzf 檔名 -c /tmp 指定解壓路徑

從打包文件中刪除檔案

tar --delete etc/hosts -f etc.tar

which

which find

linux基本命令

linux常用命令 基礎 eg man ls 就可以檢視ls相關的用法 注 按q鍵或者ctrl c退出,在linux下可以使用ctrl c終止當前程式執行。2.ls 檢視目錄或者檔案的屬 列舉出任一目錄下面的檔案 eg ls usr man ls l a.d表示目錄 directory 如果是乙個 ...

《linux基本命令》

博主部落格 斷橋殘雪 uname 顯示版本資訊 同win2k的 ver dir 顯示當前目錄檔案,ls al 顯示包括隱藏檔案 同win2k的 dir pwd 查詢當前所在的目錄位置 cd cd 回到上一層目錄,注意cd 與.之間有空格。cd 返回到根目錄。cat 檔名 檢視檔案內容 cat abc...

LINUX 基本命令

檔案和目錄操作的基本命令 cat clear cmp cut diff du emacs fgrep file grep head ln less more pico pwd sort stat strings tail touch umask uniq vi wc whatis ls ls 選項 ...