1. 程式人生 > >淺談Linux中男人的魅力—man

淺談Linux中男人的魅力—man

com 這樣的 lease linux org format work img mman

在Linux系統中提供幫助的命令。通俗點來說它就是命令的使用手冊。
它共分九個章節
1、用戶命令
2、系統調用
3、C庫調用
4、設備文件及特殊文件
5、配置文件格式
6、遊戲
7、雜項
8、管理命令及守護進程
9、Linux內核API(CentOS7以後出現)
比如想知道某一個命令屬於man的那一章節
我們可以用whatis command(命令)
例: whatis pwd
[root@localhost ~]# whatis pwd
pwd (1) - print name of current/working directory
pwd (1p) - return working directory name
pwd (3tcl) - 返回當前的工作目錄
該命令可以清楚顯示該命令屬於哪一個章節
Linux中有許多命令我們不可能都記得,我們可以根據通過對命令的man來了解
在這裏舉個例子說明
在本機字符終端登陸時,除顯示原有信息外,再顯示當前登陸終端號,主機名,以及時間。提示: cat /etc/issue
通過man命令完成要求
以下時操作步驟:
1、提示中有關於issue,我們可以從issue下手,看一看有沒有能幫助我們的信息
采用 man issue 獲取信息
[root@localhost ~]# man issue
ISSUE(5) Linux Programmer‘s Manual ISSUE(5)

NAME
issue - prelogin message and identification file

DESCRIPTION
The file /etc/issue is a text file which contains a message or sys‐
tem identification to be printed before the login prompt. It may
contain various @char and \char sequences, if supported by the
getty-type program employed on the system.

FILES
/etc/issue

SEE ALSO
motd(5), agetty(8), mingetty(8)

COLOPHON
This page is part of release 3.53 of the Linux man-pages project.
A description of the project, and information about reporting bugs,
can be found at http://www.kernel.org/doc/man-pages/.

Linux 1993-07-24 ISSUE(5)
Manual page issue(5) line 7/27 (END) (press h for help or q to quit)
從這裏我們好像沒有得到太多的信息,但是我們從這裏知道issue 中NAME中說時顯示登陸前的信息和標識文件,是一個文本文件,對於一個文本文件我們應該可以去編輯它,所以我們可以用gedit /etc/issue 去看看,裏面寫了什麽
技術分享圖片
我們可以看到裏面有系統的版本號以及內核信息,也就是本機字符登陸時顯示的信息。
那怎麽顯示當前登陸終端號,主機名和時間呢?一開始我在issue文本文件裏寫入了tty(當前終端)date(時間)hosttime(主機名)
然後從新進入終端,卻發現時這樣的情況
技術分享圖片
請原諒我是一個小白-.-!
好吧 那就只能再去man issue了
正好在SEE ALSO中提示讓我去其文件看看
打著試試的心裏 man了motd
裏面的內容時這樣的:
[root@localhost ~]# man motd
MOTD(5) Linux Programmer‘s Manual MOTD(5)

NAME
motd - message of the day

DESCRIPTION
The contents of /etc/motd are displayed by login(1) after a suc?
cessful login but just before it executes the login shell.

   The abbreviation "motd" stands for "message of the day",  and  this
   file has been traditionally used for exactly that (it requires much
   less disk space than mail to all users).

FILES
/etc/motd

SEE ALSO
login(1), issue(5)

COLOPHON
This page is part of release 3.53 of the Linux man-pages project.
A description of the project, and information about reporting bugs,
can be found at http://www.kernel.org/doc/man-pages/.

Linux 1992-12-29 MOTD(5)
Manual page motd(5) line 9/29 (END) (press h for help or q to quit)
發現好像還是都沒有用,好吧 ,繼續,還有兩個
man agetty
內容好多,我英文不好,直接下一個吧。這裏提一下關於內容多的時候可以使用快捷鍵快速翻頁或者查找某一個字母
f向下翻一頁
b向上翻一頁
d向下翻半頁
u向上翻半頁
G 跳至尾頁
g 跳至首頁
搜索關鍵字
/關鍵字 n 向下 N向上
?關鍵字 n 向上
q 退出man
繼續man mingetty
這個內容也不少,不過比那個要少多了 搜索一下關鍵字,hostname(上面說過如何搜索關鍵字)
終於找到我需要的信息:
技術分享圖片
/t /n /l 分別表示的是時間,主機名,終端,把這三個添加到issue文本文件中就可以了
技術分享圖片
然後順帶說下中文man的安裝和使用方法。
首先下載一個中文man的包,然後通過mount /dev/cdrom /media掛載
rpm -ivh /meida/Packages/man... 後面太長 大家按TAB鍵自動補齊吧……^.^
當安裝完成時需要使用man -aw command(命令)試一下是否成功
舉例:
[root@localhost ~]# man -aw ls
/usr/share/man/man1/ls.1.gz
/usr/share/man/zh_CN/man1/ls.1.gz
/usr/share/man/man1p/ls.1p.gz
這裏顯示中文包已經安裝完成。
使用:
直接使用man command時系統會自動選擇第一個,也就是英文版的解釋
我們需要使用 man -a command
這條命令會按照順序一個一個的執行,也就是按照 man -aw ls下顯示的順序一個一個執行。
舉例
man -a ls
第一個顯示的是英文版
技術分享圖片
按一下q鍵 退出第一個,再按ENTER,進入第二個,也就是中文版的解釋。
技術分享圖片

淺談Linux中男人的魅力—man