1. 如何創建或編輯文件?
新建文件t1.txt:先按鍵盤ESC,切換到命令模式,再按i鍵。進行文件內容的輸入
1111
2222
3333
1111
2222
3333
如要在文件中查找,則先按鍵盤ESC,再按/鍵,輸入想要查找的內容,如輸入3,如果想繼續查找,則可以按n鍵,繼續查找。
如要在文件中顯示行號,則先按鍵盤ESC,再按:鍵,輸入set number
如要保存文件,則先按鍵盤ESC,再按:鍵,輸入wq。
2. 如何查找文件?
當需要確定文件具體位置時,如查找在整個系統中查找文件t1.txt,可執行命令:
find / -name t1.txt -print
root@linux:~# find / -name t1.txt -print
/home/test/t1.txt
如在當前目錄查找,可執行:
find / -name t1.txt -print
3. 如何查找包含某個字符串的文件?
root@linux:/home/test# grep -rn "111" ./
./t1.txt:1:11111111
root@linux:/home/test# find / -name t1.txt -print | xargs grep -l "11"
/home/test/t1.txt
xargs是execute arguments的縮寫,用于從標準輸入中讀取內容,并將此內容傳遞給后面的命令,并作為該命令的參數來執行。
4. 如何解壓縮文件?
root@linux:/home# tar -zcvf test.gz /home/test/
tar: Removing leading `/' from member names
/home/test/
/home/test/t1.txt
z:gzip壓縮文件;c:創建tar包;v:顯示tar執行過程;f:指定壓縮文件名
目的包名test.gz,源目錄為/home/test/
root@linux:/home# ll
total 24
drwxr-xr-x 5 root root 4096 Jan 25 15:36 ./
drwxr-xr-x 26 root root 4096 Jan 25 14:49 ../
drwxr-xr-x 2 root root 4096 Jan 25 20:33 test/
-rw-r--r-- 1 root root 184 Jan 25 20:36 test.gz
解開壓縮
tar -zxf network.gz
5. 如何從其他機器獲取文件?
scp是secure copy的簡寫,用于遠程拷貝文件。
命令格式:scp 源 目的
(1)從本地復制到遠程
登錄到本地服務器,將/home/test目錄下所有的文件傳輸到IP為30.0.1.37的/home/develop目錄,執行命令:
scp -r /home/test root@30.0.1.37:/home/develop
root@linux:/home/test# scp -r /home/test root@30.0.1.37:/home/develop
The authenticity of host '30.0.1.37 (30.0.1.37)' can't be established.
ECDSA key fingerprint is SHA256:THHVZ1IfwqJk0YpV7Qk/a+ZvMds4phRQJEbrJIJFagg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '30.0.1.37' (ECDSA) to the list of known hosts.
root@30.0.1.37's password:
t1.txt 100% 10 15.8KB/s 00:00
t2.txt
登錄到30.0.1.37上,就可以看到文件已經存在。
root@linux:/home/develop/test# ll
total 16
drwxr-xr-x 2 root root 4096 Jan 25 21:12 ./
drwxr-xr-x 3 root root 4096 Jan 25 21:12 ../
-rw-r--r-- 1 root root 10 Jan 2521:12 t1.txt
-rw-r--r-- 1 root root 12 Jan 2521:12 t2.txt
(2)從遠程復制到本地
登錄到本地服務器,將30.0.1.37上的/home/develop/目錄下所有文件復制到本地服務器的/home/test目錄下,執行命令:
scp -r root@30.0.1.37:/home/develop /home/test
root@linux:/home/test# scp -r root@30.0.1.37:/home/develop /home/test/
root@30.0.1.37's password:
d1.txt 100% 14 14.0KB/s 00:00
d2.txt 100% 12 28.7KB/s 00:00
root@linux:/home/test/develop# ll
total 16
drwxr-xr-x 2 root root 4096 Jan 25 21:21 ./
drwxr-xr-x 3 root root 4096 Jan 25 21:21 ../
-rw-r--r-- 1 root root 14 Jan 25 21:21 d1.txt
-rw-r--r-- 1 root root 12 Jan 25 21:21 d2.txt
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。
舉報投訴
-
參數
+關注
關注
11文章
1867瀏覽量
32870 -
命令
+關注
關注
5文章
730瀏覽量
22676 -
內容
+關注
關注
0文章
56瀏覽量
15103
發布評論請先 登錄
相關推薦
熱點推薦
Linux操作系統-C語言編程入門介紹在LINUX 下進行C 語言編程所需要的基礎知識.在這篇
Linux操作系統-C語言編程入門介紹在LINUX 下進行C 語言編程所需要的基礎知識.在這篇文章當中,我們將會學到以下內容:?? 源程序編譯?? Makefile 的編寫?? 程序庫
發表于 12-08 09:56
鴻蒙移植必備的基礎知識
1. 基礎知識移植內核對技術的要求比較高、比較細。1.1 單片機相關的知識棧的作用加載地址、鏈接地址重定位幾個簡單的硬件知識串口定時器中斷的概念1.2 Linux
發表于 07-01 06:35
嵌入式linux應用開發基礎知識
:嵌入式linux應用開發基礎知識 BV1kk4y117Tu第5篇:嵌入式linux驅動開發基礎知識 BV14f4y1Q7ti第6篇:項目實戰 BV1it4y1Q75z第7篇:驅動大全
發表于 12-24 08:18
Linux基礎知識
Linux基礎知識
硬盤 硬盤是可以存儲大量信息資源的媒介。我們平時看到的硬盤是方方正正的一塊挺沉的鐵匣子,但是其實硬盤是圓的,加上一些控制電路以后,為了便于
發表于 01-18 09:57
?514次閱讀
Linux設備驅動程序基礎知識的了解
了解Linux設備驅動程序的基礎知識,重點關注設備節點,內核框架,虛擬文件??系統和內核模塊。
提出了一個簡單的內核模塊實現。
Linux驅動編程基礎知識講解
由于Linux驅動編程的本質屬于Linux內核編程,因此我們非常有必要熟悉Linux內核以及Linux內核的特點。 這篇文章將會幫助讀者打下Linu
評論