【Linux】一步一步学Linux——alias命令(205)
发布日期:2021-06-29 20:45:03
浏览次数:2
分类:技术文章
本文共 2433 字,大约阅读时间需要 8 分钟。
00. 目录
文章目录
01. 命令概述
alias命令用来设置指令的别名。我们可以使用该命令可以将一些较长的命令进行简化。使用alias时,用户必须使用单引号 ‘ ‘ 将原来的命令引起来,防止特殊字符导致错误。
alias命令的作用只局限于该次登入的操作。若要每次登入都能够使用这些命令别名,则可将相应的alias命令存放到bash的初始化文件 /etc/bashrc中。
02. 命令格式
用法:alias [-p] [名称[=值] ... ]
03. 常用选项
-p 以可重用的格式打印所有的已定义的别名
04. 参考示例
4.1 查看命令别名
[deng@localhost ~]$ alias 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 vi='vim'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'[deng@localhost ~]$
4.2 打印所有的已定义的别名
[deng@localhost ~]$ alias -palias 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 vi='vim'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'[deng@localhost ~]$
4.3 设置命令别名
[deng@localhost ~]$ alias lx='ls -lh'[deng@localhost ~]$ lx总用量 55Mdrwxrwxr-x 7 deng deng 61 1月 22 2019 bakdrwxrwxr-x 8 deng deng 73 3月 28 11:14 bj34drwxr-xr-x 4 deng deng 4.0K 8月 16 11:10 instantclient_11_2-rwxrwxr-x 1 deng deng 55M 1月 22 2019 oracle_client_11gR2.tar.gzdrwxrwxr-x 3 deng deng 18 1月 22 2019 oradiag_dengdrwxrwxr-x 10 deng deng 163 9月 1 16:05 projects-rwxrwxr-x 1 deng deng 2.1K 6月 30 15:14 scott_data.sqldrwxrwxr-x 6 deng deng 50 9月 1 09:38 sharedrwxrwxr-x 8 deng deng 73 3月 10 09:16 sz12-rwxrwxr-x 1 deng deng 599 8月 27 09:56 test.c-rwxrwxr-x 1 deng deng 1.7K 8月 3 15:05 test.cpp-rwxrwxr-x 1 deng deng 199 9月 1 19:50 test.sh-rw-rw-r-- 1 deng deng 13 9月 1 19:22 txtdrwxr-xr-x. 2 deng deng 6 11月 8 2018 公共drwxr-xr-x. 2 deng deng 6 11月 8 2018 模板drwxr-xr-x. 2 deng deng 6 11月 8 2018 视频drwxr-xr-x. 2 deng deng 6 11月 8 2018 图片drwxr-xr-x. 2 deng deng 6 11月 8 2018 文档drwxr-xr-x. 2 deng deng 6 11月 8 2018 下载drwxr-xr-x. 2 deng deng 6 11月 8 2018 音乐drwxr-xr-x. 2 deng deng 6 7月 25 22:10 桌面[deng@localhost ~]$
注意:命令中选项必须使用引号
4.4 设置命令别名
[deng@localhost ~]$ alias lxx=ls[deng@localhost ~]$ lxxbak oradiag_deng sz12 txt 图片 桌面bj34 projects test.c 公共 文档instantclient_11_2 scott_data.sql test.cpp 模板 下载oracle_client_11gR2.tar.gz share test.sh 视频 音乐[deng@localhost ~]$
05. 总结
06. 附录
参考:
转载地址:https://dengjin.blog.csdn.net/article/details/100187796 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年04月22日 03时54分48秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
移植Qt4.7.3
2019-04-30
Qt移植对USB鼠标键盘、触摸屏的支持
2019-04-30
LCD驱动移植
2019-04-30
驱动开发小结
2019-04-30
Qt Creator创建纯C、c++工程
2019-04-30
Android单元测试之 Robolectric3.0+
2019-04-30
qt configure参数解释
2019-04-30
Git Push 避免用户名和密码方法
2019-04-30
Java总结篇系列:Java多线程(一)
2019-04-30
产品设计开发要领
2019-04-30
Android线程操作类(暂停、重新开启、停止)
2019-04-30
android - JNI - 一维数组、二维数组的访问与使用
2019-04-30
在 Android Studio 2.2 中愉快地使用 C/C++
2019-04-30
C++和JNI的数据转换
2019-04-30
JNI 传递结构体参数
2019-04-30
JNI中枚举类型作为参数
2019-04-30
qlineedit tab焦点处无法输入问题
2019-04-30
android精确绘制文字位置的方法
2019-04-30
Android中UI线程与后台线程交互设计的5种方法
2019-04-30
[Android]调用字符串资源的几种方法
2019-04-30