小弟我的openwrt学习笔记(十八):linux便捷开发命令之alias

我的openwrt学习笔记(十八):linux便捷开发命令之alias

                        我的openwrt学习笔记(十八):linux便捷开发命令之alias

         学习linux命令的是LINUX 的基础,相信很多人N多年前就知道这个命令,学习额时候也用过它,但是久而久之这个命令就淡出了我们的视野!在实际的工作中有时候会遗忘它,终其主要原因是字实际应用中运用的不够多!

  

Linux命令:alias

功能说明:设置指令的别名。
语  法:alias[别名]=[指令名称]
补充说明:用户可利用alias,自定指令的别名。若仅输入alias,则可列出目前所有的别名设置。 
alias的效力仅及于该次登入的操作。若要每次登入是即自动设好别名,可在~/.bashrc中设定指令的别名。

 

     Alias个人在实际的工作中用的最多就是,进入比较厂的linux目录,比如编译openwrt的目录(d/home/linux/svn0825/develop/openwrt-3.10.14),比较长,如果靠cd 一级级的进入实在太委屈linux 了,你说呢?

设置别名,修改

linux@ubuntu:~/svn0825/develop/openwrt-3.10.14$ vi ~/.bashrc 文件

# enable programmable completion features (you don't need to enable

# this, if it's already enabled in /etc/bash.bashrc and /etc/profile

# sources /etc/bash.bashrc).

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then

    . /etc/bash_completion

fi

alias op7688='cd /home/linux/svn0825/develop/openwrt-3.10.14'

让设置的op7688生效

linux@ubuntu:~$ source ~/.bashrc

 

 

查看alias设置情况

linux@ubuntu:~$ alias

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

alias egrep='egrep --color=auto'

alias fgrep='fgrep --color=auto'

alias grep='grep --color=auto'

alias l='ls -CF'

alias la='ls -A'

alias ll='ls -alF'

alias ls='ls --color=auto'

alias op7688='cd /home/linux/svn0825/develop/openwrt-3.10.14'

 

 

测试op7688别名

linux@ubuntu:~$ pwd

/home/linux

linux@ubuntu:~$ op7688

linux@ubuntu:~/svn0825/develop/openwrt-3.10.14$ pwd

/home/linux/svn0825/develop/openwrt-3.10.14

 

至此,就可以在任何目录下随意的的重新进入openwrt开发目录了,alias的精神得领悟哦。

 

 

希望可以授人以渔,^--^ 

版权声明:本文为博主原创文章,未经博主允许不得转载。文章转载只能用于非商业性质,且不能带有虚拟货币、积分等附加条件;转载必须注明出处。