[root@localhost ~]# alias
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# alias cp
alias cp='cp -i'
[root@localhost ~]# alias cls='clear'
[root@localhost ~]#
[root@localhost ~]# alias cls
alias cls='clear'
[root@localhost ~]# alias
alias cls='clear'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
[root@localhost ~]# cls #清屏了
这时增加临时别名,一重启就没有了。
如果要长久有效,需要在配置文件增加一下
如果在 .bashrc文件增加一条,或是在/etc/profile。我下面这种方法是在.bashrc文件下加的。
[root@localhost ~]# cls
bash: cls: 未找到命令...
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# vi .bashrc
[root@localhost ~]# cat .bashrc
# .bashrc # User specific aliases and functions alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cp='cp -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi echo "hellow"
alias cls='clear'
[root@localhost ~]# [root@localhost ~]# alias cls 已经添加到配置文件了,为啥查看出现未找到,是因为没加载文件,加载文件有两种方式,一种是source .bashrc 另一种是 . .bashrc
-bash: alias: cls: 未找到
[root@localhost ~]# source .bashrc
hellow
[root@localhost ~]# alias cls
alias cls='clear'
[root@localhost ~]#
[root@localhost ~]# alias
alias cls='clear'
alias cp='cp -i'
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@localhost ~]# unalias -a 临时清空所有别名
[root@localhost ~]# alias
[root@localhost ~]# . .bashrc 一加载或是重启系统,所有别名就又存在了
hellow
[root@localhost ~]# alias
alias cls='clear'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
[root@localhost ~]# [root@localhost ~]# cat .bashrc
# .bashrc # User specific aliases and functions alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cp='cp -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi echo "hellow"
alias cls='clear'
[root@localhost ~]# unalias cls #unalias cls 删除指定别名为cls='clear'。
[root@localhost ~]# alias cls
-bash: alias: cls: 未找到
[root@localhost ~]#

shell脚本,alias别名命令用法。的更多相关文章

  1. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  2. (转)shell脚本之seq命令

    shell脚本之seq命令 原文:http://blog.csdn.net/paoxiaohui/article/details/52830595 seq 用于生成从一个数到另一个数之间的所有整数. ...

  3. Linux shell脚本中shift的用法说明【转】

    本文转载自:http://blog.csdn.net/zhu_xun/article/details/24796235 Linux shell脚本中shift的用法说明 shift命令用于对参数的移动 ...

  4. shell脚本一条命令直接发送http请求(xjl456852原创)

    我们知道nc命令是一个网络工具.可以连接tcp/udp.也能模拟发送http请求. 现在介绍通过shell脚本,一条命令直接发送http请求. 命令如下,可以对下面的地址等信息自行修改: #!/bin ...

  5. shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出

    shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出 如: #/bin/sh local ret='sqlite3 test.db "select test ...

  6. shell脚本批量执行命令----必需判断上一步执行结果--没有捷径

    # 注意:shell脚本批量执行命令,不能只写一个函数,然后把所有命令复制进去,之前试过这样是不行的.必须要有一个判断命令执行成功与否的语句 # 简单的命令可以不加结果判断符号,但是遇到解压包.sed ...

  7. shell脚本中常用命令

    1           Shell中的特殊符号 1.1           $  美元符号.用来表示变量的值.如变量NAME的值为Mike,则使用$NAME就可以得到“Mike”这个值. 1.2    ...

  8. shell 脚本之获取命令输出字符串以及函数参数传递

    在ubuntu 14.04之后,所有的U盘挂载也分用户之分,最近很多操作也和U盘有关,所以就研究了一上午shell脚本函数以及字符串操作的方法. 字符串操作: 获取他的命令输出比较简单,打个简单的比方 ...

  9. SHELL脚本的常规命令

    **shell脚本的执行方式: 方法一:首先赋予x权限,再输入相对路径或绝对路径,./testdot.sh或/root/shell/testdot.sh 方法二:sh testdot.sh(会新开一个 ...

随机推荐

  1. Codeforces Round #383 【总结】

    总结一下这场... 搞起大号就崩了... A题没啥问题..通过电脑到手机上提交没啥大问题: B题,讲个最严重的问题,也是最近以来最严重的问题,虽然我说你开了个数组,虽然这个数组是不是最终的答案数组,但 ...

  2. ZOJ 4016 Mergeable Stack(from The 18th Zhejiang University Programming Contest Sponsored by TuSimple)

    模拟题,用链表来进行模拟 # include <stdio.h> # include <stdlib.h> typedef struct node { int num; str ...

  3. python错误之RuntimeError: dictionary changed size during iteration

    pythonn报错信息: C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/Ad ...

  4. C# 基础之构造函数

    什么是构造函数? 构造函数主要用于创建类的实例对象,当调用一个构造函数创建对象时,构造函数会为对象分配内存空间并初始化类的成员. 构造函数分为:1.实例构造函数.2.静态构造函数 1.实例构造函数 使 ...

  5. 292. Nim游戏

    292. Nim游戏 class Solution(object): def canWinNim(self, n): """ :type n: int :rtype: b ...

  6. Linux (一)

    Linux目录结构 / :根目录.位于分层文件系统的最顶层,可以说它包含了所有的目录和文件 /bin :系统可执行目录 /sbin :系统管理员的可执行文件 /boot :存放用于启动linux系统的 ...

  7. JS面向对象方法(一): 使用原生JS 实现导航栏下多级分类弹出效果

    利用二级菜单的onmouseover/out事件 重新构建一级菜单 ".hover" 样式类 代码如下: CSS部分: 在原来的目标:hover样式中 增加 .hover状态 li ...

  8. bio,nio,aio简介

    https://mp.weixin.qq.com/s/F9WwcsFdCOwOeeDc0oc98w——<BIO,NIO,AIO 总结>总结和对比这三种的区别 https://www.jia ...

  9. [在读]Secrets of the javascript Ninja

    很棒的一本,可惜没有中文版.

  10. Problem D. What a Beautiful Lake dp

    Problem D. What a Beautiful Lake Description Weiming Lake, also named "Un-named Lake", is ...