Linux knowledge necessary for software testing, you say you don't know, this is a bit too much to say.

1. Why do testers learn Linux

For software testers, any products we test are based on operating systems. For example, the QQ software we use every day, it has windows, ios, Android, Mac OS and other versions, you need to install QQ on each platform in order to carry out corresponding tests. Therefore, proficient use of these operating systems and the basic knowledge of a series of operating systems should be the basic skills that every test engineer must master.

At present, the mainstream operating systems on the market include windows, unix, linux, etc., and linux, as the operating system used in the back-end server deployment of many software applications, is also the most widely used server-side operating system. Proficiency in the use of linux systems, such vocabulary often appears in the requirements of the test position and the description of the skills of job applicants. In the group of testers, those who can really use the Linux operating system proficiently, even if they are only familiar with common commands, are relatively rare! Therefore, testers learning Linux can not only increase the depth of testing, but also increase their core competitiveness, broaden their skill stack, and improve their testing capabilities in a deeper level.

What can testers learn about Linux? As a beginner, setting up a test environment should be the primary purpose of learning.

2. What is linux

Linux is an open source and free operating system. Its stability, security, and processing multiple concurrency have been recognized by the industry. At present, many neutral, large and even huge projects are using Linux.

Linux kernel: redhat, red flag linux, ubuntu, suse, fedora,

Their kernels are the same (linux is actually a collective name)

The linux operating system has many advantages: open source and free, support for multi-threading, support for multi-users, good security, superior memory and file management, embedded system suitable for small kernel programs, etc.

The disadvantage of Linux is that it uses command line operations, so the operation is relatively difficult, but it is this character-level command line operation that will occupy less system resources and reduce the possibility of attacks and errors.

3. The difference between Linux and Windows
Insert picture description here4. How to learn Linux

Testers learning Linux is not necessarily very systematic, because proficient in Linux is the job responsibility of operation and maintenance personnel. As a tester, the primary purpose of learning should be to be proficient in using common commands and building a test environment. Therefore, keep practicing commands. You should type every common command several times to verify the feedback after entering the command. In the end, practice makes perfect, and you can slowly remember the common commands.

So, how to learn linux? One word: practice!

Five.Linux file

All contents of linux are saved as files, including hardware (all contents are files), and linux does not distinguish file types by extension.

There are many basic types of linux, and there are three common ones as follows: 6. linux
Insert picture description here
directory

The linux file system adopts a hierarchical tree-like directory structure. The top level in this structure is the root directory "/", and then other directories are created under this directory.

In a linux system, all files and directories start with the root directory /, the directories starting with / become absolute directories, and those not starting with root directory / are called relative directories.

The linux system file directory is organized as follows:
Insert picture description hereInsert picture description hereseven common shortcut keys

Insert picture description here8. Common commands

After logging in to Linux, users can enter commands behind the Linux command prompt to interact with the system.

As follows:

[root@localhost~]#

among them:

root: currently logged in user

localhost: host name

:The current directory, which means the home directory

#: Super user's prompt, if it is an ordinary user's prompt is $

The command format of linux: command [option] [parameter]

Such as: cp dir1 dir2, cp is a copy command, dir1 and dir2 are parameters, which means to copy dir1 to dir2

note:

Some commands do not follow this format

When there are multiple commands, they can be written together

Simplified and complete options, such as -a is equal to -all

Linux is strictly case sensitive, general commands have no special instructions, they are all lowercase

There is a space between linux commands and parameters, please don’t squeeze them all together like English letters

The following is a detailed description of the most frequently used and commonly used commands for Linux.

Nine. Disk Management
1. cd

cd, switch directory (chang directory)

The cd command allows login to switch between different directories

Syntax: cd [target directory]

Here are some commonly used directory switching

Insert picture description hereThe difference between relative path and absolute path

cd relative path: as long as the beginning is not / or it is a relative path, it will refer to the current directory and search through the relative path

cd absolute path: The absolute path is the file name or directory name beginning with the root directory /. For example: /home/data/package, starting from the root directory (ie top directory/), recursive search is performed level by level. The absolute path e is used through the cd command. As long as the path is correct, it can be in any directory Enter the specified directory.

2.ls, list the contents of the directory

Syntax: ls [target directory]

The ls command can list the contents of the directory, including the names of files and subdirectories. The
Insert picture description heregeneral working habit is that after the cd command switches to a certain directory, directly enter ls to view the contents of the current directory, similar to clicking on a folder on the windows system .

Another commonly used wording is ll. ll is the abbreviation of ls -l. The contents of the directory can be listed in a list format, such as:

Insert picture description here
The description of each attribute of the package below: The
Insert picture description hereInsert picture description herefirst 10 characters of each line can determine the type of the file and the permissions of different users for the file

The first character indicates the type: file (-), directory (d), link (l)

The remaining characters are each set of 3 (rwx), read (r), write (w), execute (x)

The first set of rwx: the permissions of the file owner are read, write and execute

The second group rx: the permissions of users in the same group as the file owner are read and execute, and no write permissions

The third group rx: the permissions of other users who are not in the same group as the file owner are read and execute, and no write permissions

Reading, writing, and execution are represented by numbers as r=4, w=2, and x=1.

rwx =4+2+1=7

r-x=4+0+1=5

r-x=4+0+1=5

Therefore, the permissions of the file for different users can be represented by the value 755

3 .pwd

pwd, display working directory (print working directory)

Execute the pwd command to get the absolute path of the current working directory.

  1. mkdir

mkdir, create directory (make directory)

-p: Recursively create a directory, that is, if the upper directory of the created directory is not created, the upper directory will be created together.

5 rmdir

