Java interview summary summary, including Java key knowledge, as well as common open source framework, welcome to read. The article may have wrong place, because individual knowledge is limited, welcome everybody big guy to point out! The article continues to be updated at……
ID The title address 1 Design Mode Interview Questions (Most comprehensive summary of interview questions) Juejin. Cn/post / 684490… 2 Java Basics (most comprehensive interview questions) Juejin. Cn/post / 684490… 3 Java Set interview Questions (the most comprehensive interview questions) Juejin. Cn/post / 684490… 4 JavaIO, BIO, NIO, AIO, Netty Interview Questions (Most comprehensive summary of interview questions) Juejin. Cn/post / 684490… 5 Java Concurrent Programming Interview questions (most comprehensive interview questions) Juejin. Cn/post / 684490… 6 Java Exception Interview Questions (The most comprehensive interview Questions) Juejin. Cn/post / 684490… 7 Java Virtual Machine (JVM) Interview Questions Juejin. Cn/post / 684490… 8 Spring Interview Questions (the most comprehensive interview questions) Juejin. Cn/post / 684490… 9 Spring MVC Interview Questions (The most comprehensive interview Questions) Juejin. Cn/post / 684490… 10 Spring Boot Interview Questions (Most comprehensive summary of interview questions) Juejin. Cn/post / 684490… 11 Spring Cloud Interview Questions (The most comprehensive interview questions) Juejin. Cn/post / 684490… 12 Redis Interview Questions (most comprehensive summary of interview questions) Juejin. Cn/post / 684490… 13 MyBatis Interview Questions (most comprehensive interview questions) Juejin. Cn/post / 684490… 14 MySQL Interview Questions (most comprehensive interview questions) Juejin. Cn/post / 684490… 15 TCP, UDP, Socket, HTTP interview questions Juejin. Cn/post / 684490… 16 Nginx Interview Questions (The most comprehensive interview Questions) Juejin. Cn/post / 684490… 17 ElasticSearch interview questions 18 Kafka interview questions 19 RabbitMQ interview questions (most comprehensive summary of interview questions) Juejin. Cn/post / 684490… 20 Dubbo Interview Questions (the most comprehensive interview questions) Juejin. Cn/post / 684490… 21 ZooKeeper Interview Questions Juejin. Cn/post / 684490… 22 Netty Interview Questions (Most comprehensive summary of interview questions) 23 Tomcat Interview Questions (The most comprehensive interview questions) Juejin. Cn/post / 684490… 24 Linux Interview Questions (Most comprehensive Summary of interview questions) Juejin. Cn/post / 684490… 25 Internet Related interview Questions (the most comprehensive summary of interview questions) 26 Internet Security Questions (Summary of the most comprehensive interview questions)
Linux overview
What is a Linux
-
Linux is a unix-like operating system that is free to use and spread freely. Most WEB projects are deployed on Linux operating system. Linux is a multi-user, multi-task, multi-threaded and multi-CPU operating system based on POSIX and Unix. It can run major Unix tools, applications, and network protocols. It supports both 32-bit and 64-bit hardware. Linux inherits the design idea of Unix taking network as the core, and is a stable multi-user network operating system.
Difference between Windows and Linux
- Windows is an operating system developed by Microsoft. It can be used for entertainment, video and Internet. The Windows operating system has a powerful logging system and powerful desktop applications. The advantage is that it can help us achieve a very colorful effect, can be very convenient to carry out entertainment, video, Internet.
- Linux application is relatively simple, there is no colorful effect, so the performance of Linux is very good, can be completely targeted for the configuration of the machine optimization,
- Simply speaking, Windows is suitable for ordinary users for entertainment and office use, while Linux is suitable for software development and deployment
What’s the difference between Unix and Linux?
- Linux and Unix are both powerful operating systems and widely used server operating systems. There are many similarities, and some people even mistakenly believe that Unix and Linux are the same. However, this is not the case.
- Linux is an open source operating system, you do not need to pay, you can use; Unix is a traditional commercial software that protects the intellectual property of source code and requires a paid license.
- Cross-platform Linux operating system has good cross-platform performance and can run on a variety of hardware platforms. Unix operating systems have poor cross-platform performance and must be used with hardware.
- Visual interface Linux in addition to command line operation, there is a window management system; Unix is just a command line system.
- Hardware The Linux operating system has low requirements on hardware, and the installation method is easy to master. Unix has strict requirements on hardware.
- Linux is widely used by individuals and businesses; Unix is used by a narrow group of users, mostly by large enterprises with high security requirements, such as banks and telecom departments, or by Unix hardware manufacturers, such as Sun. Compared with the Unix operating system, The Linux operating system is more popular with computer enthusiasts, the main reason is that the Linux operating system has all the functions of the Unix operating system, and can realize all the Unix features on ordinary PC computers, open source free features, easier to use!
What is the Linux kernel?
- The core of a Linux system is the kernel. The kernel controls all hardware and software on a computer system, allocating hardware when necessary, and executing software as needed.
- System Memory Management
- Application Management
- Hardware Device Management
- File System Management
What are the basic components of Linux?
- Just like any other typical operating system, Linux has all of these components: the kernel, the shell and the GUI, the system utilities and applications. What gives Linux an advantage over other operating systems is that every aspect comes with additional functionality, and all the code can be downloaded for free.
Linux architecture
- On a large scale, the Linux architecture can be divided into two parts:
- User Space: User Space includes User Applications and C Library.
- Kernel Space: The Kernel Space includes System Call Interface, Kernel, and architecture-dependent Kernel Code.
Why is the Linux architecture divided into user space and kernel space?
- 1. Modern cpus implement different working modes, which can execute instructions and access registers differently.
- 2. From the perspective of CPU, Linux divides the system into two parts in order to protect the kernel security.
- User space and kernel space are for program executionTwo different states, we can accomplish the transition from user space to kernel space in two ways:
- System call;
- Hardware is interrupted.
What are the basic differences between BASH and DOS?
- The main differences between BASH and the DOS console lie in three areas:
- The BASH command is case-sensitive, while the DOS command is not.
- Under BASH, / character is the directory separator and \ is the escape character. Under DOS, / is used as the command parameter separator, and \ is the directory separator
- DOS follows the convention in named files, which is an 8-character filename followed by a dot and a 3-character extension. BASH does not follow such conventions.
Linux Boot process?
Understand.
-
1. Power on the host and perform a self-check to load BIOS hardware information.
-
2. Read the boot file of the MBR (GRUB and LILO).
-
3. Boot the Linux kernel.
-
4. Run the first process init (process number is always 1).
-
5. Enter the corresponding run level.
-
6. Run the terminal and enter the user name and password.
What is the default running level for Linux?
- To turn it off.
- Single-machine user mode.
- Character interface in multi-user mode (no network support).
- Character interface multi-user mode.
- Not allocated.
- Multi-user mode of graphical interface.
- Restart.
Interprocess communication used by Linux?
Understand can, don’t need too deep.
- 1, pipe (PIPE), flow pipe (S_PIPE), named pipe (FIFO).
- 2. Signal.
- 3. Message queues.
- Shared memory.
- 5. Semaphore.
- 6. Socket.
What system log files does Linux have?
- The important thing is
/var/log/messages
Log files.
This log file is a summary of many process log files, from which any intrusion attempts or successful intrusions can be seen.
In addition, if there is a centralized collection of ELK logs in your system, it will also be collected.
Is it helpful to install multiple desktop environments for Linux?
- Usually, a desktop environment, such as KDE or Gnome, is sufficient to run without problems. Although the system allows switching from one environment to another, this is a priority for users. Some programs work in one environment but not in another, so it can also be considered a factor in choosing which environment to use.
What is interchange space?
- Swap space is a space used by Linux to temporarily hold programs that run concurrently. This happens when RAM does not have enough memory to hold all the programs being executed.
What is the root account
- The root account is like a system administrator account, allowing you complete control of the system. You can create and maintain user accounts here, assigning different permissions to each account. This is the default account every time you install Linux.
What is LILO?
- LILO is the boot loader for Linux. It is primarily used to load the Linux operating system into main memory so that it can start running.
What is BASH?
- BASH is short for Bourne Again SHell. It was written by Steve Bourne as an alternative to the original Bourne Shell (represented by /bin/sh). It combines all the features of the original Bourne Shell, as well as other features, to make it easier to use. Since then, it has been adapted as the default shell for most systems running Linux.
What is CLI?
-
The command line interface (CLI) was the most widely used user interface before the popularity of graphical user interfaces. It usually did not support a mouse. Users input commands through the keyboard, and the computer executed the commands after receiving them. Some call it CUI (Character User interface).
-
A command line interface (CLI) is generally considered less user-friendly than a graphical user interface (GUI). Because, the command line interface software usually needs the user to memorize the command operation, but, because of its own characteristics, the command line interface should save the resources of the computer system compared with the graphical user interface. Using a command line interface is usually faster than using a graphical user interface (GUI), provided you have memorized commands. As a result, graphical user interface operating systems retain an optional command line interface.
What is a GUI?
-
Graphical User Interface (GUI) is a Graphical User Interface used for computer operations.
-
A graphical user interface is an interface display format for communication between a person and a computer that allows the user to use input devices such as a mouse to manipulate on-screen ICONS or menu options to select commands, invoke files, launch programs, or perform some other everyday tasks. Graphical user interfaces have many advantages over character interfaces that perform routine tasks by typing text or character commands on a keyboard.
What are the advantages of open source?
- Open source allows you to distribute software (including source code) for free to anyone who is interested. One can then add features and even debug and correct errors in the source code. They can even make it work better, and then freely redistribute the enhanced source code again. This ultimately benefits everyone in the community.
What is the importance of the GNU project?
- This so-called free software movement has many advantages, such as the freedom to run programs and learn and modify them as you see fit. It also allows you to redistribute copies of software to others, as well as the freedom to improve the software and distribute it to the public.
Disk, directory, file
Simple Linux file system?
In Linux, all resources managed by the operating system, such as network interface cards, disk drives, printers, I/O devices, common files, or directories, are treated as one file.
-
That said, there is an important concept in Linux: everything is a file. In fact, this is a reflection of the Unix philosophy, and Linux is a rewrite of Unix, so the concept has been passed on. On Unix systems, all resources are considered files, including hardware devices. UNIX systems treat each piece of hardware as a file, often called a device file, so that users can access the hardware by reading and writing files.
-
Linux supports five file types, as shown in the following figure:
What is the directory structure of Linux?
That’s a question you don’t usually ask. More is needed when it comes to practical use.
- Linux file systems have distinct hierarchies, like an upside-down tree, with the root directory at the top:
Common Directories:
directory introduce /bin Binary executable files (ls,cat,mkdir, etc.), common commands are generally here; /etc Store system management and configuration files. /home The root directory that stores all user files is the base point of the user’s home directory. For example, the home directory of the user is /home/user, which can be expressed as ~user. /usr For storing system applications; /opt The location where the optional application package for additional installation is placed. Normally, we can install Tomcat and so on here; /proc A virtual file system directory is a mapping of system memory. Access this directory directly for system information; /root The home directory of the superuser (system administrator) (privileged class); /sbin Store binary executable files accessible only by root. The system commands and programs used by system administrators are stored here. Such as ifconfig, etc.; /dev Used to store device files; /mnt This directory is provided by the system for users to temporarily mount other file systems. /boot Store various files used for system boot; /lib Store and system operation related library files; /tmp Used to store all kinds of temporary files, is a public temporary file storage point; /var It is used to store files that need to change data at run time, and it is also an overflow area for some large files, such as log files for various services (system startup logs, etc.). And so on; /lost+found This directory is usually empty, the system abnormally shut down, leaving the “homeless” file (called.chk under Windows) here
What is an inode?
Typically, inode is not asked in interviews. But inodes are an important concept that is fundamental to understanding Unix/Linux file systems and hard disk storage.
-
To understand inodes, start with file storage.
-
Files are stored on a hard disk in a unit called a Sector. Each sector stores 512 bytes (equivalent to 0.5KB).
-
When the operating system reads disks, it does not read disks one sector at a time, which is inefficient. Instead, it reads disks consecutively, that is, one block at a time. This “block”, composed of multiple sectors, is the smallest unit of file access. The size of a “block” is 4KB, that is, eight consecutive sectors constitute a block.
-
The file data is stored in “chunks,” so obviously we have to find a place to store meta-information about the file, such as who created the file, the date it was created, the size of the file, and so on. The area where the meta information is stored is called an inode, or “index node” in Chinese.
-
Each file has an inode that contains information about the file.
How does the Linux file system convert the logical structure and physical structure of a file through the I node?
If you look confused, that’s okay. Generally speaking, this question is not asked by interviewers.
- Linux uses inode node tables to transform the logical and physical structure of files.
- The inode node is a 64-byte long table that contains information about files, including file size, file owner, file access permission, and file type. The most important element in the inode node table is the disk address table. There are 13 block numbers in the disk address table, and the file reads the corresponding blocks in the order in which they appear in the disk address table.
- The Linux file system connects the inode node to the file name. When the file needs to be read, the file system searches for the item corresponding to the file name in the current directory table to obtain the inode node number corresponding to the file. The logical structure of the file is connected by the disk address table of the inode node.
What are hard links and soft links?
-
Hard link: Since a file under Linux is identified by an inode, a hard link can be thought of as a pointer to a file inode, and the system does not reassign the inode to it. Each time you add a hard link, the number of links in the file increases by 1.
- Inadequate:
- Do not create links between files on different file systems.
- Only superusers can create hard links for directories.
- Inadequate:
-
Soft links: Soft links overcome the disadvantages of hard links. There is no limitation of any file system. Any user can create symbolic links pointing to directories. It is now more widely used and has greater flexibility, even linking files across different machines and networks.
- Disadvantages: because the link file contains the path information of the original file, so when the original file is moved from a directory to other directories, and then access the link file, the system will not find, and the hard link does not have this defect, you want to move how to move; It also requires the system to allocate extra space to create new index nodes and save paths to original files.
-
In actual scenarios, soft links are used. The differences are summarized as follows:
- Hard links cannot cross partitions, but software chains can cross partitions.
- Hard links point to an inode node, while soft links create a new inode node.
- Deleting a hard link file does not delete the original file. Deleting a soft link file does delete the original file.
What is RAID?
RAID is called Redundant Array of Independent Disks (RAID). The basic idea of RAID is to combine multiple inexpensive hard Disks into a disk Array to achieve or exceed the performance of an expensive hard disk with a large capacity. RAID is typically used on server computers, using identical hard drives to form a logical sector, so the operating system treats it as a single hard drive.
RAID is classified into different levels. Each level has different trade-offs in data reliability and read/write performance. In actual applications, you can select different RAID solutions based on your actual requirements.
- Of course, because many companies are using cloud services, it is difficult to contact the concept of RAID, more likely to be ordinary cloud disk, SSD cloud disk maozi concept.
security
What security work does a Linux system need to do after initialization?
-
1. Add common user login, disable root user login, and change SSH port number.
Modifying an SSH port may not be absolute. Of course, if you want to be exposed to the Internet, it is recommended to change. l
-
2. The server uses the key to log in, but does not use the password.
-
3. Enable the firewall, disable SElinux, and set firewall rules based on service requirements.
-
4. Install fail2ban, which prevents VIOLENT SSH attacks.
-
5. Set only the export IP of the company’s office network to log in the server (depending on the actual needs of the company)
You can also install software such as VPN to connect only the VPN to the server.
-
6. Change the number of historical commands to 10.
-
7. Only servers that need access to the Internet are allowed.
-
8, do a good job of software protection.
- 8.1 Configuring the Nginx_WAf module to prevent SQL injection
- 8.2 Start the Web service as WWW user, change the owner and group of the website directory to WWW.
What is CC attack? What is a DDOS attack?
-
CC attacks, mainly used to attack the page, simulate multiple users to visit your page, so that your system resources are exhausted.
-
Distributed denial of Service (DDOS) attack refers to the use of server technology to unite multiple computers as an attack platform to launch DDOS attacks on one or more targets.
An attack is an attempt to paralyze the network by occupying a large number of network resources through a large number of legitimate requests.
How do I prevent CC and DDOS attacks?
- To prevent CC and DDOS attacks, only hardware firewalls are used to clean traffic and divert attack traffic to black holes.
In terms of traffic cleaning, we can mainly buy anti-attack services from ISP service providers. Generally, there is free traffic in the computer room, so we usually buy services. After all, attacks will not last for a long time.
What is Web database injection?
- Due to the varying level and experience of programmers, most programmers do not judge the validity of user input data when writing code.
- The application has security risks. Procedure The user can submit a piece of database query code, according to the results returned by the program, to obtain some of the data he wants to know, this is called SQL injection.
- SQL injection, from the normal WWW port access, and the surface looks like the general Web page access is no different, if the administrator does not view the log habit, may be invaded for a long time will not be detected.
How to filter and prevent?
- Database web side injection of this, you can consider using nginx_WAF to do filtering and prevention.
What is a Shell script?
- A Shell script is a text file that contains one or more commands. As system administrators, we often need to use multiple commands to complete a task, we can add all these commands in a text file (Shell script) to complete these daily work tasks.
In actual combat
How do I select a Linux OPERATING system version?
In general, desktop users prefer Ubuntu; RHEL or CentOS is preferred for the server. CentOS is preferred.
-
According to specific requirements:
-
If security requirements are high, select Debian or FreeBSD.
-
Users who need advanced database services and E-mail network applications can choose SUSE.
-
Feddora is a beta and pre-release version of RHEL and CentOS for new technologies and features.
-
【 Key 】 According to the current situation, the vast majority of Internet companies choose CentOS. Now more commonly used is the 6 series, now accounts for about half of the market. Another reason is that CentOS is more server oriented and has no copyright restrictions.
CentOS 7 series, also slowly used will be more.
-
How to plan a Linux host, what are the steps?
-
1. Determine what the machine is for, such as WEB, DB, or game server.
The configuration of the machine will be different for different purposes.
-
2, after determining, it is necessary to determine how the system needs to be installed, which system is installed by default, how to do partitions.
-
3. Which parameters of the system need to be optimized, which users need to be created, and so on.
How do you deal with users’ feedback of slow website access?
What are the factors that can cause slow site access?
-
1. The egress bandwidth of the server is insufficient
- The egress bandwidth purchased by the server is relatively small. Once the concurrency is large, the egress bandwidth allocated to each user will be small, and the access speed will naturally be slow.
- Cross-carrier networks reduce bandwidth. For example, the company’s website is placed on the telecom network, so the customer side is connected to the Great Wall broadband or Unicom, which may also lead to the reduction of bandwidth.
-
2. The server is overloaded and fails to respond
It can be analyzed from two aspects:
- To analyze the system load, run the w command or uptime command to view the system load. If the load is high, run the top command to check the CPU usage, MEM usage, etc. Either the CPU is busy or the memory is insufficient.
- If both are normal, use the SAR command to analyze network adapter traffic and determine whether the network adapter is attacked. Once the cause of the problem is identified, take appropriate actions to resolve it, such as deciding whether to kill some processes or disable some access.
-
3. Database bottlenecks
- If the slow query is more. Then it is up to the developer or DBA to help tune the SQL statements.
- If the database is slow to respond, consider adding a database cache, such as Redis. Then, you can set up a MySQL master/slave database, with one MySQL server responsible for writing and several secondary databases responsible for reading.
-
4, the website development code is not optimized
- For example, SQL statements are not optimized, resulting in time-consuming database reads and writes.
For slow website access, how to go to the investigation?
-
1. First determine whether the problem is on the client side or the server side. When receiving user feedback that access is slow, the other side immediately visit the website to have a look, if their access is fast, basically concluded that the user side of the problem, you need to be patient with the customer to explain, to help customers solve the problem.
Don’t start with the server side. Be sure to start at the source and work your way down.
-
2, if access is also slow, then you can use the browser’s debugging function to see which data takes too long to load, is the image load slow, or some data load slow.
-
3. For server load. Check the hardware consumption (network, CPU, and memory) of the server. If the cloud host is purchased, such as Ali Cloud, you can log in to Ali Cloud platform to provide monitoring of various aspects, such as CPU, memory and bandwidth usage.
-
4. If you find that hardware resource consumption is not high, you need to check the log, for example, check the log of MySQL slow query to see whether a CERTAIN SQL statement query is slow, resulting in slow website access.
How to solve it?
- 1, if the export bandwidth problem, so long to apply for increasing the export bandwidth.
- 2. If there are a lot of slow queries, then the developer or DBA is required to assist in SQL statement optimization.
- 3, if the database is slow to respond, consider adding a database cache, such as Redis, etc. You can also set up a MySQL master/slave database, with one MySQL server responsible for writing and several secondary databases responsible for reading.
- 4. Apply for purchasing CDN service and load user access.
- 5. If the access is still slow, you need to optimize the overall architecture. To achieve a dedicated role, multiple servers to provide the same service.
What are the methods for Tuning Linux performance?
- Disabling daemons 1.
- Shutting down the GUI.
- 3, Changing the kernel parameters
- 4, Kernel parameters.
- 4, Tuning the processor subsystem
- 6, Tuning the memory subsystem
- 4, Tuning the file system
- 8, Tuning the network subsystem
Basic commands
CD (change directory) To change a directory
cd .. /; CD /opt; Go there now and jump directly to the specified opt folder CD ~; Toggles the current user's home directory. The root user's home directory is the root directory.Copy the code
PWD (print working directory: print absolute directory)
pwdShows the current absolute road strengthCopy the code
Ls (short for ls: list, view list) View all folders in the current directory (ls only lists file names or directory names)
ls -a ; Show all folders, hidden files also show ls -r; List it along with subdirectoriesCopy the code
Ll (short for list) view all details and folders in the current directory
ll -a ; Show all files, hidden files also show ll-r; List lL-h with subdirectory contents; Friendly display details, you can see the size lL-AL; Shows both hidden files and detailed lists.Copy the code
Touch Creates a file
touch test.txt ; TXT file touch /opt/ Java /test.java; Create the test.java file in the specified directoryCopy the code
Mkdir (mkdir: create directory) Creates a directory
Mkdir folder name; Create a folder mkdir /opt/ Java/JDK in this directory. Creates a folder in the specified directoryCopy the code
Cat (concatenate: to display or concatenate multiple text files) view file command (to quickly view the contents of the current file) (cannot quickly navigate to the last page)
cat lj.log ; Quick view file command Ctrl + C; Pause display file Ctrl + D; Exit the view file commandCopy the code
More page view file command (can’t quickly locate to last page)
Enter: n rows down, need to define, default is 1 row. Space bar: Scroll down a screen or Ctrl+F B: Return to the previous layer or Ctrl+B Q: Exit moreCopy the code
Less (lese: less) paging through files command (to quickly navigate to the last page)
Less-m Displays the percentage similar to the more command. Less-n Displays the line number of each line. (uppercase N) Use both arguments together such as less-mn file name so that the line number can be paginated. Space bar: Next page or page down. Enter: The next line. B: Go back a page or page up. Q: Exit. D: Half a page forward. U: Go back half a pageCopy the code
View file commands (see how many lines are left)
tail -10 ; File names look at the last 10 linesCopy the code
Cp (abbreviation of copy, copy function)
cp /opt/java/java.log /opt/logs/ ; Log /opt/logs/ cp /opt/ Java /java.log /opt/logs/aaa.log; Log cp -r /opt/ Java /opt/logs/; Copy the folder and contents into the logs fileCopy the code
Mv (abbreviation of move word, move function, the file name function)
mv /opt/java/java.log /opt/mysql/ ; Log mysql.log; Rename java.log to mysql.logCopy the code
Rm removes a file or folder
-for --force Forcibly deletes a file or directory. -r or -r or -- recursively deletes all files and subdirectories in a specified directory. -rf Forcibly deletes the folder and content rm file name. Delete safely command (yes delete no cancel) rm -rf Forcibly delete folders and contents rm -rf * Delete all contents in the current directory. Rm -rf /* Delete all contents in the root directory of the Linux system. The system will go down.Copy the code
Find Finds the specified file or directory
* indicates 0 to multiple characters. Find-name Specifies the name of the file. Search for files by the specified name Search for files by the specified name search for files by the specified name find-name '* file name '; Find / -name '* file name *'; Fuzzy query files with file names globallyCopy the code
Vi (VIsual: VIsual) Text editor similar to Windows Notepad (operation similar to underground vim command, see below vim operation)
Vim IMproved Text editor (Shift + up or down for viewing and editing files)
Enter "Vim file name" to open the file, previously "general mode". Common mode: Browse file contents and perform quick text operations. Such as single-line copy, multi-line copy, single-line delete, multi-line delete, (exit), etc. Insert mode: edit file contents. Bottom line mode: can be forced exit operation, do not save :q! You can save the configuration and exit the vi editor :wq Press I or A or O to enter the Insert mode (Edit mode) from the general mode. Press "Esc" in Edit mode to go to General mode. Press ":" in general mode to enter bottom line mode. Dd shortcut in normal mode; Delete an entire line of X; Delete forward is equivalent to delete key X in windowNS system; Delete backward and capital X in opposite direction Ctrl + F; Ctrl + B; Look ahead one page. Undo previous action /word; Search down word keyword type :n to find next, n to find last (either lookup is a global lookup but n is in the opposite direction)? log ; N to find the previous one, n to find the next one :1,90s/redis/ redis/ g; Replace lines 1-90 with redis. Syntax n1,n2s/ old keyword/new keyword /g, n1 for execution,n2 for ending line,g is required :0; Move the cursor to the first line :$; Move the cursor to the last line :300; Move the cursor to line 300 and enter as many numbers as you want to move to lines :w; Save: w! ; Forced save :q; Exit: q! ; Forced exit 5DD; Delete the following 5 lines and type a parameter for yourself to fill in 5x; Delete 5 characters d1G after this cursor; Delete all d0's before this cursor; Delete from cursor current position to the first position yy in this line; Copy the p; Paste it below the cursor. Paste in the cursor doorCopy the code
| piping used multiple commands (combined)
Pipe command syntax: command 1 | 2 | 3 command.Copy the code
Grep (grep: regular expression) The regular expression is used to search for strings (fuzzy query). If you don’t understand, you can go ahead
Use it alone: grep String test.java; In the test. The search String in the Java file location, return the entire line Generally this command does not use the following list of several commonly used commands alone (via pipelines underground command combined use) ps aux | grep Java; Lookup process with Java keyword ll | grep Java; Find folders and files with Java keywordsCopy the code
Yum install -y LRZSZ yum install -y LRZSZ
You can pull files from Windows to Linux using this installation package
# Wait until the download is complete, then enter:Rz Select a file from win and upload it to Linux. Sz File name Select a file from Linux and copy it to WinCopy the code
Tar (decompression compression command)
Common combination command: -z Whether to use gzip compression. -c command to create a compressed file (create) -x command to extract a compressed file (extract) -v command to display a compressed file (verbose) -f Command to use the file name, f command to extract a compressed file (file) ZXVF common compression parameters: ZCVF decompress command: tar -zxvf redis-3.2.8.tar.gz; Gz -c /opt/ Java /; tar -zxvf redis-3.2.8.tar.gz -c /opt/ Java /; Tar -zcvf redis-3.2.8.tar.gz redis-3.2.8/; redis-3.2.8/; Syntax tar-zcvf Compressed name File to be compressed tar-zcvf Compressed file (directory can be specified) File to be compressed (directory can be specified)Copy the code
Ps (Process Status: process status, similar to Windows task manager)
Common combinations: Ps - ef standard format to check the system process ps - aux BSD format to check the system process ps - aux | grep redis BSD format to check the process name with redis skills () / / display system process of some of the properties, need to know (ps aux) USER // Username PID // Process ID, which is used to kill the process %CPU // Percentage of CPU occupied by the process %MEM // percentage of memory occupied VSZ // Virtual memory used by the process (KB) RSS // Fixed memory used by the process (KB) STAT // Process status START // START TIME when the process is started TIME // Actual CPU running TIME of the processCopy the code
Clear The screen clearing command. (for people with obsessive-compulsive disorder)
Using the kill command, you can stop a process. Ps is similar to starting the task manager, kill is similar to closing the process. Kill -5 Pid of the process. Recommended: kill -9 PID; It is not recommended to forcibly kill the processCopy the code
The ifconfig command
View and change the IP address and parameters of a network interface, including the IP address, network mask, and broadcast address. The permission is super user. If this command is invalid, enter yum -y install net-tools ifconfigCopy the code
Ping (used to check connectivity to the destination) syntax: ping IP address
Test: 1, in the Windows operating system CMD ipconfig, check the local IP address: 2, then enter ping IP address in the LInux system (company computer, I will not expose THE IP, there is no picture to try) press Ctrl + C can stop the test.Copy the code
Free command (display system memory)
Display system memory usage, including physical memory, interactive area memory (SWAP), and kernel buffer memory. -b Displays the memory usage in Byte. -k Displays the memory usage in KB. -m Displays the memory usage in MB. -g Displays the memory usage in GBCopy the code
The top command
-c Displays the complete process command. -s Confidential mode -p < process number > Displays the specified process. -n < times > Displays the number of cyclesCopy the code
The netstat command
The Linux netstat command is used to display network status. The netstat directive lets you know the network condition of the entire Linux system. Netstat [-accefghilMnNoprSTUVVwx][-a < network type >][-- IP]Copy the code
File (view file type)
The file name of the fileCopy the code
Restart Linux
Linux centos Restart command: rebootCopy the code
Shutdown Linux
Linux centos shutdown command: haltCopy the code
Time synchronization command
ntpdate ntp1.aliyun.com
Copy the code
Change to Beijing time command
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Copy the code
View the time command:
date
Copy the code