主頁 > 作業系統 > 快速上手Linux核心命令(九):檔案備份與壓縮

快速上手Linux核心命令(九):檔案備份與壓縮

2023-04-28 12:38:53 作業系統

目錄
  • tar 打包備份
  • gzip 壓碩訓解壓檔案
  • zip 打包和壓縮檔案
  • unzip 解壓zip檔案
  • scp 遠程檔案復制
  • rsync 檔案同步工具

這期呢主要說一說Linux中檔案備份與壓縮命令,一共6個命令,這6個命令都是平常作業中非常非常常用的,

tar 打包備份

1、簡介

tar 可以將多個檔案壓縮打包、壓縮,是作業中經常用到的命令

2、語法格式

tar [引數選項] [檔案或目錄]

3、引數說明

引數 引數說明
z 通過gzip壓碩訓解壓
c 創建新的tar包
v 顯示詳細的tar命令執行程序
f 指定壓縮檔案名字
t 不解壓查看tar包的內容
p 保持檔案的原有屬性
j 通過bzip2命令壓碩訓解壓
x 解開tar包
C 指定解壓的目錄路徑
--exclude=PATTERN 打包時排除不需要處理的檔案或目錄
-h 打包軟連接檔案指向的真實源檔案
-hard-dereference 打包硬鏈接檔案

4、實踐操作

① 打包博客檔案(將/home/hexoBlog 打包成hexoBlog.tar.gz)

[root@xiezhr home]# tar zcvf hexoBlog.tar.gz hexoBlog
hexoBlog/
hexoBlog/page/
hexoBlog/page/3/
hexoBlog/page/3/index.html
hexoBlog/page/2/
hexoBlog/page/2/index.html
hexoBlog/contact/
hexoBlog/contact/index.html
hexoBlog/baidusitemap.xml
hexoBlog/movies/
hexoBlog/movies/index.html
hexoBlog/images/
hexoBlog/images/0.jpg
hexoBlog/images/2020年年終總結.jpg
hexoBlog/archives/
hexoBlog/archives/87a8e6ef.html
hexoBlog/archives/93a2b0e4.html
hexoBlog/archives/b55ad976.html
hexoBlog/archives/page/
hexoBlog/archives/page/3/

[root@xiezhr home]# ll 
drwxr-xr-x 30 git    git        4096 Jun  6 20:42 hexoBlog
-rw-r--r--  1 root   root   43478804 Jun 14 22:43 hexoBlog.tar.gz

② 不解壓查看壓縮包的內容

[root@xiezhr home]# tar ztvf hexoBlog.tar.gz 
drwxr-xr-x git/git           0 2022-06-06 20:42 hexoBlog/
drwxr-xr-x git/git           0 2022-02-26 16:43 hexoBlog/page/
drwxr-xr-x git/git           0 2022-06-03 14:57 hexoBlog/page/3/
-rw-r--r-- git/git       56427 2022-06-03 14:57 hexoBlog/page/3/index.html
drwxr-xr-x git/git           0 2022-06-03 14:57 hexoBlog/page/2/
-rw-r--r-- git/git       63574 2022-06-03 14:57 hexoBlog/page/2/index.html
drwxr-xr-x git/git           0 2022-06-03 14:57 hexoBlog/contact/
-rw-r--r-- git/git       43745 2022-06-03 14:57 hexoBlog/contact/index.html
-rw-r--r-- git/git        4169 2022-06-03 14:57 hexoBlog/baidusitemap.xml
drwxr-xr-x git/git           0 2022-06-03 14:57 hexoBlog/movies/
-rw-r--r-- git/git       43246 2022-06-03 14:57 hexoBlog/movies/index.html
drwxr-xr-x git/git           0 2021-02-13 19:32 hexoBlog/images/
-rw-r--r-- git/git      570852 2020-11-29 16:42 hexoBlog/images/0.jpg
-rw-r--r-- git/git      133945 2021-02-13 19:32 hexoBlog/images/2020年年終總結.jpg
drwxr-xr-x git/git           0 2022-06-06 20:42 hexoBlog/archives/
-rw-r--r-- git/git       97587 2022-06-03 14:57 hexoBlog/archives/87a8e6ef.html

