CyberKeeda In Social Media

How to run Code on Atom text editor



Have a look on the Video. ...



Read more ...

How to Install Atom Text Editor in Ubuntu




Have a look on the Video.


Read more ...

Ubuntu : How to change default file application.

How to make change default open file with application.
How to set default application type for particular application type.


Many times we use open with parameter in the file browser to open an application with certain application.
For instance default writer / office package for Ubuntu is Libre office , but I feel WPS Office suite more friendly.
or
I want to Use VLC as a media player instead of Videos pre installed within Ubuntu.

Instead of opening a file/media with Open with I want to make it work on Double click of mouse only with preferred application type.

  1. Select a file of the type whose default application you want to change. For example, to change which application is used to open Video files, select a .mp4 or FLV file.
  2. Right-click the file and select Properties.
  3. Select the Open With tab.
  4. Select the application you want and click Set as default. By default, the file manager only shows applications it knows can handle the file. To look through all the applications on your computer, click Show other applications.

Have a look on the Video.




Read more ...

How to add Hosts and Host groups into Ansible Server



Ansible Initial Host Configuration.

Ansible knows the hosts and hostgroups from a host file by default it is located as /etc/ansible/hosts.

Read more ...

How to Install Ansible on CentOS 7



Need Automation on Linux : Ansible will become your best friend for sure.

Ansible is the simplest way to automate apps and IT infrastructure. Application Deployment + Configuration Management + Continuous Delivery.

So let's not discuss more jump into installation to have hands on it.


Redhat/Centos ships ANSIBLE on its default repository, so you don’t ned to woory about packages or it’s dependencies.

Just a single command will install ansible and your Automation cockpit is ready to fly.

cybeerkeeda@Linux-Maniac:~ yum install ansible

If you too found the same issue while installing ansible from one liner yum command.
cybeerkeeda@Linux-Maniac:~ yum install ansible 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
No package ansible available.
Error: Nothing to do

Make sure first of all you are connected to internet, then simply install the epel repo first.

cybeerkeeda@Linux-Maniac:~ yum install epel-release
Then run the same earlier command  yum install ansible.
cybeerkeeda@Linux-Maniac:~ yum install ansible
Done ! All fine 

Now lets confirm it’s installation status by checking the installed ansible version.
cybeerkeeda@Linux-Maniac:~ ansible --version

 ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]

Do find the video for reference purpose too.



Read more ...

nagios 4.0.8 fails to start with "Error:




nagios 4.0.8 fails to start with "Error: Failed to initialize query handler" (bind() failed: No such file or directory)

qh: Failed to init socket '/usr/local/nagios/var/rw/nagios.qh'. bind() failed: No such file or directory

error: Failed to initialize query handler. Aborting


Nagios Core responds me these errors while starting nagios.

Fix : Error itself give us an hint about no directory error, hence leading to failure while starting  the service.

Fix:  To fix this issue I will create the missing directory manually and aligning permissions to it.



  • Depending upon your error of missing directory create it.

cybeerkeeda@Linux-Maniac:~ mkdir -p  /usr/local/nagios/var/rw/
  • Provide full permission to it.
cybeerkeeda@Linux-Maniac:~ chmod -R 777  /usr/local/nagios/var/rw/
  • Restart Nagios again
cybeerkeeda@Linux-Maniac:~ sudo service nagios restart




Read more ...

DPKG Cheat Sheet


DPKG [ dpkg ] is a traditional yet powerful CLI tool for the debian based Linux Distribution.
It is used to install/manage individual packages.

Here are some useful dpkg commands which you can use as a cheat code.




SyntaxDescriptionExample
dpkg -i {.deb package}Install the packagedpkg -i zip_virtualbox-5.amd64.deb
dpkg -i {.deb package}Upgrade package if it is installed else install a fresh copy of packagedpkg -i virtualbox-5.amd64.deb
dpkg -R {Directory-name}Install all packages recursively from directorydpkg -R /tmp/downloads
dpkg -r {package}Remove/Delete an installed package except configuration filesdpkg -r zip
dpkg -P {package}Remove/Delete everything including configuration filesdpkg -P apache-perl
dpkg -lList all installed packages, along with package version and short descriptiondpkg -l
dokg -l | less
dpkg -l '*apache*'
dpkg -l | grep -i 'sudo'
dpkg -l {package}List individual installed packages, along with package version and short descriptiondpkg -l apache-perl
dpkg -L {package}Find out files are provided by the installed package i.e. list where files were installeddpkg -L apache-perl
dpkg -L perl
dpkg -c {.Deb package}List files provided (or owned) by the package i.e. List all files inside debian .deb package file, very useful to find where files would be installeddpkg -c virtualbox-5.amd64.deb
dpkg -S {/path/to/file}Find what package owns the file i.e. find out what package does file belongdpkg -S /bin/netstat
dpkg -S /sbin/ippool
dpkg -p {package}Display details about package package group, version, maintainer, Architecture, display depends packages, description etcdpkg -p lsof
dpkg -s {package} | grep StatusFind out if Debian package is installed or not (status)dpkg -s lsof | grep Status
Read more ...

