天天看點

那些有意思的linux指令

who 檢視目前登入的所有使用者名/時間/方式

whoami 目前登入使用者名

who am i 目前登入使用者名/時間/方式

which

manual手冊:

which returns the pathnames of the files (or links) which would be exe‐

cuted in the current environment, had its arguments been given as com‐

mands in a strictly POSIX-conformant shell. It does this by searching

the PATH for executable files matching the names of the arguments. It

does not follow symbolic links.

就是說 which 是根據PATH在目前環境中尋找可執行的檔案或連接配接

whereis

manual手冊:

whereis locates source/binary and manuals sections for specified files.

The supplied names are first stripped of leading pathname components

and any (single) trailing extension of the form .ext, for example, .c.

Prefixes of s. resulting from use of source code control are also

dealt with. whereis then attempts to locate the desired program in a

list of standard Linux places.

定位到制定名字的源檔案,二進制檔案和手冊

whatis

manual手冊

whatis - display manual page descriptions 主要是從手冊裡拿到簡短描述

Each manual page has a short description available within it. whatis

searches the manual page names and displays the manual page descrip‐

tions of any name matched.

name may contain wildcards (-w) or be a regular expression (-r). Using

these options, it may be necessary to quote the name or escape (\) the

special characters to stop the shell from interpreting them.

index databases are used during the search, and are updated by the

mandb program. Depending on your installation, this may be run by a

periodic cron job, or may need to be run manually after new manual

pages have been installed. To produce an old style text whatis data‐

base from the relative index database, issue the command:

whatis -M manpath -w '*' | sort > manpath/whatis

where manpath is a manual page hierarchy such as /usr/man.

type

type指令用來顯示指定指令的類型。一個指令的類型可以是如下之一

alias 别名

keyword 關鍵字,Shell保留字

function 函數,Shell函數

builtin 内建指令,Shell内建指令

file 檔案,磁盤檔案,外部指令

unfound 沒有找到

它是Linux系統的一種自省機制,知道了是那種類型,我們就可以針對性的擷取幫助

sl -- ls敲錯時,跑小火車的指令

cowsay --“狐狸叫” #cowsay -f daemon "help me"

nethack --有人說,如果一生人隻做一件事的話,那就玩Nethack吧。經典遊戲!!

cat和tac

:(){ :|:& };: --fork bomb,你懂得。

神馬不懂,看這裡看這裡

注解如下:

:() # 定義函數,函數名為":",即每當輸入":"時就會自動調用{}内代碼

{ # ":"函數開始辨別

: # 用遞歸方式調用":"函數本身

| # 并用管道(pipe)将其輸出引至...(因為有一個管道操作符,是以會生成一個新的程序)

: # 另一次遞歸調用的":"函數

# 綜上,":|:"表示的即是每次調用函數":"的時候就會生成兩份拷貝

& # 調用間脫鈎,以使最初的":"函數被殺死後為其所調用的兩個":"函數還能繼續執行

} # ":"函數結束辨別

; # ":"函數定義結束後将要進行的操作...

: # 調用":"函數,"引爆"fork bomb

其中函數名“:”隻是簡化的一例,實際實作時可以随意設定,一個較易了解(将函數名替換為“forkbomb”)的版本如下:

forkbomb(){ forkbomb|forkbomb & } ; forkbomb

試試這個: who is cleverest? who is sb?

yes指令, output a string repeatedly until killed

輸出很多個y,可以用來對付選擇很多y/n的應用

fortune指令,随機輸出一句話,或者是一句英文名言,

fortune-zh指令 随機一首唐詩宋詞

ubuntu下安裝:

sudo apt-get install fortune

sudo apt-get install fortune-zh

又可以看些東西,蠻有意思的

cal 9 1752,列印月曆,但是這個月非常有意思(在9月2日後居然跳到了14日了),這是有原因的:

在1582年,羅馬教皇格列高裡十三世宣布改曆(由于閏年積累的原因),要求從1582年的10月4的下一天定為格列曆10月15日,中間跳過了10天,在意大利、西班牙等國家都這樣處理了,其他的天主國家也很快跟着這麼做了,但是新教國家不願意修改,而且希臘等東正教國家直到20世紀初才修改,是以這個改革在英國及其殖民地(包括美國)在1752年9月2日後面跟着的就是9月14日。但是在windows下,由于電腦的日期無法調回到那個時候(1980再往前就是2099年了),看來這段曆史要靠Linux才能了解到了。

這個,呵呵了

xev - print contents of X events

xeyes - a follow the mouse X demo

factor - factor numbers

shred - overwrite a file to hide its contents, and optionally delete it #檔案粉碎機,話說連英文發音都這麼獨特

cmatrix - simulates the display from "The Matrix" 模拟黑客帝國的矩陣風格動畫

oneko - Creates a cute cat chasing around your mouse cursor 喵星人,蠻cute的

figlet 、toilet指令 藝術字生成器,由ASCII字元組成,把文本顯示成标題欄

toilet還可以添加顔色,舉例:$ toilet -f mono12 -F gay a girl

繼續閱讀