③ 解壓檔案到指定目錄

[root@xiezhr home]# tar -zxvf hexoBlog.tar.gz -C /home/test/
hexoBlog/
hexoBlog/page/
hexoBlog/page/3/
hexoBlog/page/3/index.html
hexoBlog/page/2/
hexoBlog/page/2/index.html
hexoBlog/contact/
hexoBlog/contact/index.html
hexoBlog/baidusitemap.xml
hexoBlog/movies/
hexoBlog/movies/index.html
hexoBlog/images/
hexoBlog/images/0.jpg
hexoBlog/images/2020年年終總結.jpg
hexoBlog/archives/
hexoBlog/archives/87a8e6ef.html

[root@xiezhr home]# cd /home/test/
[root@xiezhr test]# ll
total 1
drwxr-xr-x 30 git    git      4096 Jun  6 20:42 hexoBlog

④ 排除指定檔案后打包

# hexoBlog/books 目錄下的檔案將被排除后打包
[root@xiezhr home]#  tar zcvf hexoBlog.tar.gz  hexoBlog --exclude=hexoBlog/books
hexoBlog/
hexoBlog/page/
hexoBlog/page/3/
hexoBlog/page/3/index.html
hexoBlog/page/2/
hexoBlog/page/2/index.html

⑤ 使用-h引數打包鏈接檔案

[root@xiezhr etc]# tar zcfh local_h.tar.gz ./rc.local 
[root@xiezhr etc]# tar tfv local_h.tar.gz 
-rwxr-xr-x root/root       749 2022-03-22 09:10 ./rc.local

tar 使用小結

  • 打包一個目錄時,一般需要進入到目錄的上級目錄,然后再執行打包命令,解壓時需要非常注意,檔案是否會覆寫原檔案

  • 打包記憶:**tar zcvf /路徑/籃子.tar.gz 相對路徑/雞蛋 ** 【把雞蛋放到籃子里】

gzip 壓碩訓解壓檔案

1、簡介

gzip 命令用于將一個大的檔案通過壓縮演算法變成一個小檔案,

注意: gzip 命令不能直接壓縮目錄,如果要壓縮目錄時,先要用tar 將目錄打包成一個檔案,然后tar 再呼叫gzip壓縮

2、語法格式

gzip [引數選項] [檔案]

3、引數說明

引數 引數說明
-d 解壓檔案
-v 顯示命令執行的程序
-l 列出壓縮檔案的內容資訊
-c 將內容輸出到標準輸出,不改變原始檔案
-r 對目錄下的所有檔案遞回進行壓縮
-數字<1-9> 指定壓縮率,默認是6,值越大壓縮率越高
-t 測驗,檢查壓縮檔案是否完整

4、實踐操作

① 把目錄下的每個檔案都單獨壓縮成.gz檔案

[root@xiezhr dir3]# ls
a.txt  b.txt  c.txt  money.java  test.java  test.txt  tt.txt  user.java  xiezhr.java  xiezhr.txt
[root@xiezhr dir3]# gzip *.txt
[root@xiezhr dir3]# ls
a.txt.gz  b.txt.gz  c.txt.gz  money.java  test.java  test.txt.gz  tt.txt.gz  user.java  xiezhr.java  xiezhr.txt.gz

② 不解壓顯示壓縮檔案資訊

[root@xiezhr dir3]# gzip -l xiezhr.txt.gz 
         compressed        uncompressed  ratio uncompressed_name
                 31                   0   0.0% xiezhr.txt

③解壓檔案,并顯示解壓程序

