1. 如何創(chuàng)建或編輯文件?
新建文件t1.txt:先按鍵盤ESC,切換到命令模式,再按i鍵。進行文件內容的輸入
1111
2222
3333
1111
2222
3333
如要在文件中查找,則先按鍵盤ESC,再按/鍵,輸入想要查找的內容,如輸入3,如果想繼續(xù)查找,則可以按n鍵,繼續(xù)查找。
如要在文件中顯示行號,則先按鍵盤ESC,再按:鍵,輸入set number
如要保存文件,則先按鍵盤ESC,再按:鍵,輸入wq。
2. 如何查找文件?
當需要確定文件具體位置時,如查找在整個系統(tǒng)中查找文件t1.txt,可執(zhí)行命令:
find / -name t1.txt -print
root@linux:~# find / -name t1.txt -print
/home/test/t1.txt
如在當前目錄查找,可執(zhí)行:
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的縮寫,用于從標準輸入中讀取內容,并將此內容傳遞給后面的命令,并作為該命令的參數(shù)來執(zhí)行。
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:創(chuàng)建tar包;v:顯示tar執(zhí)行過程;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目錄下所有的文件傳輸?shù)絀P為30.0.1.37的/home/develop目錄,執(zhí)行命令:
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上,就可以看到文件已經(jīng)存在。
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目錄下,執(zhí)行命令:
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
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。
舉報投訴
-
參數(shù)
+關注
關注
11文章
1862瀏覽量
32453 -
命令
+關注
關注
5文章
698瀏覽量
22139 -
內容
+關注
關注
0文章
56瀏覽量
15031
發(fā)布評論請先 登錄
相關推薦
Linux操作系統(tǒng)-C語言編程入門介紹在LINUX 下進行C 語言編程所需要的基礎知識.在這篇
Linux操作系統(tǒng)-C語言編程入門介紹在LINUX 下進行C 語言編程所需要的基礎知識.在這篇文章當中,我們將會學到以下內容:?? 源程序編譯?? Makefile 的編寫?? 程序庫
發(fā)表于 12-08 09:56
Linux基礎知識學習
Linux基礎知識學習1.Linux的構成Linux系統(tǒng)主要分為四個部分:內核、文件系統(tǒng)、shell、應用內核主要功能:對
發(fā)表于 03-20 21:42
如何學習嵌入式系統(tǒng)基礎知識
轉發(fā):如何學習嵌入式系統(tǒng)基礎知識,不錯資料1、Linux 基礎安裝Linux操作系統(tǒng):Linux文件
發(fā)表于 09-13 11:04
鴻蒙移植必備的基礎知識
1. 基礎知識移植內核對技術的要求比較高、比較細。1.1 單片機相關的知識棧的作用加載地址、鏈接地址重定位幾個簡單的硬件知識串口定時器中斷的概念1.2 Linux
發(fā)表于 07-01 06:35
嵌入式linux應用開發(fā)基礎知識
:嵌入式linux應用開發(fā)基礎知識 BV1kk4y117Tu第5篇:嵌入式linux驅動開發(fā)基礎知識 BV14f4y1Q7ti第6篇:項目實戰(zhàn) BV1it4y1Q75z第7篇:驅動大全
發(fā)表于 12-24 08:18
Linux基礎知識
Linux基礎知識
硬盤 硬盤是可以存儲大量信息資源的媒介。我們平時看到的硬盤是方方正正的一塊挺沉的鐵匣子,但是其實硬盤是圓的,加上一些控制電路以后,為了便于
發(fā)表于 01-18 09:57
?496次閱讀
linux /Android 基礎知識總結大全
本文檔介紹了linux /Android 基礎知識總結大全,包含了源代碼以及詳解,供網(wǎng)友參考。
發(fā)表于 09-11 17:46
?7次下載
Linux設備驅動程序基礎知識的了解
了解Linux設備驅動程序的基礎知識,重點關注設備節(jié)點,內核框架,虛擬文件??系統(tǒng)和內核模塊。
提出了一個簡單的內核模塊實現(xiàn)。
Linux驅動編程基礎知識講解
由于Linux驅動編程的本質屬于Linux內核編程,因此我們非常有必要熟悉Linux內核以及Linux內核的特點。 這篇文章將會幫助讀者打下Linu
linux操作系統(tǒng)好學嗎_要學什么
linux操作系統(tǒng)的基礎知識是比較好學的,但是需要我們通過大量地練習來牢記這些基礎知識。
發(fā)表于 05-23 09:33
?3090次閱讀
評論