Linux File Management commands and linux commands

Source: Internet
Author: User

Linux File Management commands and linux commands

Directory management:

Ls cd pwd mkdir rmdir tree

File Management:

Touch stat file rm cp mv nano

Date and Time:

Date clock hwclock cal

View text:

Cat tac more less head tail

 

Cat: connect and display (multiple files can be connected)

 

Split-screen display:

More, less

More: similar to cat, the cat command displays the content of the entire file on the screen from top to bottom. more is displayed on one page for users to read on one page, the most basic command is to press the space key to display it on the next page. Press the B key to display the page back and search for strings.

Less: a tool that displays files or other outputs. It is a tool used by linux to view file content. It is extremely powerful. The usage of less is more flexible than that of more. At the time of more, we can't flip forward, but we can only look at it later. However, if less is used, you can use the [pageup] [pagedown] and other buttons to access and view the file, making it easier to view the content of a file! In addition, you can have more search functions in less, not only to search down, but also to search up.

 

Head: view the first n rows

Tail: n rows after viewing

-F: Check the end of the file and do not exit. Wait for the new content appended to the file to be displayed. (new content is written to the file by other processes and will be immediately displayed)

 

Text processing:

Cut (Text cutting), join (Text join), sed (powerful, difficult), awk (more difficult, your own command is a programming language)

Cut:

-D: Specifies the field separator. The default value is space.

-F: Specifies the field to be displayed.

-F 1, 3: show 1 3 fields

-F 1-3: show 1-3 fields

Text sorting: sort

-N: Numerical sorting (by default, sort sorting is performed by character in ascending order based on the ASCII code value. Here, it is sorted by number)

-R: sort in descending order (sort characters by ASCII code values in descending order)

-T: field separator

-K: Which field is used for sorting, usually used in combination with-t

Eg

Sort-t:-k3/etc/passwd sort by ASCII code values in ascending order based on the third field: field separator

-U: The same rows are displayed only once after sorting.

Uniq:

-C: displays the number of duplicates in the file.

-D: only duplicate rows are displayed.

 

Text statistics: wc (word count! No water closet haha)

Eg wc/etc/passwd

Description: The/etc/passwd file contains 38 rows, 66 words, and 1911 bytes.

-L: displays only rows.

-W: only display the number of words

-M: displays only the number of bytes.

 

Character Processing Command: tr converts or deletes characters

Tr [OPRION]... SET1 [SET2]

-D: Delete All characters in the character set.

Eg

1. tr 'AB' </etc/passwd

Replace all AB in/etc/passwd with AB

2. tr-d 'AB' deletes all input content including AB

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.