[root@xiezhr dir3]# ls
a.txt.gz  b.txt.gz  c.txt.gz  money.java  test.java  test.txt.gz  tt.txt.gz  user.java  xiezhr.java  xiezhr.txt.gz
[root@xiezhr dir3]# gzip -dv *.gz
a.txt.gz:         0.0% -- replaced with a.txt
b.txt.gz:         0.0% -- replaced with b.txt
c.txt.gz:         0.0% -- replaced with c.txt
test.txt.gz:     15.9% -- replaced with test.txt
tt.txt.gz:        0.0% -- replaced with tt.txt
xiezhr.txt.gz:    0.0% -- replaced with xiezhr.txt
[root@xiezhr dir3]# ls
a.txt  b.txt  c.txt  money.java  test.java  test.txt  tt.txt  user.java  xiezhr.java  xiezhr.txt

注: 以上實踐我們看到gzip命令在壓縮和解壓檔案時,都會把源檔案洗掉,當然也有其他方法可以解決這個問題,但是使用起來有點麻煩,

zip 打包和壓縮檔案

1、簡介

zip 壓縮格式是Windows和Linux通用的壓縮格式,和gzip命令相比,zip命令壓縮檔案不會洗掉源檔案,還可以壓縮目錄,所以相比gzip命令,我們使用zip命令會更多一些

2、語法格式

zip [引數選項] [檔案或目錄]

3、引數說明

引數 引數說明
-r 指定目錄下的所有檔案和子目錄一并壓縮
-x 壓縮檔案時排除某個檔案
-q 不顯示壓縮資訊

4、實踐操作

① 壓縮檔案

[root@xiezhr testdir]# ls
xiezhr.txt
[root@xiezhr testdir]# zip xiezhr.zip xiezhr.txt 
  adding: xiezhr.txt (deflated 17%)
[root@xiezhr testdir]# ls
xiezhr.txt  xiezhr.zip

②壓縮目錄

# 這里只將testdir這個目錄壓縮了,目錄下的檔案并沒有壓縮
[root@xiezhr test]# zip testdir.zip ./testdir/
  adding: testdir/ (stored 0%)
# 使用-r引數可以將目錄及目錄下的檔案也遞回壓縮了
[root@xiezhr test]# zip -r testdir.zip ./testdir/
updating: testdir/ (stored 0%)
  adding: testdir/xiezhr.txt (deflated 17%)

③ 排除壓縮

# 將abc.txt 檔案排除到壓縮之外
[root@xiezhr testdir]# ll
total 8
-rw-r--r-- 1 root root  49 Jun 26 16:01 abc.txt
-rw-r--r-- 1 root root 527 Jun 26 15:50 xiezhr.txt
[root@xiezhr testdir]# cd ..
[root@xiezhr test]# zip -r testdir.zip ./testdir/ -x testdir/abc.txt 
updating: testdir/ (stored 0%)
updating: testdir/xiezhr.txt (deflated 17%)xxxxxxxxxx -[root@xiezhr testdir]# lltotal 8-rw-r--r-- 1 root root  49 Jun 26 16:01 abc.txt-rw-r--r-- 1 root root 527 Jun 26 15:50 xiezhr.txt[root@xiezhr testdir]# cd ..[root@xiezhr test]# zip -r testdir.zip ./testdir/ -x testdir/abc.txt updating: testdir/ (stored 0%)updating: testdir/xiezhr.txt (deflated 17%)shell

unzip 解壓zip檔案

1、簡介

unzip 命令可以解壓zip格式的檔案,一般與zip配套使用

2、語法格式

unzip [引數選項] [壓縮檔案]

3、引數選項

引數 引數說明
-l 在不解壓的情況下顯示壓縮包的內容
-o 解壓時不提示是否覆寫檔案
-d 指定解壓目錄
-v 解壓時顯示詳細資訊

4、實踐操作

①不解壓查看壓縮包里的檔案

[root@xiezhr test]# unzip -l testdir.zip 
Archive:  testdir.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  06-26-2022 16:01   testdir/
      527  06-26-2022 15:50   testdir/xiezhr.txt
---------                     -------
      527                     2 files

