Sie sind auf Seite 1von 18

Tackling Linux - A Tester's

Cheat Sheet
Authors: Eevuri Sri Harsha & Ranjani Sivagnanam

Abstract: This is a set of guidance which can be used by the test engineers to get
very good knowledge in Linux commands to install well known application servers
and databases.

Sri Harsha is working as an Associate Software Engineer (QA) for IBM Policy Atlas team under ECM. Reach
out to her at eeharsha@in.ibm.com
Ranjani, is working as a Staff Software Engineer (QA) for IBM Policy Atlas team under ECM. Reach out to
her at ranjani.sivagnanam@in.ibm.com

Tackling Linux - a Tester's Cheat Sheet

Introduction
Linux is an open source, free to use operating system widely used for computer hardware and software,
game development, tablet PCS, mainframes etc.
To work with Linux systems, the user has to do this primarily from the command line. This document will
contain useful Linux commands to interact with the Linux machine.
This document gives the details for installing well known application servers like Websphere Application
Server, Weblogic Application server and JBOSS Server, databases like DB2 and Oracle. Also, includes
some basic Linux commands

Installation of Websphere Application Server


1. Unzip the tar install file in a folder
$ tar zxvf <websphereinstallfile>.tar.gz
2. From the folder
$ ./launchpad.sh
These screens come up:

Tackling Linux - a Tester's Cheat Sheet

Tackling Linux - a Tester's Cheat Sheet

Tackling Linux - a Tester's Cheat Sheet

3. Starting the appserver:


$ cd /opt/IBM/WebSphere/Appserver/profiles/<profile_name>/bin
$ chmod +x startServer.sh
$ ./startServer.sh server1
4. Stopping the appserver:
$ cd /opt/IBM/WebSphere/Appserver/profiles/<profile_name>/bin
$ chmod +x stopServer.sh
$./stopServer.sh server1

Tackling Linux - a Tester's Cheat Sheet

For >WAS 8: We have to install using Installation manager


For installing Install manager:
$ tar zxvf <websphereinstallfile>.tar.gz
user@-<unzippedfolder>$ ./userinst
After installing the IBM Installation Manager, complete the following steps to add the repositories
where the installation media exists:
1. Open the IBM Installation Manager and navigate to File > Preferences > Repositories.
2. Select Add Repositories.
3. Select Browse and navigate to the Portal-install-eimage/Setup/eimage/repository.config file and
then click OK.
4. Ensure that all required repositories are checked. Then click Test Connections to ensure that the
IBM Installation Manager can successfully access the directory where the service repositories
are stored.
5. Select Apply.
6. Select OK.
On the main IBM Installation Manager panel, select Install to begin the installation process.
1. On the Install Packages: Select packages to install panel, select both the WebSphere Application
Server and WebSphere Portal Express packages.
2. Click Next.
3. On the Install Packages: Select the fixes to install panel.
4. Accept the license agreement and then click Next.
5. Select the directory where you want to store shared resources and then click Next.
6. Complete the following steps on the Install Packages:
a. Select the WebSphere Application Server Package Group Name and then select the
installation directory path.
b. Select the WebSphere Portal Express Package Group Name and then select the installation
directory path.
c. Click Next.
7. Select the translations to install and then click Next.
8. On the Install Packages: Select the features to install panel, expand the WebSphere Application
Server to modify the features you want to install and then click Next
9. Click Next.
10. Confirm the information on the Summary panel and then click Install.

Tackling Linux - a Tester's Cheat Sheet

Installation of DB2

Create a folder for DB2 compressed binary files and copy it that folder (in this tutorial
we used DB2_ESE_97_Linux_x86.tar.gz);

bash:/# mkdir /opt/db2bin


bash:/# cd /opt/db2bin
bash:/opt/db2bin# ls -la

Uncompress DB2 compressed binary files (in this tutorial we used


DB2_ESE_97_Linux_x86.tar.gz);

bash:/opt/db2bin# gunzip DB2_ESE_97_Linux_x86.tar.gz


bash:/opt/db2bin# tar xvf DB2_ESE_97_Linux_x86.tar

Files & Libraries installation:

bash:/opt/db2bin# cd server
bash:/opt/db2bin/server# ./db2_install

License installation:

bash:/opt/db2bin/server# /opt/ibm/db2/V9.7/adm/db2licm -a db2ese.lic

Create DB2 Instance


Create Essential User IDs and Groups

bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#
bash:/opt/db2bin/server#

groupadd db2grp1
groupadd dasadm1
groupadd db2fgrp1
useradd -g db2grp1 -G dasadm1 -m db2inst1
passwd db2inst1
useradd -g dasadm1 -G db2grp1 -m dasusr1
passwd dasusr1
useradd -g db2fgrp1 -m db2fenc1
passwd db2fenc1

Create DAS

bash:/opt/db2bin/server# cd /opt/IBM/db2/V9.7/instance
bash:/opt/ibm/db2/V9.7/instance# ./dascrt -u dasusr1
SQL4406W The DB2 Administration Server was started successfully.
DBI1070I Program dascrt completed successfully.