SED : How to delete N numbers of starting lines from a file using SED




Lets take an example of simple nagios host config file.

Example file name : localhost.cfg
# for the local machine
# A host for the local machine
# Monitoring template
# Define a host for the local machine

define host{
        use                     linux-server                    
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }
Here I want to delete starting 3 lines of my file localhost.cfg
to completely look like as
# Define a host for the local machine
define host{
        use                     linux-server                    
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }

Using sed to delete starting 3 lines of a file
cybeerkeeda@Linux-Maniac:~ sed -i -e "1,3d"   localhost.cfg
Change number 3 with your desired line number you want to delete


Note :

sed  -i  : Here -i    parameter will directly write the changes into the file.

I suggest to take a automatically take up backup during this comand.
cybeerkeeda@Linux-Maniac:~ sed -i.bak -e "1,3d"   localhost.cfg

 Search more SED tutorials on the go here.


Read more ...

SED: How to comment or nullify N number of starting lines of a file using SED




Lets take an example of simple nagios host config file.

Example file name : localhost.cfg
Lets take an example of simple nagios host config file.

Example file name : localhost.cfg

# Define a host for the local machine
define host{
        use                     linux-server                    
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        contacts                nagiosadmin
        }
        
define host{
        use                     windows-server                    
        host_name               windows
        alias                   windows-srv
        address                 10.0.0.1
        contacts                nagiosadmin
        }
Here I want to comment starting 8 lines of my file to make it invalid

to nullify the string values my localhost.cfg should  look like below.
## Define a host for the local machine
#define host{
#        use                     linux-server                    
#        host_name               localhost
#        alias                   localhost
#        address                 127.0.0.1
#        contacts                nagiosadmin
#        }
        
