Linux基本命令概述1

X window與文字模式的切換

Kernel 3.10.0-957.27.2.el7.x86_64 on an x86_64: 顯示 Linux 核心的版本爲3.10.0-957.27.2.el7.x86_64, 且目前這部主機的硬件等級爲x86_64。
在這裏插入圖片描述
如果你的Linux默認使用純命令行,那麼 tty1~tty6 就會被文字界面佔用。若你在純文本環境中啓動 X 窗口,那麼圖形界面就會出現在當時的那個tty上面

#純命令行下(不能有X存在)啓動窗口界面的作法
[withong@withong ~]$	startx

你必須要已經安裝了X Window system,並且Xserver是能夠順利啓動的

提示符

至於提示字符方面,在Linux當中,默認root的提示字符爲#,而一般身份使用者的提示字符爲$

一個稱職的網絡/系統管理人員,通常都會具有兩個帳號,平時以自己的一般帳號來使用Linux主機的任何資源, 有需要動用到系統功能修訂時,纔會轉換身份成爲root呢!所以,強烈建議你創建一個普通的帳號來供自己平時使用!

那麼如何離開系統呢?其實應該說“登出Linux”纔對!登出很簡單,直接這樣做:

[withong@withong~]$	exit

命令模式

指令, 選項, 參數等這幾個咚咚中間以空格來區分,不論空幾格 shell 都視爲一格。所以空格是很重要的特殊字符!;

指令太長的時候,可以使用反斜線 (\) 來跳脫[Enter]符號,使指令連續到下一行。注意!反斜線後就立刻接特殊字符,才能跳脫!

常用的簡單指令:
修改語系:

[withong@withong ~]$ locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

修改語系成爲英文語系
[dmtsai@study	~]$	LANG=en_US.utf8

顯示日期:

[withong@withong ~]$ date
2020年 02月 21日 星期五 21:00:43 CST

顯示日曆:

[withong@withong ~]$ cal
      二月 2020     
日 一 二 三 四 五 六
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29

計算器:

[withong@withong ~]$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
scale=3	 <== 保留小數點位數,默認整數
1+2+3
6 

【Tab】鍵:具有“命令補全”與“文件補齊”的功能

[withong@withong ~]$ cal [tab][tab]	 <==[tab]按鍵是緊接在a字母后面!
cal            calibrate_ppa  caller

以cal爲開頭的指令都被顯示出來

[withong@withong /]$ ls -al ~/.bash[tab][tab]
.bash_history  .bash_logout   .bash_profile  .bashrc 

在該目錄下面所有以.bash爲開頭的文件名稱都會被顯示出來

[withong@withong /]$ date --
--date        --help        --reference=  --rfc-3339=   --universal   
--date=       --iso-8601    --rfc-2822    --set=        --version  

選項/參數的補齊

【Tab】鍵總結:

  • [Tab]接在一串指令的第一個字的後面,則爲“命令補全”;
  • [Tab]接在一串指令的第二個字以後時,則爲“文件補齊”!
  • 若安裝 bash-completion 軟件,則在某些指令後面使用 [tab] 按鍵時,可以進行“選項/參
    數的補齊”功能!

[Ctrl]-c 按鍵 中斷目前程序

[withong@withong~]$	find	/
....(一堆東西都省略)....
#	此時屏幕會很花,你看不到命令提示字符的!直接按下[ctrl]-c即可!

[Ctrl]-d 按鍵
鍵盤輸入結束(End Of File, EOF 或 End Of Input)

[shift]+{[PageUP]|[Page Down]}按鍵
往前翻頁 往後翻頁

幫助信息

–help 用在協助你查詢“你曾經用過的指令所具備的選項與參數

