Bash commands for the tester
Introduction
Most testers in their careers will sooner or later have to deal with the problem. terminal Linux
Most likely, this will begin as the need to go to the server and look at the logs.
Servers run on different operating systems:
family
Linux
popular:
Also often used UNIX similar OS:
- OpenBSD
- FreeBSD
They are slightly different from each other, but there is a common property:
There is usually no graphical interface on the server.
But there's 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:
Work with directories
The tester has to constantly work with logs. Every bug found is usually needed.
Describe how functional: what doesn’t work, what was done, what the UI showed.
So confirm documented: timestamp + client logs/ server/ partner backend.
Even if you don't need logs in a particular case, developers are likely to ask for them.
Just out of habit.
In order to find logs, you need to be able to move between directories and look from the content.
Viewing directories
To go to the directory with logs, just enter command cd 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.
The contents of the current directory can be found using commands.
ls
For example,
ls -la
where l It requires output in the so-called long format.
The conclusion will contain
access rights, number of hard links to the file, owner, group, size,
The last change and the name of the file.
a This is an option that requires you to show hidden files - those whose name begins with .
Move to the directory level below using commands cd directory name
cd testProject01
Go up a level
cd ..
Creation of a directory
In order to create a directory execute command:
mkdir directory_name
where the directory name is the directory you want to create.
For example, let’s create a test Project2 directory:
mkdir test_Project2
Copying the directory
To copy a directory from one place to another, execute command:
cp -a project01 project02
where project01 is the source (the directory you want to copy)
Project02: Recipient (the directory you want to copy)
-a 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 / Rename the directory
For moving and renaming directories, Linux is responsible command mv.
Consider examples:
Moving the directory /usr/local/projects to the existing, in the home directory, project01arj:
mv /usr/local/statistics ~/project01arj/
Rename the directory /usr/local/projects to /usr/local/testedProjects:
mv /usr/local/statistics /usr/local/newstatistics
Removal of the directory
The directory and its contents can be removed using commands rmdir or rm:
delete the directory /usr/local/testedProjects/temp:
rmdir /usr/local/testedProjects/temp
or recursively the directory /usr/local/testedProjects/temp, with all the 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 «Learning Logs»
Viewing the latest logs
Opening the entire file often takes too long. In this case, you can use command tail.
sudo tail -n 1000 ~/glassfish_domains/server/logs/project-name-2019-09-25.log
This command will output the last 1000 lines of the log.
Logs in real time
-f allows you to monitor changes in real time
sudo tail -f ~/glassfish_domains/server/logs/project-name-2019-09-25.log
If you want to cut a certain range of lines from the log - read
My article about text preprocessors:
How to Cut Lines from Logs with SED
To calculate how many lines in the file latest.log use
wc -l latest.log
282608 latest.log
Article author: Andrei Olegovich