Create DB2 Instance

bash:/opt/ibm/db2/V9.7/instance# cd /opt/IBM/db2/V9.7/instance
bash:/opt/ibm/db2/V9.7/instance# ./db2icrt -u db2fenc1 db2inst1

Tackling Linux - a Tester's Cheat Sheet

DBI1070I

Program db2icrt completed successfully.

Start DB2:

bash:/opt/ibm/db2/V9.7/instance# su - db2inst1
db2inst1@bash:~$ db2start
03/15/2014 20:58:34
0
0
SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.

Stop DB2

db2inst1@bash:~$ db2stop force


03/15/2014 20:58:34
0
0
SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.

Test CLP:

db2inst1@bash:~$ db2
db2 =>

Quit CLP:

db2 => quit


DB20000I The QUIT command completed successfully.

2. Database Creation

Prepare database:

bash:/opt/ibm/db2/V9.7/instance# su - db2inst1
db2inst1@bash:~$ db2

Create database:

db2 => ATTACH TO db2inst1


Instance Attachment Information
Instance server
Authorization ID
Local instance alias

= DB2/LINUX 9.7.0
= DB2INST1
= DB2INST1

db2 => CREATE DATABASE TUT_DB USING CODESET UTF-8 TERRITORY US


DB20000I The CREATE DATABASE command completed successfully.
db2 => CONNECT TO TUT_DB
Database Connection Information
Database server
SQL authorization ID

= DB2/LINUX 9.7.0
= DB2INST1

Tackling Linux - a Tester's Cheat Sheet

Local database alias

= TUT_DB

db2 => CREATE BUFFERPOOL tut_buffer PAGESIZE 4096


DB20000I The SQL command completed successfully.
db2 => CREATE REGULAR TABLESPACE tut_data PAGESIZE 4096 MANAGED BY DATABASE
USING (file '/db2repo/TUT_TBS' 19200) EXTENTSIZE 16 OVERHEAD 10.5
PREFETCHSIZE 16 TRANSFERRATE 0.33 BUFFERPOOL tut_buffer DROPPED TABLE
RECOVERY ON
DB20000I The SQL command completed successfully.

Installation of Weblogic Application Server

Copy the install files to the Linux machine, using Winscp or the mv command as
mentioned in the basic commands section
Grant all permissions to the file :
o chmod a+x wls1033_linux32.bin
Run the bin file to start the installation
o ./wls1033_linux32.bin
Until the Choose the Home Directory option comes, Choose the default options and
naviagate to the next section
Home Directory Selection
o "Middleware Home" = [Enter new value or use default
"/root/Oracle/Middleware"]
o Enter new Middleware Home OR [Exit][Previous][Next]> /usr/local/weblogic103
Confirm the location and proceed
For registering for the security updates Choose Yes or NO and give the appropriate
details if you choose Yes
Installation type Selection
o Choose Typical type 1
Choose the default values for Product installation directory
Click next on the Installation Information and Progress
After 100%, Weblogic Application Server installation is complete

Post Installation Steps:


$cd <Weblogic Server>/common/bin
$sh quickstart.sh
This will give the UI to create user domains. After creating , the following are the commands to
start and stop the appserver
To start the server:
Navigate to WebLogic Server: [/usr/local/weblogic103/wlserver_10.3]
$cd <Weblogic Server>/user_projects/domains/<DomainName>/bin

Tackling Linux - a Tester's Cheat Sheet

$./startWebLogic.sh
To start the server:
Navigate to WebLogic Server: [/usr/local/weblogic103/wlserver_10.3]
$cd <Weblogic Server>/user_projects/domains/<DomainName>/bin
$./ stopWebLogic.sh

Installation of Jboss
Install Java JDK:

Open the command line


Run java version command

Install JBoss Application server:

From http://jbossas.jboss.org/downloads, download the JBoss Application Server

Run these commands:


mkdir jbossinstallationdir
Move the jboss-as-distribution-6.1.0.Final.zip to this folder
cd jbossinstallationdir
tar -xvf jboss-as-distribution-6.1.0.Final.zip

Setting the Environment variable in Linux


1. Set the JAVA HOME variable, for example:
export JAVA_HOME=/opt/jdk1.6.0_10
2. Export the path to the JAVA HOME variable, for example:
export PATH=$JAVA_HOME/bin:$PATH

Setting Memory Allocation for UNIX:


1. Open the JBOSS_HOME/bin/run.conf file in a text editor
2. Locate the following text:
-Xms128m -Xmx512m

3. Change the text to the following:


$JAVA_OPTS -XX:PermSize=128M -XX:MaxPermSize=256M -Xms1280m -Xmx1280m

4. Save and close the run.conf file.


Start the server:
1. Navigate to JBOSS_HOME/bin
2. Run the command ./run.sh

Tackling Linux - a Tester's Cheat Sheet

Stop the server


1. Navigate to JBOSS_HOME/bin
2. Run the command: ./shutdown.sh -s jnp://localhost:1099 (For the default port 8080)

Installation of Oracle database using Oracle Universal Installer


