search
HomeOperation and MaintenanceCentOSDetailed explanation of file viewing and editing in CentOS

The following column of centos Basic Tutorial will introduce you to the file viewing and editing of CentOS. I hope you can learn more about it if you need it. Friends help!

Detailed explanation of file viewing and editing in CentOS

First of all, let’s introduce cat. The original meaning of cat command is concatenate, which is used to connect the contents of multiple files and output them to the standard output stream (the standard output stream defaults to for the screen). In actual application, we often use it to display file contents.

cat file1.php displays the contents of the file1.php file;

cat -n file2.py displays the contents of the file2.py file and displays the line number ;

cat file1.php file2.py displays the contents of file1.php and file2.py files;

vi is the abbreviation of "Visual Interface", and the vi editor is the most basic text editor on Linux and Unix. It can perform many text operations such as output, delete, find, replace, block operations, etc., and users can customize it according to their own needs, which is not available in other editing programs. vi is not a typesetting program. It cannot edit fonts, formats, paragraphs and other attributes like Word or WPS. It is just a text editing program. vi has no menus, only commands, and there are many commands. Due to space limitations, this article only introduces commonly used commands. vi has three basic working modes: command line mode, text input mode and last line mode.

To enter and exit vi, enter the file name to be edited in shell mode, such as: vim file1.php to edit the file.

When exiting vi, you need to enter the exit command "q" in the last line mode. If you are in text input mode, first press the "ESC" key to enter the command mode, and then enter ":" to enter the last line mode. In the last line mode, you can use the following exit command.

When exiting: 1. :q is to exit directly; 2. wq is to exit after saving; 3. :q! - does not save the content, force exit

In the last line mode, enter set number to display the line number

In the last line mode, you can use the following "nu" command (abbreviation for number) to display the line number of the line where the cursor is located and the content of the line.

vi provides two insert commands: i and I.

1. The i command inserts text starting from before the cursor position, and you can use the key to delete incorrect input during the insertion process. At this time, vi is in the insert state, and the word "-INSERT-" is displayed on the bottom line of the screen.

2. I command This command moves the cursor to the beginning of the current line and then inserts text before it.

#vi also provides many deletion commands. These commands x (lowercase) 0 delete the character at the cursor. X (uppercase) deletes the character before the cursor dd deletes the entire line where the cursor is. The D or d$ commands have the same function, they both delete the content from the cursor position to the end of the line. d0 deletes the content starting from the character before the cursor to the beginning of the line. dw deletes a word.

vi also has a text copy command yy to copy the entire line where the cursor is located. Once the line of text has been copied, it can be pasted anywhere by using the "p" command introduced above.

Related recommendations: "linux course"

The above is the detailed content of Detailed explanation of file viewing and editing in CentOS. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
CentOS in Action: Server Management and Web HostingCentOS in Action: Server Management and Web HostingApr 18, 2025 am 12:09 AM

CentOS is widely used in server management and web hosting. Specific methods include: 1) using yum and systemctl to manage the server, 2) install and configure Nginx for web hosting, 3) use top and mpstat to optimize performance, 4) correctly configure the firewall and manage disk space to avoid common problems.

CentOS: A Community-Driven Linux DistributionCentOS: A Community-Driven Linux DistributionApr 17, 2025 am 12:03 AM

CentOS is a stable, enterprise-grade Linux distribution suitable for server and enterprise environments. 1) It is based on RedHatEnterpriseLinux and provides a free, open source and compatible operating system. 2) CentOS uses the Yum package management system to simplify software installation and updates. 3) Support advanced automation management, such as using Ansible. 4) Common errors include package dependency and service startup issues, which can be solved through log files. 5) Performance optimization suggestions include the use of lightweight software, regular cleaning of the system and optimization of kernel parameters.

What Comes After CentOS: The Road AheadWhat Comes After CentOS: The Road AheadApr 16, 2025 am 12:07 AM

Alternatives to CentOS include RockyLinux, AlmaLinux, OracleLinux, and SLES. 1) RockyLinux and AlmaLinux provide RHEL-compatible binary packages and long-term support. 2) OracleLinux provides enterprise-level support and Ksplice technology. 3) SLES provides long-term support and stability, but commercial licensing may increase costs.

CentOS: Exploring the AlternativesCentOS: Exploring the AlternativesApr 15, 2025 am 12:03 AM

Alternatives to CentOS include UbuntuServer, Debian, Fedora, RockyLinux, and AlmaLinux. 1) UbuntuServer is suitable for basic operations, such as updating software packages and configuring the network. 2) Debian is suitable for advanced usage, such as using LXC to manage containers. 3) RockyLinux can optimize performance by adjusting kernel parameters.

Centos shutdown command lineCentos shutdown command lineApr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Difference between centos and ubuntuDifference between centos and ubuntuApr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Centos configuration IP addressCentos configuration IP addressApr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

How to install centosHow to install centosApr 14, 2025 pm 09:03 PM

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor