Linux常用命令(3)

1、命令别名设置
   alias,unalias
   alias lm='ls -l|more'
   unalias lm
2、历史命令:history
   history // 列出历史命令
   66 man rm
   67 alias
   68 man history
   69 history
   !66  执行第66条命令
   !!执行上一个命令,本例中即!66
3、bash的登录与欢迎信息:/etc/issue,/etc/motd,/etc/issue.net
   /etc/issue是本地系统登录时显示的
   /etc/issue.net是当我们使用telnet连接到主机时,主机的登录界面就会显示/etc/issue.net,而不是/etc/issue。


   \d  本地端时间的日期
   \l  显示第几个终端机接口
   \m  显示硬件的等级(i386/i486/i586/i686)
   \n  显示主机的网络名称
   \o  显示domain name
   \r  操作系统的名称(相当于uName -r)
   \t  显示本地端时间的时间
   \s  操作系统的名称
   \v  操作系统的版本
4、bash的环境配置文件 /etc/profile
   HOSTNAME:依据主机的hostname命令决定此变量内容
   HISTSIZE:历史命令记录条数
   PATH:会依据UID决定PATH变量要不要含有sbin的系统命令目录
   MAIL:依据账号设置好用户的mailbox到/var/spool/mail/账号名

   更改完profile使立即生效,source profile 或 . profile
5、数据流重定向
   将命令的数据全部写入名为list的文件中
   find /home -name .bashrc > list 2> list  错误
   find /home -name .bashrc > list 2> &1 正确
   find /home -name .bashrc &> list 正确

   一次执行多个命令,例如在关机的时候希望可以先执行两次sync同步写入磁盘后才shutdown计算机
   sync;sync;shutdown -h now

   $?(命令回传码)与&&或||
   cmd1&&cmd2   若cmd1执行完毕切正确执行($?=0),则开始执行cmd2,,反之不执行。
   cmd1||cmd2   若cmd1执行完毕切正确执行($?=0),则cmd2不执行,反之开始执行cmd2。

猜你喜欢

转载自junle.iteye.com/blog/2187220