Linux Cloud Computing Cluster Architecture Learning notes: 1-3 viewing file contents

Source: Internet
Author: User

View File Contents 1.cat command

Function: View the contents of a file

Syntax: Cat file name

2. More Commands

Role: View the contents of a file by paging

Syntax: more file names

Example: MORE/ETC/PASSWD

Press ENTER to refresh a row, press the space to refresh one screen

Exit: Press Q Health

3.less command

Role: View the contents of a file by paging

Syntax: less file name

Example: LESS/ETC/PASSWD

Use the cursor keys to page UP

Exit: Press Q Health

Summary:

The difference between more and less in Linux

MORE: Does not support back, but almost no need to add parameters, the space bar is the page down, the ENTER key is down the line, in the case of no need to back the situation is convenient.

Less: Supports rollover, either up (PageUp button) or down (pagedown button). , the SPACEBAR is a page down, and the ENTER key is a downward-turning line

4. Head command

Function: View the first few lines of the file

Syntax: Head-n file name (n is a specific number that represents the first n rows)

Example: View/etc/passwd Top 3 lines of content

[Email protected] ~]# head-3/etc/passwd

Root:x:0:0:root:/root:/bin/bash

Bin:x:1:1:bin:/bin:/sbin/nologin

Daemon:x:2:2:daemon:/sbin:/sbin/nologin

5.tail command

Function: View the contents of the file after several lines

Syntax: Tail-n file name (n is a specific number that represents the reciprocal n line)

Description: Starting from the following line, viewing the file, showing the last 10 rows by default

Parameter-n shows how many rows

Example: Add an Nginx user, the/etc/passwd file will be appended to the Nginx user-related information, can be displayed with the tail command

[Email protected] ~]# Useradd nginx

[Email protected] ~]# tail-1/etc/passwd

Nginx:x:1002:1002::/home/nginx:/bin/bash

[Email protected] ~]#

-F Dynamic Display data (not closed) often used to view logs

Linux Cloud Computing Cluster Architecture Learning notes: 1-3 viewing file contents

Related Article

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.