五、bash运算及启动脚本
01.使用bash的命令历史
#history
……
#set(显示所有的变量) | grep HIS
HISTFILE=/root/.bash_history
HISTFILESIZE=1000(历史文件个数)
HISTSIZE=1000(文件的历史大小)
#vi /root/.bash_history
……(1016)
#exit(保存最新的1000个命令)
#history -c(清除历史命令)
不同的console中保存各自的bash命令
#vi .bash_logout
#~/.bash_logout
clear
history -c(退出控制台后,彻底清空bash命令)
:wq
#
#Ctrl+r
(reverse-i-search)'mount -t':mount -t proc none /mnt
输入印象中的前几个字母即可出现整行命令
#history
……
#!213
#!!(上一条命令)
02.bash的变量类型
#AA=aaaaaa
#set |grep AA
AA=aaaaaa
#env AA(显示AA的环境变量)
#export AA(改变AA的环境变量)
#set | grep AA
AA=aaaaaa
alis别名
#alis ooo=HHHHHHHH
#echo ooo
HHHHHHHH
03.bash中的运算符
#!20执行第20条命令
#!!执行上一条命令
#!$ 上一条命令的最后一个参数
#$求出某个变量的值
#*表示任意多个任意字符的文件名
#echo ???文件名的一部分三个字符
#echo [abc]*  abc开头的文件名
#tauch {a,b,c}-{a,b,c}(表示枚举)
#ls -l
touch 36
-rw-r--r-- 1 root root 0 jul 2 11:09 a-1
-rw-r--r-- 1 root root 0 jul 2 11:09 a-2
-rw-r--r-- 1 root root 0 jul 2 11:09 a-3
-rw-r--r-- 1 root root 0 jul 2 11:09 b-1
-rw-r--r-- 1 root root 0 jul 2 11:09 b-2
-rw-r--r-- 1 root root 0 jul 2 11:09 b-3
-rw-r--r-- 1 root root 0 jul 2 11:09 c-1
-rw-r--r-- 1 root root 0 jul 2 11:09 c-2
-rw-r--r-- 1 root root 0 jul 2 11:09 c-3
#&(丢入后台的命令)
#~主目录
#cd ~byf
[root@byf]#
#aaa()
>{
>echo this is aaa
>ls
>cd /tmp
>touch /tmp/ddd/a
>}
#aaa
#touch a b(a,b间的空格,如果a,b不加双引号时,表示参数结束)
#ls 
a
a b
b
#touch "a b"
#ls
a b
#touch 'a b $USER'
(单引号屏蔽所有的符号)
#ls -l
a b $USER
#touch "a b  $USER"
#ls -l
a b root
#echo `which ls`
alias ls='ls --color=try' /bin/ls
#echo which ls
which ls
#touch log`date+%y%m%d`(年月日)
#ls 
log160310
#rm a\ (转义字符)b
(删去单个文件“a b”)
#echo $?
上一条命令是否为假
#[-f /etc/passwd] &&(前边的命令为真的时候执行后边的命令) echo ok
#[-f (文件)passwd /etc/passwddddd] || echo ok
ok
#[-d(是不是目录) /orical] && echo begin the install
(如果指定文件存在,返回结果begin the install)
#-l(链接) -b(block) -c(字符) -x(执行) -r(读) -w(写)
#[$USER =root] && echo hello root
hello root
0.4定制bash
/etc/profile(全体成员配置)
~/.bash_profile(个人配置)
~/.bashrc(个人配置)
/etc/bashrc(全体成员配置)
#ifconnfig
cannot find:……
#vi /etc/profile
(添加新的语句)
PATH=$PATH:/sbin(增加环境变量)
#ifconfig
cannot find:……
#exit
#su byf
#ifcongfig
eth0:
lo:
(修改后,要记得还原)
#vi /etc/bashrc
#exit(执行~/.bash_logout)
#vi ~/bashrc
增加
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
alt+f1
# su root
#echo $LANG
zh_CN.UTF-8
#start -- : 1(切换到中文版的linux)
Ctrl+f7回到原来的界面
#vi /exc/sysconfig/i18n
也可以实现上述功能,修改整个系统
#export LANG=zh_CN.UTF-8

Linux shell入门基础(五)的更多相关文章

  1. Linux shell入门基础(六)

    六.Shell脚本编程详解 将上述五部分的内容,串联起来,增加对Shell的了解 01.shell脚本 shell: # #perl #python #php #jsp 不同的脚本执行不同的文本,执行 ...

  2. Linux shell入门基础(一)

    Linux shell入门基础(一): 01.增加删除用户: #useradd byf   userdel byf(主目录未删除)  userdel -r byf   该用户的属性:usermod 用 ...

  3. Linux shell入门基础(八)

    八.shell脚本sed&awk 01.sed的使用 流编辑器-Steam Editor #ed /etc/passwd 1,10p …… 1s/root/byf/p(替换root为byf) ...

  4. Linux shell入门基础(三)

    三.输入输出重定向及管道 01.过滤器   Linux过滤器分三种:     1.过滤器(重定向只对过滤器有作用) #gzip a(将a作为输入源,涉及到输入输出)     2.编辑器     3.交 ...

  5. Linux shell入门基础(二)

    二.shell对文本的操作 01.查看文本的命令 #cat /etc/passwd(并非对文本文件操作) #tail -5 /etc/passwd(查看末尾5行) #tail -f /var/log/ ...

  6. Linux shell入门基础(七)

    七.bash脚本中的流程控制   条件判断控制   -[]([]中的表达式是否为真)  &&(前边的结果是true的时候执行后边的命令)   ||(前边的结果是false的时候执行后边 ...

  7. Linux shell入门基础(四)

    四.进程优先级前台后台 01.进程控制 #find /name aaa & #ps aux | grep find #updatedb &  #ps aux | grep update ...

  8. 1)Linux程序设计入门--基础知识

    )Linux程序设计入门--基础知识 Linux下C语言编程基础知识 前言: 这篇文章介绍在LINUX下进行C语言编程所需要的基础知识.在这篇文章当中,我们将 会学到以下内容: 源程序编译 Makef ...

  9. linux shell 入门

    本文是本人学习linux shell入门收集整理,不完全原创. 参考博文: http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html ...

随机推荐

  1. 百度的一个Ajax跨域方法 JavaScript是没有域的限制

    baidu的通行证处理都是在二级域名passport.baidu.com中处理的,但是baidu很多地方登录都好像是用ajax处理的,他是怎么做的呢?研究了一下,发现一个小技巧. 在http://zh ...

  2. Notepad++插件之FingerText

    FingerText是一个标签触发片段插件记事本.支持多个热点同时编辑,嵌套的热点,动态热点(很多不仅仅是纯文本的,可以通过命令,或触发另一个片段中的片段),热点的文本提示(而不是仅仅是$或#号)和热 ...

  3. 发送邮件(E-mail)方法整理合集

    在IOS开发中,有时候我们会需要用到邮件发送的功能.比如,接收用户反馈和程序崩溃通知等等.其实这个功能是很常用的,因为我目前就有发送邮件的开发需求,所以顺便整理下IOS发送邮件的方法. IOS原生自带 ...

  4. Node.js回调概念

    什么是回调? 回调是一个异步等效的功能.在完成特定任务回调函数被调用. Node大量使用了回调.Node的所有的API都支持回调这样的一种方式. 例如,一个函数读取一个文件可能开始读取文件,并使得下一 ...

  5. BZOJ 1049 数字序列

    Description 现在我们有一个长度为n的整数序列A.但是它太不好看了,于是我们希望把它变成一个单调严格上升的序列.但是不希望改变过多的数,也不希望改变的幅度太大. Input 第一行包含一个数 ...

  6. BZOJ 3091 城市旅行

    Description Input Output Sample Input 4 5 1 3 2 5 1 2 1 3 2 4 4 2 4 1 2 4 2 3 4 3 1 4 1 4 1 4 Sample ...

  7. 使用NetUserAdd API函数创建远程用户

    http://apps.hi.baidu.com/share/detail/33407620 使用NetUserAdd编程创建远程用户Windows API NetUserAdd()可以创建Windo ...

  8. SORT ORDER BY STOPKEY

    select * from ( select * from ( select a.*,rownum rn from page a where object_id >1000 and owner= ...

  9. 【HDOJ】2896 病毒侵袭

    AC自动机模板题. #include <iostream> #include <cstdio> #include <cstring> #include <qu ...

  10. java学习之二维数组

    java当中的二维数组,存储一组比较特殊的对象.他存储一个数组,同时存储的数组当中又存储着元素. java二维数组的声明方式一: class Arr2Demo { public static void ...