linux 基础学习入门 3

发布时间:2019-07-05 09:54:43编辑:auto阅读(1681)

    linux day 3

    第三天内容并不明确, 自我总结


    内部命令 用 help command   或  man bash


    外部命令 用 command --help 或  command -h

    使用手册 man command

    信息页 info command


    date命令:

    显示昨天 : date -d yesterday

    显示前天 : date -d '-2 day' 


    date -d '-2 day' +%F


    练习:

    显示当前日期,格式:2016-08-08

    显示当天是星期几。

    设置当前日期为2008-08-08 08:08


    date +%F

    date +%w

    date 080808082008

    clock -s  恢复



    man 帮助

    manual 手册 简称 man


    man下 搜索 按/ 输入


    Linux的man很强大,该手册分成很多section,使用man时可以指定不同的section来浏览,各个section意义如下: 

    1 - commands

    2 - system calls

    3 - library calls

    4 - special files

    5 - file formats and convertions

    6 - games for linux

    7 - macro packages and conventions

    8 - system management commands

    9 - 其他


    其中:

    1是普通的命令

    2是系统调用,如open,write之类的

    3是库函数,如printf,fread

    4是特殊文件,也就是/dev下的各种设备文件

    5是指文件的格式,比如passwd, 就会说明这个文件中各个字段的含义

    6是给游戏留的,由各个游戏自己定义

    7是附件还有一些变量,比如向environ这种全局变量在这里就有说明

    8是系统管理用的命令,这些命令只能由root使用,如ifconfig

    使用手册方式举例:

    man 1 ls         #查看第一章中的ls命令帮助

    man 3 printf     #查看库函数printf帮助


    确定章节?man的用法

    先  whatis command  =  man -f command

    确定想看的 章节  然后 在man x command


    man -a command 看command 所有帮助



    history命令


    history -c 删除内存记录所有命令

    rm -rf .bash_history 删除记录文件的所有历史纪录命令



    重复前一个命令,有4种方法:

    按上方向键

    按!!

    输入!-1

    按Ctrl+p

    !字符串:重复前一个以“字符串”开头的命令

    !numL:按照history命令输出中的序号重复对应命令

    !?字符串:重复包含字符串的命令 如 !?tr 就会查询history列表里包含tr命令最近的命令

    !-n:重复n个命令之前的那个命令


    ctrl+r  搜索history列表中出现过的命令



    要重新调用前一个命令中最后一个参数

     !$

     esc松开+.

     图形界面下 Alt + .



    [root@Centos7 ~]# cat /testdir/xx.txt 

    this is test

    [root@Centos7 ~]# ll !$

    ll /testdir/xx.txt

    -rw-r--r--. 1 root root 13 Jul 26 13:02 /testdir/xx.txt


    [root@Centos7 ~]# cat /etc/issue /etc/issue.net /etc/redhat-release 


    \S

    Kernel \r on an \m


    the hostname is \n

    login terminal is \l

    the time is \t

    \S

    Kernel \r on an \m

    CentOS Linux release 7.2.1511 (Core) 

    [root@Centos7 ~]# ll !*

    ll /etc/issue /etc/issue.net /etc/redhat-release

    -rw-r--r--. 1 root root 79 Jul 25 11:54 /etc/issue

    -rw-r--r--. 1 root root 22 Dec  9  2015 /etc/issue.net

    lrwxrwxrwx. 1 root root 14 Jul 21 23:23 /etc/redhat-release -> centos-release

    [root@Centos7 ~]# ll !:2

    ll /etc/issue.net

    -rw-r--r--. 1 root root 22 Dec  9  2015 /etc/issue.net


    !n:^ 调用第n条命令的第一个参数

    !n:$ 调用第n条命令的最后一个参数

    !m:n 调用第m条命令的第n个参数

    !n:* 调用第n条命令的所有参数






    关于命令的使用

    ls

    [root@Centos7 ~]# alias ls

    alias ls='ls --color=auto'

    如想使用ls 的原始命令 不带颜色 

    \ls

    或者

    'ls'


    *********************************************

    bash的快捷键

    Ctrl+l 清屏,想到与clear命令

    Ctrl+c 取消命令的执行

    Ctrl+a 会移动到命令行的最前面

    Ctrl+e 会移动到命令行的最后面

    Ctrl+u 会删除到行首

    Ctrl+k 会删除到行尾

     Ctrl+b 或 +f 会左右移动一个字符

     ESC +b 或 +f 会左右移动一个单词


关键字

上一篇: vs2010 mvc3

下一篇: postfix安装以及配置3