天天看點

Linux C/C++計劃Shell指令大雜燴(1)

1, 請參見發行資訊

    cat /etc/issue

2, 檢視核心版本号

   uname -r 檢視核心版本号

   uname -p 檢視處理器類型32bit/64bit

   uname -n 檢視網絡主機名(or hostname)

3,OpenJDK和JDK啥差别?

   Oracle JDK is based on the OpenJDK source code. In addition, it contains closed-source components. 也就是說,OpenJDK去掉了JDK中涉及一些版權問題的API和源碼,功能比JDK少點。

4,父Shell、子Shell

  當在運作一個Shell Script時,父Shell會依據Script程式的第一行#!之後指定的Shell程式開啟一個子Shell環境,然後在子Shell中運作此Shell Script。一旦子Shell中的Script運作完成,此子Shell随即結束。回到父Shell中。不會影響父Shell原本的環境。子Shell環境擁有與父Shell同樣的環境變量、标準輸入、輸出、錯誤等。

5, source指令作用?

      能夠用help source檢視幫助文檔。P.S. 點指令與source指令一樣,使用方法為. filename [arguments]

      source: source filename [arguments]

              Execute commands from a file in the current shell.

Read and execute commands from FILENAME in the current shell.  The entries in $PATH are used to find the directory containing FILENAME.  If any ARGUMENTS are supplied, they become the positional parameters when FILENAME is executed.
    Exit Status:
    Returns the status of the last command executed in FILENAME; fails if FILENAME cannot be read.

  檔案filename能夠沒有運作權限。

  在目前shell中運作和在子shell中運作的差别是,後者定義的變量和函數在運作結束後就消失了,而前者卻能夠保留下來。是以,若我們改動了/etc/profile裡面的内容,如添加了環境變量。那麼假設要馬上生效的話,就必須使用source指令或者點指令在目前shell中運作一下。

6, 環境變量

    (1)檢視全部環境變量:

      $ set

    (2)檢視某個環境變量:

      $ echo "$PATH"

   (3)環境變量設定:

export ANT_HOME=/path/to/ant/dir      
export PATH=${PATH}:${ANT_HOME}/bin:${JAVA_HOME}/bin      

 (4) 持久化環境變量的檔案:

     /etc/profile, 存放系統級環境變量的地方,對全部使用者有效。設定完之後須要又一次登入才幹生效。

     ~/.bashrc, 存放目前使用者環境變量的地方,僅僅對目前使用者有效。

設定完之後僅僅須要又一次啟動shell。

     當然,上面介紹的source指令能夠馬上生效。

版權聲明:本文部落格原創文章。部落格,未經同意,不得轉載。

繼續閱讀