Linux testers must know and study notes: detailed explanation of basic commands

1. As a tester, master the value and use of linux:

1. Look at the test environment log to troubleshoot the problem

2. Test environment construction and deployment, and the use of some other test platforms and tools

3. Run the stress test script

4. Automated script running, continuous integration, etc.

2. How to get the practice environment for beginners:

1. To install a linux virtual machine in the virtual machine, you can choose VirtualBox or VMware tools to install the virtual machine

2. You can use the functions of the linux subsystem in the windows operating system. For detailed operations, see the article:

Article: Installing the Ubuntu subsystem on Windows for practicing basic linux commands

Video: Install Ubuntu subsystem on Windows to practice linux commands

3. You can buy that kind of low-profile cloud server by yourself, but it is recommended to buy a longer term for the first time when purchasing, because the follow-up fee after the server expires is very expensive.

The above is only to solve the problem of the linux operating system. Next, we need to understand the tools for connecting to the linux server:

The more famous one should be xshell, but the disadvantage is that it has to be paid. Here are other software alternatives:

1. FinalShell SSH tool

http://www.hostbuf.com/t/989.html

Disadvantages: Although this tool is free, jdk is used in this tool instead of oraclejdk, and some companies may not allow it.

2. electerm tool

https://github.com/electerm/electerm/releases

This is an open source and free software on github, which is what I am currently using.

After mastering the above two points, you can officially start learning the common commands of linux.

3. Common commands of linux

Commands for directory operations:

  • cd means enter a directory

  • cd / indicates the root directory of the linux operating system, corresponding to my computer in our windows system

  • pwd shows the current directory

  • . Current directory

  • .. Parent directory

  • cd ~ Enter the directory where the current user is located. If you are the root user, it is equivalent to entering /root. Assuming that the current user is xiaobotester, it is equivalent to entering the /home/xiaobotester directory:

    1462b314d8a71ba155716b0b4ac550e0.png

  • ls View all files in the current directory (only file names are displayed)

  • ll View detailed information of all files in the current directory (displayed in the format of a list)

bd53e9e7ec0449cdf56ac13e2c942e0c.png

File class commands:

cp: The operation of copying files. For common usage, please refer to the following cases:

cp test.txt test.backup.txt 复制 test.txt 成 test.backup.txt

mv: move the file, you can rename the file during the move

mv a.txt /home/b.txt

touch a.txt: Create a file name of a.txt in the current directory

mkdir -p /home/xxx/xxxtest/study: Create a study folder in a certain directory, and add the -p parameter to indicate that if the parent directory does not exist, the parent directory will be automatically created

./api.sh: Execute the api.sh script in the current directory

File Editing Operations

vi a.txt : edit a.txt file

Enter i to enter the edit mode, you can modify the text, press Esc to exit the edit mode,

Enter: wq to save and exit

There are many shortcut key operations in the file editing area, such as turning pages, moving to the first line, the end of the line, deleting this line, etc. The shortcuts of these commands are not necessary to memorize, but they are used a lot , Check it out when the time comes, and I will remember it naturally. As long as you know how to use the vi command to enter and edit files, and then how to save and exit.

What is the use of learning this editing command?

For example, if you deploy a test environment in the future, you will definitely need to change the configuration file, such as changing the configuration file of nginx, you may need to use this command.

Commands for file viewing classes:

  • cat log.txt: Read and print the contents of the log.txt file at one time

  • more log.txt and less log.txt: both can read files, read one screen of data display each time, press the space bar to go to the next page, and press b to go to the previous page. At the same time, less can also press the up and down keys to turn pages, but more does not support it. The less command can read data from a file without reading the entire file into memory, so it can handle larger files, while more will first read the contents of the entire file.

  • tail -100 log.txt: 100 lines after reading the file

  • tail -f log.txt: read and print log files in real time

  • head -10 log.txt: read the first 10 lines of the log file

Creation is not easy, everyone who supports me, you can set the star mark on the official account to follow, so that you can receive the push of new articles as soon as possible. Anyone who wants to learn skills and make progress together can contact me on WeChat (xiaobotester) privately. If you want to join the group and learn from more outstanding peers, you can also chat with me privately on WeChat.

Guess you like

Origin blog.csdn.net/liboshi123/article/details/130418131