答:环境变量 HISTSIZE 在配置文件 /etc/profile 文件中,因此要使其可以保存10000条命令历史须要修改配置文件 /etc/profile,将HISTSIZE=10000html
[root@localhost ~]# vi /etc/profile fi HOSTNAME=`/usr/bin/hostname 2>/dev/null` else pathmunge /usr/local/sbin after pathmunge /usr/sbin after fi HOSTNAME=`/usr/bin/hostname 2>/dev/null` HISTSIZE=10000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi
答:PS1="[\u@\h \W]$ " 须要将双引号改成单引号,由于双引号下须要转义python
for i in
ls
;do mv $iecho $i|tr '[a-z]' '[A-Z]'
;donelinux
[root@localhost ~]#sort -t: -k5 /etc/passwd adm:x:3:4:adm:/var/adm:/sbin/nologin bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin halt:x:7:0:halt:/sbin:/sbin/halt user1:x:1000:1000::/home/user1:/bin/bash user2:x:1001:1001::/home/user2:/bin/bash lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin mail:x:8:12:mail:/var/spool/mail:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin root:x:0:0:root:/root:/bin/bash shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown sync:x:5:0:sync:/sbin:/bin/sync systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:997:User for polkitd:/:/sbin/nologin chrony:x:998:996::/var/lib/chrony:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin
[root@localhost ~]#cut -d: -f3 /etc/passwd 0 1 2 3 4 5 6 7 8 11 12 14 99 192 81 999 89 74 998 1000 1001
配置文件 | 做用 |
---|---|
/etc/profile | 无论哪一个用户,登录时都会读取该文件。 |
/etc/bashrc | bash执行时,无论是何种方式,都会读取此文件 |
.bashrc | 当bash以non login方式执行时,读取此文件。 |
.bashrc_profile | 当bash以login形式执行时,读取此文件。一般该配置文件还 |
会配置成去读取.bashrc。 7. export 的做用是什么?bash
答: export 定义子bash继承的全局变量ssh
a. 设定变量的格式为”a=b”,其中a为变量名,b为变量的内容,等号两边不能有空格post
b. 变量名只能由英、数字以及下划线组成,并且不能以数字开头spa
c. 当变量内容带有特殊字符(如空格)时,须要加上单引号;.net
d. 若是变量内容中须要用到其余命令运行结果则可使用反引号;code
e. 变量内容能够累加其余变量的内容,须要加双引号;htm
[root@localhost ~]#sleep 1000 & [1] 3678 [root@localhost ~]#fg sleep 1000
使用命令 好比:sleep & ,可使命令在后台运行。若是把后台的命令调到前台运行,使用fg命令。
[root@localhost ~]#ls test* test1.txt test.txt test: 123.txt 234.txt
使用 ls 能够列出当前目录的全部文件,test加上 * 后列出当前目录下全部以 test开头的文件以及目录包括目录下的子文件。
[root@localhost ~]#ls [12].txt abc.txt >right.txt 2>erro.txt [root@localhost ~]#cat right.txt 1.txt 2.txt [root@localhost ~]#cat erro.txt ls: 没法访问abc.txt: 没有那个文件或目录
> 正确的信息输出到文件中, >>正确信息追加到文件中, 2> 错误的信息输出到文件中,2>>错误的信息追加到文件中
alias abc=abcdefg
[root@localhost ~]#ls [12].txt ab.txt &>a.txt [root@localhost ~]#cat a.txt ls: 没法访问ab.txt: 没有那个文件或目录 1.txt 2.txt
split -b10M filename
split -l10000 filename
特殊符号 | 做用 |
---|---|
; | 多条命令写到一行,使用;分隔 |
|| | 用于命令之间,前面命令成功执行,后边命令不执行,若是前面命令不能执行,则执行后面命令。直到成功执行。 |
& & | 用于命令之间,若是前面命令成功执行,则执行后面的命令。若是前面命令不执行,则不执行后面的命令。 |
[root@localhost ~]#ls ; cat right.txt ;cat erro.txt 123 2.txt abcd a.txt right.txt test1.txt 1.txt abc anaconda-ks.cfg erro.txt test test.txt 1.txt 2.txt ls: 没法访问abc.txt: 没有那个文件或目录
[root@localhost ~]#la || ls -bash: la: 未找到命令 123 2.txt abcd a.txt right.txt test1.txt 1.txt abc anaconda-ks.cfg erro.txt test test.txt
-&&
[root@localhost ~]#la && ls -bash: la: 未找到命令
能够写入.bash_profile
set ##显示系统全部的变量和当前用户自定义的变量
扩展阅读:
Linux环境变量之“PS1" http://www.lishiming.net/thread-5364-1-1.html
Linux支持中文 http://www.lishiming.net/thread-5360-1-1.html
让命令历史永久保存并加时间戳 http://www.lishiming.net/thread-283-1-1.html
linux 下/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 干啥的 http://www.lishiming.net/thread-909-1-1.html