② 解壓檔案

# 不帶引數解壓檔案時,會提示是否覆寫檔案
# [y]es, [n]o, [A]ll, [N]one, [r]ename  
# y--是  n--否  A--所有檔案都替換 N--所有檔案都不替換 r--重命名
[root@xiezhr test]# unzip testdir.zip 
Archive:  testdir.zip
replace testdir/xiezhr.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
  inflating: testdir/xiezhr.txt 
# -o 引數,解壓時不提示覆寫
[root@xiezhr test]# unzip -o testdir.zip 
Archive:  testdir.zip
  inflating: testdir/xiezhr.txt 

③ 指定解壓目錄解壓檔案

# 將testdir.zip 解壓到指定目錄dir7下
[root@xiezhr test]# mkdir dir7
[root@xiezhr test]# unzip -d /home/test/dir7/ testdir.zip 
Archive:  testdir.zip
   creating: /home/test/dir7/testdir/
  inflating: /home/test/dir7/testdir/xiezhr.txt  
[root@xiezhr test]# cd dir7/
[root@xiezhr dir7]# ls
testdir

scp 遠程檔案復制

1、簡介

scp 命令用于不同主機之間檔案復制,scp命令每次都是全量完整復制,因此效率不高,適合第一次復制時候使用,增量復制建議使用rsync命令

2、語法格式

scp [引數選擇] [用戶@主機1:檔案1] [用戶@主機2:檔案2]

3、引數選項

引數 引數說明
-C 壓縮傳輸
-l 指定傳輸占用的寬帶,單位Kbit/s
-P 指定傳輸的埠號
-p 傳輸后保留檔案原始屬性
-q 不顯示傳輸進度
-r 遞回復制整個目錄

4、實踐操作

① 將本地檔案或目錄復制到遠程服務器

[root@xiezhr ~]# scp  /home/test/xie.txt  42.192.46.248:/tmp
[email protected]'s password: 

② 從遠程服務器將資料復制到本地

[root@xiezhr ~]# scp 42.192.21.248:/tmp .

rsync 檔案同步工具

1、簡介

rsync 可以實作全量或增量的檔案復制的開源工具, 可以在本地計算機與遠程計算機之間,或者兩個本地目錄之間同步檔案 , 它也可以當作檔案復制工具,替代cpmv命令

2、語法格式

# 1、本地模式
rsync [引數選項] [源檔案] [目標檔案]
# 2、遠程同步模式
# 拉取檔案
rsync [引數選項] [用戶@主機:源檔案] [目標檔案]
# 推送檔案
rsync [引數選項] [源檔案] [用戶@主機:目標檔案]

3、引數選項

引數 引數說明
-r 遞回方式同步目錄
-a 可以替代-r引數,除了可以遞回同步,還可以同步檔案屬性(修改時間、權限等)
-n 不確定 rsync 執行后會產生什么結果,可以先用-n引數模擬執行結果
--delete 使目標目錄內容和源保持目錄一致,洗掉不同檔案
--exclude 同步時,排除不需要的檔案或目錄
--include 同步時,必須包含的檔案

4、實踐操作

注: 有些Linux系統中可能沒有默認安裝rsync ,我們只需按照如下命令安裝即可

yum -y install rsync

① 將當前目錄下的hexoBlog 同步到 dir7目錄下

[root@xiezhr test]# rsync -r hexoBlog/ dir7/hexoBlog
[root@xiezhr test]# cd dir7/
[root@xiezhr dir7]# ll
total 4
drwxr-xr-x 30 root root 4096 Jun 29 20:54 hexoBlog

② 將當前目錄下的logo.png 和hexoBlog 同步到dir8/test 目錄下

[root@xiezhr test]# rsync -r logo.png hexoBlog/  dir8/test
[root@xiezhr test]# cd dir8/test/
[root@xiezhr test]# ll
total 1420
drwxr-xr-x  2 root root   4096 Jun 29 21:00 about
drwxr-xr-x  6 root root   4096 Jun 29 21:00 archives
drwxr-xr-x  2 root root   4096 Jun 29 21:00 artitalk

