Linux basic commands

  
        

ls command

Meaning of this command: Displays a list of files and folders in the specified directory.


root@iZ259pk6ziaZ:/home# ls

haocai

Description: Displays files or folders in this directory.


wcjdeMBP:~ wcj$ ls -a

. .matplotlib Pictures

.. .mysql_history Public

.CFUserTextEncoding . Python27_compiled PycharmProjects

Description: Displays files or folders under this directory. (including hidden)


root@iZ259pk6ziaZ:/home# ls -l

total 4

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

Description: Displays the permissions, owner, size, timestamp, and file name of the files or folders in this directory.


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

Description: Display files or folders under this directory and subdirectories


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 2 0: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

Description: The combination of -l and -R, with both commands Function


cat command

Meaning of this command: Display the contents of the file.


root@iZ259pk6ziaZ:/# cat text1.txt

2016-01

2016-02

2016-03< Br>

Description: Display the entire contents of the file


root@iZ259pk6ziaZ:/# cat >text4.txt

Description: Create file 4





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

: Pass the contents and line number of file 1 to file 2, if 2 does not exist, create it. If there is no > point to file 2, file 2 must exist


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

> 2016-01

> 2016-01

> 2016-03

> EOF

Description: Create file 1 and input the content, EOF can be replaced with any of the same characters


head command

Meaning of this command: Display file header information.


root@iZ259pk6ziaZ:/# head text1.txt

2016-01

2016-02

2016-03< Br>

2016-04

2016-05

2016-06

2016-07

2016-08

2016-09

2016-10

Description: Display the first 10 lines of file 1 (default)


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

2016-01

2016-02

2016-03

2016-04

2016-05

Description: Displays the first 5 lines of information in file 1.

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

2016-01

2016-02

Description: Display file 1 Remove the last 10 lines of information.


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

2016-01

2016

: Displays information about the first 12 bytes of file 1.


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

2016-01

2016-02

2016-0

Description: Display file 1 removes the last 74 bytes of information.


tail Command

Meaning of this command: Display file tail information.


root@iZ259pk6ziaZ:/# tail text1.txt

2016-03

2016-04

2016-05< Br>

2016-06

2016-07

2016-08

2016-09

2016-10

2016-11

2016-12

Description: Display 10 lines of information at the end of file 1 (default)



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

2016-08

2016-09

2016-10

2016-11

2016-12

Description: Displays the last 5 lines of information in file 1.


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

2016-11

2016-12

Description: Displays all information from file 1 to the end of line 1.


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

Description: Cycle through all the information of file 1. (Dynamic real time)



wc command

Meaning of this command: Count the number of lines, words, and subsections in the specified file.


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

12 text1.txt

Description: Displays the number of lines in file 1.


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

12 text1.txt

Description: Displays the number of words in file 1.


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

96 text1.txt

Description: Displays the number of bytes in file 1.


root@iZ259pk6ziaZ:/# wc text1.txt

12 12 96 text1.txt

Description: Display -l,-w,- c function


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

96 text1.txt

Description: Display the characters of file 1. number.


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

7 text1.txt

Description: Display the longest line of file 1. length.



Copyright © Windows knowledge All Rights Reserved