Linux 學習總結 unit01訪問命令行


#0. 輸入法設置

      Application -> System Tools ->Setting -> Regin&Language

   ->Input Sources

#1.shell

        Shell俗稱殼(用來區別於核),是指“提供使用者使用
        界面”的軟件(命令解析器)
       - 圖形界面shell:Gnome,KDE......
       - 命令行式shell:bash,csh,ksh.......

                 Linux系統缺省的shell類型爲bash

 ##1.1.打開shell的4種方式

               快捷鍵:

                                ctrl+shift+n      //打開一個新的shell

                    ctrl+shift+t         //在一個窗口中打開新的table

                    alt+數字           //當爲alt+2時代表切換到第二個

                 table

                             ctrl+shift+PgUp/PgDn        //將table前移/後移

 ##1.2.退出shell

                 exit

                 ctrl+d

                 logout

 ##1.3GNOME常用快捷操作

• Ctrl+Alt+上|下 //切換工作界面
• Ctrl+Alt+L /win+L//鎖屏
• Alt + F1 //打開主菜單Application
• Alt + F10 //最大化當前窗口
• PrtSc //截取全屏
• Ctrl+Shift+PrtSc //截取選中的屏幕
• Alt + Tab //切換窗口
• Alt + F4 //關閉窗口

#2.

 ##2.1.命令行提示符:

                           [用戶名  分隔符@  主機名  當前所在目錄]  身份提示符

                                [root@fundation77 desktop]#

                                [stu@localhost 桌面]$

[kiosk@foundation0 Desktop]$:

kiosk //開啓shell的用戶
@ //分隔符
foundation0 //主機的短名稱,表示shell開啓在那臺主機裏
Desktop //表示你在系統的什麼位置
$ //身份提示符中的普通用戶,超級用戶的提示符爲:#

##2.2.虛擬控制檯

虛擬控制檯最有用的時候是當一個程序出錯鎖住輸入時可以切
換到其他虛擬控制檯
ctrl+alt+f2~f6 //進入虛擬控制檯
ctrl+alt+F1|F7 //回到圖形

虛擬機的管理
rht-vmctl start desktop //開啓虛擬機desktop
rht-vmctl view desktop //顯示虛擬機desktop
rht-vmctl powerofff desktop //強制關閉虛擬機des

##2.3.切換用戶:

                        su -l 用戶名          //切換到某個用戶,eg:su -l root

                                                                                     //root用戶切換到普通用戶不需要密碼,普通用戶切換到root用戶需要密碼


 ##2.4.修改用戶密碼passwd(只能在root用戶下修改):

[root@Hello18 桌面]# passwd --help
Usage: passwd [OPTION...] <accountName>
  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only)
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before
                          password expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an
                          account becomes disabled (root only)


  -S, --status            report password status on the named account (root
                          only)
  --stdin                 read new tokens from stdin (root only)

Help options:
  -?, --help              Show this help message
  --usage                 Display brief usage message


[root@Hello18 桌面]# 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.

//普通用戶student的密碼只能在root下修改
[root@Hello18 桌面]# passwd student
Changing password for user student.
New password:                                       //此處不會顯示密碼
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:                               //此處不會顯示密碼
passwd: all authentication tokens updated successfully.




                                                                                                                                                                                                                                      

 ##2.5.怎麼獲取命令幫助(以passwd爲例)

                    查看幫助的4種方式:

                                1.passwd --help

[root@Hello18 桌面]# passwd --help
Usage: passwd [OPTION...] <accountName>
  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only)
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before
                          password expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an
                          account becomes disabled (root only)
  -S, --status            report password status on the named account (root
                          only)
  --stdin                 read new tokens from stdin (root only)

Help options:
  -?, --help              Show this help message
  --usage                 Display brief usage message

                                 2.man passwd[n向下翻頁N向上翻頁q退出]

PASSWD(1)                       User utilities                       PASSWD(1)

NAME
       passwd - update user's authentication tokens

SYNOPSIS
       passwd  [-k]  [-l]  [-u  [-f]]  [-d] [-e] [-n mindays] [-x maxdays] [-w
       warndays] [-i inactivedays] [-S] [--stdin] [username]

