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 取消别名

转载于:https://www.cnblogs.com/mingerlcm/p/10791074.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值