Sunday, 7 January 2018

Samba server without password


--------------------Server[192.168.10.108]------------------------------------

[root@station108 ~]# yum install samba*

[root@station108 ~]# yum whatprovides */smb.conf

[root@station108 ~]# vim /etc/samba/smb.conf

[myfiles]
path=/sambaa
host allow=192.168.10.0/255.255.255.0
browseable=yes
writable=yes
guest ok=yes

[root@station108 ~]# mkdir /sambaa

[root@station108 ~]# chmod 777 /sambaa

--------------------Client[192.168.10.109]--------------------------------------

[root@station109 ~]# yum install cifs-utils samba-client

[root@station109 ~]# systemctl restart smb

[root@station109 ~]# systemctl enable smb

[root@station109 ~]# mkdir /mnt/samba

[root@station109 ~]# mount -o guest  //192.168.10.108/myfiles  /mnt/samba

Wednesday, 3 January 2018

RAID 0 configuration in RHEL7

RAID stands for redundant array of independent disks or redundant array of inexpensive disks.

RAID  is the combination of physical drives which is accessed by the operating system as one single drive.

In the schema of RAID, data is divided and replicated among multiple physical drives.

There are many different ways to organize data in RAID array. These ways are called as "RAID Levels".

Some most used RAID levels are :-

RAID 0
RAID 1
RAID 5
RAID 6
RAID 10 = RAID 1+0

------------------------------------------------------------------------------------------------------------------
Here we will focus upon RAID level 0

                                                                RAID 0 {stripping}




It requires at least two raid partition and the data is distributed across all the physical devices or partitions.

It provides or offers increased performance means accessing of data is fast but it doesn't provide fault tolerance means if one disk in the array fails then the entire array doesn't work.

--> to check partition table

# fdisk  -l        


we have two physical devices here  /dev/vdb  &   /dev/vdc





# mdadm --create /dev/md0 --level=0 --raid-devices=2  /dev/vdb1 /dev/vdc1



# mdadm  --detail  /dev/md0



# lsblk



# mkfs.ext4   /dev/md0



# mkdir  /raid

# mount   /dev/md0   /raid

# mount








Saturday, 30 December 2017

configure DHCP server in RHEL7

DHCP stands for 'Dynamic Host Configuration Protocol'
It is a protocol for assigning IP address to the host/computer system dynamically.

[root@localhost ~]# yum install dhcp

[root@localhost ~]# cd /etc/dhcp

[root@localhost dhcp]# cd /usr/share/doc

[root@localhost doc]# ls

dhcp-4.2.5/        dhcp-common-4.2.5/

[root@localhost doc]# cd dhcp-4.2.5

[root@localhost dhcp-4.2.5]# ls

dhcpd6.conf.example  dhcpd.conf.example  ldap

[root@localhost dhcp-4.2.5]# cp dhcpd.conf.example  /etc/dhcp/dhcpd.conf 

[root@localhost dhcp-4.2.5]# vim /etc/dhcp/dhcpd.conf

default-lease-time 600;

max-lease-time 7200;

subnet 192.168.0.0 netmask 255.255.255.0{

range 192.168.0.10  192.168.0.200 ;

}

[root@localhost dhcp-4.2.5]# systemctl restart dhcpd

[root@localhost dhcp-4.2.5]# systemctl enable dhcpd


------------------------------- Dhcp client configuration-------------------------

[root@client ~]# dhclient -v  enp2s0



Friday, 29 December 2017

Configure Nginx server as a reverse proxy in RHEL7 / CentOS

INSTALLATION OF Nginx :-

[root@station108 ~]# rpm -ivh http://nginx.org/packages/rhel/7/noarch/RPMS/nginx-release-rhel-7-0.el7.ngx.noarch.rpm

[root@station108 ~]# yum install nginx-1.12.1 -y

second method:-

[root@station108 ~]# vim /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/7/$basearch/
gpgcheck=0
enabled=1

[root@station108 ~]# yum repolist all

[root@station108 ~]# rpm -qc nginx

/etc/logrotate.d/nginx
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug

 [root@station108 ~]# cp /etc/nginx/conf.d/default.conf  /etc/nginx/conf.d/default.conf.bak

[root@station108 ~]# vim /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  station108.example.com;


    location / {
       # root   /usr/share/nginx/html;
        #index  index.html index.htm;

        proxy_pass   http://192.168.10.105 ;   

            }

