命名别名与历史命令
命名别名
语法:alias 别名=’命令’
unalias别名
alias 如后面什么也不跟。代表查询所有别名命名信息
举例1:查看所有别名
[root@localhost ~]# alias alias cp='cp -i' alias grep='grep --color=auto' alias l.='ls -d .* --color=tty' alias ll='ls -l --color=tty' alias ls='ls --color=tty' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
举例2:设置别名
[root@localhost ~]# alias dir='cd' [root@localhost ~]# dir /tmp [root@localhost tmp]# [root@localhost tmp]#
举例3:取消别名
[root@localhost tmp]# unalias dir
历史命令
语法:history n
history [-c]
history [raw]histfiles
选项与参数:
n:数字,列出最近n条命令
-c:将目前shell中所有历史命令全部清除
-a:将目前新增的历史命令添加到histfiles,若没有加histfiles则默认添加到~/.bash_history
-r:将histfiles 读取到 这个shell的记忆
-w:将目前的history记忆写入histfiles中
说明:$HISTSIZE记录了shell以及文件中最大存储历史记录数量
系统注销时会将bashshell历史记录记录到文件中~/.bash_history
举例:
[root@localhost tmp]# history 3 =>查看历史最近3条记录 876 echo $HISTSIZE 877 history 878 history 3 [root@localhost tmp]# history –c =>清空shell中的历史记录 [root@localhost tmp]# history 4 =>以前的被清空 因此这里只能查询到这1条 1 history 4 [root@localhost tmp]# history –w =>shell中的历史记录写入文件 [root@localhost tmp]# vim ~/.bash_history history 5 vim ~/.bash_history history –w
使用历史命令执行命令
语法:
!number:执行第几条命令
!command:由最近的命令向前搜索由command开头的命令
!!:执行上一个命令
说明:使用以上命令可以做好保密性,别人看到你的命令历史记录却不能知道你的操作
举例:
[root@localhost /]# history 5 =>先查询历史命令 16 cd / 17 history -a 18 vim ~/.bash_history 19 alias 20 history 5 [root@localhost /]# !19 =>执行第19条命令 alias alias cp='cp -i' alias grep='grep --color=auto' …… [root@localhost /]# !! =>执行上一个命令 alias alias cp='cp -i' alias grep='grep --color=auto' [root@localhost /]# !al =>执行以al开头命令 alias alias cp='cp -i'
相关推荐
10.3.1 Shell基础-Bash基本功能-历史命令与补全 10.3.2 Shell基础-Bash基本功能-别名与快捷键 10.3.3 Shell基础-Bash基本功能-输入输出重定向 10.3.4 Shell基础-Bash基本功能-多命令顺序执行与管道符 10.3.5.....
目录 网盘文件永久连接 ...10.3.1 Shell基础-Bash基本功能-历史命令与补全 10.3.2 Shell基础-Bash基本功能-别名与快捷键 10.3.3 Shell基础-Bash基本功能-输入输出重定向 10.3.4 Shell基础-Bash基本功能
要想真正理解Linux系统,就必须从Linux命令学起,通过基础的命令学习可以进一步理解Linux系统。 不同Linux发行版的命令数量不一样,但Linux发行版本最少的命令也有200多个。这里笔者把比较重要和使用频率最多的命令...
本书内容翔实、涉及领域广泛,并且提供了详细的例子和大量的参考资料(包括书籍、电子文档和Internet站点),是一本学习、使用和管理Linux不可多得的好书。 目 录 译者序 前言 第一部分 Red Hat Linux的介绍与安装 ...
交互式命令历史记录 调试 scriptics的tclpro 其他工具 性能调校 第14章 名字空间 使用名字空间 名字空间变量 命令查找 嵌套名字空间 过程的进口与输出 回调与名字空间 内省(introspection) namespace...
4.6 思考:命令别名是干什么的/ 68 4.7 备份本章的工作成果/ 69 第5章 Git 暂存区/ 70 5.1 修改不能直接提交吗/ 70 5.2 理解 Git 暂存区(stage)/ 76 5.3 Git Diff 魔法/ 78 5.4 不要使用 git commit -a/ 81 5.5 ...
+ 7.1.5 数据库,表,索引,列和别名的命名 # 7.1.5.1 名字的大小写敏感性 o 7.2 用户变量 o 7.3 列类型 + 7.3.1 列类型的存储要求 + 7.3.5 数字类型 + 7.3.6 日期和时间类型 # 7.3.6.1 问题和日期类型 # ...
7.1.4 NULL值 7.1.5 数据库,表,索引,列和别名的命名 7.1.5.1 名字的大小写敏感性 7.2 用户变量 7.3 列类型 7.3.1 列类型的存储要求 7.3.5 数字类型 7.3.6 日期和时间类型...
7 MySQL 语言参考 7.1 文字:怎样写字符串和数字 7.1.1 字符串 7.1.2 数字 7.1.3 十六进制值 7.1.4 NULL值 7.1.5 数据库,表,索引,列和别名的命名 7.1.5.1 名字的大小写敏感性 ...