自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux Bash Shell命令別名介紹

運維 系統(tǒng)運維
命令別名是一個很有趣的東西,特別是你的慣用指令特別長的時候!還有,預(yù)防一些不小心誤殺檔案的情況發(fā)生的時候!

Linux Bash Shell命令別名是一個很有趣的東西,特別是你的慣用指令特別長的時候!還有,預(yù)防一些不小心誤殺檔案的情況發(fā)生的時候!舉個例子來說,如果你要查詢隱藏檔,并且需要長的列出與一頁一頁翻看,那么需要下達(dá)『 ls -al | more 』這個指令,我是覺得很煩啦!要輸入好幾個單字!那可不可以使用 lm 來簡化呢?!當(dāng)然可以,你可以在命令列下面下達(dá):

[test @tset test]# alias lm='ls -al | more'

要注意的是:『alias 的定義規(guī)則與變數(shù)定義規(guī)則幾乎相同』,所以你只要在 alias 后面加上你的{『別名』='指令 參數(shù)' },以后你只要輸入 lm 就相當(dāng)于輸入了 ls -al|more 這一串指令!很方便吧!另外,我們知道 root 可以移除( rm )任何資料!所以當(dāng)你以 root 的身份在進(jìn)行工作時,需要特別小心,但是總有失手的時候,那么 rm 提供了一個參數(shù)來讓我們確認(rèn)是否要移除該檔案,那就是 -i 這個參數(shù)!所以,你可以這樣做:

[test @tset test]# alias rm='rm -i'
嘿嘿!那么以后使用 rm 的時候,就不用太擔(dān)心會有錯誤刪除的情況了!這也是命令別名的優(yōu)點啰!那么如何知道目前有哪些的命令別名呢?就使用 alias 呀!
 

  1. [test @tset test]# alias   
  2. alias l.='ls -d .[a-zA-Z]* --color=tty'   
  3. alias ll='ls -l'   
  4. alias lm='ls -al'   
  5. alias ls='ls --color=tty'   
  6. alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 

· 至于如果要取消命令別名的話,那么就使用 unalias 吧!
· 歷史指令記錄資料:
前面我們提過 Linux Bash Shell有提供指令歷史的服務(wù)!那么如何查詢我們曾經(jīng)下達(dá)過的指令呢?就使用 history 啰!
o history, !command
顯示歷史指令記錄內(nèi)容, 下達(dá)歷史紀(jì)錄中的指令
Linux Bash Shell語法:
 
 

  1. [test @tset test]# alias   
  2. alias l.='ls -d .[a-zA-Z]* --color=tty'   
  3. alias ll='ls -l'   
  4. alias lm='ls -al'   
  5. alias ls='ls --color=tty'   
  6. alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 

Linux Bash Shell說明:
基本上 history 的用途很大的!但是需要小心安全的問題!尤其是 root 的歷史紀(jì)錄檔案,這是 Cracker 的最愛!因為不小心的 root 會將很多的重要資料在執(zhí)行的過程中會被紀(jì)錄在 ~/.bash_history 當(dāng)中,如果這個檔案被解析的話.....而使用『 ! 』配合曾經(jīng)使用過的指令下達(dá)是很有效率的一個指令方法!
鳥哥的常用的個人喜好設(shè)定值:
底下是 VBird 最喜歡的設(shè)定值啰!大家可以隨意的參考看看就好了!
 

  1. [test @test test]# vi .bashrc   
  2. # .bashrc   
  3. # User specific aliases and functions   
  4. PATH="/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/sbin:/usr/bin:$PATH" <==常用!   
  5. export PATH   
  6. alias rm='rm -i'   
  7. alias cp='cp -i'   
  8. alias mv='mv -i'   
  9. alias ll='ls -l'   
  10. alias lm='ls -al|more' <==常用!   
  11. alias h='history'<==常用!   
  12. # Source global definitions   
  13. if [ -f /etc/bashrc ]; then   
  14. . /etc/bashrc   
  15. fi   

[test @test test]# source ~/.bashrc<==將剛剛改的資料直接讀入這一次的程序當(dāng)中!不需登出!

當(dāng)然還有一些個人比較常用的變數(shù),這里就不列出來了!那么改寫完畢之后。此外,通常我們改寫的這些設(shè)定,必須要登出再登入才能被啟用!但是我們可以使用 source 來直接的啟用他!這也是很多朋友為了因應(yīng)不同的軟體或者是其他的執(zhí)行環(huán)境,而寫了不同的環(huán)境設(shè)定檔案(不一定是 .bashrc 這個檔案),然后在需要的時候再以 source 來將設(shè)定讀出來即可!這個指令可也是相當(dāng)重要的呦!

【編輯推薦】

  1. Linux Bash命令關(guān)于程序調(diào)試詳解 
  2. Linux Bash命令關(guān)于快捷鍵應(yīng)用
  3. Linux Bash Shell系統(tǒng)的應(yīng)用詳解
  4. Linux Bash具體安裝步驟及使用介紹
  5. Linux Bash命令查詢相關(guān)事件詳解

 

責(zé)任編輯:chenqingxiang 來源: Linux社區(qū)
相關(guān)推薦

2010-06-23 16:31:10

Linux Bash

2010-06-23 17:34:03

Linux Bash

2010-06-23 17:37:14

Linux Bash

2010-06-23 17:29:07

Linux Bash

2023-07-27 17:41:02

BashZshFish

2010-06-23 16:05:36

Linux Bash

2018-01-16 10:08:25

Linuxbashshell

2010-06-23 15:55:36

Linux Bash

2010-06-23 14:45:02

Linux Bash

2009-12-25 09:47:05

LinuxShell編程bash

2010-06-23 16:42:33

2010-06-23 16:09:40

Linux Bash

2018-10-12 10:40:45

LinuxBash命令

2010-06-23 16:35:50

Linux Bash

2010-06-23 15:36:23

Linux Bug B

2010-03-23 15:52:41

Linux shell

2023-10-31 16:17:42

2009-12-18 08:57:27

Linux shell

2010-06-23 10:03:18

Linux Bash命

2019-08-05 10:00:13

LinuxBash命令
點贊
收藏

51CTO技術(shù)棧公眾號