🏠 | 💻 IT | 🔨QA |

Bash for QA Engineer

Contents
Introduction
Viewing directories
Creating a directory
Copying a directory
Moving / Renaming a directory
Deleting a directory
Working with logs
Viewing recent logs
Real-time logs
Testing training
Useful software for testers

Introduction

Большинству тестировщиков в своей карьере рано или поздно придётся столкнуться с терминалом Linux

Most likely it will start as a need to log in to the server and look at the logs.

Инженер в серверной bash для тестировщика image from website www.aredel.com
Engineer in the server room. Photo: freepik.com

Servers are made on different operating systems:

From the Linux family most popular are:

UNIX-like operating systems are also often used:

They are slightly different from each other, but there is also a common property:

There is usually no graphical interface on the server

But there is a command shell like bash

That is why the tester needs to master the basics of working with the Linux terminal.

In this article, you will see the commands that the tester needs. More useful commands can be found in the articles:

Working with directories

The tester has to constantly work with logs. Every bug found usually needs describe how functional: what doesn't work, what was done at the same time, what the UI showed. And document it: timestamp + logs of the client/server /partner backend.

Even if logs are not needed in any particular case, developers will most likely ask for them - just out of habit.

In order to find logs, you need to be able to navigate between directories to look from the contents.

Viewing directories

To go to the directory with logs, it is enough to enter the cd command and its absolute address.

For example:

cd /glassfish_domains/server_name/logs

If the absolute address of the directory is unknown, you need to move somewhere from the current directory.

To find out the contents of the current directory, use the command ls

For example

ls -la

where the l option requires output in the so-called long format.

The output will contain access rights, number of hard links to a file, owner, group, size, the time of the last change and the name of the file.

a is an option that requires you to show hidden files - those whose names begin with .

You can move to a directory at a lower level using the cd directory name command

cd testProject01

Climb a level higher

cd ..

Creating a directory

To create the execute directory command:

mkdir_directory name

where directory_name is the directory you want to create.

For example, let's create the test_Project2 directory:

mkdir test_Project2

Copying a directory

To copy a directory from one location to another, execute the command:

cp -a project01 project02

where project01 is the source (the directory you want to copy) and project02 is the recipient (the directory you want to copy to) the -a key means that we are performing non-recursive copying.

For example, copy the directory /usr/local/project01 to your home directory and call it project01arj:

cp -a /usr/local/project01 ~/project01arj

Moving / Renaming a directory

The mv command is responsible for moving and renaming directories in Linux.

Let's look at the examples:

moving the directory /usr/local/projects to the already existing, in the home directory, directory project01arj:

mv /usr/local/statistics ~/project01arj/

renaming the directory /usr/local/projects to /usr/local/testedProjects:

mv /usr/local/statistics /usr/local/newstatistics

Deleting a directory

Deleting the directory and its contents can be done using the rmdir or rm commands:

deleting the directory /usr/local/testedProjects/temp:

rmdir /usr/local/testedProjects/temp

or recursively the directory /usr/local/testedProjects/temp, with all directories inside it:

rm -rf /usr/local/testedProjects/temp

Working with logs

Read more about what logs are and what they are in the paragraph «Studying logs»

Просмотр последних логов

Зачастую открывать весь файл слишком долго. В этом случае можно воспользоваться командой tail

sudo tail -n 1000 ~/glassfish_domains/server/logs/project-name-2019-09-25.log

Эта команда выведет 1000 последних строк лога.

Логи в реальном времени

Опция -f позволяет мониторить изменения в реальном времени

sudo tail -f ~/glassfish_domains/server/logs/project-name-2019-09-25.log

Если Вы хотите вырезать определённый диапазон строк из лога - читайте мою статью про текстовые препроцессоры:

Как вырезать строки из лога с помощью SED

To подсчитать сколько всего строк в файле latest.log используйте

wc -l latest.log

282608 latest.log

Articles about Testing
API testing lessons
API testing
Testing with Python
Selenium + Python
SOAP UI
JMeter
Clumsy 0.2
Python script for ZPL
Python Sockets
Integration Testing
Share in social media: