天天看點

linux運維 基礎篇 unit1練習與習題

  1   #虛拟機控制#

[kiosk@foundation0 Desktop]$ rht-vmctl start desktop    #開啟desktop虛拟機

Error: desktop not started (is already running)         #報錯,desktop已經運作

[kiosk@foundation0 Desktop]$ rht-vmctl view  desktop    #顯示desktop

[kiosk@foundation0 Desktop]$ rht-vmctl poweroff desktop #關閉dekstop

Powering off desktop..

[kiosk@foundation0 Desktop]$ rht-vmctl start desktop    #開啟desktop

Starting desktop.

[kiosk@foundation0 Desktop]$ rht-vmctl view desktop

[kiosk@foundation0 Desktop]$ rht-vmctl poweroff desktop

Error: unable to view desktop - not currently running.  #虛拟機沒開啟無法顯示

[kiosk@foundation0 Desktop]$ rht-vmctl reset desktop    #當虛拟機出現故障,reset表示重置

Are you sure you want to reset desktop? (y/n) y         #詢問是否重置y表示yes

Resetting desktop.                                      #正在重置

  2    #進入系統#

1)普通使用者登陸

student 普通使用者,密碼student

2)超級使用者登陸

->not listed                        點選未列出

username                            提示輸入使用者名稱

->****                              為系統超級使用者

passwd                              提示輸入密碼

->*****                             是超級使用者密碼

  3   #語言調整#

Applications----->system tools---->settings ----->Region & language --->language

 打開指令行---> reboot

                                          ######################

                                                  第一單元 

     1 行提示符

[kiosk@foundation0 Desktop]$

kiosk                  ##打開shell的使用者

@                      ##分隔符

foundation0            ##主機名稱

Desktop                ##工作目錄名稱

$                      ##身份提示符,#表示超級使用者,$表示普通使用者

           注意:指令要在行提示符之後輸入才能執行

     2.切換使用者

[kiosk@founda7tion0 Desktop]$ su - username

*)進階使用者切換到低級使用者不需要密碼,低級使用者切換到進階或者平級使用者的切換需要密碼

     3.虛拟控制台

Ctrl+Alt+F(1|7)進入圖形

Ctrl+Alt+F(2~6) 進入虛拟控制台

Red hat Enterprise Linux Server 7.0 (Maipo)        ##系統版本

Kernel 3.10.0-123.el7.x86_64 on an x86_64          ##核心版本,系統位數

desktop0 login:root                               ##登陸使用者名稱輸入

Password:                                         ##直接與系統對話,密碼輸入無回顯

     4.指令的執行

1>.指令必須在行提示符之後輸入

2>.指令格式

   指令 參數 目标

3>.ctrl +c                                          ##撤銷命名的執行

<a href="https://s3.51cto.com/wyfs02/M00/8F/5F/wKioL1jcgyTgc065AAAdzDIHjjY367.png-wh_500x0-wm_3-wmp_4-s_1431565120.png" target="_blank"></a>

4&gt;.指令參數

   —參數                                           ##單詞縮寫

   ——參數                                         ##單詞的全拼

     5.指令的幫助

<a href="https://s3.51cto.com/wyfs02/M02/8F/61/wKiom1jcg5Ti37EGAADV2GoSne4201.png-wh_500x0-wm_3-wmp_4-s_3653074316.png" target="_blank"></a>

whatis 指令                                         ##檢視指令的功能

指令 -help                                          ##檢視指令的幫助

[]                                                  ##選擇加入的内容,可加可不加

...                                                 ##加入的内容個數任意

&lt;&gt;                                                  ##内容在指令執行過程當中必須要加

     6.系統的使用基礎方法

1)系統登陸

  圖形登陸方式

  文本登陸方式

  gnome-session-quit ——force                        ###登出使用者 ——force強制登出,不詢問

2)工作界面轉換

3)開始bash

  1.Applications&gt;Utilities&gt;Terminal

  2.滑鼠右鍵-----&gt;open in terminal

  3.gnome-terminal

  4.ctrl+shift+n                                      ##在新視窗中打開shell

    ctrl+shift+t                                      ##同一個視窗中打開新的tab

  5.退出:exit | ctrl+d

4)系統關機,重新開機

  重新開機 

  reboot | init 6 |shutdown -r now

  關機

  poweroff | init 0 | shutdown -h now

5)鎖屏

  ctrl + alt +L                                     ##在rhel7.0

  win鍵 + L                                         ##在rhel7.2

##簡單的系統指令

1) date

watch -n 1 date                      ##讓date指令每秒執行一次,ctrl +c 退出監控模式

date 11181115                        ##把系統時間設定為11月18日11:15 格式:月月天天小時分鐘

