歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux基本命令

Linux基本命令

日期:2017/4/19 14:21:06   编辑:關於Linux

ls命令

此命令意義:顯示指定目錄裡的文件及文件夾清單。

root@iZ259pk6ziaZ:/home# ls

haocai

說明:顯示此目錄下的文件或文件夾。

wcjdeMBP:~ wcj$ ls -a

. .matplotlib Pictures

.. .mysql_history Public

.CFUserTextEncoding .python27_compiled PycharmProjects

說明:顯示此目錄下的文件或文件夾。(包括隱藏)

root@iZ259pk6ziaZ:/home# ls -l

total 4

drwxr-xr-x 4 root root 4096 Jun 20 17:30 haocai

說明:顯示此目錄下的文件或文件夾的權限、所有者、大小、時間戳、文件名。

root@iZ259pk6ziaZ:/home# ls -R

.:

haocai

./haocai:

log skynet

./haocai/log:

skynet.log skynet.log.2016-05-26 skynet.log.2016-06-03 skynet.log.2016-06-13

./haocai/skynet:

account comment ingredient sample util.py

activity config menu search util.pyc

application.py cookrecord oplog static weixin

application.pyc database.py permission storage.py

cache.pyc database.pyc push storage.pyc

categoryLatest feedback README.md templates

column firmware requirements.txt user

./haocai/skynet/account:

__init__.py __init__.pyc module.py module.pyc view.py view.pyc

說明:顯示此目錄下及子目錄的文件或文件夾

root@iZ259pk6ziaZ:/home# ls -lR

.:

total 4

drwxr-xr-x 4 root root 4096 Jun 20 17:30 haocai

./haocai:

total 8

drwxr-xr-x 2 root root 4096 Jun 14 20:06 log

drwxr-xr-x 22 root root 4096 Jun 15 16:42 skynet

./haocai/log:

total 128

-rw-r--r-- 1 root root 102387 Jun 15 16:30 skynet.log

-rw-r--r-- 1 root root 9668 Jun 3 17:14 skynet.log.2016-05-26

-rw-r--r-- 1 root root 661 Jun 13 10:47 skynet.log.2016-06-03

-rw-r--r-- 1 root root 9528 Jun 15 09:52 skynet.log.2016-06-13

說明:-l和-R的合並,同時具有這兩個命令的功能

cat命令

此命令意義:顯示文件內容。

root@iZ259pk6ziaZ:/# cat text1.txt

2016-01

2016-02

2016-03

說明:顯示文件的全部內容

root@iZ259pk6ziaZ:/# cat >text4.txt

說明:創建文件4

root@iZ259pk6ziaZ:/# cat -n text1.txt>text2.txt

說明:把文件1的內容和行號傳給文件2,如果2不存在則創建,如果沒有>指向文件2的話,文件2必須存在

root@iZ259pk6ziaZ:/# cat >>text1.txt<

> 2016-01

> 2016-01

> 2016-03

> EOF

說明:創建文件1並輸入內容,EOF可以換成任何相同的字符

head命令

此命令意義:顯示文件頭部信息。

root@iZ259pk6ziaZ:/# head text1.txt

2016-01

2016-02

2016-03

2016-04

2016-05

2016-06

2016-07

2016-08

2016-09

2016-10

說明:顯示文件1的前10行信息(默認)

root@iZ259pk6ziaZ:/# head -5 text1.txt

2016-01

2016-02

2016-03

2016-04

2016-05

說明:顯示文件1的前5行信息。

root@iZ259pk6ziaZ:/# head -n -10 text1.txt

2016-01

2016-02

說明:顯示文件1的去掉末尾10行信息。

2016-0root@iZ259pk6ziaZ:/# head -c 12 text1.txt

2016-01

2016

說明:顯示文件1的前12個字節的信息。

2016-root@iZ259pk6ziaZ:/# head -c -74 text1.txt

2016-01

2016-02

2016-0

說明:顯示文件1去掉末尾74個字節的信息。

tail命令

此命令意義:顯示文件尾部信息。

root@iZ259pk6ziaZ:/# tail text1.txt

2016-03

2016-04

2016-05

2016-06

2016-07

2016-08

2016-09

2016-10

2016-11

2016-12

說明:顯示文件1的尾部10行信息(默認)

root@iZ259pk6ziaZ:/# tail -5 text1.txt

2016-08

2016-09

2016-10

2016-11

2016-12

說明:顯示文件1的末尾5行信息。

root@iZ259pk6ziaZ:/# tail -n +11 text1.txt

2016-11

2016-12

說明:顯示文件1的從第11行開始到末尾的所有信息。

root@iZ259pk6ziaZ:/# tail -f text1.txt

2016-03

2016-04

2016-05

2016-06

2016-07

2016-08

2016-09

2016-10

2016-11

2016-12

說明:循環顯示文件1的所有信息。(動態實時)

wc命令

此命令意義:統計指定文件中的行數、字數、子節數。

root@iZ259pk6ziaZ:/# wc -l text1.txt

12 text1.txt

說明:顯示文件1的行數。

root@iZ259pk6ziaZ:/#wc -w text1.txt

12 text1.txt

說明:顯示文件1的單詞數。

root@iZ259pk6ziaZ:/# wc -c text1.txt

96 text1.txt

說明:顯示文件1的字節數。

root@iZ259pk6ziaZ:/# wc text1.txt

12 12 96 text1.txt

說明:顯示-l,-w,-c的功能

root@iZ259pk6ziaZ:/# wc -m text1.txt

96 text1.txt

說明:顯示文件1的字符數。

root@iZ259pk6ziaZ:/# wc -L text1.txt

7 text1.txt

說明:顯示文件1的最長行的長度。

Copyright © Linux教程網 All Rights Reserved