define host{
        use                     windows-server                    
        host_name               windows
        alias                   windows-srv
        address                 10.0.0.1
        contacts                nagiosadmin
 Here we go, we will use SED to add   #  at the beginning of line for starting 8 lines

Using sed to add string on seventh line.
cybeerkeeda@Linux-Maniac:~ sed -i '1,8 s:^:#:' localhost.cfg
Change number 8 with your desired line number and # with your desired word or string


Note :

sed  -i  : Here -i    parameter will directly write the changes into the file.

I suggest to take a automatically take up backup during this comand.
cybeerkeeda@Linux-Maniac:~ sed -i.bak '1,8 s:^:#:' localhost.cfg


Read more ...

SED : How to add specific string after N number of line in a file.




Lets take an example of simple nagios host config file.

Example file name : localhost.cfg
# Define a host for the local machine
define host{
        use                     linux-server                    
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }
 Here I want to add a line as  "  contacts                nagiosadmin " after address
contacts                nagiosadmin
to completely look like as
# Define a host for the local machine
define host{
        use                     linux-server                    
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        contacts                nagiosadmin
        }
 Hence I have to add contact string at seventh ( 7 )line for the same file localhost.cfg

Using sed to add string on seventh line.


cybeerkeeda@Linux-Maniac:~ sed -i '7i\ contacts   nagiosadmin' localhost.cfg
Change number 7 with your desired line number


Note :

sed  -i  : Here -i    parameter will directly write the changes into the file.

I suggest to take a automatically take up backup during this comand.
cybeerkeeda@Linux-Maniac:~ sed -i.bak '7i\ contacts   nagiosadmin' localhost.cfg
White spaces after \ are intentional , you can remove it as per your requirement.

Without white space it would look like this.
cybeerkeeda@Linux-Maniac:~ sed -i.bak '7i\contacts nagiosadmin' localhost.cfg

 Search more SED tutorials on the go here.



Read more ...

Owncloud : Unable to change Max Upload size




Increase File Upload Size from default admin pannel.

Go to File handling --  Change Upload size.


Chnage it's value from 2 to something as per your requirement.

Now save -- Login as a normal user after 5 Min and then check back again.
If all seems good then.. this tutorial is just got an ending for you.


If not, just dig into some files.

I have tried to change it from 2 to 8 MB , but even after saving it didn't went well.

Locate your  owncloud root folder, wherever you have kept it, i have my owncloud folder under /var/www/html/owncloud and open the file .htaccess

cybeerkeeda@Linux-Maniac:~ vim /var/www/html/owncloud/.htaccess
cybeerkeeda@Linux-Maniac:~ vim .htaccess
You must find the updated value within the two lines, if not change it do the desired value but remember both must be of same value ( like i have taken limit as 8 MB )

 php_value upload_max_filesize 8M
 php_value post_max_size 8M


Save and restart webserver 


cybecybeerkeeda@Linux-Maniac:~ service httpd restart
cyberkeeda@Linux-Maniac:~ systemctl restart httpd
Now, check again it should work.

Till now, if it's not working for you locate the default php.ini file , find and update the same value over there too.


cybeerkeeda@Linux-Maniac:~ locate php.ini
cybeerkeeda@Linux-Maniac:~ vim php.ini

upload_max_filesize = 8M

post_max_size = 8M


Restart your web server again and check, it must be working.

Now you can upload file size more then default value.
Read more ...

How to enable Microsoft Word support on OwnCloud



This tutorial will guide to enable Microsoft / LibreOffice/OpenOffice Word document Online view on browser.


Install Libreoffice package on Owncloud server
cybeerkeeda@Linux-Maniac:~ yum install libreoffice*
cybeerkeeda@Linux-Maniac:~ yum install libreoffice-headless
cybeerkeeda@Linux-Maniac:~ yum install libreoffice-impress

These are the mandatory packages that are supposed to be installed within your Owncloud Server

Now Enable Documents from the App window



Check within your config.php file ( owncloud/config/config.php ), if the below mentioned line has been added or not
if not then add it manually
'preview_libreoffice_path' => '/usr/bin/libreoffice',

Now Again Click on Admin -- Documents -- Local - Apply and Test

Now confirm it from the below similar looking pic

You must be able to View the Document within your browser.

Read more ...

GNOME : How to add Custom Folder links to left panel




Are you looking the way to Add Folder Shortcut To Left Panel File Browser ( Places ).

Toggle into the directory you want to make a shortcut and hit  Ctrl+D from your keyboard 

Lets take an example 
I want a folder named as NIB to be appear into the left panel of file browser.

Toggle into NIB and simply hit  Ctrl+D



I hope this help you.. 





Read more ...

SOLVED PHP Installed but still php : command not found



I have encountered the problem while upgrading PHP version from 5.3 to 5.4 or 5.5

By default RHEL keeps its stable version of PHP within system, even after upgradation.
This is the reason why it show the default last version even after upgrading.
'

cybeerkeeda@Linux-Maniac:~ php -v
PHP 5.3.3 (cli) (built: Nov 29 2012 14:12:23)
Copyright (c) 1997-2010 The PHP Group



But Wait... we know we have upgraded the version of PHP to 5.4

For some user , while running the same command , it shows command not found

cybeerkeeda@Linux-Maniac:~ php -v
bash: php: command not found


Fix : Fix it permanently by enabling it by sourcing the path.

cybeerkeeda@Linux-Maniac:~ source /opt/rh/php54/enable
Run again the php command to verify
cybeerkeeda@Linux-Maniac:~ php -v

PHP 5.4.14 (cli) (built: May 23 2013 15:42:19)
Copyright (c) 1997-2013 The PHP Group




Hope it gonna work for you too.




Read more ...

BASH : Using while loop to ssh to multiple servers and run multiple commands



So today I got a requirement to perform some regular tasks to be executed on 100 Hosts.

These are the two task that i have to perform on 100 servers from SSH remote execution.

Create a Symbolic Link for a directory into User's directory
Give Ownership of the same Symbolic link.

Commands involved.
ln -s /home/BackUP_Data/  /home/user_directory
chown -R userid.gid  /home/user_directory/BackUP_Data

So it seems to be pretty simply , but here are two variables that I'm supposed to fetch out from two files.

/tmp/xyz_host.txt contains all 100 hostname
/tmp/xyz_user.txt conatins all 100 Users with respect to the same hostname in parralel to it.

Hence upon addition of variables from my files we have to execute something like below.

ssh root@$x " ln -s /home/BackUP_Data/  /home/$y  && chown -R userid.gid  /home/user_directory/BackUP_Data "
"

Task looks simple and i tried to use my old WHILE loop snippet to perform the same activity.

While Loop with Multiple Variables from multiple file as input

But somehow it didn't went well just after executing the commands into the first host , the loop stucks at all.

Somehow our common friend google is here and STACKexchnage is my best friend during scripting.

It somehow fixed me , just by adding  an extra   < /dev/null;


So overall the while loop will look like


while read -r x && read -r y <&3; do ssh root@$x " ln -s /home/BackUP_Data/  /home/$y  && chown -R userid.gid  /home/user_directory/BackUP_Data
" < /dev/null; done</tmp/xyz_host.txt 3</tmp/xyz_user.txt


The same has been briefly explained here as

ssh is reading the rest of your standard input.
while read HOST ; do … ; done < servers.txt
read reads from stdin. The < redirects stdin from a file.

Unfortunately, the command you're trying to run also reads stdin, so it winds up eating the rest of your file. You can see it clearly with

Explained well as Workaround / Solution for it by using SECOND Redirect
while read HOST ; do ssh $HOST "uname -a" < /dev/null; done < servers.txt

A detailed explanation can be found here ...  Stackexchange
Reference : Stackexchange









Read more ...
Designed By Kunal Saha