新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
[root@jzplinux-01 ~]# ls /root/.bash_history/root/.bash_history [root@jzplinux-01 ~]# cat !$cat /root/.bash_history
[root@jzplinux-01 ~]# history | tail 995 make install 996 echo $? 997 ls /usr/local/apache2 998 init 0 999 ls /root/.bash_history 1000 cat $! 1001 ls /root/.bash_history 1002 cat /root/.bash_history 1003 history 1004 history | tail [root@jzplinux-01 ~]#
可以看到有1004 条,是因为还没有写入到文件中,暂时存在于内存中
创新互联公司是一家专业提供回民企业网站建设,专注与成都网站设计、成都网站建设、H5页面制作、小程序制作等业务。10年已为回民众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。
[root@jzplinux-01 ~]# echo $HISTSIZE1000[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# history -c[root@jzplinux-01 ~]# history 8 history [root@jzplinux-01 ~]# cat .bash_history | tailcd ..lscd httpd-2.2.32 lsmakeecho $?make installecho $?ls /usr/local/apache2 init 0[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# vim /etc/profileHOSTNAME=`/usr/bin/hostname 2>/dev/null` HISTSIZE=2000if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth
[root@jzplinux-01 ~]# echo $HISTSIZE1000[root@jzplinux-01 ~]# source /etc/profile[root@jzplinux-01 ~]# echo $HISTSIZE2000[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S " [root@jzplinux-01 ~]# echo $HISTTIMEFORMAT%Y/%m/%d %H:%M:%S [root@jzplinux-01 ~]# history 8 2017/06/25 12:27:07 history 9 2017/06/25 12:31:05 cat .bash_history 10 2017/06/25 12:31:14 cat .bash_history | tail 11 2017/06/25 12:35:08 cat /etc/profile 12 2017/06/25 13:10:00 vim /etc/profile 13 2017/06/25 13:14:38 echo $HISTORY 14 2017/06/25 13:15:34 echo $HISTTORY 15 2017/06/25 13:16:10 echo $HISTSIZE 16 2017/06/25 13:16:47 source /etc/profile 17 2017/06/25 13:17:13 echo $HISTSIZE 18 2017/06/25 13:19:55 history 19 2017/06/25 13:25:16 HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S " 20 2017/06/25 13:25:37 echo $HISTTIMEFORMAT 21 2017/06/25 13:25:49 history [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# vim /etc/profileHISTSIZE=2000HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "[root@jzplinux-01 ~]# source /etc/profile
[root@jzplinux-01 ~]# chattr +a /root/.bash_history[root@jzplinux-01 ~]# lsattr /root/.bash_history-----a---------- /root/.bash_history [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls111.txt 1.txt 1.txt.1 2.txt 3.txt anaconda-ks.cfg httpd-2.2.32.tar.gz [root@jzplinux-01 ~]# !!ls111.txt 1.txt 1.txt.1 2.txt 3.txt anaconda-ks.cfg httpd-2.2.32.tar.gz [root@jzplinux-01 ~]# w 13:43:44 up 5:12, 2 users, load average: 0.00, 0.01, 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.86.1 08:32 8.00s 0.21s 0.06s w root pts/1 192.168.86.1 13:33 9:04 0.03s 0.03s -bash [root@jzplinux-01 ~]# !!w 13:43:46 up 5:12, 2 users, load average: 0.00, 0.01, 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.86.1 08:32 2.00s 0.16s 0.01s w root pts/1 192.168.86.1 13:33 9:06 0.03s 0.03s -bash [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# history 8 2017/06/25 12:27:07 history 9 2017/06/25 12:31:05 cat .bash_history 10 2017/06/25 12:31:14 cat .bash_history | tail 11 2017/06/25 12:35:08 cat /etc/profile 12 2017/06/25 13:10:00 vim /etc/profile 13 2017/06/25 13:14:38 echo $HISTORY 14 2017/06/25 13:15:34 echo $HISTTORY 15 2017/06/25 13:16:10 echo $HISTSIZE 16 2017/06/25 13:16:47 source /etc/profile 17 2017/06/25 13:17:13 echo $HISTSIZE 18 2017/06/25 13:19:55 history 19 2017/06/25 13:25:16 HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S " 20 2017/06/25 13:25:37 echo $HISTTIMEFORMAT 21 2017/06/25 13:25:49 history 22 2017/06/25 13:31:12 vim /etc/profile 23 2017/06/25 13:33:21 source /etc/profile 24 2017/06/25 13:39:08 chattr +a /root/.bash_history 25 2017/06/25 13:39:38 lsattr /root/.bash_history 26 2017/06/25 13:43:18 ls 27 2017/06/25 13:43:40 W 28 2017/06/25 13:43:43 w 29 2017/06/25 13:45:46 history [root@jzplinux-01 ~]# !17echo $HISTSIZE2000[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# history | tail -n 7 29 2017/06/25 13:45:46 history 30 2017/06/25 13:46:00 echo $HISTSIZE 31 2017/06/25 13:50:11 w 32 2017/06/25 13:53:03 history | tail 33 2017/06/25 13:53:18 history | tail -n 3 34 2017/06/25 13:53:32 history | tail -n3 35 2017/06/25 13:53:47 history | tail -n 7[root@jzplinux-01 ~]# [root@jzplinux-01 ~]# !echoecho $HISTSIZE2000[root@jzplinux-01 ~]# !ww 13:50:11 up 5:19, 2 users, load average: 0.00, 0.01, 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.86.1 08:32 3.00s 0.17s 0.01s w root pts/1 192.168.86.1 13:33 15:31 0.03s 0.03s -bash [root@jzplinux-01 ~]#
敲一下 补全命令或路径
敲两下 列出当前目录下的所有文件
安装完之后需要重新启动系统,才能生效
[root@jzplinux-01 ~]# rpm -q bash-completionbash-completion-2.1-6.el7.noarch [root@jzplinux-01 ~]# systemctl restart network
[root@jzplinux-01 ~]# alias restartnet='systemctl restart network.service'[root@jzplinux-01 ~]# restartnet[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# aliasalias 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 restartnet='systemctl restart network.service'alias rm='rm -i'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'[root@jzplinux-01 ~]#
/root/.bashrc
[root@jzplinux-01 ~]# cat /root/.bashrc# .bashrc# User specific aliases and functionsalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrc fi [root@jzplinux-01 ~]#
/etc/profile.d 下的脚本文件中
[root@jzplinux-01 ~]# ls /etc/profile.d256term.csh colorgrep.csh colorls.sh less.csh vim.sh356term.sh colorgrep.sh lang.csh less.sh which3.csh bash_completion.sh colorls.csh lang.sh vim.csh which3.sh
[root@jzplinux-01 ~]# unalias restartnet[root@jzplinux-01 ~]# restartnet-bash: restartnet: 未找到命令 [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls *.txt111.txt 1.txt 2.txt 3.txt [root@jzplinux-01 ~]# ls *txt*111.txt 1.txt 1.txt.1 2.txt 3.txt [root@jzplinux-01 ~]# ls 1*111.txt 1.txt 1.txt.1[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls ?.txt1.txt 2.txt 3.txt [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls [0-9].txt1.txt 2.txt 3.txt [root@jzplinux-01 ~]# le [23].txt-bash: le: 未找到命令 [root@jzplinux-01 ~]# ls [23].txt2.txt 3.txt [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls {1,2}.txt1.txt 2.txt [root@jzplinux-01 ~]# ls {1,2,3}.txt1.txt 2.txt 3.txt [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# cat 2.txt1234567890[root@jzplinux-01 ~]# cat 1.txtchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologin [root@jzplinux-01 ~]# cat 1.txt > 2.txt[root@jzplinux-01 ~]# cat 2.txtchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologin [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# cat 1.txtchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologin [root@jzplinux-01 ~]# cat 2.txtchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologin [root@jzplinux-01 ~]# cat 1.txt >> 2.txt[root@jzplinux-01 ~]# cat 2.txtchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologinchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologin [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# touch a.txt[root@jzplinux-01 ~]# lsaaa -bash: lsaaa: 未找到命令 [root@jzplinux-01 ~]# lsaaa 2> a.txt[root@jzplinux-01 ~]# cat a.txt-bash: lsaaa: 未找到命令 [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# cat a.txt-bash: lsaaa: 未找到命令 [root@jzplinux-01 ~]# lsaaa 2>> a.txt[root@jzplinux-01 ~]# lsaaa 2>> a.txt[root@jzplinux-01 ~]# cat a.txt-bash: lsaaa: 未找到命令 -bash: lsaaa: 未找到命令 -bash: lsaaa: 未找到命令 [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls [23].txt aaa.txt &> a.txt[root@jzplinux-01 ~]# cat a.txtls: 无法访问aaa.txt: 没有那个文件或目录 2.txt3.txt[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls [23].txt aaa.txt &>> a.txt[root@jzplinux-01 ~]# cat a.txtls: 无法访问aaa.txt: 没有那个文件或目录 2.txt3.txtls: 无法访问aaa.txt: 没有那个文件或目录 2.txt3.txt[root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# ls [23].txt aaa.txt > 1.txt 2> a.txt[root@jzplinux-01 ~]# cat 1.txt2.txt3.txt [root@jzplinux-01 ~]# cat a.txtls: 无法访问aaa.txt: 没有那个文件或目录 [root@jzplinux-01 ~]#
[root@jzplinux-01 ~]# cat 2.txtchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologinchrony:x:997:995::/var/lib/chrony:/sbin/nologinaming:x:1000:1000::/home/aming:/bin/bashuser1:x:1001:1001::/home/user1:/bin/bashtcpdump:x:72:72::/:/sbin/nologinnginx:x:996:994:Nginx web server:/var/lib/nginx:/sbin/nologin [root@jzplinux-01 ~]# wc -l <2.txt10[root@jzplinux-01 ~]#