(一)Linux基本描述,基本命令以及環境變量

1 Linux 發行版

Linux 發行版(英語:Linux distribution,也被叫做GNU/Linux 發行版),爲一般用戶預先集成好的Linux操作系統及各種應用軟件。一般用戶不需要重新編譯,在直接安裝之後,只需要小幅度更改設置就可以使用,通常以軟件包管理系統來進行應用軟件的管理。現在有超過300個Linux發行版(Linux發行版列表)。大部分都正處於活躍的開發中,不斷地改進。
由於大多數軟件包是自由軟件和開源軟件,所以Linux發行版的形式多種多樣——從功能齊全的桌面系統以及服務器系統到小型系統(通常在嵌入式設備,或者啓動軟盤)。除了一些定製軟件(如安裝和配置工具),發行版通常只是將特定的應用軟件安裝在一堆函數庫和內核上,以滿足特定用戶的需求。

流行的發行版

基於Dpkg (Debian系)

商業發行版

        Ubuntu,一個非常流行的桌面發行版,由Canonical維護
        社羣發行版
        Debian,一個強烈信奉自由軟件,並由志願者維護的系統
        Kubuntu, 使用KDE桌面的Ubuntu
        Linux Mint,從Ubuntu派生並與Ubuntu兼容的系統
        Knoppix,第一個Live CD發行版,可以從可移動介質運行,Debian的派生版
        OpenGEU,Ubuntu的派生版
        Elementary OS:基於Ubuntu,接口酷似Mac OS X
        gOS和其他上網本用的系統

基於RPM (Red Hat系)

商業發行版

        Red Hat Enterprise Linux,Fedora的商業版,由Red Hat維護和提供技術支持
        openSUSE,最初由Slackware分離出來,現在由Novell維護

社羣發行版

        Fedora,是Red Hat的社區版,會經常引入新特性進行測試
        PCLinuxOS,Mandriva的派生版本,由社區維護的非常流行的發行版
        CentOS,從Red Hat發展而來的發行版,由志願者維護,旨在提供開源的,並與Red Hat 100%兼容的系統
        Mageia,從Mandriva發展而來的發行版

基於其他包格式

        ArchLinux,一個基於KISS(Keep It Simple and Stupid)的滾動更新的操作系統
        Chakra,一個從ArchLinux派生出來,只使用KDE桌面的半滾動更新發行版
        Gentoo,一個面向高級用戶的發行版,所有軟件的源代碼需要自行編譯
        Slackware,最早的發行版之一,1993年創建,由Patrick J. Volkerding維護

2 Linux常用命令格式

Linux系統常用命令格式: command[選項] [參數]

其中選項以-開始,多個選項可用一個-連起來,如ls -l -a與ls -la。根據命令的不同,參數分爲可選的或必須的。

使用linux命令最主要的是要會使用命令幫助,常見的命令幫助有:
1.man command(系統手冊中的命令幫助)
2.info command(超級詳細的命令幫助)
3.command --help(shell內部的命令幫助)
4.whatis(簡短的命令說明)
5.apropos(聯機模糊搜索)

Linux命令格式實例

cat

[root@svr-75# cat --help
Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s), or standard input, to standard output.

  -A, --show-all           equivalent to -vET
  -b, --number-nonblank    number nonempty output lines, overrides -n
  -e                       equivalent to -vE
  -E, --show-ends          display $ at end of each line
  -n, --number             number all output lines
  -s, --squeeze-blank      suppress repeated empty output lines
  -t                       equivalent to -vT
  -T, --show-tabs          display TAB characters as ^I
  -u                       (ignored)
  -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
      --help     display this help and exit
      --version  output version information and exit

With no FILE, or when FILE is -, read standard input.

Examples:
  cat f - g  Output f's contents, then standard input, then g's contents.
  cat        Copy standard input to standard output.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'cat invocation'

cat 命令用於連接文件並打印到標準輸出設備上。使用--help查詢cat命令的用法。(介於文檔都是英文的,學好英語很重要

一個實例,使用cat -n顯示出每個line屬於哪一行

[root@ansible-svr data]# cat welcome
This is a test file.
Welcome to the Linux World.
Hope you have a amazing journey with me.
[root@ansible-svr data]# cat -n welcome
     1  This is a test file.
     2  Welcome to the Linux World.
     3  Hope you have a amazing journey with me.

history

linux的history命令的作用是,記錄執行過的命令。
用法:

* history [n]  n爲數字,列出最近的n條命令
* -c  將目前shell中的所有history命令消除
* -a 將目前新增的命令寫入histfiles, 默認寫入~/.bash_history
* -r  將histfiles內容讀入到目前shell的history記憶中
* -w 將目前history記憶的內容寫入到histfiles

history命令可以修改輸出格式,下面是正常的輸出格式:

[root@ansible-svr ~]# history
    1  history

數字代表第一條歷史記錄,如果現在我們想更改輸出格式,使之可以顯示出時間,我們則可以用以下命令:

HISTTIMEFORMAT="%F %T "

我們再來看看history的輸出“

[root@ansible-svr ~]# history
    1 2019-11-01 01:32:24 history
    2 2019-11-01 01:34:24 HISTTIMEFORMAT="%F %T "
    3 2019-11-01 01:34:27 history

但是使用這段命令並不能永久保存,退出環境下次就不能生效,如何使之永久生效呢。這時候得配置永久的環境變量。

3 環境變量

上例代表臨時更改環境變量,那麼如何永久更變環境變量呢。

profile文件:

修 改/etc/profile(對所有用戶都是有效的)
#vi /etc/profile
在裏面加入:
export PATH="$PATH:/home/xyz/Tesseract/bin"

bashrc文件:

修改~/.bashrc文件。  (每個用戶目錄下都有,ls -all,單獨用戶有效)
cd ~
vi .bashrc
在裏面加入:
export PATH="$PATH:/opt/au1200_rm/build_tools/bin"

永久設置方法一般需要重新註銷系統才能生效

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