当前位置: 首页 > news >正文

Linux命令(95)之alias

linux命令之alias

1.alias介绍

linux命令alias是用来将/bin目录下的命令进行别名设置,将一些较长的命令进行简化。

alias命令的作用只局限于该次登入的操作,相当于临时变量。

如果对当前用户永久生效,需修改~/.bashrc文件,使用命令source .bashrc生效。

如果对全局用户生效,需修改/etc/profile或/etc/bashrc文件,使用命令source /etc/profile或source /etc/bashrc生效。

2.alias用法

alias [参数] key=value

alias参数
参数说明
-p以可重用的格式打印所有的已定义的别名

3.实例

3.1.alias帮助

命令:

help alias

[root@centos79-3 ~]# help alias
alias: alias [-p] [name[=value] ... ]Define or display aliases.Without arguments, `alias' prints the list of aliases in the reusableform `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 foralias substitution when the alias is expanded.Options:-p	Print all defined aliases in a reusable formatExit Status:alias returns true unless a NAME is supplied for which no alias has beendefined.
[root@centos79-3 ~]# 

3.2.设置临时别名

命令:

alias cp='echo aaaaa'

[root@centos79-3 ~]# alias cp='echo aaaaa'
[root@centos79-3 ~]# alias cp
alias cp='echo aaaaa'
[root@centos79-3 ~]# 

3.3.打印所有已定义的别名

命令:

alias -p

[root@centos79-3 ~]# alias -p
alias cp='echo aaaaa'
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 mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@centos79-3 ~]# 

3.4.取消cp别名设置

命令:

unalias cp

[root@centos79-3 ~]# unalias cp
[root@centos79-3 ~]# alias cp
-bash: alias: cp: not found

3.5.取消所有别名设置

命令:

unalias -a

备注:

-a :取消所有命令别名

[root@centos79-3 ~]# unalias -a
[root@centos79-3 ~]# alias
[root@centos79-3 ~]# 

3.6.unalias帮助

命令:

help unalias

[root@centos79-3 ~]# help unalias
unalias: unalias [-a] name [name ...]Remove each NAME from the list of defined aliases.Options:-a	remove all alias definitions.Return success unless a NAME is not an existing alias.
[root@centos79-3 ~]# 

http://www.lryc.cn/news/183225.html

相关文章:

  • DHCPsnooping 配置实验(2)
  • Qt 综合练习小项目--反金币(2/2)
  • 安装matplotlib__pygame,以pycharm调入模块
  • 编写可扩展的软件:架构和设计原则
  • 算法-排序算法
  • Android_Monkey_测试执行策略及标准
  • windows安装nginx
  • Java日期的学习篇
  • spark on hive
  • Linux Vi编辑器基础操作指南
  • WEB3 创建React前端Dapp环境并整合solidity项目,融合项目结构便捷前端拿取合约 Abi
  • rust运算
  • 游戏引擎,脚本管理模块
  • 2023年7月工作经历三
  • 1801_codesys产品主样本了解
  • flink的计时器
  • @SpringBootApplication剖析
  • 浅谈wor2vec,RNN,LSTM,Transfermer之间的关系
  • 【11】c++设计模式——>单例模式
  • 深度学习-卷积神经网络-AlexNET
  • 人机关系不是物理关系也不是数理关系
  • <html dir=ltr>是什么意思?
  • 工厂模式:简化对象创建的设计思想 (设计模式 四)
  • 【2023最新】微信小程序中微信授权登录功能和退出登录功能实现讲解
  • 复习 --- C++运算符重载
  • 复习 --- select并发服务器
  • 程序三高的方法
  • 全志ARM926 Melis2.0系统的开发指引⑦
  • 全志ARM926 Melis2.0系统的开发指引⑧
  • 区别对比表:阿里云轻量服务器和云服务器ECS对照表