Delete empty directories, this command is rarely used in actual operation, we generally use rm

Note that the rmdir command can only delete empty directories. If you want to delete all files in the directory, it is available: rm -rf path

6 df

df, display information about the disk, such as the usage of the file system

df [-ahikHTm] [directory or file name]

-a: List all file systems

-k: Display each file system in KB

-m: Display each file system in MB

-h: display in GB, MB, KB and other formats

-H: replace the calculation method of M=1024K with M=1000K

-T: List along with the file system name of the partition (for example, ext3)

-i: Do not use hard disk capacity, but display the number of inodes

df [path], check which partition a directory is in, and display other information

Note that the two commands df and du are not used frequently for testers.

  1. of

du, displays the size of a directory or file, the du command displays the disk space occupied by the specified directory or file

Syntax: du [-ahskm] [name of file or directory]

-a: List all files and directory capacity

-h: Display in human-readable capacity format (G/M)

-s: Display the total, not the capacity occupied by each directory

-k: List capacity display in KB

-m: List capacity display in MB

X. File Management

  1. touch

touch, change the file or directory time, or create an empty document

touch [-acdmt] filename

-a: modify access time

-c: modify the time without creating a file

-d: The date can be followed by, or you can use --date="date or time"

-m: modify mtime

-t: time can be followed by the time, the format is [YYMMDDhhmm]

  1. cp

cp copy command

The cp command is used to copy files or directories. The parameter must specify two or more files or directories, and the last path must be an existing directory. You can copy the previously specified file or directory to this directory.

Common parameters:

-a This option is usually used when copying directories. It preserves links, file attributes, and copies directories recursively.

-p Copy the content of the source file, and copy the modification time and access permissions to the new file

-r If the given source file is a directory file, cp will recursively copy all subdirectories and files in the directory. At this time, the target file must be a directory name

Such as: cp -r dir1 dir2 dir3, recursive copy, copy dir1, dir2 to the dir3 directory

  1. mv

mv, move and rename

The mv command can move files or directories, and can also change the names of files or directories

grammar:

mv [source file or directory] [target file or directory]

Such as mv dir1 dir2: move dir1 to dir2 directory

mv /home/hello /home/world; Rename the hello file in the /home directory to world

  1. rm

rm, delete files and directories

The rm command can delete files or directories, use the parameter "-r" to delete directories, otherwise the default is to delete files

rm -rf *, delete all content, including directories and files

Where -r means recursion, -f means mandatory

5.cat

cat, display the content of the file and print the content of the file to the standard output device

Syntax: cat fileName

Common parameters:

-n: Number the number of output lines

  1. head

View the first N lines of a plain text document and write to standard output

head -n 20 View the first 20 lines of the text file

  1. tail

View the last N lines of a plain text document and write to standard output

tail -n 20 View the last 20 lines of the text document

tail -f error.log keeps refreshing, real-time view file content changes

  1. more、less

more, display file content with paging

Syntax: more fileName

The more command is similar to cat, which is displayed in a page by page format, which is easy to read. Press the space bar to go back to the next page, and press the b key (or ctrl + pag up to go up) to go to the previous page.

more + 10 fileName: display the content of fileName from line 10

less, display file content with paging

less is similar to more, you can browse files at will with less

  1. echo

echo: output string

Syntax: echo [-ne] [string] or echo [–help][–version]

echo will send the input string to standard output

11. System Settings
1.alias

alias: Some commands are very long, or the names are awkward, you can give the command an alias

Command: alias: display all aliases currently defined by the system

[Case] ​​alias cp ='cp -i'

[Case] ​​alias li ='ls -l -color=tty'

Users can use alias to customize the alias of the command. If only alias is entered, all current alias settings can be listed. The effect of alias is only based on the operation of this login. If you want to automatically set the alias every time you log in, you can set the alias of the command in /etc/profile or your own ~/.bashrc.

Also, if you want to give each user an effective alias, please add the line alias la ='ls -al' at the end of /etc/bashrc

bashrc is the configuration file of environment variables. The difference between /etc/bashrc and ~/.bashrc is that one is set for the whole system and the other is set for single user use. If you want to give each user an effective alias, please set alias la ='ls -al' is added at the end of /etc/bashrc, bashrc is the configuration file of environment variables. The difference between /etc/bashrc and ~/.bashrc is that one is set for the whole system and the other is set for single user use.

Order of execution of commands:

1: Execute commands using absolute and relative paths

2: execute alias

3: Execute Bash's internal commands

4: Execute the first command found in the directory defined by the ¥PATH environment variable

2 .alias

unalias: delete alias

Syntax: unalias alias

3 .export

export, set and display environment variables

The export command can add, modify and delete environment variables

export -p: List all the environment variables assigned to the program by the shell.

4 .man

man [command], help, similar to help in dos; man is actually manual (operation instructions),

Man level:

1: View the help of the command

2: View the help of functions that can be called by the kernel

3: View the help of functions and function libraries

4: Help to view special files, mainly files in the /dev directory

5: View the help of the configuration file

6: View the help of the game

7: View other miscellaneous help

8: View the help of commands available to the system administrator

9: Help to view and kernel-related files

To view which level of help the command has:

man -f command, equivalent to whats command

eg:man -5 passwd

man -4 null

man -8 ifconfig

View all help related to commands

man -k command, equivalent to apropos command

I recommend a software testing exchange group, QQ;642830685. The group will share software testing resources, test interview questions and industry information from time to time. You can actively exchange technology in the group, and everyone is also concerned about paying attention to my WeChat public account program Yuan Yifei, there are good things to share with you.

Guess you like

Origin blog.csdn.net/weixin_53519100/article/details/112886269