歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> 培訓第三天內容簡要

培訓第三天內容簡要

日期:2017/3/3 11:10:19   编辑:Linux技術

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 會左右移動一個單詞

Copyright © Linux教程網 All Rights Reserved