Third, Linux Primer--Common commands for file processing commands

Source: Internet
Author: User
Tags file permissions

1. Create an empty file: Touch

Location:/bin/touch

Execute Permissions: All Users

Syntax: touch [filename]

Example: Touch test.list

Touch/root/test.list

Touch Girl boy created Girl and boy two files in the current directory

Note: In addition to the "/" in Linux, other symbols including spaces, quotation marks, etc. can be used as the name of the file, but generally do not use

2. Display file contents: Cat

Location:/bin/cat

Execute Permissions: All Users

Syntax: cat [filename]

-N: Show line numbers

Example: Cat/etc/issue

Cat-n/etc/issue

Reverse display of file contents: TAC

TAC does not have the-n option

3, pagination display file content: more

Location:/bin/more

Execute Permissions: All Users

Syntax: more [filename]

Press space or F key: Flip page

Enter: line break

Q or Q: Exit

Usage: Used to view files with too many file information

Note: The more command can only page down or line wrap cannot be returned to view

Page display of file contents: Less (can page up)

  Less contains all the features of more, and also page UP and keyword search

  PageUp: Page Up

Up ARROW: one line up

entering the/[keyword in the less command browser],linux will label the search keyword and press N to find it down

4. Display the first few lines of the file: Head

Location: Usr/bin/head

Execute Permissions: All Users

Syntax: head-n [number of rows] [filename]

-N: Specifies the number of rows to display

Example: Head-n 20/etc/services

Head/etc/services Display the first 10 rows by default

Display the file after a few lines: tail

 Syntax: tail [file name]

-N: Specify the number of rows

-F: Dynamically displays the end of the file, such as the real-time update of log files

For example: Tail-n 3/etc/services display the last 3 lines, if you do not specify a few rows by default to 10 rows

5. Generate Link file: ln 

English Name: Link

Location:/BIN/LN

Execute Permissions: All Users

Syntax: ln-s [Original file] [target file]

-S: Generate soft Links

Example: ln-s/etc/issue/tmp/issue.soft generating a soft link file

Ln/etc/issue Tmp/issue.hard Generating a hard-link file

   Soft Link File : The Linux system in the soft connection file is similar to Windows shortcut, it will link to the corresponding directory of the execution file, simply said it is just a link to the original file.

The permissions of the soft link file are equivalent to the permissions of the shortcut keys, and do not affect the permissions of the original file

The three main features of a soft link file:

(1) All soft link files are identified by the letter "L"

(2) All soft link files have an arrow "-" pointing to the original file

(3) All soft link file permissions are lrwxrwxrwx, and the file is relatively small

Hard - link files: similar to cp-p reserved properties, the difference is that hard links can be updated synchronously, meaning that hard links are updated immediately if the original file is manipulated. The reason is the same as the I node of the original file and the hard link file.

Note: A file corresponds to an I node, but an I node can correspond to multiple files.

The difference between a soft link and a hard link:

(1) Hard links cannot span partitions

(2) Hard links cannot be used for directories

Third, Linux Primer--Common commands for file processing commands

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.