Basic Linux commands for beginners

Scenario:- What are some of basic commands one should know when moving from windows enviornment to linux(say ubuntu)?

Solution:- Its a learning experience when moving from mouse click(windows) to terminal evniornment(ubuntu)

We are trying to cover some the very basic commands, please feel free to add more from experience as comments to this post, as its said
If you want to lift yourself up, lift up someone else ..

1.Sudo(Run as adminstator in windows) – sudo command executes a command with administrative privileges (root-user administrative level), which is necessary
example sudo mkdir test 

mkdir ubuntu

2.mkdir(new folder), creates new working directory in the selected location 

3.pwd, tells the current working directory

4. ls, list all the files in the given folder 

5.ll, another form of listing the items try it out

6.Editing a file :-

  • Open file sudo vi filename
  • press ESC
  • press i (for inserting values into file)
  • move cursor the position where editing need to be done
  • edit
  • type :wq (to write and quit the file after saving)
7.Change to root user, sudo -s
8.Rename a file by using move, sudo mv “oldfilename” “new file name”
9.clear, for clearing the terminal
10. Most important how to launch terminal, press ALT+SHIFT+T
11.How to open new tab in terminal, CTRL+SHIFT+T
12.Get to know the existing used commands in terminal, use history in terminal 

history command in linux

13.Launch background screen when remote into linux box using ssh
For example we used ssh userName@IP to remote into linux box, now we want to run an new terminal instance apart from the login window instance. We can use “screen -R Name” command to achieve this.
a)We can shift to main terminal by “CTRL+SHIFT+A” than press “D”.
b) Move back to secondary terminal any time even our original session is broken by screen -R terminalName
c)list all the present screens, screen -ls 
d)kill the instance of screen
screen -X -S screenId kill

kill screen instance in linux

14.How to move directory from local machine to remote machine?
Using secure copy command as below
scp -r ./localpath remoteuser@remoteIP(
-r means recursive copy

15.How to check the file system size in human readable form?
df -h 

16. How to search a given file in all the computer directories?
find / | grep filename 

17. Check that given process is running?
ps ax | grep processname 

18.Open the big file to show only last 100 lines?
tail -n 100 filename

19.Open a given file showing the updated view each time when new content is appended?
tail -f filename

20. Download code or file directly from given server?

21.Change file permission for folder for given user?

chown userName -R folderName

22. How to check application running on given port?
lsof -i :portNo
lsof -i :3000

23.Find file with given extension (mac terminal)?

find ~ -type f -name ‘*.log’

Practical issues and solutions for working with JMeter – Part2

jmeter issues

More Scenarios

How to display results from Beanshell sampler to response?

Solution :- 

Simple code example:- 

String display=”HelloWorld”;

//Taking results and displaying in response
SampleResult.setResponseData( display);

SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT );

Not able to understand the error message thrown by jmeter in beanshell sampler or beanshell assertions?

Solution :-  

Use try-catch

int expectedMsgs = ${noOfMessages} * ${messageThreads};
int actualCount =Integer.parseInt(SampleResult.getResponseDataAsString());

if (expectedMsgs!=actualCount) {
Failure = true;
FailureMessage ="Expected Messages Sent"+expectedMsgs+"!="+actualCount+"ActualMessages in cassandra";
print("Expected Messages Sent"+expectedMsgs+"!="+actualCount+"ActualMessages in cassandra");
catch(Exception e){
log.error("Failed check the erro"+e);

Connect to remote mySql instance (say ubuntu box) using JMeter?

Solution :- 
Before doing this we need to provide privileges to the remote user to access the database using 
1.SSH into remote machine
ssh username@ip address > enter password

2.Login to mysql using root user
mysql -u root -pPassword

login to mysql using terminal

3.Grant permission as below

4.Make sure to comment the following line in Mysql configuration file,

comment bind-address = using the # symbol

Mysql configuration file

5.Now we can replace the localhost, username and password in our connection settings for mysql.

Incase you are getting the below error
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Solution is run the command uninstall plugin validate_password;

Practical Examples

Practical issues and solutions for working with JMeter – Part1

Most of the time we are struck with very granular issues with JMeter. To overcome these type of hurdles we are sharing the pragmatic solutions to problems.

Refer part2 of learning for more issues

Do share your issues/solutions in the comment section below to help others as we always believe sharing is caring, and Life is short..share while you still have knowledge

How to pass random value in Json URI or Json parameters for API call using Jmeter?

Solution :- 
By using “Random Variable”
Where to find in JMeter
Add > Config Element > Random Variable

Name the variable as you want, put the range or create your own formula and start using this variable in Json URI or Json parameters

How to create RandomString?

Random variable in jmeter
Not to execute the second sampler if first sampler value fails in Jmeter?

Solution :- 
By using “if controller”
Where to find in JMeter
Add > Logic controller > if controller

In condition add ${JMeterThread.last_sample_ok} 
Note:- Above value is predefined variables in jmeter

if controller jmeter

How to execute python script(command script) in jmeter?

Solution :- 
By using “OS sampler”
Where to find in JMeter

Add > Sampler > Os sampler

Example:- Lets say we want to run our MQTT test generator code
We will replicate the command step in OS sampler, 
python3 10 10 1  and define the working directory(referring to the script path)

command script from jmeter

More scenarios