設置別名
1.1 別名,有些命令很危險,修改別名防止誤操作
1.1.1查看別名
[[email protected] ~]# alias
alias cp=‘cp -i‘
alias l.=‘ls -d .* --color=auto‘
alias ll=‘ls -l --color=auto‘
alias ls=‘ls --color=auto‘
alias mv=‘mv -i‘
alias which=‘alias | /usr/bin/which --tty-only--read-alias --show-dot --show-tilde‘
[[email protected] ~]#
1.1.2臨時修改別名,重啟服務器失效
[[email protected] ~]# alias rm=‘echo -bash: rm:command not found‘
[[email protected] ~]# rm -rf /tmp
-bash: rm: command not found -rf /tmp
[[email protected] ~]#
1.1.3把修改寫入配置文件
[[email protected] ~]# echo "alias rm=‘echo-bash: rm: command not found‘" >> /etc/profile
[[email protected]
unset -f pathmunge
alias rm=‘echo -bash: rm: command not found‘
[[email protected] ~]#
1.1.4讓配置文件生效
[[email protected] ~]# source /etc/profile
[[email protected] ~]#
1.1.5如果命令有其他別名,這裏還要修改/root/.bashrc文件
[[email protected] ~]# cat /root/.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
[[email protected] ~]#
1.1.5.1 等下次重啟服務器後別名永久生效
每天都需要成長。。。
本文出自 “12933988” 博客,請務必保留此出處http://12943988.blog.51cto.com/12933988/1951803
設置別名