Skip to main content

Posts

Showing posts from October, 2017

CREATING HARDLINKS AND SOFTLINKS

There are mainly two type of links in linux that we use - hard links and soft links. HARDLINKS We can create hardlinks only for files.If we create hatdlink for a file the file really exist as a copy.Also syncing of contents will also occur.Eventhogh if we deleted the original file hardlink exist.Both will have different inode number. ln test /var/hard this command will ctrete a hardlink named hard for file test. SOFTLINKS We can create softlinks for files and folders.It is just a symbolic link pointing towars original file.Both will have same inode number. ln -s test /var/soft this command will create a softlink named soft for file test. If the symbolic link already exist, we may get an error, to force the operation (remove exiting symbolic link), use the -f option. ln -sf test1 /var/soft CONVERTING HARDLINK TO SOFTLINK To make a hard link directly into a soft link, use the -P flag like this ln -P hardlinkname softlinkname

VNSTAT ON CENTOS 7

For installing vnstat we want to enable epel-release first. #yum install epel-release -y #yum update Now install vnstat package #yum install vnstat -y Consider enps08 is our interface.Vnstat defaultly detects on eth0 interface.So we want to enable it in configuration file. #vi /etc/vnstat.conf Interface enps08 #service vnstat start Then add the enp0s8 interface to database #vnstat -i enp0s8  Now change the permission of database file /var/lib/vnstat/enp0s8 #chmod 777 /var/lib/vnstat/enp0s8 Now restart vnstat service #service vnstat restart #vnstat -d This will give report of the day regarding transmitted data received data and total data

TO SET PASSWORD AUTHENTICATION WITH APACHE ON UBUNTU 16.04 USING .HTACCESS FILE

1.Install apache2 #apt-get install apache2 2.Create a Password file We now have access to the htpasswd command. We can use this to create a password file that Apache can use to authenticate users. We will create a hidden file for this purpose called .htpasswd within our /etc/apache2 configuration directory. #htpasswd -c /etc/apache2/.htpasswd arun Leave out the -c argument for any additional users you wish to add: #htpasswd  /etc/apache2/.htpasswd Rahul If we view the contents of the file, we can see the username and the encrypted password for each record: #cat /etc/apache2/.htpasswd arun:$apr1$zgRuzA6/$RSvqTSJPxikIXEKxgYu4f0 rahul:$apr1$yX/HaM9G$S0vY8PfVef0JhG66xsCFq. 3.Configuring Access Control with apache2 configuration file: #vi /etc/apache2/apach2.conf Add the following entries <Directory /var/www/html/test>       Options Indexes FollowSymLinks       AllowOverride All       Require all granted       AuthType Basic       AuthName "

CREATING SUDO USERS/GROUPS IN CENTOS/UBUNTU

1.By adding user to group having sudo privilege UBUNTU First create a user to which we want to have sudo privileges.Here arun is the user to which we are assigning sudo privilege. #useradd arun Set a password for user arun #passwd arun Set the password Add this user to sudo group. By default, on Ubuntu, members of the sudo group have sudo privileges. #usermod -aG sudo arun Now switch to user arun. #su arun Now we can start using sudo privileges.For example $sudo ls -al Note:For ubuntu under ubuntu 11.0 we can use sudo group as admin CENTOS First create a user to which we want to have sudo privileges #useradd arun Set a password for user arun #passwd arun Set the password Add this user to sudo group. By default, on Ubuntu, members of the sudo group have sudo privileges. #usermod -aG wheel arun Now switch to user arun. #su arun Now we can start using sudo privileges.For example $sudo ls -al 2.By visudo #useradd popy #passwd popy Set a password fo

NAGIOS 4.2.0 SERVER/CLIENT CONFIGURATION IN CENTOS

Nagios is a best server monitoring software on the market. Server monitoring is made easy in Nagios because of the flexibility to monitor your servers with both agent-based and agentless monitoring.In this article we will explain about configuring nagios server and host which we will monitor. Install the required packages #yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip Create a new nagios user and nagcmd group account and set a password. # useradd nagios # groupadd nagcmd add both the nagios user and the apache user to the nagcmd group. # usermod -G nagios Nagios # usermod -G nagios apache Download Nagios Core 4.2.0 and Nagios Plugin 2.1.2 #mkdir /root/nagios #cd /root/Nagios Now download latest Nagios Core 4.2.0 and Nagios plugins 2.1.2 packages with wget command. # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz # wget https://www.nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz Extract the do

