linux shell 學習摘記(3)
《linux shell 指令碼程式設計攻略 (第2版)》 第三章 “以檔案之名” 筆記
常用命令:
comm
,chmod/chown
,chattr
,touch
,列出目錄的相關命令
,readlink
,file
,<<<
,dd
,有關光碟的各類命令
,mkfs.ext4
,mkisofs
,isohybrid
,mount/umount
,fdisk
,loseup
,sync
,cdrecord
,eject
,diff
,patch
,seq
,tail
,dmesg
,pidof
,pushd/popd
,wc
,tree
comm A.txt B.txt -2 -3
刪除第二列和第三列,保留只在A.txt中出現的行檔案許可權
chmod u=rwx g=rw o=r filename
, 即chmod 764 filename
chown USER.GROUP filename
修改使用者名稱和組chmod a+t directoryname
給目錄設定粘滯位(只有目錄的所有者才能刪除目錄中的檔案)chmod +s executablefile
允許其他使用者以檔案所有者的身份來執行檔案(setuid),只能應用於Linux ELF格式二進位制檔案上chattr +i file
將檔案設定為不可修改,chattr -i file
移除不可修改屬性
touch -d "2016-09-22" filename
也用-c -m
引數,表示更改檔案訪問時間和內容修改時間ls -s target symboliclinkname
,ls -l | grep "^1"
,find . -type l -print
readlink symboliclinkname
file -b filename
<<<
可以將字串作為輸入檔案 此處有程式碼loopback(環迴檔案)是指那些在檔案中而非物理裝置中建立的檔案系統,可以將這些檔案掛載到掛載點上(在物理磁碟中建立邏輯磁碟。
dd if=/dev/zero of=loopbackfile.img bs=1G count=1
mkfs.ext4 loopbackfile.img
mount -o loop loopbackfile.img /mnt/loopback
掛載環迴檔案系統(連線到名為/dev/loop1或loop2上)或者手動losetup /dev/loop1 loopbackfile.img && mount /dev/loop1 /mnt/loopback
umout /mnt/loopback
或umount /dev/loop1
在環回映象中建立分割槽(並掛在其中一個分割槽)
losetup /dev/loop1 loopback.img
fdisk /dev/loop1
建立分割槽losetup -o 32256 /dev/loop2 loopback.img
掛載第一個分割槽
ISO檔案作為環迴檔案掛載
mount -o loop linux.iso /mnt/iso
sync
生成ISO檔案,
dd if=/dev/cdrom of=image.iso
(建立iso映象)或者mkisofs -V "Label" -o image.iso sourcedir
(建立ISO檔案系統)將可引導的ISO檔案寫入USB裝置來換成混合ISO
isohybrid image.iso
獲得混合image.isodd if=image.iso of=/dev/sdb1
或者cat image.iso /dev/sdb1
燒錄ISO
cdrecord -v dev=/dev/cdrom image.iso
, 加引數-speed 8
表示燒錄速度為8x; 多區段燒錄cdrecord -v dev=/dev/cdrom image.iso -multi
eject
,eject -t
命令列開啟/關閉光碟機diff -u file1.txt file2.txt > version.path
,patch -p1 file1.txt < version.path
(對已修補過的檔案進行修補將會撤銷修改)diff -Naur
-a 將所有檔案視為文字檔案, -u 生成一體化輸出, -r 遍歷目錄下的所有檔案, -N 將所有確實檔案視為空檔案seq 100 | tail -n 5
,tail -n +M
列印第M行及之後的行,dmesg | tail -f -s 2
dmesg檢視核心的環形緩衝區訊息,每隔2秒,PID=$(pidof Foo) && tail -f file --pid $PID
程式技術後tail也會結束列出目錄
ls -d */
,ls -F | grep "/$"
,ls -l | grep "^d"
,find. -type d -maxdepth 1 -print
多個目錄間來回切換
pushd /var/www
,pushd /usr/scr
(壓入並切換路徑),pushd +3
切換路徑(從0開始),popd
刪除最後新增的路徑並切換至該目錄,popd +3
移除特定的路徑並切換wc file
(列印出檔案行數,單詞書,字元數)列印目錄樹
tree . -P "*.md"
顯示出匹配某種樣式的檔案,tree . -I "*.md~"
顯示不匹配某種樣式的檔案,tree . -h
列印出檔案和目錄大小,tree . -H http://localhost -o out.html
相關文章
- linux shell 學習摘記(4)Linux
- linux shell 學習摘記(5)Linux
- linux shell 學習摘記(6)Linux
- linux shell 學習摘記(7)Linux
- linux shell 學習摘記(8)Linux
- linux shell 學習摘記(9)Linux
- linux shell 學習摘記(1)Linux
- linux shell 學習摘記(2)Linux
- Linux Shell 程式設計學習筆記Linux程式設計筆記
- shell學習筆記筆記
- shell學習總結-3
- 【Linux學習筆記29】shell指令碼基礎Linux筆記指令碼
- 《Shell指令碼學習指南》學習筆記指令碼筆記
- Linux學習(Shell基礎)Linux
- Shell指令碼學習筆記指令碼筆記
- Shell 學習筆記 基礎筆記
- lftp學習備記錄--轉摘於網上FTP
- Linux學習-shell基礎02Linux
- Linux學習之(shell展開)Linux
- shell指令碼學習筆記-1指令碼筆記
- linux shell陣列深入學習理解Linux陣列
- Linux命令和shell指令碼學習Linux指令碼
- 前端學習 linux —— shell 程式設計前端Linux程式設計
- Linux Shell 學習資料推薦Linux
- MongoDB 學習筆記之常用 shell 命令MongoDB筆記
- Shell學習筆記_時間計算筆記
- 如何學習shell程式設計?Linux運維學習shell程式設計是什麼程式設計Linux運維
- 什麼是shell指令碼?Linux為什麼學習shell?指令碼Linux
- 強化學習-學習筆記3 | 策略學習強化學習筆記
- 【學習】Linux Shell指令碼程式設計Linux指令碼程式設計
- Linux學習之路(三)Shell指令碼初探Linux指令碼
- Linux Bash Shell學習(十):流程控制——forLinux
- 《dive into python3》 筆記摘錄Python筆記
- Vue學習筆記3Vue筆記
- Thymeleaf 3學習筆記筆記
- CCNA學習筆記3筆記
- [Shell] awk學習(3)-regular expression 正規表示式Express
- 學習Shell 教程