跳转至

alias 命令


2015-09-18 by dongnan

举个栗子

创建一个别名 upcode

alias upcode='sudo salt -N web cmd.run "/path/salt_upcode.sh" -v'

使用这个别名

upcode

永久生效

设置的 alias只在当前会话有效,退出控制台后消失,如果永久生效需要在 .bashrc 文件添加这条 alias 命令。

# 编辑文件
vim .bashrc

# 自定义的alias
alias upcode='sudo salt -N web cmd.run "/path/salt_upcode.sh" -v'

即时生效

source .bashrc

查看当前的 alias 列表

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 rm='rm -i'
alias upcode='sudo salt -N web cmd.run "/path/salt_upcode.sh" -v'

命令帮助

alias --help
alias: alias [-p] [name[=value] ... ]
    Define or display aliases.

    Without arguments, `alias' prints the list of aliases in the reusable
    form `alias NAME=VALUE' on standard output.

    Otherwise, an alias is defined for each NAME whose VALUE is given.
    A trailing space in VALUE causes the next word to be checked for
    alias substitution when the alias is expanded.

    Options:
      -p    print all defined aliases in a reusable format

    Exit Status:
    alias returns true unless a NAME is supplied for which no alias has been
    defined.



回到页面顶部