命令别名与历史命令

摘要:
1.命令别名设置:alias,unalias命令别名可以帮助您在一些常见命令过长时简化它们,并帮助您减少命令错误示例:*现有命令别名的示例[root@server3~]#aliasasiascp='cp-ialiasegsrep='grep--color=auto'aliasfgrep='grep--color=auto'aiasgrep='grep--color=auto'aliasl.='ls-d.*--Color=auto'aliasll='ls-l--Color=auto'aiasls='ls--Color=auto'aliasmv='mv-ialiasrm='rm-ialiashwhich='alias|/usr/bin/with--tty only--read alias--show dot--show tilde'*设置命令别名[root@server3~]#Aliasvi=vim#使用vi=使用vim[root@server3~]#aliasasiascp='cp-ialiasegsrep='grep--color=auto'aliasfgrep='grep--color=auto'aiasgrep='grep--color=auto'aliasl.='ls-d.*--Color=auto'aliasll='ls-l--Color=auto'aiasls='ls--Color=auto'aliasmv='mv-ialiasrm='rm-ialiasvi='vim'aliashwhich='alias|/usr/bin/whith--tty only--read alias--show dot--show title'*取消命令别名[root@server3~]#unaliasvi[root@server3~]#aliasasiascp='cp-ialiasegsrep='grep--color=auto'aliasfgrep='grep--color=auto'aiasgrep='grep--color=auto'aliasl.='ls-d.*--Color=auto'aliasll='ls-l--Color=auto'aiasls='ls--Color=auto'aliasmv='mv-ialiasrm='rm-ialiashwhich='alias|/usr/bin/with--tty only--read alias--show dot--show filter'2.历史命令:history format:history[n]history[-c]history[-raw]histofilesn:number,列出最后n个命令的含义-c:删除当前shell中的所有历史记录命令-a:将新添加的历史记录命令添加到histofile中,如果未添加histofile,则默认为write~/bash_ history-r:将histofile的内容读取到当前shell的历史记录内存-w:将当前历史记录作为内容写入histofile

1.命令别名设置:alias,unalias

    命令别名可以帮助你在一些惯用命令特别长的时候,进行简化,帮助你减少命令误差

 

例:

*例出当前已有的命令别名

[root@server3 ~]# alias

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@server3 ~]# alias vi=vim       #使用vi地时候就=使用vim

[root@server3 ~]# alias

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 vi='vim'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

*取消命令别名

[root@server3 ~]# unalias vi

[root@server3 ~]# alias

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'

 

2.历史命令:history

格式:

    history [n]

    hisyory [-c]

    history [-raw] histfiles

n:数字,列出最近n条命令的意思

-c:将目前shell中所有的history命令全部删除

-a:将目前新增的history命令新增入histfiles中,若没有加histfiles,

    则默认写入~/.bash_history

-r:将histfiles的内容读到目前这个shell的history记忆中

-w:将目前的history即以内容写入到histfiles中

 

免责声明:文章转载自《命令别名与历史命令》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇CentOS 每个版本的区别jmeter之如何减负-实现稳定超高并发测试(性能调优)之正确添加监听器下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

【10】react 之 react-router

1.1.  路由 路由:URL与处理器的映射。 浏览器当前的 URL 发生变化时,路由系统会做出一些响应,用来保证用户界面与 URL 的同步。 1.2.  Router安装 npm i react-router -save 1.3.  Router使用 路由器Router就是React的一个组件,所以使用方式跟React组件使用方式一样。 import {...

Linux bash运维操作日志审计(单服务器)

目前公司有几台机器比较重要,需要把所有用户的操作记录下来,于是就是参照资料来完成 1. vim /etc/profile.d/oplogrc.sh logdir=/opt/oplog userdir=$logdir/${LOGNAME} DT=`date +"%Y%m%d"` export HISTFILE="/$userdir/history.$DT"...

修改centos history记录数上限

修改/etc/profile [root@5201351 ~]# sed -i 's/^HISTSIZE=1000/HISTSIZE=200/' /etc/profile [root@5201351 ~]# source /etc/profile...

vue 记录 mode:history 模式 踩过的坑

先上官网文档地址 https://router.vuejs.org/zh/guide/essentials/history-mode.html 由于公司内容原因没有https的测试域名 所以在正式接口后加了个、/t/  eg:https:xxxx.com  测试接口域名====>https:xxxx.com/t 1.需要在路由文件  router /...

不留痕迹的清除部分history历史命令记录(转)

有时候只想清除自己执行的一些历史命令,而不想清除整个系统的历史命令,而且也不想让别人看到自己有编辑过.bash_history文件。 有的人会说直接使用history -c命令来清除。这种方法不是不可以,不过要注意自己的系统版本。有些系统版本是会把.bash_history里的所有历史命令清除掉的。 我测试的两种环境: 1 2 oracle lin...

4.JS跳转路由/刷新/返回页面

1.JS跳转路由(需要拿到父组件的history)   clickHandle(){     let history = this.props.history;     history.push( '/home')   } 2.刷新页面(需要拿到父组件的history)   clickHandle(){     let history = this.pro...