1. Copy the install files to the Linux machine, using Winscp or the mv command as
mentioned in the basic commands section
2. Grant all permissions to the file :
a. $ cd <Folder with the install files>/database/install/
b. $ chmod a+x runInstaller.sh
3. Run the bin file to start the installation
a. ./ runInstaller.sh
4. The following pages of the installer will appear

Tackling Linux - a Tester's Cheat Sheet

5. Create a database

6. Choose Server or Desktop Class on the System class screen of the installation

Tackling Linux - a Tester's Cheat Sheet

7. On the Typical Install Configuration screen, give the Administrative password

8. Click Next
9. Click Finish after checking the details of the installation Summary

Tackling Linux - a Tester's Cheat Sheet

10. Next screen will show the installation progress

Basic commands for Linux Navigation


1. man command :

The man command is used to format and display the man pages.
The man pages are a user manual that is by default built into most Linux versions.
The syntax to specify an article from a particular section is:

man section_number keyword


Thus, for example, the following would display the article about mount from Section 2

Tackling Linux - a Tester's Cheat Sheet

man 2 mount

2. whereis command :

When you want to find out where a specific Unix command exists (for example, where
does ls command exists?), you can execute the following command.
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

3. mkdir command :

Creates one or more new directories.


Syntax is : mkdir [ -m Mode ] [ -p ] Directory ...

4. rmdir command:

Delete / remove directory


To delete directory called foo, enter:
rmdir foo
Remove DIRECTORY and its ancestors
Remove all directories and subdirectories, use rm command with -r option:
rm -rf /home/data/2000

5. ls command and ls -a command :

You can list the contents of a directory with ls.


ls -a command :A frequently used option with ls is -a to show all files. Showing all files
means
including the hidden files

List directory /home/user/Documents/Books with absolute path.


$ ls /home/user/Documents/Books
List root directory:
$ ls /
List parent directory:
$ ls ..
List user's home directory (e.g: /home/user):
$ ls ~

Tackling Linux - a Tester's Cheat Sheet

6.pwd command :

display current directory path


Syntax: pwd [OPTION]...
pwd prints the full pathname of the current working directory .

7. cd command :

used to change directory.


syntax cd /xyz :
it will change directory folder to xyz folder
You can also use ../ to move you up one level in the file structure, or ../../ to move up
two levels etc.

8. cd.. command & cd command :

cd.. command : to come out of directory or file (to move to parent directory)
cd command : to go to previous directory

9. mount command :

All files accessible in a UNIX system are arranged in one big tree, the file hierarchy,
rooted at /. These files can be spread out over several devices. The mount command
serves to attach the file system found on some device to the big file tree
# mount -t cifs //ntserver/download -o username=vivek,password=myPassword
/mnt/ntserver
ex : mount -t cifs //ipaddress/installables -o username=Administrator,password=xyz
/home/pqr

10. gedit command :

gedit - simple text editor for GNOME


The gedit application is a simple text editor. You can use gedit to create and edit text
files.
gedit [--help] [--debug[-section]] [--quit] [filename(s)...]

Tackling Linux - a Tester's Cheat Sheet

options :
--quit: Quit an existing instance of gedit.
filename(s)... :Specifies the file to open when gedit starts - if this is not specified, gedit
will load a blank file with an Untitled label.

11. rm command : remove file

rm -rf filename : to remove file ( f- force, r- recursive)

12. cp command : copy the files and directories

cp source destination
cp -r source destination ( to copy all dir recursively)

13. mv command : rename or move file to directory

mv source destination ( to rename file or moving file to other directory).


mv [options] old-file-name new-file-name
mv file1 file2

14. User permissions Permissions for executing :

Chmod command :
chmod is a Linux command that will let you \&quot;set permissions\&quot; (aka, assign
who can read/write/execute) on a file.
syntax :chmod permission1_permission2_permission3 file
When using chmod, you need to be aware that there are three types of Linux users that
you are setting permissions for : Owner,Group,World
ex : chmod 777 mydoc.txt gives full permsions to owner , group , world.

15.1: setting the user name and pwd :

Set or Change User Password:


Type passwd command as follows to change your own password:
$ passwd -> Output:

Tackling Linux - a Tester's Cheat Sheet

Changing password for vivek


(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

15.2 : Change Password For Other User Account:

You must login as root user, type the following command to change password for user
testuser1:
# passwd testuser1 -> Output:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Where, testuser1 is username or account name.

16. search or find command :

The find command is used to locate files on a Unix or Linux system.


find where-to-look criteria what-to-do
find / -name foo
This will search the whole system for any files named foo and display their pathnames.
Here we are using the criterion name with the argument foo to tell find to perform a
name search for the filename foo.
The output might look like this: /home/wpollock/foo

Conclusion
This article provides basic Linux commands and outline for setting up any application server and
database server using Linux environment.
This document in brief overview these points:
Installation of Websphere Application Server
Installation of DB2
Installation of Weblogic Application Server
Installation of Jboss
Installation of Oracle database using Oracle Universal Installer
Basic commands for Linux Navigation

Tackling Linux - a Tester's Cheat Sheet