linux 學習內容

一:系統基本常識
1.什麼是linux?
linux是一款免費使用和自由傳播的類unix操作系統,是一個基於posix,unix的多用戶,多任務,支持多線程和多cpu的操作系統。他能運行主要的unix工具軟件,應用程序和網絡協議。他支持32位和64位硬件,linux繼承了unix以網絡爲核心的設計思想,是一個性能穩定的多用戶操作系統。
2.什麼是shell?
shell是用戶和linux操作系統之間的藉口。
二:如何在linux中運行命令
1.怎樣打開shell?
點擊鼠標右鍵,點擊 Open Terminal 。
在命令提示符後輸入動作
三:行提示符含義
[kiosk @foundation() Desktop ]
kiosk ##用戶
@ ##分隔符
foundation ##主機短名稱
Desktop ## 所在系統位置
$ ##身份提示符$表示普通用戶#表示超級用戶
四:命令的組成
命令 參數 目標
-s ##單詞的縮寫
--size ##單詞的全拼
五:虛擬機管理命令

  1. rht-vmctl start desktop | server ##開啓
    linux 學習內容
    2.rht-vmctl view desktop| server ##顯示
    linux 學習內容linux 學習內容
    3.rht-voctl poweroff desktop | server
    linux 學習內容
    六:linux系統結構
    linux是一個倒樹結構
    linux中所有的東西都是文件
    這些文件都在系統頂級目錄“/” /就是根目錄
    /目錄以下爲二級目錄這些目錄都是系統裝機時系統自動建立的
    二級目錄的作用
    /bin ##二進制可執行文件也就是系統命令
    /sbin ##系統管理命令存放位置
    /boot ##啓動分區,負責系統啓動
    /dev ##設備管理文件
    /etc ##大多數系統管理文件
    /home ##普通用戶的家目錄
    /lib ##32位系統庫文件存放位置
    /lib64 ##64位系統庫文件存放位置
    /media ##系統臨時設備掛載點
    /mnt ##系統臨時設備掛載點
    /run ##系統臨時設備掛載點
    /opt ##第三方軟件安裝位置
    /proc ##系統信息
    /root ##超級用戶家目錄
    /srv,/var ##系統數據
    /sys ##系統管理,主要是關於內核的
    /tmp ##系統臨時文件存放位置
    /usr ##系統用戶相關信息數據及用戶自定義軟件存放位置
    七:linux下的文件和管理
    1.建立文件
    touch file #建立空文件或者修改時間戳

linux 學習內容
linux 學習內容

2.建立目錄
mkdir ##建立單目錄
linux 學習內容
mkdir -p ##建立多層目錄
linux 學習內容
linux 學習內容

3.文件的刪除
rm -f file ##強行刪除文件不提示
linux 學習內容
linux 學習內容
rm -fr dir ##強行刪除目錄本身和裏面的內容不提示
linux 學習內容
4.文件的編輯
vim file
進入文件瀏覽模式,不能編輯
輸入<I>進入插入模式寫字符
編寫完成後按<esc>退出插入模式
輸入:wq 完成文件編輯 w表示寫入 q 表示退出
linux 學習內容
linux 學習內容
linux 學習內容

5.vim使用技巧
在瀏覽模式
yy ## 副之一整行
linux 學習內容
yl ##複製一個字母
linux 學習內容
yw ##複製一個單詞
linux 學習內容
p ##粘貼

dd ##刪除一整行
linux 學習內容

dl ## 刪除一個字母
linux 學習內容

dw ##刪除一個單詞
linux 學習內容

cc ##剪掉整行
linux 學習內容
cl ##剪掉一個字母
linux 學習內容
linux 學習內容
cw ##剪掉一個單詞
linux 學習內容
linux 學習內容
注意:
當剪切後vim會進入插入模式
如果要粘貼需要按<esc>退出插入模式後粘貼