[withong@withong /]$ date --help
用法:date [選項]... [+格式]
 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING         display time described by STRING, not 'now'
  -f, --file=DATEFILE       like --date once for each line of DATEFILE
  -I[TIMESPEC], --iso-8601[=TIMESPEC]  output date/time in ISO 8601 format.
                            TIMESPEC='date' for date only (the default),
                            'hours', 'minutes', 'seconds', or 'ns' for date
                            and time to the indicated precision.
  -r, --reference=文件		顯示文件指定文件的最後修改時間
  -R, --rfc-2822		以RFC 2822格式輸出日期和時間
				例如:200687日,星期一 12:34:56 -0600
      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
                            TIMESPEC='date', 'seconds', or 'ns' for
                            date and time to the indicated precision.
                            Date and time components are separated by
                            a single space: 2006-08-07 12:34:56-06:00
  -s, --set=STRING          set time described by STRING
  -u, --utc, --universal    print or set Coordinated Universal Time (UTC)
      --help		顯示此幫助信息並退出
      --version		顯示版本信息並退出

man(manual的縮寫 不是男人哈)page

[withong@withong /]$ man date

DATE(1)                                  FSF                                 DATE(1) 
<==這個(1)有特殊含義喲 
NAME
       date - 打印或設置系統日期和時間

總覽
       date [選項]... [+格式]
       date [選項] [MMDDhhmm[[CC]YY][.ss]]

描述
       根據指定格式顯示當前時間或設置系統時間.

       -d, --date=STRING
              顯示由 STRING 指定的時間, 而不是當前時間

       -f, --file=DATEFILE
              顯示  DATEFILE 中每一行指定的時間, 如同將 DATEFILE 中的每行作爲 --date
              的參數一樣

              -I, --iso-8601[=TIMESPEC] 按照 ISO-8601 的日期/時間格式輸出時間.

              TIMESPEC=`date'  (或者不指定時)僅輸出日期,等於   `hours',   `minutes',
              或`seconds' 時按照指定精度輸出日期及時間.

       -r, --reference=FILE

進入man指令的功能後,你可以按下“空白鍵”往下翻頁,可以按下“ q ”按鍵來離開man的環境。

DATE(1)中的數字的特殊含義:
在這裏插入圖片描述
上述的表格內容可以使用“man man”來更詳細的取得說明。1, 5, 8這三個號碼特別重要,也請讀者要將這三個數字所代表的意義背下來喔!

man page大致分成下面這幾個部分:
在這裏插入圖片描述
有時候除了這些外,還可能會看到Authors與Copyright等,不過也有很多時候僅有NAME與DESCRIPTION等部分。

man page 文檔關鍵字查找: /
例如在上面的搜尋當中,我輸入了“/date”會變成怎樣?
在這裏插入圖片描述

man page常用的按鍵整理:
在這裏插入圖片描述
上面的按鍵是在man page的畫面當中才能使用的!
man page的文檔通常是放在/usr/share/man這個目錄裏頭

查找更多說明文檔:-f
系統中還有哪些跟“man”這個指令有關的說明文檔呢

[withong@withong /]$ man -f man
man (1)              - 格式化並顯示在線幫助手冊頁
man (7)              - 格式化手冊頁的宏
man (1p)             - display system documentation

使用 -f 這個選項就可以取得更多與man相關的信息

指定不同的文件的

[withong@withong~]$	man	1	man		<==這裏是用	man(1)	的文件數據
[withong@withong~]$	man	7	man		<==這裏是用	man(7)	的文件數據

忘記了下達數字,只有輸入“ man man ”時,那麼取出的數據到底是1還是7啊? 這個就跟搜尋的順序有關了。搜尋的順序是記錄在/etc/man_db.conf 這個配置文件當中, 先搜尋到的那個說明文檔,就會先被顯示出來! 一般來說,通常會先找到數字較小的那個啦!因爲排序的關係啊!所以, man man 會跟 man 1 man 結果相同!

列出包含關鍵字的所有文檔:找出系統的說明文檔中,只要有man這個關鍵字就將該說明列出來

[withong@withong~]$	man	-k	man

command (1)          - GNU Bourne-Again SHell (GNU 命令解釋程序 “Bourne二...
man (1)              - 格式化並顯示在線幫助手冊頁
man (7)              - 格式化手冊頁的宏
man.conf (5)         - man 的 設 定 資 料
man.config (5)       - man 的 設 定 資 料
PagesManager (3tk)   - 頁面管理器組件
bpf (2)              - perform a command on an extended BPF map or program
bsd_signal (3)       - signal handling with BSD semantics
cproj (3)            - project into Riemann Sphere
cprojf (3)           - project into Riemann Sphere
cprojl (3)           - project into Riemann Sphere
fallocate (2)        - manipulate file space
getopt (3)           - Parse command-line options
getopt_long (3)      - Parse command-line options
getopt_long_only (3) - Parse command-line options
gnu_dev_major (3)    - manage a device number
gnu_dev_makedev (3)  - manage a device number
gnu_dev_minor (3)    - manage a device number
hcreate (3)          - hash table management
hcreate_r (3)        - hash table management
hdestroy (3)         - hash table management
hdestroy_r (3)       - hash table management

這個是利用關鍵字將說明文檔裏面只要含有man那個字眼的(不見得是完整字串) 就將他取出來!

提示:不記得打印的相關指令,僅記得 lp (line print)而已。那我就由 man lp 開始,去找相關的說明,然後,再以 lp[tab][tab] 找到任何以 lp 爲開頭的指令,找到我認爲可能有點相關的指令後,先以–help去查基本的用法,若有需要再以man去查詢指令的用法!

info page

你要查詢的目標數據的說明文檔必須要以info的格式來寫成才能夠使用info的特殊功能

[withong@withong~]$	info info
File: info.info,  Node: Top,  Next: Getting Started,  Up: (dir)

Info: An Introduction
*********************

The GNU Project distributes most of its on-line manuals in the "Info
format", which you read using an "Info reader".  You are probably using
an Info reader to read this now.

   There are two primary Info readers: 'info', a stand-alone program
designed just to read Info files (*note What is Info?: (info-stnd)Top.),
and the 'info' package in GNU Emacs, a general-purpose editor.  At
present, only the Emacs reader supports using a mouse.

   If you are new to the Info reader and want to learn how to use it,
type the command 'h' now.  It brings you to a programmed instruction
sequence.

   To read about advanced Info commands, type 'n' twice.  This brings
you to 'Advanced Info Commands', skipping over the 'Getting Started'
chapter.

   This file describes how to use Info, the on-line, menu-driven GNU
documentation system.
--zz-Info: (info.info.gz)Top, 52 lines --Top-------------------------------------------
No `Prev' or `Up' for this node within this document.

