linux 基礎學習入門 3

linux day 3linux

第三天內容並不明確, 自我總結centos


內部命令 用 help command   或  man bashbash


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

使用手冊 man command函數

信息頁 info commandthis


date命令:spa

顯示昨天 : date -d yesterday.net

顯示前天 : date -d '-2 day' 命令行


date -d '-2 day' +%Form


練習:

顯示當前日期,格式: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 會左右移動一個單詞

相關文章
相關標籤/搜索