Linux commands used in work

Source: Internet
Author: User

Linux commands used in work

File editing operation commands


The method for searching strings in vi is as follows:
1. Enter "/string" in command mode, for example, "/Section 3 ".
2. If you want to find the next one, press "n.
To search up from the current cursor position, run the following command:
/Pattern Enter
Where, pattern indicates the specific character sequence to be searched.
To search down from the current cursor position, run the following command:
? Pattern Enter
After pressing Enter, vi searches for the specified pattern and positions the cursor at the first character of pattern.

Press the Insert key. You can see "Insert" in the lower left corner of the window, indicating that the current status is Insert and edit. Then, the content entered from the keyboard is inserted to the cursor position, and then press the Insert key, "Replace" is displayed in the lower-left corner, indicating that the current status is "Replace". The content entered from the keyboard replaces the content at the cursor position.

After editing the file, Press esc,


A. if you want to force exit Vi without saving the modified file, run the following command: q!
Vi abandons the modification and directly returns to shell;


B. Enter the command: wq, Vi will first save the file, and then exit Vi and return to shell.


C. Press the uppercase letter Z twice for a connection. If the current edited file has been modified, Vi will save the file and exit, and return to shell;
If the current edited file has not been modified, Vi exits directly and returns to shell;


D. Enter the command: w
Vi saves the current editing file, but does not exit, but continues waiting for the user to enter the command. When you use the w command, you can create a new file name for the editing file. : W newfile Vi saves the content of the current file to the specified newfile, while the original file remains unchanged. If newfile is an existing file, the Vi prompts in the status line of the display window:
File exists (use! To override)
If you really want to replace the original content in newfile with the current content of the file, you can use the command
: W! Newfile
Otherwise, you can select another file name to save the current file.

E. Enter the command: q
The system exits Vi and returns to shell. If the editing file is not saved when you exit Vi with this command, the last line of the Vi display window displays the following information:

No write since last change (use! To overrides)

Other common commands


1. Command for moving folders: cp-r/usr/local/www/vhosts/var/ftp/pub

2. Switch users
In the inux system, the user switchover command is su, And the syntax is: su [-fmp] [-c command] [-s shell] [-- help] [-- version] [-] [USER [ARG]


Parameter description
-F,-fast: do not need to read the Startup File (such as csh. cshrc). It is only used for csh or tcsh shells.
-L,-login: After this parameter is added, it is like re-login. Most environment variables (such as HOME, SHELL, and USER) are dominated by this USER, the working directory also changes. If no USER is specified, the default value is root.

-M,-p,-preserve-environment: the environment variable is not changed when su is executed.
-C command: the USER who changed the account to USER, and then executes the command to change it back to the original USER.
-Help: display the description file
-Version: displays version information.
USER: USER account to be changed,
ARG: input a new Shell parameter.

2. difference between su [user] And su-[user]: su [user] switches to another user, but does not switch environment variables, su-[user] Completely switches to the new user environment.

3. Search for files

Find.-maxdepth 1-name "@*"
This command is used to search for files or directories starting with @ in the current directory. The search depth is the first level, that is, it is only found in the current directory and does not enter the subdirectory, if you want to start from the/directory:
Find/-maxdepth 1-name "@*"
If you want to search for the entire disk, remove-maxdepth 1.

4. automatically install software

The command Format of yum is generally as follows: yum [options] [command] [package...]
[Options] are optional, including-h (HELP) and-y (when the installation prompt is "yes "), -q (the installation process is not displayed. [Command] is the operation object. [package...] is the operation object.

For example:

yum install zabbix20-server zabbix20-agent zabbix20-web-mysql nmap httpd policycoreutils-python net-snmp net-snmp-utils

 

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.