u ##撤銷
linux 學習內容
linux 學習內容
ctrl+v ##恢復
linux 學習內容
linux 學習內容

1.如何批量添加字符
1)把光標移動到要加入字符所在列
2)ctrl+v 進入可視化模式
3)選中要加字符所在列
4)按<I>進入插入模式並寫入要加入的字符
5)按<esc>批量添加結束
linux 學習內容
linux 學習內容

2.如何批量修改
:%s/原有字符/修改後字符/g
linux 學習內容
linux 學習內容
:1,5s/原有字符/修改後字符/g
linux 學習內容
linux 學習內容

3.如何同時i編輯多個文件
vim file
:sp file1
linux 學習內容

注意: 光標默認在哪個文件中就是哪個文件
    ctrl+w  按完放開再按上或下可以移動光標所在窗口
        ![](http://i2.51cto.com/images/blog/201808/02/c5e90b626855fd2bd920cf27d4bc19e3.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
        ![](http://i2.51cto.com/images/blog/201808/02/afbe6460e6bbcbfa7191bd7091049a01.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
4.vim的退出

正常退出方法
:q ##當文件沒有做任何修改時可用的
linux 學習內容
:q! ##文件修改但不想保存時可用

linux 學習內容
linux 學習內容
:wq ##退出保存
linux 學習內容
linux 學習內容
:wq! ##文件屬於自己或用戶爲root時可用
linux 學習內容
linux 學習內容
異常退出
當 vim非正常退出會產生.filename.swap文件
Found a swap file by the name ".file.swp"
owned by: root dated: Wed Aug 1 02:59:25 2018
me: ~root/Desktop/file
modified: YES
user name: root host name: localhost
process ID: 2046
h swap file by the name ".file.swp"
owned by: root dated: Wed Aug 1 02:59:25 2018
ile opening file "file"

Swap file ".file.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
只讀打開 放棄未保存數據 恢復 刪除.swp文件 退出 退出
進入文件

5.文件查看
cat file ##輸出文件的所有內容linux 學習內容

cat -b file ##輸出文件所有內容並加入行號
linux 學習內容
less ##分頁瀏覽
linux 學習內容

上|下 ##向上|向下移動一行

<pgup>|<pgdn> ##向上|向下移動一頁

/關鍵字 ##高亮顯示關鍵字,n向下匹配N向上匹配

q ##退出
linux 學習內容
linux 學習內容
tail -n ##顯示文件的後多少行
linux 學習內容
linux 學習內容
head -n ##顯示文件的前多少行
linux 學習內容
linux 學習內容
#6.文件複製
cp sourcefile destfile ##文件複製
linux 學習內容
linux 學習內容
cp sourcefile1 sourcefile2 destdir/ ##複製多個文件到目錄中

linux 學習內容
linux 學習內容
cp -r sourcedir destdir/ ##複製目錄
linux 學習內容
linux 學習內容
#7.文件的移動
mv sourcefile destfile ##重名命
linux 學習內容
mv sourcefile destdir ##移動
linux 學習內容
mv sourcedir destdir ##移動目錄
linux 學習內容
mv test/* . ##"."代表當前目錄
linux 學習內容

#8.文件路徑
1.相對路徑
文件相對當前系統位置的一個名稱簡寫
文件名稱省略了當前路徑的值
只有當前在此目錄中時可以使用
文件名稱不以/開頭
文件名稱會自動在字符前加入'pwd'顯示的路徑

2.絕對路徑
是文件在系統中真實的位置
任何時間都可以精確表示一個文件的名稱
文件名稱以/開頭
#9.關於路徑的命令
pwd ##顯示當前工作目錄
linux 學習內容
cd ##切換當前工作目錄
linux 學習內容
cd /mnt ##切換到/mnt目錄中
linux 學習內容
cd - ##進入當前目錄之前所在目錄中
linux 學習內容
cd ~student ##進入到student用戶家目錄
linux 學習內容

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章