DESCRIPTION
       The passwd utility is used to update user's authentication token(s).

       This task is achieved through calls to the Linux-PAM and  Libuser  API.
       Essentially, it initializes itself as a "passwd" service with Linux-PAM
       and utilizes configured  password  modules  to  authenticate  and  then
       update a user's password.

       A simple entry in the global Linux-PAM configuration file for this ser‐
       vice would be:

        #
        # passwd service entry that does strength checking of
        # a proposed password before updating it.
 ------------------------------------------------------------------不贅述

                                 3.pinfo passwd

                                 4./usr/share/doc

##2.6.讀懂幫助信息

• [內容] //內容選加
• <內容> //內容必加
• 內容... //內容個數任意

#3.shell命令

 ##3.1.shell中如何使用命令?

1. 命令一定要在提示符之後輸入
2. 命令的輸入方式:命令 參數 目標
參數是命令功能的指定:
-參數 //單詞的縮寫
--參數 //單詞的全拼

##3.2.簡單的命令(具體可自行搜索)

   date 
1.顯示時分秒
date +%H:%M:%S
date +%T
date +%X
2.顯示年月日
date +%Y-%m-%d''%x
date +%Y-%m-%d\%x

   passwd
1.passwd -d username刪除密碼
2.passwd -l username鎖定用戶密碼
3.passwd -uusername解除鎖定
4.passwd -S username查看密碼狀態
5.passwd -x  num username密碼最大生存時間


   cal
cal -s 週日爲第一天的日曆
cal -m 週一爲第一天的日曆
cal -j 顯示今天是這一年的多少天
cal -y 這一年的日曆
cal -3 顯示上個月這個月下個月的日曆

   file
1.file -f列出文件中文件名的文件類型
2.file -b列出文件辨識結果時,不顯示文件名稱。
3.file -c詳細顯示指令執行過程,便於排錯或分析程序執行的情形
4.file -i輸出mime類型的字符串
5.file -z嘗試去解讀壓縮文件的內容

   head
1.

head -n 5   filename   顯示文檔中的前5行

head -n -5 filename   顯示文件除了最後n行以外的其他內容

2.head -q  filename  隱藏文件名3.head -c  filename 顯示字節數
4.head filename顯示文件前10行
5.head -v  filename顯示文件名

   tail
1.tail -n num filename //顯示文件的後幾行
2.tail -k  filename num 從 Number 變量表示的1KB 塊位置開始讀取指定文件
3.tail -r [-n num] filename 從文件末尾以逆序方式顯示輸出。
4.tail -c num filename 從 Number 變量表示的字節位置開始讀取指定文件。
5.tail -f /var/log/messages 參數-f使tail不停讀新內容,實時監視,用Ctrl+c可終止.

   wc
1.wc filename顯示文件的行數,單詞數和字節數
2.wc -l filename顯示文件的行數
3.wc -w filename顯示文件的單詞數
4.wc -c filename顯示文件的字節數(注意:1箇中文字符=3個字
5.wc -m filename顯示文件的字符數

   history
查看歷史命令:
1.history查看歷史命令
2.history -c清空歷史命令
調用歷史命令:
3.!數字//執行第(數字)條命令
4.!關鍵字//執行該關鍵字開頭的命令
5.ctrl+r然後輸入關鍵字//逆向搜索歷史命令並執行

 ##3.3.歷史命令調用

   !數字 //執行第多少條命令
  !關鍵字 //執行最近一條以關鍵字開頭的命令
  ctrl+R+關鍵字 //調出最近一條含有關鍵字的命令
  上下鍵 //從最後一條命令開始向前查看或者向後查看
   history //查看歷史
   history -c //清除歷史

 ##3.4.命令行常用快捷鍵

ctrl + a //光標移動到行首
ctrl + e //光標移動到行尾
ctrl + u //光標所在位置刪除到行首
ctrl + k //光標所在位置刪除到行尾
ctrl + r //調出最近一條含有關鍵字的命令
 ctrl + 左|右 //以單詞爲單位移動光標
ctrl + c //撤銷已輸入的命令
ctrl + d //關閉當前環境
ctrl + shift + t  //在現有shell中新打開一table
ctrl + shift + pageup|pagedown  //切換table




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