【Linux】一步一步学Linux——alias命令(205)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——alias命令(205)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 總結
- 06. 附錄
01. 命令概述
alias命令用來設置指令的別名。我們可以使用該命令可以將一些較長的命令進行簡化。使用alias時,用戶必須使用單引號 ‘ ‘ 將原來的命令引起來,防止特殊字符導致錯誤。
alias命令的作用只局限于該次登入的操作。若要每次登入都能夠使用這些命令別名,則可將相應的alias命令存放到bash的初始化文件 /etc/bashrc中。
02. 命令格式
用法:alias [-p] [名稱[=值] ... ]03. 常用選項
-p 以可重用的格式打印所有的已定義的別名04. 參考示例
4.1 查看命令別名
[deng@localhost ~]$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [deng@localhost ~]$4.2 打印所有的已定義的別名
[deng@localhost ~]$ alias -p alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [deng@localhost ~]$4.3 設置命令別名
[deng@localhost ~]$ alias lx='ls -lh' [deng@localhost ~]$ lx 總用量 55M drwxrwxr-x 7 deng deng 61 1月 22 2019 bak drwxrwxr-x 8 deng deng 73 3月 28 11:14 bj34 drwxr-xr-x 4 deng deng 4.0K 8月 16 11:10 instantclient_11_2 -rwxrwxr-x 1 deng deng 55M 1月 22 2019 oracle_client_11gR2.tar.gz drwxrwxr-x 3 deng deng 18 1月 22 2019 oradiag_deng drwxrwxr-x 10 deng deng 163 9月 1 16:05 projects -rwxrwxr-x 1 deng deng 2.1K 6月 30 15:14 scott_data.sql drwxrwxr-x 6 deng deng 50 9月 1 09:38 share drwxrwxr-x 8 deng deng 73 3月 10 09:16 sz12 -rwxrwxr-x 1 deng deng 599 8月 27 09:56 test.c -rwxrwxr-x 1 deng deng 1.7K 8月 3 15:05 test.cpp -rwxrwxr-x 1 deng deng 199 9月 1 19:50 test.sh -rw-rw-r-- 1 deng deng 13 9月 1 19:22 txt drwxr-xr-x. 2 deng deng 6 11月 8 2018 公共 drwxr-xr-x. 2 deng deng 6 11月 8 2018 模板 drwxr-xr-x. 2 deng deng 6 11月 8 2018 視頻 drwxr-xr-x. 2 deng deng 6 11月 8 2018 圖片 drwxr-xr-x. 2 deng deng 6 11月 8 2018 文檔 drwxr-xr-x. 2 deng deng 6 11月 8 2018 下載 drwxr-xr-x. 2 deng deng 6 11月 8 2018 音樂 drwxr-xr-x. 2 deng deng 6 7月 25 22:10 桌面 [deng@localhost ~]$注意:命令中選項必須使用引號
4.4 設置命令別名
[deng@localhost ~]$ alias lxx=ls [deng@localhost ~]$ lxx bak oradiag_deng sz12 txt 圖片 桌面 bj34 projects test.c 公共 文檔 instantclient_11_2 scott_data.sql test.cpp 模板 下載 oracle_client_11gR2.tar.gz share test.sh 視頻 音樂 [deng@localhost ~]$05. 總結
06. 附錄
參考:【Linux】一步一步學Linux系列教程匯總
總結
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——alias命令(205)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Linux】一步一步学Linux——p
- 下一篇: 【Linux】一步一步学Linux——u