Showing posts with label Redhat Linux. Show all posts
Showing posts with label Redhat Linux. Show all posts

Monday, March 18, 2019

Top 10 Linux commands - Basic Linux commands

If you are new to Linux, you should start getting familiar with Linux commands. Let us take a look at top 10 commands.

1. ls

ls command will list all the files in the directory.

2. cp
cp command will copy the files from source to dest folder

3. mv
mv command will copy the files from source to dest folder
4. rm

rm command will remove file from file system.

5. cd

cd command changes the directory

6. mkdir

mkdir creates new directory.

7. cat

cat command displays the content of a file

8. sudo 

Every single command that needs root's permission, need this sudo command. You can use sudo before each command that requires root permissions -
 
9. grep
 
You need to find a file but you don't remember its exact location or the path. grep will help you to solve this problem. You can use the grep command to help finding the file based on given keywords. 

10. poweroff

poweroff command is used to poweroff directly from terminal.

Monday, April 9, 2018

Ansible playbook for installing Apache on Redhat Linux

---
 - hosts: Apache_Group
   become: true
   tasks:
     - name: install the latest version of Apache
       yum:
         name: httpd
         state: latest

     - name: ensure apache started
       service: name=httpd state=started enabled=yes

Monday, September 11, 2017

How to install Sonarqube on Redhat enterprise Linux - Install Sonarqube on Redhat enterprise Linux (RHEL)

SonarQube is popular static code analysis tool. It is Java based tool. Here are the steps for installing Sonarqube.

first you need to install a database as SonarQube uses database to store code quality report. We can use MySQL, Postgres, Oracle or MSSQL. Here are the steps for setting up SonarQube using MySQL database :

sudo yum update -y
sudo yum install wget -y

MySQL installation steps:
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-server -y

Start MySQL service
sudo systemctl start mysqld
sudo mysql_secure_installation

enter n as we will not be setting any admin password for user root.

Would you like to setup VALIDATE PASSWORD component?
type n

now set up password for root user

Remove anonymous users?
type y
for Disallow root login remotely?
type y
for Remove test database and access to it?
type y
for Reload privileges tables
type y


Setup Sonarqube user and password

mysql -u root -p
SHOW GLOBAL VARIABLES LIKE 'storage_engine';
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'password';

CREATE DATABASE sonar;
GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost';

now type exit to come out of MySQL.

Sonarqube web server installation steps:

Start with java installation.

sudo wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' 'http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm'

sudo rpm -i jdk-8u141-linux-x64.rpm

now type java -version to make sure Java 8 is installed.


Download SonarQube
cd /opt 
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-6.7.6.zip

sudo yum install unzip -y
sudo unzip sonarqube-6.7.6.zip
sudo mv sonarqube-6.7.6 sonarqube



Modify Sonar Conf file
sudo vi /opt/sonarqube/conf/sonar.properties
uncomment the below lines by removing #:

sonar.jdbc.username=sonar
sonar.jdbc.password=password
sonar.web.host=0.0.0.0
sonar.web.javaOpts=-Xmx512m -Xms256m -XX:+HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts=-Xmx512m -Xms256m -XX:+HeapDumpOnOutOfMemoryError

Run Sonarqube as sonar user
create a user called sonar by executing below command:
sudo useradd sonar

sudo chown -R sonar:sonar /opt/sonarqube

Edit the sonar.sh start script and change the #RUN_AS_USER to be RUN_AS_USER=sonar

sudo vi /opt/sonarqube/bin/linux-x86-64/sonar.sh

Change 
RUN_AS_USER=sonar
now start the server 
sudo sh /opt/sonarqube/bin/linux-x86-64/sonar.sh start
for any issues, look at logs at 

tail -f /opt/sonarqube/logs/sonar.log

Verify by going to browser http://hostname:9000