注: -r表示遞回,即包含子目錄,注意,-r是必須的,否則 rsync 運行不會成功

③-a 引數,遞回同步,同步修改時間、權限等資訊

# rsync -a hexoBlog hexoBlog_new
# 目標目錄hexoBlog_new 如果不存在,rsync 會自動創建,
# 執行上面的命令后,源目錄hexoBlog被完整地復制到了目標目錄hexoBlog_new下面,hexoBlog_new/hexoBlog的目錄結構,

[root@xiezhr test]# ll
total 16
drwxr-xr-x  2 xiezhr xiezhr 4096 Mar 26 21:46 dir
drwxr-xr-x 30 git    git    4096 Jun  6 20:42 hexoBlog
-rw-r--r--  1 root   root     35 May  9 21:36 xie.txt
-rw-r--r--  1 root   root    527 Apr  9 10:55 xiezhr.txt
[root@xiezhr test]# rsync -a hexoBlog hexoBlog_new
[root@xiezhr test]# ll
total 20
drwxr-xr-x  2 xiezhr xiezhr 4096 Mar 26 21:46 dir
drwxr-xr-x 30 git    git    4096 Jun  6 20:42 hexoBlog
drwxr-xr-x  3 root   root   4096 Jul  2 09:15 hexoBlog_new
-rw-r--r--  1 root   root     35 May  9 21:36 xie.txt
-rw-r--r--  1 root   root    527 Apr  9 10:55 xiezhr.txt

#如果只想同步源目錄 hexoBlog 里面的內容到目標目錄hexoBlog_new,則需要在源目錄后面加上斜杠,
[root@xiezhr test]# rsync -a hexoBlog/ hexoBlog_new
#上面命令執行后,hexoBlog目錄里面的內容,就都被復制到了hexoBlog_new目錄里面,并不會在hexoBlog_new下面創建一個hexoBlog子目錄,

-n 引數模擬執行結果

注: 如果不確定 rsync 執行后會產生什么結果,可以先用-n 引數模擬執行結果

[root@xiezhr test]# rsync -anv xie.txt testdir
sending incremental file list
xie.txt

sent 49 bytes  received 19 bytes  136.00 bytes/sec
total size is 35  speedup is 0.51 (DRY RUN)

# -n引數模擬命令執行的結果,并不真的執行命令,-v引數則是將結果輸出到終端,這樣就可以看到哪些內容會被同步,

--delete 引數的使用,保持源目錄和目標目錄檔案一致

[root@xiezhr test]# rsync -av --delete hexoBlog hexoBlog_0702
sending incremental file list
created directory hexoBlog_0702
hexoBlog/
hexoBlog/Staticfile.txt
hexoBlog/baidu_urls.txt
hexoBlog/baidusitemap.xml
hexoBlog/favicon.png
hexoBlog/tags/問卷調查/index.html

sent 63,638,655 bytes  received 8,246 bytes  42,431,267.33 bytes/sec
total size is 63,597,216  speedup is 1.00

注: 默認情況下,rsync 只確保源目錄的所有內容(明確排除的檔案除外)都復制到目標目錄,它不會使兩個目錄保持相同,并且不會洗掉檔案,使用--delete引數,這將洗掉只存在于目標目錄、不存在于源目錄的檔案,

--exclude 引數 的使用,同步時排除某些檔案

[root@xiezhr test]# rsync -av --exclude '*.txt' hexoBlog hexoBlog_test
sending incremental file list
created directory hexoBlog_test
hexoBlog/
hexoBlog/baidusitemap.xml
hexoBlog/favicon.png
hexoBlog/favicon1.png
hexoBlog/tags/問卷調查/index.html

sent 63,638,026 bytes  received 8,208 bytes  127,292,468.00 bytes/sec
total size is 63,596,717  speedup is 1.00