WORDPRESS 4.7 ON UBUNTU 16.04

First install LAMP server in your ubuntu machine.For that follow our blog http://www.goserverspace.blogspot.com/2017/10/lamp-in-ubuntu-1604.html Install required packages #apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc Download wordpress tar file #cd / #wget -c http://wordpress.org/latest.tar.gz  Extract it #tar -xzvf latest.tar.gz Rsync the contents to /var/www/html #rsync -av wordpress/* /var/www/html/ Set correct ownership and permissions #chmod -R 755 /var/www/html/ # chown -R www-data:www-data /var/www/html/ #cd /var/www/html Rename the file #mv wp-config-sample.php wp-config.php Create WordPress Database.We can either use phpmyadmin or follow set of mysql commands for it #mysql -u root -p mysql> CREATE DATABASE mywordpressdb; mysql> GRANT ALL PRIVILEGES ON mywordpressdb.* TO 'mywordpressuser'@'localhost' IDENTIFIED BY 'redhat'; mysql> FLUSH PRIVILEGES; mysql>

SETTING SWAP SPACE

There are two methods to increase the swap memory after installation 1.FDISK UTILITY First check the system for swap information, use swapon -s option #swapon -s It will show you no swap space #free -m (This command will give you information about total swap memory available) We can see no swap memory available Now we have to create a partition.our attached harddisk is xvdf.so using fdisk utility #fdisk /dev/xdvf Now select primary or extended partition that we want.We go with primary. Then select partition number.we select 1 which is default.After that we set size as +500M. Then we want to select type,so type t and then L for listing.Out of it select 82 which is the swap partition Now save it by typing w #lsblk From this we can see that certain space is allocated as swap space Then refresh the system settings, using the partprobe command #partprobe /dev/xvdf1 Format the swap partition by using mkswap command #mkswap /dev/xdvf1

TOMCAT8 - CHANGING DEFAULT PORT(8080) TO 80 (PRIVILEGED PORT)

First install tomcat 8 from source (Assumed to be installed in /opt/tomcat) http://www.goserverspace.blogspot.com/2017/10/installing-tomcat-8-in-centos-7.html Edit server.xml file #vi  TOMCAT HOME/conf/server.xml Search "Connector port" Replace "8080" by your port number But for portnumber less than 1024(privilaged ports) we can't do this. For that inaddition to these we have to make following changes. CENTOS: Install authbind #wget https://s3.amazonaws.com/aaronsilber/public/authbind-2.1.1-0.1.x86_64.rpm #yum install authbind-* Make port 80 available to authbind (you need to be root): touch /etc/authbind/byport/80 chmod 500 /etc/authbind/byport/80 chown tomcat7 /etc/authbind/byport/80 Make IPv4 the default (authbind does not currently support IPv6). To do so, create the file TOMCAT/bin/setenv.sh with the following content: (here in /opt/tomcat/bin/setenv.sh) CATALINA_OPTS="-Djava.net.preferIPv4Stack=true" Change /usr/share/tomc

PHPMYADMIN ON UBUNTU 16.04

phpMyAdmin was created so that users can interact with MySQL through a web interface.Before installing phpmyadmin follow our blog regarding LAMP setup on ubuntu: http://www.goserverspace.com/2017/10/lamp-in-ubuntu-1604.html Install necessery packages # apt-get install phpmyadmin php-mbstring php-gettext The only thing we need to do is explicitly enable the PHP mcrypt and mbstring extensions, which we can do by typing: # phpenmod mcrypt # phpenmod mbstring Now make following changes in config.inc.php #vi /etc/phpmyadmin/config.inc.php [...] $cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http or cookie based)? [...] # systemctl restart apache2 Configuration file: etc/apache2/conf-available/phpmyadmin.conf(we don't want to use it now) Here in our LAMP setup we have installed mariadb package.So we want to first create a user with all privileges inorder to use phpmyadmin.So first create it Mysql -u root -

LAMP ON UBUNTU 16.04

A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP. First update your os #apt-get update Install apache2 package #apt-get install apache2 Install php (Here iam using php 7.0) and dependencies #apt-get -y install php7.0 libapache2-mod-php7.0 To test php support for apache,create a info.php file in /var/www/html with following comtent #vi /var/www/html/info.php <?php Phpinfo(); ?> Now change the ownership #chown www-data:www-data /var/www/html/info.php Now restart the service #service apache2 restart Now open your browser and check http://your ip/info.php We can see php info page Installing mariadb #apt-get -y install mariadb-server mariadb-client mysq

CHANGING MTU VALUE FOR UBUNTU/CENTOS

MTU is the maximum transmission unit.It is the size of the largest datagram that can be transmitted through a given network. Any messages larger than the MTU are divided into smaller packets before being sent.In some cases we have to increase MTU value for enabling jumbo frames UBUNTU Command: #ifcfg eth0 mtu 2000 Configuration file: #vi /etc/network/interfaces iface eth0 inet static address 192.168.0.1 network 192.168.0.0 gateway 192.168.0.254 netmask 255.255.255.0 mtu 2000 Restart service #/etc/init.d/networking restart To view MTU value #ifconfig eth0 | grep MTU CENTOS Command: #ifcfg eth0 mtu 1492 Configuration file: #vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" NM_CONTROLLED="yes" ONBOOT=yes HWADDR=A4:BA:DB:37:F1:04 TYPE=Ethernet BOOTPROTO=static NAME="System eth0" UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 IPADDR=192.168.1.23 MTU 2000 Restart service # /etc/init.d/netwo

ENABLING SSL FOR APACHE TOMCAT

For enabling ssl in tomcat first we need to create a keystroke file Create keystroke # keytool -genkey -alias svr1.tecadmin.net -keyalg RSA -keystore /etc/pki/keystore Sample o/p: Enter keystore password: Re-enter new password: What is your first and last name?   [Unknown]:  Arun Mohan What is the name of your organizational unit?   [Unknown]:  G7cr What is the name of your organization?   [Unknown]:  G7cr tech What is the name of your City or Locality?   [Unknown]:  Bangalore What is the name of your State or Province?   [Unknown]:  Karnataka What is the two-letter country code for this unit?   [Unknown]:  IN Is CN=Arun Mohan, OU=G7cr, O=G7cr tech, L=Bangalore, ST=Karnataka, C=IN correct?   [no]:  yes Enter key password for         (RETURN if same as keystore password): Re-enter new password: The keystroke file will be saved in /etc/pki Get CA Signed SSL [ Ignore SelfSigned Users ] Create CSR: # keytool -certreq -keyalg RSA -alias svr1.tecadmin.net -fil

TOMCAT 8 ON CENTOS 7

First install java package #yum install java-1.7.0-openjdk-devel Note:JAVA_HOME directory, which we will need to configure Tomcat later, can be found at /usr/lib/jvm/jre Create tomcat user and group # groupadd tomcat Now  create /opt/tomcat directory where we install binaries # mkdir /opt/tomcat Create tomcat user with noshell login            # useradd  -s /bin/nologin -g tomcat -d /opt/tomcat tomcat Download tomcat binary zip file #wget http://redrockdigimark.com/apachemirror/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz Extract package to /opt/tomcat directory # tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1 #cd /opt/tomcat Change ownership of files # chgrp -R tomcat /opt/tomcat # chmod -R g+r conf # chmod g+x conf # chown -R tomcat webapps/ work/ temp/ logs/ Now install systemd unit file   (open tomcat.service file and make following entries) #vi /etc/systemd/system/tomcat.service # Systemd unit

SETTING STATIC IP FOR UBUNTU

Important Networking configuration files: /etc/network/interfaces describes the network interfaces /etc/hostname configures the nameserver credentials /etc/hosts resolves IP addresses to hostnames To manualy set IP address: Below is an example of a static IP configuration on a system with only one Ethernet interface (eth0) and 10.0.0.41/24 for the IP address. Opening the /etc/network/interfaces file will produce: #vi /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static     address 10.0.0.41     netmask 255.255.255.0     network 10.0.0.0     broadcast 10.0.0.255     gateway 10.0.0.1     dns-nameservers 10.0.0.1 8.8.8.8     dns-domain acme.com     dns-search acme.com Now make interface down #ifdo