date 111811152016.55                 ##2016表示年(可以不加).55 表示秒(可以不加)

-d +xday -xday                       ##檢視x天前或者後的時間

+%....                               ##設定date的輸出格式

2)passwd

1.passwd 修改使用者密碼

[root@foundation0 ~]passwd

Changing password for user root.     ##改變超級使用者密碼

New password:                        ##輸入密碼

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:                 ##确認密碼

passwd: all authentication tokens updated successfully.

[kiosk@foundation0 Desktop]$ passwd

Changing password for user kiosk.    ##改變普通使用者密碼

Changing password for kiosk.

(current) UNIX password:             ##輸入目前密碼

New password:

BAD PASSWORD: The password is the same as the old one                ##和原始密碼不能相似

BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic                                                                                      ##密碼必須是無序數字+字母

BAD PASSWORD: The password is shorter than 8 characters              ##密碼必須&gt;8位

passwd參數使用者名稱

-S  student                        ##使用者密碼資訊

——status student

-l student                         ##鎖定帳号

-u student                         ##解鎖

-n 1student                        ##設定密碼最短有效期

-x 30student                       ##設定密碼最長有效期

-w 3student                        ##警告期

-i 2student                        ##設定使用者非活躍天數

-dstudent                          ##清除使用者密碼

監控passwd密碼資訊

watch -n 1 passwd -S student

3)file

file 檔案名字                     ##檢視檔案類型

4)檔案的檢視

cat filename                       ##顯示檔案的全部内容

less file                          ##分頁浏覽,按“q”退出

head filename                      ##顯示一個檔案的前幾行

head -n 5 filename                 ##前五行

tail filename                      ##顯示檔案後幾行

tail -n 5 filename                ##顯示一個檔案的後5行

5)wc統計檔案容量資訊

wc -l                             ##統計行數

   -w                             ##統計字數

   -c                             ##統計位元組數

   -m                             ##統計字元數

     ##tab鍵##

在系統中table鍵可以自動補齊存在的指令,檔案名稱和某些指令的參數

a+TAB x2                          ##a+兩次tab  顯示系統中所有a開有的指令

##history曆史調用##

history                           ##顯示曆史

hostory -c                        ##清除目前環境當中的曆史指令

!數字                            ##執行第多少行指令

!字母                            ##執行最近一條以這個字母開頭的指令

ctrl +R +關鍵字                   ##執行最近一條含有這個關鍵字的指令

上下鍵                            ##逐行調用指令

##linux中的快捷鍵##

左右                              ##一個字元一個字元移動

ctrl +左右                        ##一個字一個字移動

ctrl    + a                       ##光标移動到行首

        + e                       ##光标移動到行尾

        + u                       ##光标所在位置删除到行首

        + k                       ##光标所在位置删除到行尾

        + r+關鍵字                ##調出最近一條含有關鍵字的指令

        + c                       ##撤銷以輸入的指令

        + d                       ##關閉目前環境

        + L                       ##清空螢幕

        + shift + c               ##複制

        + shift + v               ##粘貼

        + shift + t               ##在現有shell中重新打開一個table        

        + shift + n               ##在shell中打開一個新的shell

        + shift + pageup|pagedown ##切換table

        + alt + l                 ## 鎖屏

        + alt +上|下              ##切換工作界面

        + alt + f1|f7             ##進入圖形界面

        + alt + f2-f6             ##進入虛拟控制台  

&lt;&lt;&lt;第一單元練習題&gt;&gt;&gt;

1.用student使用者登陸系統圖形界面

2.打開一個bash

3.修改student的密碼,把密碼更新成"T3st1ngtlme"(主機字母和數字)

<a href="https://s1.51cto.com/wyfs02/M00/8F/61/wKiom1jcigbQXPKjAAyP8vAx_Eo832.png-wh_500x0-wm_3-wmp_4-s_4021413845.png" target="_blank"></a>

4.顯示目前系統時間

5.顯示目前系統時間,顯示格式為:"小時:分鐘:秒 AM/PM"(AM/PM為上下午辨別)

6.顯示“/usr/bin/clean-binary-files”的檔案類型

7.統計“/usr/bin/clean-binary-files”的檔案大小

8.用快捷方式在shell中調用已經執行過的第4條指令

9.用快捷方式執行最近一條含有"date"關鍵字的指令

<a href="https://s3.51cto.com/wyfs02/M00/8F/5F/wKioL1jciinQ7sxLAA09U5TQdDc843.png-wh_500x0-wm_3-wmp_4-s_1085874952.png" target="_blank"></a>

本文轉自 漂浮的天堂  51CTO部落格,原文連結:http://blog.51cto.com/12774215/1911725,如需轉載請自行聯系原作者