注: 上面腳本將hexoBlog 目錄下除了.txt外的檔案都同步到了hexoBlog_test 目錄下

--include 引數的使用,同步時必須包含某些檔案

[root@xiezhr test]# rsync  -av --include "*.txt" --exclude "*" hexoBlog hexo_xie
sending incremental file list

sent 18 bytes  received 12 bytes  60.00 bytes/sec
total size is 0  speedup is 0.00

注:上述命令將hexoBlog目錄下的所有檔案排除,但包含txt檔案同步到hexo_xie目錄下

⑧遠程同步資源

注: rsync 命令除了可以本地同步之外,還支持遠程同步資源

# 以下命令是將本地資源source 同步到遠程服務器destination
[root@xiezhr test]# rsync -av source/ username@remote_host:destination
# 以下命令是將遠程服務器資源source同步到本地 destination
[root@xiezhr test]# rsync -av username@remote_host:source/ destination

由于博主比較窮,手上只有一臺云服務器,這里就沒法做具體演示了??

⑨增量備份

[root@xiezhr test]# rsync -a --delete --link-dest /compare/path /source/path /target/path

上述命令解釋

  • --link-dest引數指定基準目錄/compare/path

  • /source/path 代表源目錄

  • /target/path 代表目標目錄

  • 命令的第一次備份時是全量備份,后面 源目錄/source/path跟基準目錄/compare/path 進行比較,找出變動的檔案,將它們拷貝到目標目錄/target/path 實作增量更新

注: 上面命令可以寫成shell腳本,然后添加到Linux任務調度里,就實作了增量備份檔案的功能,

關于rsync命令小結

  • rsync 用法很多,所以上面說了好多常用例子,當然還有很多用法沒法一一例舉出來,
  • rsync 不僅用于Linux,也同樣可以再Windows上使用,用于文章上關于Linux的,所以沒列舉Windows上使用方法,感興趣的小伙伴可自行查找資料,或者后面出一篇文章具體介紹
  • 關于rsync命令的用法,阮一峰大佬也寫了一篇文章,講的也非常好,大家可以去看看,文章地址:https://www.ruanyifeng.com/blog/2020/08/rsync.html

這期主要是說了Linux系統檔案備份與壓縮相關命令,大概內容就這些了,下期根據思維導圖就到了 軟體安裝相關 的命令了,

涉及到的命令有: rpm、 yum兩個命令

這些命令呢比較基礎,但也是比較常用比較重要的

敬請期待哦(●’?’●)

專欄目錄:快速上手Linux核心命令專欄目錄

上一篇:快速上手Linux核心命令(七):Linux系統資訊相關命令x
下一篇:快速上手Linux核心命令(十):軟體安裝命令(博主正在玩命更新中)

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/551412.html

標籤:Linux

上一篇:明解STM32—GPIO應用設計篇之API函式及配置使用技巧

下一篇:返回列表

