Linux筆記(一):基本命令

{"type":"doc","content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"前言: 每個知識都是一個無底洞,切記被淹沒在知識的海洋裏,找不到上岸的路!","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我學習linux不過是想彌補下前端的發佈流程的空缺而已.","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"No鼠標,該如何操控文件?","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"首先在Linux中有個重要的概念,一切文件(文件夾是一種特殊的文件)","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果你是一名windows用戶善用鼠標操作的話,也許是個挑戰。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"但是你的四大基本需求我想是不會變的。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"查看,新增,修改,刪除","attrs":{}}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"查看","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# 查看當前工作目錄 pring working directory pwd\npwd\n\n# 查看工作目錄的內容 list show ls\nls\nls -a # 查看隱藏文件 all\nls -l # 長格式顯示內容 long\nls -r # 逆序顯示 reverse(逆序)\nls -t # 按時間順序顯示 time\nls -R # 遞歸顯示所有文件 recursive(遞歸)\n## 參數是可以合併使用,例如:\nls -alrtR\n\n# 控制檯翻滾查看\n## shift+PgUp 向前翻看,一般翻13頁左右。\n## shift+PgDown 向後翻看,一般翻13頁左右。","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新增","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# 創建文件夾 make directory mkdir\nmkdir a\nmkdir a b c # 創建多個文件夾\nmkdir -p a/b/c/d # 逐層創建問個文件夾\n\n# 創建文件 \ntouch a.js\ntouch a.py b.js c.txt\n","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"刪除","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# 刪除文件夾 remove directory rmdir\nrmdir a\nrmdir a b c # 刪除多個文件夾\n\n# 刪除文件 remove rm\nrm test.js # 刪除文件\nrm -r test1.js # 刪除文件\nrm -r a # 刪除a文件夾以及內部的所有文件\nrm -f test2.js # 強制刪除文件(不進行詢問) force\n","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"修改","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# 移動 move mv\nmv j.js a.js # 將j.js 改名爲 a.js\nmv *.js e/ # 將所有帶有.js文件的 移動到 e/目錄下面\n\n# 複製 copy cp\ncp test.js e/ # 將test.js 文件複製到 e/目錄下面去\ncp test.js e/mod.js # 將test.js 文件複製到 e/目錄中去 然後改名稱爲 mod.js\ncp fold e/ -r # 複製文件夾裏所有的內容包括該文件夾 至 e/目錄中去","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"【批量操作】通配符:因爲沒有鼠標所以你只能通過正則表示這個技能進行批量操作","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"* 匹配任意字符","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"? 匹配1個字符","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"[XYZ] 匹配這些內容","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"[A-Z] 匹配該範圍","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"[!A] 或 [^a] 不匹配","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"如何查看文件內容","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"cat:⽂文本內容顯示到終端","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"head:查看⽂文件開頭","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"tail:查看⽂文件末尾","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"常⽤用參數-f⽂文件內容更更新後,顯示信息同步更更新","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"wx:統計⽂文件內容信息","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"打包和壓縮、解壓","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"打包","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"tar cf etc-backup.tar /etc -v\n# c 打包\n# f 指定操作類型爲⽂文件\n# -v 顯示打包的過程\n# tar 這個命令的option不需要加-,而且順序和之前的不同","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"壓縮","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# 可使用 gzip bzip2 進行打包\n# 也可以是用tar命令(集成的壓縮)\n# -z gzip 格式壓縮和解壓縮\n# -j bzip2 格式壓縮和解壓縮\n\ntar czf etc-backup.tar.gz /etc\n\ntar cjf etc-backup.tar.bz2 /etc","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"解壓","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"codeblock","attrs":{"lang":"shell"},"content":[{"type":"text","text":"# 打包的逆操作\n# x解壓縮\ntar xf etc-backup.tar -C a/ # -C 指定目錄否則解壓縮至當前目錄下\n\ntar jxf etc-backup.tar.bzip2\n\ntar zxf etc-backup.tar.gizp","attrs":{}}]},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"tips:","attrs":{}}]}],"attrs":{}},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":".tar.gz ---> .tgz","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":".tar.bz2 ---> .tbz2","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"總結:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一切皆文件","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"操作無非 增/刪/改/查","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"批量操作用正則來解決","attrs":{}}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":1,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"打包壓縮tar/gizp/bzip2","attrs":{}}]}],"attrs":{}}],"attrs":{}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/12/12380d3031720ee0a9f92bea120cb521.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"http://assets.processon.com/chart_image/5fbf63825653bb1d54fbc405.png","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"參考:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://blog.csdn.net/qq_22918577/article/details/46976041","title":""},"content":[{"type":"text","text":"linux命令行終端的翻屏滾屏","attrs":{}}]}]}],"attrs":{}},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://github.com/geektime-geekbang/geekbanglinux/blob/master/ppt/2%E3%80%81%E7%B3%BB%E7%BB%9F%E6%93%8D%E4%BD%9C%E7%AF%87.pdf","title":""},"content":[{"type":"text","text":"2、系統操作篇.pdf","attrs":{}}]}]}],"attrs":{}}],"attrs":{}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章