[root@station108 ~]#  systemctl restart nginx

[root@station108 ~]#  systemctl enable nginx




Thursday, 28 December 2017

Break Root Password in RHEL or CentOS

  1. Press 'e' at the boot menu





    2. Go to line which starts from linux16  having rhgb quiet with the help of downward arrow key 




   3. Press 'End' key and write rd.break enforcing=0


   4. Then press Ctrl+x

   5. After entering in emergency mode remount root file system in read write mode which is previously in read only mode.

    switch_root:/# mount -o remount,rw /sysroot

  

   6. Once the root file system remounted in read write permission,change into a chroot jail as given below.

   switch_root:/# chroot /sysroot





   7. Now reset the password for root

   sh-4.2# passwd root



   8. Type your new password and also confirm it by retyping






   9. Then press 'Ctrl + d'  two times to exit

   10. After login with new password, open your terminal and type as given   below to restore the security context.

   [root@localhost Desktop]# restorecon /etc/shadow




      

Set grub password in rhel7 or CentOS

--> Anyone can get the root login by breaking the root password in rhel7 or CentOS type OS

--> So to stop anyone to break root password we have to secure it by grub password.

# cd /etc/grub.d/

# ls
00_header  01_users  20_linux_xen     30_os-prober  41_custom
00_tuned   10_linux  20_ppc_terminfo  40_custom     README

--> First you have to generate the hash for password by using this command

# grub2-mkpasswd-pbkdf2
 Enter password: ******
 Reenter password: ******
 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.1231312121
 fdafagadgg646564365j3j53h524klnlblh242lfhikufhiulaiunmln24wfkkhj
 sflfafjkl3l42kljlhrwi5ojhjb245jlbjhlhlkhjlkjj24lkhlhhkknlnafkjlanlkai99





--> copy the generated hash of password like from grub.pbkdf2... upto last



--> Then you have to select the 40_custom file in which you have to enter the following entries in the last line.



 # vim 40_custom

set superusers='root'
password_pbkdf2 root   ---------------paste here the generated password---------



# cd /boot/grub2/

# ls

# grub2-mkconfig > grub.cfg


# reboot

----> Press 'e' key at boot menu (To Check)

Mariadb Server


 --> To install mariadb-server use following command

# yum install mariadb*


 # systemctl start mariadb

 # mysql



--> to show list of databases

 MariaDB [(none)]> show databases;

--> to create a new database

 MariaDB [(none)]> create database db;

--> here db is the name of database



--> to use the created database

MariaDB [(none)]> use db;


 --> to create table inside the database(db)

MariaDB [(none)]> create table info(name char(20),password char(15));

--> here info is the name of table and name,password are attributes.


 --> to insert values of attributes inside the table info

MariaDB [(none)]> insert into info(name,password)values('sarvesh','redhat');



 MariaDB [(none)]> show tables;

MariaDB [(none)]> desc info;



 --> to see the entire contents of the table

MariaDB [(none)]> select * from info;


 --> to exit out of the database

MariaDB [(none)]> exit



 --> to secure the database with password

[root@mariadb_server ~]# mysql_secure_installation


 
--> set the root password





 --> Now login with the secure password

[root@mariadb_server ~]# mysql -u root -p





 --> In case of forget password

[root@mariadb_server ~]# rm -rf /var/lib/mysql/*




---------------------------------------- #####---------------------------------------------

Some important commands to perform following inside the database

--> To rename Table
  # alter table tablename rename new_tablename ;

--> To add new attribute to the existing table
  # alter table tablename add attribute data_type(size) ;

--> To remove attribute from the existing table
  # alter table tablename drop attribute ;

--> To change size of attribute or type of attribute
  #alter table tablename modify attribute data_type(size) ;

--> Fetching column without repetition of any data
  # select distinct column_name from table_name ;

--> To update the data in particular row
  # update table_name set attribute='xyz' where attribute='zyxa' ;

--> To delete the particular row
 # delete from tablename where attribute='X' ;

--> To delete all rows in which data starting with 'X'
 # delete from tablename where attribute like 'X%' ;


--> To delete all tuples from the table
 #  truncate table table_name ;

--> To delete table schema along with its tuple
 # drop table table_name ;