標籤雲
其他(158258) Python(38107) JavaScript(25396) Java(18003) C(15218) 區塊鏈(8260) C#(7972) AI(7469) 爪哇(7425) MySQL(7152) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5870) 数组(5741) R(5409) Linux(5333) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4565) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2432) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1964) Web開發(1951) HtmlCss(1928) python-3.x(1918) 弹簧靴(1913) C++(1912) xml(1889) PostgreSQL(1874) .NETCore(1857) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • CA和證書

    1、在 CentOS7 中使用 gpg 創建 RSA 非對稱密鑰對 gpg --gen-key #Centos上生成公鑰/密鑰對(存放在家目錄.gnupg/) 2、將 CentOS7 匯出的公鑰,拷貝到 CentOS8 中,在 CentOS8 中使用 CentOS7 的公鑰加密一個檔案 gpg -a ......

    uj5u.com 2020-09-10 00:09:53 more
  • Kubernetes K8S之資源控制器Job和CronJob詳解

    Kubernetes的資源控制器Job和CronJob詳解與示例 ......

    uj5u.com 2020-09-10 00:10:45 more
  • VMware下安裝CentOS

    VMware下安裝CentOS 一、軟硬體準備 1 Centos鏡像準備 1.1 CentOS鏡像下載地址 下載地址 1.2 CentOS鏡像下載程序 點擊下載地址進入如下圖的網站,選擇需要下載的版本,這里選擇的是Centos8,點擊如圖所示。 決定選擇Centos8后,選擇想要的鏡像源進行下載,此 ......

    uj5u.com 2020-09-10 00:12:10 more
  • 如何使用Grep命令查找多個字串

    如何使用Grep 命令查找多個字串 大家好,我是良許! 今天向大家介紹一個非常有用的技巧,那就是使用 grep 命令查找多個字串。 簡單介紹一下,grep 命令可以理解為是一個功能強大的命令列工具,可以用它在一個或多個輸入檔案中搜索與正則運算式相匹配的文本,然后再將每個匹配的文本用標準輸出的格式 ......

    uj5u.com 2020-09-10 00:12:28 more
  • git配置http代理

    git配置http代理 經常遇到克隆 github 慢的問題,這里記錄一下幾種配置 git 代理的方法,解決 clone github 過慢。 目錄 git配置代理 git單獨配置github代理 git配置全域代理 配置終端環境變數 git配置代理 主要使用 git config 命令 git單獨 ......

    uj5u.com 2020-09-10 00:12:33 more
  • Linux npm install 裝包時提示Error EACCES permission denied解

    npm install 裝包時提示Error EACCES permission denied解決辦法 ......

    uj5u.com 2020-09-10 00:12:53 more
  • Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包

    Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包。 18 (flaskApi) [root@67 flaskDemo]# yum -y install nginx 19 已加載插件:fastestmirror, langpacks 20 Loading ......

    uj5u.com 2020-09-10 00:13:13 more
  • Linux查看服務器暴力破解ssh IP

    在公網的服務器上經常遇到別人爆破你服務器的22埠,用來挖礦或者干其他嘿嘿嘿的事情~ 這種情況下正確的做法是: 修改默認ssh的22埠 使用設定密鑰登錄或者白名單ip登錄 建議服務器密碼為復雜密碼 創建普通用戶登錄服務器(root權限過大) 建立堡壘機,實作統一管理服務器 統計爆破IP [root ......

    uj5u.com 2020-09-10 00:13:17 more
  • CentOS 7系統常見快捷鍵操作方式

    Linux系統中一些常見的快捷方式,可有效提高操作效率,在某些時刻也能避免操作失誤帶來的問題。 ......

    uj5u.com 2020-09-10 00:13:31 more
  • CentOS 7作業系統目錄結構介紹

    作業系統存在著大量的資料檔案資訊,相應檔案資訊會存在于系統相應目錄中,為了更好的管理資料資訊,會將系統進行一些目錄規劃,不同目錄存放不同的資源。 ......

    uj5u.com 2020-09-10 00:13:35 more
最新发布
  • 快速上手Linux核心命令(九):檔案備份與壓縮

    (檔案備份與壓縮) 這期呢主要說一說Linux中檔案備份與壓縮命令,一共6個命令。這6個命令都是平常作業中非常非常常用的。 tar 打包備份 1、簡介 tar 可以將多個檔案壓縮打包、壓縮。是作業中經常用到的命令 2、語法格式 tar [引數選項] [檔案或目錄] 3、引數說明 | 引數 | 引數說 ......

    uj5u.com 2023-04-28 12:38:53 more
  • 明解STM32—GPIO應用設計篇之API函式及配置使用技巧

    一、前言 本篇開始對STM32的GPIO在實際開發設計中的使用配置和技巧進行探討,可以先去回顧下之前介紹的GPIO的相關理論基礎知識包括基本結構,作業模式和暫存器原理。 了解過STM32的GPIO相關的理論知識,這樣在應用GPIO開發程序中,能更好的理解GPIO的特點,應用起來會更加的得心應手。 后 ......

    uj5u.com 2023-04-27 10:02:09 more
  • Linux查看各用戶硬碟占用大小

    Linux查看各用戶硬碟占用大小 在Linux中,如果要統計各用戶占用硬碟的大小,可以執行如下的命令 du -sh /home/* 這條命令會以K、M、G等單位輸出 /home 下各用戶目錄占用硬碟的總大小,例如下面這樣: [root@localhost ~]# du -sh /home/* 24K ......

    uj5u.com 2023-04-27 10:01:31 more
  • 快速上手Linux核心命令(六):Linux的文本編輯器vi和vim

    @(Linux的文本編輯器) 前言 上一篇中已經預告,我們這篇主要說Linux中vi/vim 編輯器。它是我們使用Linux系統不可缺少的工具,學會了,你就可以在Linux世界里暢通無阻,學廢了,常用操作你也會了,也是夠用了,O(∩_∩)O 簡介 vi是Linux系統下標準編輯器,就相當于Windo ......

    uj5u.com 2023-04-27 10:00:55 more
  • CentOS搭建squid正向代理

    squid介紹 官網地址:http://www.squid-cache.org/ Squid cache(簡稱為 Squid)是一個流行的自由軟體(GNU 通用公共許可證)的代理服務器和 Web 快取服務器。Squid 有廣泛的用途,從作為網頁服務器的前置 cache 服務器快取相關請求來提高 We ......

    uj5u.com 2023-04-27 10:00:29 more
  • 明解STM32—GPIO應用設計篇之API函式及配置使用技巧

    一、前言 本篇開始對STM32的GPIO在實際開發設計中的使用配置和技巧進行探討,可以先去回顧下之前介紹的GPIO的相關理論基礎知識包括基本結構,作業模式和暫存器原理。 了解過STM32的GPIO相關的理論知識,這樣在應用GPIO開發程序中,能更好的理解GPIO的特點,應用起來會更加的得心應手。 后 ......

    uj5u.com 2023-04-27 09:59:24 more
  • Linux查看各用戶硬碟占用大小

    Linux查看各用戶硬碟占用大小 在Linux中,如果要統計各用戶占用硬碟的大小,可以執行如下的命令 du -sh /home/* 這條命令會以K、M、G等單位輸出 /home 下各用戶目錄占用硬碟的總大小,例如下面這樣: [root@localhost ~]# du -sh /home/* 24K ......

    uj5u.com 2023-04-27 09:58:05 more
  • 快速上手Linux核心命令(六):Linux的文本編輯器vi和vim

    @(Linux的文本編輯器) 前言 上一篇中已經預告,我們這篇主要說Linux中vi/vim 編輯器。它是我們使用Linux系統不可缺少的工具,學會了,你就可以在Linux世界里暢通無阻,學廢了,常用操作你也會了,也是夠用了,O(∩_∩)O 簡介 vi是Linux系統下標準編輯器,就相當于Windo ......

    uj5u.com 2023-04-27 09:44:14 more
  • CentOS搭建squid正向代理

    squid介紹 官網地址:http://www.squid-cache.org/ Squid cache(簡稱為 Squid)是一個流行的自由軟體(GNU 通用公共許可證)的代理服務器和 Web 快取服務器。Squid 有廣泛的用途,從作為網頁服務器的前置 cache 服務器快取相關請求來提高 We ......

    uj5u.com 2023-04-27 09:26:12 more
  • 快速上手Linux核心命令(四):檔案內容相關命令

    @(檔案內容相關命令) 前言 上一篇中已經預告,我們這篇主要說一說Linux中檔案內容查看處理相關的命令。一共16個命令,其中 標注的為重點命令,作業中用的也比較多,需要熟練掌握 cat 合并檔案或查看檔案內容 1、簡介 cat 是concatenate 單詞的縮寫,或者理解成貓,"喵"一下檔案內容 ......

    uj5u.com 2023-04-25 09:19:54 more