Software testing must master the linux command Daquan

Test Engineer of the four basic skills: database, linux, network protocols, testing tools, either just getting started or have been working for many years, these directions are to grasp. Today we revisit the look test engineers must master the linux command.

Test engineers need to grasp the necessity of linux system?

Because Linux is widely used in the server space, there are many open-source and mature software, most applications are deployed on the background of linux, familiar with Linux operating system and related command, can deepen our structure and operational mechanism of the software understanding, can also increase their core competencies to broaden their skills stack, resulting in higher salary.

Different positions rank, capacity requirements for linux is not the same, if you are a junior test engineer, then there may only need the command to view the log, analyze the reasons bug. If you are a mid-level engineers, you need to build a variety of test environments in linux environment, including applications, middleware applications rely on, as well as software testing tools. If you are a senior, you need to optimize the system architecture, writing shell scripts, improve test efficiency.

Software Test Engineer linux Ten scene command
1. Log View

Tomcat log file to view real-time view:

cd /home/tomcat/logs #也可用相对目录`

`tail –f catalina.out #实时打印日志文件`

`ctrl+c #退出查看

View Log command:

tail -f log.txt:循环查看

tai -500f log.txt:查看最后500行

cat file:查看短文件

less file:查看长文件

head example.txt :显示文件 example.txt 的前十行内容
head -n 20 example.txt:显示文件 example.txt 的前二十行内容

2. Modify the contents of the configuration file

The most common is to modify environment variables

vim /etc/profile输入字母i,

进入编辑模式(INSERT)

输入内容,按esc,进入命令模式 。

执行:wq,保持修改。

输入 soucre /etc/profile 使环境变量生效。

可以通过 cat /etc/profile查看文件是否修改成功。
3.vi/vim Editor

vi / vim editor: linux system provides text editing tools for editing text files.

vim is an enhanced version of vi, an increase of some commands.

How to enter?

New: direct input vi

Open the file for viewing or editing: vi filename

Three modes:

Insert mode: There are "--INSERT--" mark, complete text editing features at the bottom.

i:在当前光标前插入文本;

a:在当前光标后添加文本;

o:在当前光标下一行插入文本;

Command mode: just entering the state can be achieved as well as moving the cursor to delete characters, copy, paste and so on.

x:删除字符

dw/dd:删除词/删除行

yw/yy:复制词,复制行

P:粘贴

kjhl:上下左右

ctrl+f/b:翻页

The bottom line mode: Enter into the colon command mode, you can set line numbers, find, replace characters, save and exit and so on.

set nu/nonu:设置行号

w filename:保存文件

wq:保存退出

q!:强制退出,不保存。

edit:在vi里打开另一文件。

4. Review the tomcat process, kill process, restart the process.
查看tomcat进程

ps -ef|grep tomcat

ps –aux|grep tomcat

杀死进程

kill -9 进程ID

ps -ef|grep tomcat#查看进程是否已关闭

进入tomcat的bin目录cd /usr/local/tomcat/bin

启动tomcat

./startup.sh
The compression and decompression documents
tar cvf a.tar 1.txt 2.txt 3.txt#将3个文件放到文件包a.tar中。

tar cvf /tmp/a1.tar *.txt#指定包存放的位置。

tar xvf a.tar#将文件解压缩到当前目录。

tar -zcvf a.tar.gz *.txt#打包与压缩为a.tar.gz。

tar -zxvf a.tar.gz#解压缩并解包。

Parameter Description

-c: 建立压缩档案
-x:解压
-t:查看内容
-r:向压缩归档文件末尾追加文件
-u:更新原压缩包中的文件
-z:有gzip属性的
-j:有bz2属性的
-Z:有compress属性的
-v:显示所有过程
-O:将文件解开到标准输出
6. Upload / Download

Upload can be downloaded via the following command in xshell in:

Like a general need to install, use yum install lrzsz

rz: Select upload files

sz File Name: Select the download path

Of course you can, visualize uploading and downloading through xftp tool.

7. Find file

find: real-time search, starting at the specified path by traversing the filesystem hierarchy, to find files based on attributes such as file name, file size, owner, owning group, is empty, access time, modification time.

format:

find [OPTION] ... [Search Path] [search criteria] [Processing operation]

Pipe command binding wildcards and the following examples:

find /etc  -name \*****.txt** **:在/etc目录下,查找以.txt结尾的文件,给出所有文件的路径。**

**find /etc -name '\*abc\*':在/etc目录下查找文件名中含有字符串‘abc’的文件。**

**find / -amin -5:查找在系统中最后5分钟访问的文件(access time)。**

**find / -mmin -5:查找在系统中最后5分钟里修改过的文件(modify time)。**

**find / -size -1000k:查找出小于1000KB的文件。**

**find /etc | grep  local   在/etc目录下查找含有local这几个字母的所有文件或者目录
8. Move, Copy command

Mobile mv

移动当前目录文件夹AA 到/home/aa/

mv AA/ /home/aa/

移动当前目录文件a.txt到 /home/aa/目录,并重命名为b.txt

mv a.txt /home/aa/b.txt

Cp Copy

复制当前目录文件a.txt到/home/B目录

cp a.txt /home/B

复制文件夹 AA到/home/B目录

cp -r AA/ /home/B

Cross-server copying: scp

Format:
SCP [parameters] [original path] [target path]

从远处复制文件到本地目录
scp [email protected]:/home/soft/tomcat.tar.gz /home/test/
上传本地文件到远程机器指定目录
scp /home/test/nginx-0.5.38.tar.gz [email protected]:/opt/soft/
9. permission to modify

By ls -l command, you can view the file's properties.

The first character: - (representing the file) d (representing the directory) l (L stands for a link)

The second to ninth place is owned file permissions.

Linux file permissions are divided into four kinds:

read (read) write (writable) execute (executable) none (nothing)

9 is divided into three groups:

The first group represents the owner of the owner of the file what authority

The second group of people representative of all the groups in this file group owned by permission

The third group represents what else others have rights

Modify file access:

chomod who +/- r/w/x file

chmod u + x file only give yourself permission to perform

chmod ug + x file owner and group executable permissions plus

chmod ux file executable permissions canceled by the user

Express permission in Linux (Unix) inside, with three binary numbers to represent the

Example 000: 0111: 7

Therefore, r = 4, w = 2, x = 1

7 shows the permissions all here that there is no written permission 5

假设owner:rwx,group:r-x,other:r-x

The permissions set to: chmod 755 file

10. Server Performance Monitoring

Monitor CPU, memory

top: similar to the windows task manager, capable of running real-time monitoring system, the main display system resource usage of each process, such as cpu, memory, load and so on.

free: See server memory usage, including physical memory, swap memory (the swap) and an idle and a remaining statistical kernel buffer memory.

Guess you like

Origin www.cnblogs.com/hellotesters/p/11116721.html