73、alias用法简介

1、alias - define or display aliases

1)alias [alias-name='original-command']

alias [alias-name[=string] ...]

alias[别名]=[指令名称]

通过unalias alias-name来取消别名。

2)用户可利用alias,自定指令的别名。若仅输入alias,则可列出目前所有的别名设置。alias的作用仅限于该次登入的操作。若要每次登入是即自动设好别名,可在/etc/profile或自己的~/.bashrc中设定指令的别名。

    Use your favorite text editor to create a file called ~/.bash_aliases, and type the alias commands into the file ..bash_aliases will run at login (or you can just execute it with ..bash_aliases )。Bash does not try to recursively expand the replacement text.

3)如果你想给每一位用户都生效的别名,则把alias la='ls -al' 一行加在/etc/bashrc最后面,bashrc是环境变量的配置文件,/etc/bashrc~/.bashrc 区别就在于一个是设置给全系统,一个是设置给单用户使用。

参考

参考

1】 比较全面的bash命令主页

http://ss64.com/bash/alias.html

2http://www.linuxso.com/command/alias.html

3】 对shell讲解的不错

http://blog.csdn.net/clozxy/article/details/5652275

原文地址:https://www.cnblogs.com/mydomain/p/2247220.html