仔細的看到上面這個顯示的結果,裏面的第一行顯示了很多的信息喔!第一行裏面的數據意
義爲:

  • File:代表這個info page的數據是來自info.info文件所提供的;
  • Node:代表目前的這個頁面是屬於Top節點。 意思是info.info內含有很多信息,而Top僅是info.info文件內的一個節點內容而已;
  • Next:下一個節點的名稱爲Getting Started,你也可以按“N”到下個節點去;
  • Up:回到上一層的節點總攬畫面,你也可以按下“U”回到上一層;
  • Prev:前一個節點。但由於Top是info.info的第一個節點,所以上面沒有前一個節點的信
    息。

如論你在任何一個頁面,只要不知道怎麼使用info了,直接按下h系統就能夠提供一些基本按鍵功能的介紹喔!

Basic Info command keys

x           Close this help window.
q           Quit Info altogether.
H           Invoke the Info tutorial.

Up          Move up one line.
Down        Move down one line.
DEL         Scroll backward one screenful.
SPC         Scroll forward one screenful.
Home        Go to the beginning of this node.

在這裏插入圖片描述
infopage的文件放置在/usr/share/info/目錄中

其他有用的文件(documents)

很多原版軟件釋出的時候,都會有一些安裝須知、預計工作事項、未來工作規劃等等的東西,還有包括可安裝的程序等, 這些文件也都放置在 /usr/share/doc 當中喔!而且/usr/share/doc這個目錄下的數據主要是以套件(packages)爲主的

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