linux alias 命令 查看系統設置的命令別名


 

alias命令用於查看或設置命令別名,但僅作用於該次登陸的會話,若要永久使用別名,可在 ~/.bashrc 中設定別名

[root@MongoDB ~]#  alias              // 查看別名
[root@MongoDB ~]#  alias cp='cp -i'   // 設置別名
[root@MongoDB ~]#  unalias cp         // 取消別名

 

[root@MongoDB ~]# alias 
alias cp='cp -i'
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 mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

定義別名永久生效:

/etc/profile 全局生效

~/.bashrc 當前用戶生效

root@MongoDB ~]# cat .bashrc 
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

 

 

別名的作用:

1.通過給危險的命令加一些保護的參數,防止人為誤操作。

2.把很多復雜的字符串或命令變成一個簡單的字符串或命令。

 

別名對應的命令:

alias 查看和設置別名

unalias 取消別名


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM