Thursday 8 October 2015

Power on Remote Server - Sending an magic packet

Power on Remote Server


As you think today’s technology, we are working from remote locations. Physical server will locate somewhere in thousands of miles long. If you think an emergency situations such as server is shutdown UN-unexpectedly it’s  may due to power issue, it’s may be due to cooling issue and so an.. in this situation you have to wait for the engineer who will come and switch on the server. If you think this server is serving the data for the production then..!! Don’t worry by doing below steps you can switch on your remote server without having the physical access to it.
By mistake, when you shutdown a system instead of rebooting, you can use Wake-on-LAN to power on the server remotely. Also, If you have a server that don’t need to be up and running 24×7, you can turn off and turn on the server remotely anytime you want.
We have to enable the Wake on LAN using magic packet settings in BIOS and NIC settings.

  • You can use Wakeonlan when a machine is connected to LAN, and you know the MAC address of that machine.
  • Your NIC should support wakeonlan feature, and it should be enabled before the
    shut down. In most cases, by default wakeonlan is enabled on the NIC.

BIOS Settings
Bios settings for wak on LAN
BIOS Settings WakeonLAN
In Windows Operating System
Go To. Start –> Computer –>Right Click –> Manage –> Device Manager –> Select Ethernet –> Right Click
Device Manager - NIC Settings
Device Manager – NIC Settings
Device Manager - NIC Properties
In MAC Operating System
MAC wakonLAN

In Linux Operating System
~$ sudo apt-get install ethtool 
~]# yum install wol*
~]# ethtool ens33
Wake on LAN - Linux
option d = disabled
option g = enabled
# ethtool -s eth0 wol g
After all the above settings are done. Download and install application below application for windows OS.
Wakeonlan step 1Select Language and Click Ok
click Next
Click Next
Wake on LAN - folder PathClick Next
Wake on LAN - NextClick Next
Wake on LAN - NextClick Next
Wake on LAN - NextClick on Install
Wake on LAN - finish
open application and File menu –> New Host
Wake on LAN MAc Address
Install wakeonlan package for ubuntu
$ apt-get install wakeonlan
$ wakeonlan 00:1f:d0:e8:c1:24
Sending magic packet to 255.255.255.255:9 with 00:1f:d0:e8:c1:24
using above command we can send and magic packet
Install wol package for RHEL / Centos / Fedora / Linux Mint
# yum install wol*
Please provide your valuable comments…

Restore System Default Permissions - Linux

Restore System Default Permissions - Linux


I recently came across a system which had some directories set to 777(recursively), the sysadmin needed to install an application and changed all the permissions a mess, I didn’t know where to start, i find one rpm has a parameter called --setperms and --setugids. most useful stuff when you face above situation.

I created a one liner that does the job, it takes time but It works. The same i want to share below is the one, to run this you have to have an sudo access either root access.

1) To reset uids and gids on files and directories :
~]# for u in $(rpm -qa); do rpm --setugids $u; done
2) To permissions on files and directories
~]# for p in $(rpm -qa); do rpm --setperms $p; done

Enjoy..!!

Wednesday 23 September 2015

Take RDP of your ubuntu from windows machine – Ubuntu 14.04

xrdp24b

To take the Remote desktop of your ubuntu machine from windows machine using ‘mstsc’, we have an option to do that by installing the xrdp remote desktop protocol.

With the release of Ubuntu 14.04, the xRDP functionality has been improved but some small issues are still showing up. In this post, we will show you how to
  • Easily install xRDP
  • Connect to your Ubuntu Unity Desktop Interface
  • Set the keyboard layout to be used when using xRDP
Let’s go !

~]$ sudo apt-get install ubuntu-desktop

install ubuntu-desktop

 install xrdp using below command

~$ sudo apt-get install xrdp

install xrdp


add the user to access the ubuntu using the same user account
~]$sudo adduser arkit
 add user

Note: adding the user will not have a administrator access, in order to provide administrator access to created user account provide sudo access
~]$sudo adduser arkit sudo
provide admin access to user


start the xrdp service
~]$sudo /etc/init.d/xrdp start
 
Service start

now try to access from your windows machine
Start >> Run >> mstsc

Take_remote Desktop
type the IP address and click on connect
provide_username and password
provide the user name and password which you have created
Note: if your getting an below error
error_xrdp
then do the below steps to resolve the issue
aravi@ankam-ubuntu:~$ sudo apt-get install gnome-session-fallback

aravi@ankam-ubuntu:~$ echo "gnome-session --session=gnome-fallback" > ~/.xsession aravi@ankam-ubuntu:~$ cat .xsession gnome-session --session=gnome-fallback
restart the xrdp service
~]$sudo /etc/init.d/xrdp restart

Still no Luck..!!

then try below
~]$ps -ef |grep vnc
~]$kill -9 <PID>

Now try you will get it..

Monday 21 September 2015

Screen recording (video capturing) in RHEL7 using Krut


About Kurt

Krut has an intuitive and compact interface and boasts the following features
  • Timer-controlled recording
  • Movable recording areas during recording
  • Preview of ongoing recording
  • Optional mouse pointer recording
  • Record/Playback at 2 different frame rates
  • Highly accurate audio-video synchronization
As it is written in Java and is available as a runnable jar file, it is very easy to use on your Centos 7/RHEL7

Prerequisites to run Krut

Krut is required run java you have install java, jar and jdk.
GUI desktop have to be installed since it is a graphical user mode

Installation Procedure

 

~]#yum install java*
 
click on this link to Download Kurt

~]#unzip krut_full_0_9_4.zip
~]#cd Krut
~]#java -jar krut.jar

Krut recorder - Tech Tutorials
Krut recording screen
click on record button to record the screen

krut_settings
click on the Menu -> Settings

You can change the settings whatever you want.

Enjoy..!!

Please provide your valuable comments….

 

Monday 14 September 2015

Convert time Seconds to Hours-Minutes-Seconds format - Shell Scripting

Using below script you can convert the seconds to Hours-Minutes-Seconds.

Writing loop _hms then converting the hours / 3600 because for hour 3600 seconds. Minutes can be converted using 3600/60 because it's equal to Minute.

#!/bin/bash
##Author: Ankam Ravi Kumar
##Date: 14th, SEP, 2015
##Convert seconds to Hours:Minutes:Seconds Format using this Script
##  START ##

[ -z ${1} ] && echo "Usage: $(basename $0) <seconds>" && exit||secs=${1}
_hms()
{
 local S=${1}
 ((h=S/3600))
 ((m=S%3600/60))
 ((s=S%60))
 printf "%dh:%dm:%ds\n" $h $m $s
}

_hms ${secs}
## END ##


Execution steps:
~]$ ./seconds.sh
Usage: convert.sh <seconds>

~]$ ./seconds.sh 456
1h:0m:0s

The same script also can be write as one line base line like below

$ secs=3600
$ printf ""%dh:%dm:%ds"\n" $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))

1h:0m:0s

Same conversion we can write using awk as below

$ echo - | awk -v "S=3600" '{printf "%dh:%dm:%ds",S/(60*60),S%(60*60)/60,S%60}'

1h:0m:0s 

Video Tutorial



 

Print beautiful text banners - RHEL7 for freshers






To Print Text Banners in beautiful using a simple command.

This 'figlet' command required to install the figlet fonts to install the print follow the below process. 


Login to your Linux Server then run below command
~]# wget ftp://ftp.figlet.org/pub/figlet/program/unix/figlet-2.2.3.tar.gz

Download figlet

it will download an figlet package and save in current directory

Extra your figlet tar file using tar command
~]# tar -xzvf figlet-2.2.3.tar.gz

Now run to install the figlet
~]# make figlet 
Install figlet using make command

Now copy the .flf files to /usr/local/bin/ directory
~]#cd figlet-2.2.3
~]# cp * /usr/local/bin/
~]#figlet -k ravi


Please provide your valuable comments........




Thursday 10 September 2015

How to install SpaceWalk on RHEL7 - Redhat Linux 7


Spacewalk is an open source Linux systems management solution. Spacewalk is the upstream community project from which the Red Hat Satellite product is derived.

Spacewalk provides the web interface to manage and view the updates for the system that are registered with Spacewalk, we can initiate the task such as install, update, inventory, and so on. Here is the small tutorial about installing Spacewalk on RHEL7

Software Content Management


Spacewalk manages software content updates for Red Hat derived distributions such as Fedora, CentOS, and Scientific Linux, within your firewall. You can stage software content through different environments, managing the deployment of updates to systems and allowing you to view at which update level any given system is at across your deployment. A central web interface allows viewing of systems, their associated software update status, and initiating update actions.
 

Additional Management Capabilities


Spacewalk also provides provisioning capabilities, allowing you to manage your systems throughout their lifecycle. Via Provisioning, Spacewalk enables you to kickstart provision systems and manage and deploy configuration files. Spacewalk also has virtualization capabilities to enable you to provision, control, manage, and monitor virtual KVM and Xen guests.


Features:

  • Inventory of the systems
  • Install and Update system packages.
  • Configuring Kick-start installation.
  • Deploy and Manage the configuration files from singe location
  • Start / Stop / Configure the guests.
  • Distribute the content across the multiple Geo graphical location using spacewalk proxy.

Prerequsites

  • Outbound open ports 80, 443
  • Inbound open ports 80, 443, 5222 (only if you want to push actions to client machines) and 5269 (only for push actions to a Spacewalk Proxy), 69 udp if you want to use tftp
  • Storage for database: 250 KiB per client system + 500 KiB per channel + 230 KiB per package in channel (i.e. 1.1GiB for channel with 5000 packages)
  • Storage for packages (default /var/satellite): Depends on what you’re storing; Red Hat recommend 6GB per channel for their channels
  • 2GB RAM minimum, 4GB recommended
  • Underlying (SpaceWalk Server) OS is fully up-to-date.

Setup Repositories:

Before installing Spacewalk on CentOS, we must configure required repositories for Spacewalk setup.

Lets first setup Spacewalk repository, at the time of writing, latest available Spacewalk version was 2.3.

~]#rpm -Uvh http://yum.spacewalkproject.org/2.3/RHEL/7/x86_64/spacewalk-repo-2.3-4.el7.noarch.rpm

 Setup Jpackage Repo:

~]#vi /etc/yum.repos.d/jpackage-generic.repo

 Add the following.

[jpackage-generic]
name=JPackage generic
#baseurl=http://mirrors.dotsrc.org/pub/jpackage/5.0/generic/free/
mirrorlist=http://www.jpackage.org/mirrorlist.php?dist=generic&type=free&release=5.0
enabled=1
gpgcheck=1
gpgkey=http://www.jpackage.org/jpackage.asc

~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 Your Spacewalk server should have a resolvable fully-qualified domain name (FQDN) such as “hostname.domain.com”, to do that; edit /etc/hosts file.


~]# vi /etc/hosts

Modify it according to your environment.

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# Your Spacewalk Server
192.168.12.3 server.arkit.local server

Configure Firewall:

As said in the prerequisites, we need to have outbound port opened. Run the following on terminal to allow the required ports.

firewall-cmd --add-service=http ; firewall-cmd --add-service=https

Add port 5222 if you want to push actions to client machines and 5269 for push actions to a Spacewalk Proxy, 69 udp if you want to use tftp.

Restart firewall service using command:

firewall-cmd --reload

SpaceWalk Database:

SpaceWalk supports PostgreSQL (version 8.4 or higher) or Oracle ( version 10g or higher) as a database for storing its data.

Embedded Database:

Spacewalk has the embedded setup for PostgrSQL database which will do the automatic Spacewalk installation without having user intervention to enter the database information. Embedded database method is very easy to setup and run the Spacewalk in no time; this is very useful for those who do not have any database knowledge.

yum install spacewalk-setup-postgresql

External Database:

You can use the external PostgreSQL or Oracle database to install Spacewalk, you can find the tons of documents online to setup database.

Installing SpaceWalk:

If you are planning use PostgreSQL database (Either Embedded or External PostgreSQL database).
 
yum install spacewalk-postgresql

If you are planning to use Oracle database.
 
yum install spacewalk-oracle

Configuring SpaceWalk:

If you have installed embedded database, then use below command. It will ask you to enter the admin mail and organization details to generate the self signed certificate for secured access.
 
spacewalk-setup --disconnected

if you have setup database manually, then use below commands depend on database type. It will ask you to enter external database details.

Oracle:
 
spacewalk-setup --disconnected --external-oracle

PostgreSQL:
 
spacewalk-setup --disconnected --external-postgresql


Since i am using embedded postgresql database, an example session is as follows;

# spacewalk-setup --disconnected

* Setting up SELinux..
** Database: Setting up database connection for PostgreSQL backend.
** Database: Installing the database:
** Database: This is a long process that is logged in:
** Database:   /var/log/rhn/install_db.log
*** Progress: ###
** Database: Installation complete.
** Database: Populating database.
*** Progress: ############################
* Configuring tomcat.
* Setting up users and groups.
** GPG: Initializing GPG and importing key.
** GPG: Creating /root/.gnupg directory
You must enter an email address.
Admin Email Address? redhat.ark@gmail.com ## Email Address ##
* Performing initial configuration.
* Activating Spacewalk.
** Loading Spacewalk Certificate.
** Verifying certificate locally.
** Activating Spacewalk.
* Configuring apache SSL virtual host.
Should setup configure apache's default ssl server for you (saves original ssl.conf) [Y]? ## Press Y ## 
** /etc/httpd/conf.d/ssl.conf has been backed up to ssl.conf-swsave
* Configuring jabberd.
* Creating SSL certificates.
CA certificate password? ## Enter Certificate Password ##
Re-enter CA certificate password? ## Re Enter Certificate Password ##
Organization? ARKIT ## Your Organization Name ##
Organization Unit [server.itzgeek.local]? Linux ## Your Organization Unit ##
Email Address [itzgeek.web@gmail.com]? ## Email Address ##
City? Albany ## Your City ##
State? NY ## Your State ##
Country code (Examples: "US", "JP", "IN", or type "?" to see a list)? US ## Your Country ##
** SSL: Generating CA certificate.
** SSL: Deploying CA certificate.
** SSL: Generating server certificate.
** SSL: Storing SSL certificates.
* Deploying configuration files.
* Update configuration in database.
* Setting up Cobbler..
Cobbler requires tftp and xinetd services be turned on for PXE provisioning functionality. Enable these services [Y]? ## Press Y ##
* Restarting services.
Installation complete.
Visit https://server.arkit.local to create the Spacewalk administrator account                                                                                        .

On complete, start the Spacewalk service if not started automatically.

/usr/sbin/spacewalk-service start
 
Open up your browser and navigate it to https://ip-add-ress or https://your-domain-name.

You will be asked to create administrator account for spacewalk, fill up details and click on Create Login
 Once administrator account is created, it will take you to home page of spacewalk where you can do all administration activities.




That’s All!!!, you have sucessfully installed Spacewalk on RHEL7

Please provide your Valuable Comments...