Wednesday, 11 June 2014

Commonly Used Shell Variables


echo $BASH_VERSION --holds the version of this instance of bash
3.2.25(1)-release

echo $HOSTNAME --the name of the your computer
LinuxHost

echo $CDPATH --the search path for the cd command

echo $HISTFILE --the file in which command history is saved
/root/.bash_history

echo $HISTFILESIZE --the maximum number of lines contained in the history file
1000

echo $HISTSIZE --the number of commands to remember in the command history
1000

echo $HOME --the home directory of the current user
/root

echo $IFS --the Internal Field Separator

echo $LANG --used to determine the lang

echo $PATH --the search path for commands
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

echo $PS1 --shows prompt settings
[\u@\h \W]\$

echo $TMOUT --the default timeout for the read builtin command

echo $TERM --the login terminal type
xterm
export TERM=vt100
export TERM=xterm

echo $SHELL --set path to login shell
/bin/bash

echo $DISPLAY --Set X display name
export DISPLAY=:0.1

export EDITOR=/usr/bin/vim --name of default text editor

Tuesday, 10 June 2014

Find out built in or an external command


type -a bind
bind is a shell builtin

type -a cat
cat is /bin/cat

type -a awk
awk is /bin/awk
awk is /usr/bin/awk

type -a true
true is a shell builtin
true is /bin/true

type -a select
select is a shell keyword


Basic Command Line Editing


Use the following key combinations to edit and recall commands:

CTRL + L : Clear the screen.

CTRL + W : Delete the word starting at cursor.

CTRL + U : Clear the line i.e. Delete the all words from command line.

Up and Down arrow keys : Recall commands (see command history).

Tab : Auto-complete files, directory, command names and much more.

CTRL + R : Search through previously used commands (see command history)

CTRL + C : Cancel currently running commands.

CTRL + T : Swap the last two characters before the cursor.

ESC + T : Swap the last two words before the cursor.

Find out current shell


To find all of the available shells in your system,

echo $SHELL

/bin/bash

To find out your current shell,

which bash


/bin/bash

ps $$

PID TTY      STAT   TIME COMMAND
29893 pts/0    Ss     0:00 -bash

ps -p $$

PID TTY          TIME CMD
29893 pts/0    00:00:00 bash

Valid login shells

cat /etc/shells

/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh

Wednesday, 28 May 2014

Ways to check Linux OS is 32 bit or 64 Bit


uname -m

x86_64 ==> 64-bit kernel
i686   ==> 32-bit kernel

/bin/uname -m

x86_64 ==> 64-bit kernel
i686   ==> 32-bit kernel

getconf LONG_BIT

64 ==> 64-bit kernel
32 ==> 32-bit kernel

arch

x86_64 ==> 64-bit kernel
i686   ==> 32-bit kernel

file /sbin/init

/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped    ==> 64-bit kernel

/sbin/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped   ==> 32-bit kernel

In Ubuntu

dpkg --print-architecture

amd64 ==> 64-bit kernel
amd32 ==> 32-bit kernel

Ref: http://stackoverflow.com/questions/246007/how-to-determine-whether-a-given-linux-is-32-bit-or-64-bit



Tuesday, 27 May 2014

Change Run Levels in Linux


Find Out Current Run Level

who -r
run-level 3  2014-05-27 17:04

Or

runlevel
N 3

Use the init command to change rune levels:

init 1

To change the default run level:

vi /etc/inittab
id:5:initdefault:

Reboot the system to see changes:

reboot

Ref:
http://www.cyberciti.biz/tips/linux-changing-run-levels.html
http://www.ibm.com/developerworks/library/l-lpic1-v3-101-3/

Monday, 19 May 2014

Clear Memory Cache on Linux Server

Flush file system buffers by executing,

# sync

Kernels 2.6.16.x and newer versions of kernel provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can be helpful to free up a lot of memory.

To free page cache:

# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

# echo 2 > /proc/sys/vm/drop_caches

To free page cache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

or

sync; echo 3 > /proc/sys/vm/drop_caches

Sync should be run because this is a non-destructive operation, and dirty objects are not freeable.
So you run sync in order to make sure all cached objects are freed.

To do clearing memory cache on a particular interval, just add the command to cron job

vi cacheclear.sh

#!/bin/sh
sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

Ref: http://www.unixmen.com/how-to-clear-memory-cache-on-linux-servers/

Sunday, 18 May 2014

Force fsck in Linux


fsck stands for "file system check" and it is used to check and optionally repair one or more Linux file systems. Normally, the fsck program will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of the filesystems

Login as the root:
su root

Change directory to root (/) directory:
cd /

Create a file called forcefsck:
touch /forcefsck

Now reboot the system:
reboot

login as root and type the following command to reboot and run fsck:

shutdown -rF now

The -F option force fsck on reboot.


Ref:
http://www.cyberciti.biz/faq/linux-force-fsck-on-the-next-reboot-or-boot-sequence/
https://wiki.archlinux.org/index.php/fsck


Thursday, 15 May 2014

Recursively list all hidden files and directories


The basic syntax is as follows:

find /dir/to/search/ -name ".*" -print

find /dir/to/search/ -name ".*" -ls

search only hidden files:

find /dir/to/search/ -type f -iname ".*" -ls

search only hidden directories:

find /dir/to/search/ -type d -iname ".*" -ls
find /dir/to/search -path '*/.*' -print
find /dir/to/search -path '*/.*' -ls

In this example, search $HOME for all hidden files and dirs:

find $HOME -name ".*" -ls

135237    4 -rw-r--r--   1 root     root           18 May 20  2009 /root/.bash_logout
137605    4 -rw-------   1 root     root           32 May 15 01:08 /root/.mysql_history
135240    4 -rw-r--r--   1 root     root          100 Sep 22  2004 /root/.cshrc
131153    4 drwxr-----   3 root     root         4096 Feb 27 19:28 /root/.pki
136444    4 -rw-r--r--   1 root     root          686 Feb 27 07:22 /root/.bash_profile
137510    4 drwx------   2 root     root         4096 May  8 02:00 /root/.ssh
135241    4 -rw-r--r--   1 root     root          129 Dec  3  2004 /root/.tcshrc
136494    4 -rw-r--r--   1 root     root          310 Feb 27 07:22 /root/.bashrc
137490   16 -rw-------   1 root     root        14970 May 15 01:02 /root/.bash_history

Ref: http://www.cyberciti.biz/faq/unix-linux-centos-ubuntu-find-hidden-files-recursively/

Recursively list all files and directories


ls -alR

find . -exec ls -dl \{\} \; | awk '{print $3, $4, $9}'

find . -printf "%u %g %p\n"

tree -p -u -g -f -i

tree -p -u -g -f

find $PWD -type f

find . -ls

List only .html files

find . -name "*.html"

Ref: http://stackoverflow.com/questions/501367/how-to-recursively-list-all-files-and-directories

Wednesday, 14 May 2014

History Command in Linux


List All Executed Commands in Linux

history

List All Commands with Date and Timestamp

export HISTTIMEFORMAT='%F %T  '
history
%F Equivalent to %Y - %m - %d
%T Replaced by the time ( %H : %M : %S )

Filter Commands in History

export HISTIGNORE='ls -l:pwd:date:'
history

Ignore Duplicate Commands in History

export HISTCONTROL=ignoredups
history

Unset export Command

unset export HISTCONTROL
history

Save export Command Permanently

vi .bash_profile
PATH=$PATH:$HOME/bin
export PATH

Disable Storing History of Commands

vi .bash_profile
PATH=$PATH:$HOME/bin
HISTSIZE=0
export PATH
.bash_profile (END)

source .bash_profile

Delete or Clear History of Commands

history -c

Search Commands in History Using Grep Command

history | grep pwd

Recall Lastly Executed Command

Bang and 8 (!8)

Recall Lastly Executed Specific Command

!net

List last 25 commands

history 25

Ref: 

http://www.tecmint.com/history-command-examples/
https://www.digitalocean.com/community/articles/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps

DoS and DDoS attack

A denial-of-service attack (DoS attack) or distributed denial-of-service attack (DDoS attack) is a attack in which the server resources become unavailable to its intended users.

A DOS attack is an attempt to make a system or server unavailable for legitimate users and, finally, to take the service down. This is achieved by flooding the server’s request queue with fake requests. After this, server will not be able to handle the requests of legitimate users.

In general, there are two forms of the DOS attack. The first form is on that can crash a server. The second form of DOS attack only floods a service.

In simple words DDOS attack is, when a server system is being flooded from fake requests coming from multiple sources (potentially hundreds of thousands), it is known as a DDOS attack. In this case, blocking a single or few IP address does not work. The more members in the zombie network, more powerful the attack it. For creating the zombie network, hackers generally use a Trojan.

There are basically three types of DDOS attacks:

Application layer DDOS attack: Application-layer DDOS attacks are attacks that target Windows, Apache, OpenBSD, or other software vulnerabilities to perform the attack and crash the server.

Protocol DDOS attack: A protocol DDOS attacks is a DOS attack on the protocol level. This category includes Synflood, Ping of Death, and more.

Volume-based DDOS attack: This type of attack includes ICMP floods, UDP floods, and other kind of floods performed via spoofed packets.

How to troubleshoot,

list of IP’s with maximum number of connections to server,

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

remember that ddos becomes more complex as attackers are using fewer connections with more number of attacking IP’s,

the number of active connections open to server,

netstat -n | grep :80 |wc -l

netstat -n | grep :80 | grep SYN |wc -l

Ex:
cd /edu-log/edurite/
cat 20140505.access.log | awk '{print $1}' |sort |uniq -c |sort -nr |more

------------
110.85.112.16
27.153.209.89
120.33.245.187
27.150.229.164
121.205.197.8
121.205.196.173
27.153.186.129
------------

Trace the IP using the follwoing URL,

http://tools.whois.net/whoisbyip/

One example for how to block a particular IP on the server,

iptables -A INPUT -s 27.153.186.129 -j DROP

/etc/init.d/iptables save
/etc/init.d/firewall restart

Ref:

http://webhosting.uk.com/kb/how-to-check-if-your-linux-server-is-under-ddos-attack/
http://resources.infosecinstitute.com/dos-attacks-free-dos-attacking-tools/

Monday, 28 April 2014

Configure NFS in Linux

Three rpm's are required to configure nfs server.
nfs, portmap and xinetd, check them if not found then install them,

rpm -qa nfs*
nfs-utils-1.0.9-66.el5
nfs-utils-lib-1.0.8-7.9.el5

rpm -qa portmap*
portmap-4.0-65.2.2.1

rpm -qa xinetd*
xinetd-2.3.14-17.el5


/etc/init.d/portmap restart
/etc/init.d/xinetd restart
/etc/init.d/nfs restart


chkconfig portmap on
chkconfig xinetd on
chkconfig nfs on

mkdir /data
chmod 777 /data
vi /etc/exports

/data   192.168.209.128 (rw,sync)

exportfs -r

showmount -e 192.168.209.128

Export list for 192.168.209.128:
/data (everyone)

mount -t nfs 192.168.209.128:/data/ /mnt

cd /mnt/

cat > test
This is testfile

cd
umount /mnt

mkdir /temp

vi /etc/fstab

192.168.209.128:/data /temp nfs defaults 0 0

reboot

cd /temp
ls
test

ref : http://computernetworkingnotes.com/network-administrations/nfs-server.html

Windows Useful Commands


Application = Command

Accessibility Controls = access.cpl
Add Hardware Wizard = hdwwiz.cpl
Add/Remove Programs = appwiz.cpl
Administrative Tools = control admintools
Automatic Updates = wuaucpl.cpl

Bluetooth Transfer Wizard = fsquirt
Calculator = calc
Certificate Manager = certmgr.msc
Character Map = charmap
Check Disk Utility = chkdsk

Clipboard Viewer = clipbrd
Command Prompt = cmd
Component Services = dcomcnfg
Computer Management = compmgmt.msc
Date and Time Properties = timedate.cpl

DDE Shares = ddeshare
Device Manager = devmgmt.msc
Direct X Control Panel (If Installed)* = directx.cpl
Direct X Troubleshooter = dxdiag
Disk Cleanup Utility = cleanmgr

Disk Defragment = dfrg.msc
Disk Management = diskmgmt.msc
Disk Parmelonion Manager = diskpart
Display Properties = control desktop/desk.cpl
Dr. Watson System Troubleshooting Utility = drwtsn32

Driver Verifier Utility = verifier
Event Viewer = eventvwr.msc
File Signature Verification Tool = sigverif
Findfast = findfast.cpl
Folders Properties = control folders

Fonts = control fonts
Fonts Folder = fonts
Free Cell Card Game = freecell
Game Controllers = joy.cpl
Group Policy Editor (XP Prof) = gpedit.msc

Hearts Card Game = mshearts
Iexpress Wizard = iexpress
Indexing Service = ciadv.msc
Internet Properties = inetcpl.cpl
IP Configuration = ipconfig

Java Control Panel (If Installed) = jpicpl32.cpl
Java Application Cache Viewer (If Installed) = javaws
Keyboard Properties = control keyboard
Local Security Settings = secpol.msc
Local Users and Groups = lusrmgr.msc

Logs You Out Of Windows = logoff
Microsoft Chat = winchat
Minesweeper Game = winmine
Mouse Properties = control mouse
Mouse Properties = main.cpl

Network Connections = control netconnections
Network Connections = ncpa.cpl
Network Setup Wizard = netsetup.cpl
Notepad = notepad
Nview Desktop Manager (If Installed) = nvtuicpl.cpl

Object Packager = packager
ODBC Data Source Administrator = odbccp32.cpl
On Screen Keyboard = osk
Opens AC3 Filter (If Installed) = ac3filter.cpl
Password Properties = password.cpl

Performance Monitor = perfmon.msc
Performance Monitor = perfmon
Phone and Modem Options = telephon.cpl
Power Configuration = powercfg.cpl
Printers and Faxes = control printers

Printers Folder = printers
Private Character Editor = eudcedit
Quicktime (If Installed) = QuickTime.cpl
Regional Settings = intl.cpl
Registry Editor = regedit

Registry Editor = regedit32
Remote Desktop = mstsc
Removable Storage = ntmsmgr.msc
Removable Storage Operator Requests = ntmsoprq.msc
Resultant Set of Policy (XP Prof) = rsop.msc

Scanners and Cameras = sticpl.cpl
Scheduled Tasks = control schedtasks
Security Center = wscui.cpl
Services = services.msc
Shared Folders = fsmgmt.msc

Shuts Down Windows = shutdown
Sounds and Audio = mmsys.cpl
Spider Solitare Card Game = spider
SQL Client Configuration = cliconfg
System Configuration Editor = sysedit

System Configuration Utility = msconfig
System File Checker Utility = sfc
System Properties = sysdm.cpl
Task Manager = taskmgr
Telnet Client = telnet

User Account Management = nusrmgr.cpl
Utility Manager = utilman
Windows Firewall = firewall.cpl
Windows Magnifier = magnify
Windows Management Infrastructure = wmimgmt.msc

Windows System Security Tool = syskey
Windows Update Launches = wupdmgr
Windows XP Tour Wizard = tourstart
Wordpad = write

Friday, 25 April 2014

Increasing group_concat_max_len param in MySQL


SET GLOBAL group_concat_max_len=1024M

vi /etc/my.cnf

group_concat_max_len = 1024M

/etc/init.d/mysql restart

Shutting down MySQL......                                  [  OK  ]
Starting MySQL..                                           [  OK  ]

mysql -u root -p

Enter password:

mysql>SHOW VARIABLES LIKE "%group_concat_max_len";
+----------------------+------------+
| Variable_name        | Value      |
+----------------------+------------+
| group_concat_max_len | 1073741824 |
+----------------------+------------+
1 row in set (0.00 sec)

Copying files using pscp

Copying files from your UNIX host to your Windows PC

C:\Program Files (x86)>pscp "H:\Digitally_3.6_International\vmware.log" root@172
.16.0.134:/tmp/

root@172.16.0.134's password:
vmware.log                | 84 kB |  84.0 kB/s | ETA: 00:00:00 | 100%

http://www.nber.org/pscp.html

Limit number of simultaneous logins attempts for a user


To limit the max number of logins to 2 for user vivek

vi /etc/security/limits.conf

vivek         hard    maxlogins       2

ref:http://nixcraft.com/centos-rhel-fedora/13764-ssh-limit-number-simultaneous-logins-attempts-each-user.html

Thursday, 24 April 2014

Change SVN Server IP


Modify when SVN server IP address changes

cd /data/mysql-svn-bkp/ObjectMap/

svn switch --relocate svn://172.16.0.25/db-backup/Trunk/mysql/ svn://10.98.33.63/db-backup/Trunk/mysql/


Shrink VMware Virtual Disk File (.vmdk)


To remove any unneeded files from the virtual machine to free space

yum clean

To fill the unused space with zeros

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

poweroff

Start cmd

C:\Program Files (x86)\VMware\VMware Player>vmware-vdiskmanager.exe -k "H:\Digit
ally_3.6\Edulinux_en-gb.vmdk"

  Shrink: 100% done.
Shrink completed successfully.

Ref:- http://www.howtoforge.com/how-to-shrink-vmware-virtual-disk-files-vmdk

Wednesday, 23 April 2014

Change the MySQL data default directory


Steps for MySQL data directory change,

Stopping the MySQL server

service mysql stop

Create a new data directory and move the content from the old data directory

mkdir /data/var/lib/mysql

chown mysql:mysql /data/var/lib/mysql

mv /var/lib/mysql/* /data/var/lib/mysql

Correct the MySQL configuration file

vi /etc/my.cnf

[mysqld]

datadir = /data/var/lib/mysql

socket = /data/var/lib/mysql/mysql.sock

slow_query_log_file = /data/var/lib/mysql/mysql-slow.log

general_log_file = /data/var/lib/mysql/general.log

[client]

socket = /data/var/lib/mysql/mysql.sock

Adjust SELinux parameters to accept our new change

getenforce
Disabled

If semanage SELinux Command Not Found

yum install policycoreutils-python

man semanage

rpm -qf `which semanage`
policycoreutils-python-2.0.83-19.39.el6.x86_64

semanage fcontext -a -t mysqld_db_t "/data/var/lib/mysql(/.*)?"

grep -i mysql /etc/selinux/targeted/contexts/files/file_contexts.local
/data/var/lib/mysql(/.*)?    system_u:object_r:mysqld_db_t:s0

restorecon -Rv data/var/lib/mysql

Starting the MySQL server

service mysql start

mysql -u root -p

mysql> show databases;

Optionally you can just use

mysql -u root -p --protocol tcp


Ref:-  

 http://crashmag.net/change-the-default-mysql-data-directory-with-selinux-enabled

https://blogs.oracle.com/jsmyth/entry/selinux_and_mysql

https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Confined_Services/sect-Managing_Confined_Services-MySQL-Configuration_Examples.html

Restore Power School Database


Stop Power Teacher Services

Stop Report Works Services

start cmd

cd \oracle\scripts

DropSchema.bat PRODDB

(Restart Oracle Services if schemas are fail to drop)

sqlplus / as sysdba

create user PS identified by password;

create user PS_MGMT identified by password;

grant create session, dba to PS;

grant create session, dba to PS_MGMT;

CREATE OR REPLACE DIRECTORY DATA_PUMP_DIR AS 'E:\oradata\PSPRODDB\data_pump_dir';

GRANT READ, WRITE ON DIRECTORY DATA_PUMP_DIR TO PS;

exit

replace the .dmp file in data_pump_dir

SYS@PSPRODDB AS SYSDBA>Import.bat PRODDB EXPDP_FULLDB Y

Start Power Teacher Services

Start Report Works Services


To reset user Passowrd

SYS@PSPRODDB AS SYSDBA>ALTER USER PS IDENTIFIED BY edurite;

User altered.

SYS@PSPRODDB AS SYSDBA>ALTER USER PS_MGMT IDENTIFIED BY edurite;

User altered.


To Unlock the user Accounts

SYS@PSPRODDB AS SYSDBA>ALTER USER PS_MGMT IDENTIFIED BY edurite ACCOUNT UNLOCK;

User altered.

SYS@PSPRODDB AS SYSDBA>ALTER USER PS IDENTIFIED BY edurite ACCOUNT UNLOCK;

User altered.



Backup Oracle Database in Windows Server


Start cmd

sqlplus / as sysdba

SYS@PRODDB AS SYSDBA>CREATE OR REPLACE DIRECTORY DATA_PUMP_DIR1 AS 'E:\Oracle_Backup';

Create Oracle_Backup directory if necessary.

E:\oracle\product\11.2.0\dbhome_1\BIN>expdp.exe '/ as sysdba' full=y directory=DATA_PUMP_DIR1 dumpfile=expdp_fulldb.dmp logfile=expdp_fulldb.log


Tuesday, 15 April 2014

httpd and php Installation in RHEL 6

httpd 2.2.15-30 and php 5.5.9-1 Installation in RHEL 6

2.6.32-431.3.1.el6.x86_64

yum install httpd

rpm -qa | grep httpd
httpd-tools-2.2.15-30.el6_5.x86_64
httpd-2.2.15-30.el6_5.x86_64

vi /etc/httpd/conf/httpd.conf
AllowOverride All

http://rpm.pbone.net/
search php55w-common-5.5.9-1.w6

wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-cli-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-common-5.5.9-1.w6.x86_64.rpm

rpm -ivh php55w-common-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-cli-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-5.5.9-1.w6.x86_64.rpm

wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-mcrypt-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-soap-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-pecl-apcu-devel-4.0.3-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-opcache-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-bcmath-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-mysqlnd-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-odbc-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-xml-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-pecl-apcu-4.0.3-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-pecl-memcache-3.0.8-2.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-pdo-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-mbstring-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-xmlrpc-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-devel-5.5.9-1.w6.x86_64.rpm
wget ftp://ftp.pbone.net/mirror/repo.webtatic.com/yum/el6/x86_64/php55w-pecl-xdebug-2.2.3-2.w6.x86_64.rpm
wget ftp://ftp.uni-bayreuth.de/pub/redhat.com/fedora/linux/releases/10/Everything/ppc/os/Packages/php-pear-1.7.2-2.fc10.noarch.rpm

rpm -ivh php55w-bcmath-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-mbstring-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-pdo-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-mysqlnd-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-soap-5.5.9-1.w6.x86_64.rpm
rpm -ivh php55w-xmlrpc-5.5.9-1.w6.x86_64.rpm

yum install autoconf automake pcre-devel
rpm -ivh php55w-devel-5.5.9-1.w6.x86_64.rpm


wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/csbuild:/centosextra/RHEL_5/x86_64/libtool2-ltdl-2.2.6b-3.4.x86_64.rpm
wget ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm

rpm -ivh libmcrypt-2.5.8-9.el6.x86_64.rpm
rpm -ivh libtool2-ltdl-2.2.6b-3.4.x86_64.rpm

rpm -ivh php55w-mcrypt-5.5.9-1.w6.x86_64.rpm

wget ftp://ftp.muug.mb.ca/mirror/centos/6.5/os/x86_64/Packages/unixODBC-2.2.14-12.el6_3.x86_64.rpm

rpm -ivh unixODBC-2.2.14-12.el6_3.x86_64.rpm
rpm -ivh php55w-odbc-5.5.9-1.w6.x86_64.rpm

wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/tsariounov:/tools/RedHat_RHEL-6/x86_64/libxslt1-1.1.28-66.1.x86_64.rpm
rpm -ivh libxslt1-1.1.28-66.1.x86_64.rpm
rpm -ivh php55w-xml-5.5.9-1.w6.x86_64.rpm

wget ftp://ftp.icm.edu.pl/vol/rzm2/linux-fedora-secondary/archive/development/ia64/os/Packages/php-pear-1.7.2-2.fc10.noarch.rpm
rpm -ivh php-pear-1.7.2-2.fc10.noarch.rpm

rpm -ivh php55w-pecl-apcu-4.0.3-1.w6.x86_64.rpm
rpm -ivh php55w-pecl-apcu-devel-4.0.3-1.w6.x86_64.rpm
rpm -ivh php55w-pecl-memcache-3.0.8-2.w6.x86_64.rpm
rpm -ivh php55w-pecl-xdebug-2.2.3-2.w6.x86_64.rpm

rpm -ivh php55w-opcache-5.5.9-1.w6.x86_64.rpm

pear list

Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.3.7   stable
Console_Getopt   1.2.3   stable
PEAR             1.9.4   stable
Structures_Graph 1.0.4   stable
XML_RPC          1.5.4   stable
XML_Util         1.2.1   stable

pear install Auth_SASL Config Log MDB2 MDB2_Driver_mysqli Mail Mail_Mime Mail_mimeDecode Net_SMTP Net_Socket XML_Parser

pear list

Installed packages, channel pear.php.net:
=========================================
Package            Version State
Archive_Tar        1.3.2   stable
Auth_SASL          1.0.6   stable
Config             1.10.12 stable
Console_Getopt     1.2.3   stable
Log                1.12.7  stable
MDB2               2.4.1   stable
MDB2_Driver_mysqli 1.4.1   stable
Mail               1.2.0   stable
Mail_Mime          1.8.8   stable
Mail_mimeDecode    1.5.5   stable
Net_SMTP           1.6.2   stable
Net_Socket         1.0.14  stable
PEAR               1.7.2   stable
Structures_Graph   1.0.2   stable
XML_Parser         1.3.4   stable
XML_RPC            1.5.1   stable
XML_Util           1.2.1   stable

vi /var/www/html/index.php

<?php
 phpinfo();
?>

:wq

/etc/init.d/httpd restart

Now browse on any web browser with IP



Monday, 14 April 2014

Grant usage for a specific user in MySQL


Grant usage for a specific user

mysql -u root -p
Enter password:

mysql> use mysql;

mysql> grant all on *.* to 'username'@'%' identified by 'password';

mysql> flush privileges;


Wednesday, 9 April 2014

sar command in Linux


sar - Collect, report, or save system activity information.

yum install sysstat

cd /var/log/sa

sar

Linux 2.6.18-238.9.1.el5         04/09/2014

04:40:01 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
04:50:01 AM       all      9.93      0.00      1.04      1.02      0.00     88.01
05:00:01 AM       all      8.56      0.00      0.79      1.07      0.00     89.58
05:10:01 AM       all      6.81      0.00      0.65      1.18      0.00     91.36
05:20:01 AM       all      7.63      0.10      0.68      0.91      0.00     90.69
05:30:01 AM       all      6.95      0.00      0.64      0.79      0.00     91.62
05:40:01 AM       all     10.36      0.00      0.83      0.97      0.00     87.83
05:50:01 AM       all      9.30      0.00      0.82      0.92      0.00     88.96
06:00:01 AM       all      9.34      0.00      0.81      0.90      0.00     88.95
06:10:01 AM       all     12.96      0.00      0.81      0.81      0.00     85.43
06:20:01 AM       all     11.03      0.10      1.03      0.58      0.00     87.27
06:30:01 AM       all     12.49      0.00      1.10      0.70      0.00     85.72
06:40:01 AM       all      9.44      0.00      0.82      0.66      0.00     89.07
06:50:01 AM       all      9.09      0.00      0.79      0.56      0.00     89.56
07:00:01 AM       all     10.42      0.00      0.93      0.61      0.00     88.04
07:10:01 AM       all     10.75      0.00      0.91      0.63      0.00     87.71
Average:             all      9.67      0.01      0.84      0.82      0.00     88.65


             %user
                     Percentage of CPU utilization that occurred while execut-
                     ing at the user level (application).

              %nice
                     Percentage of CPU utilization that occurred while execut-
                     ing at the user level with nice priority.

              %system
                     Percentage of CPU utilization that occurred while execut-
                     ing at the system level (kernel).

              %iowait
                     Percentage of time that the CPU or CPUs were idle  during
                     which the system had an outstanding disk I/O request.

              %idle
                     Percentage of time that the CPU or CPUs were idle and the
                     system did not have an outstanding disk I/O request.

Ref:- http://www.linuxcommand.org/man_pages/sar1.html

Friday, 4 April 2014

MySQL 5.6 Installation in RHEL 6


Download the rpm's to the /usr/local/src

wget https://downloads.skysql.com/archives/mysql-5.6/MySQL-client-5.6.12-1.el6.x86_64.rpm
wget https://downloads.skysql.com/archives/mysql-5.6/MySQL-server-5.6.12-1.el6.x86_64.rpm
wget https://downloads.skysql.com/archives/mysql-5.6/MySQL-shared-compat-5.6.12-1.el6.x86_64.rpm
wget https://downloads.skysql.com/archives/mysql-5.6/MySQL-devel-5.6.12-1.el6.x86_64.rpm
wget https://downloads.skysql.com/archives/mysql-5.6/MySQL-shared-5.6.12-2.el6.x86_64.rpm

rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps

rpm -ivh MySQL-client-5.6.12-1.el6.x86_64.rpm MySQL-devel-5.6.12-1.el6.x86_64.rpm MySQL-server-5.6.12-1.el6.x86_64.rpm MySQL-shared-5.6.12-2.el6.x86_64.rpm MySQL-shared-compat-5.6.12-1.el6.x86_64.rpm

/etc/init.d/mysql restart
Shutting down MySQL..                                      [  OK  ]
Starting MySQL.                                            [  OK  ]

Ref :- https://downloads.skysql.com/archive/index/p/mysql/v/5.6.12

Thursday, 3 April 2014

Display recently modified files in Linux


Display Today’s modified Files in Linux

ls -al --time-style=+%D | grep `date +%D`
find . -maxdepth 1 -mtime -1
find . -mtime -1 -print
find . -mtime -1 -printf "%u %p\n" | sort

Display recently modified file in present working directory

find -maxdepth 1 -type f -mtime -1
find -maxdepth 1 -type f -daystart -mtime -1
find "pwd" -mtime -1 -type f -print
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r


Display recently modified directory in present working directory

find -maxdepth 1 -type d -mtime -1
find -maxdepth 1 -type d -daystart -mtime -1
find "pwd" -mtime -1 -type d -print
find . -type d -printf '%TY-%Tm-%Td %TT %p\n' | sort -r


Wednesday, 2 April 2014

Installing PHPUnit in RHEL


 wget https://phar.phpunit.de/phpunit.phar

 chmod +x phpunit.phar

 mv phpunit.phar /usr/local/bin/phpunit

Friday, 28 March 2014

Script for disc space alert in Linux


#!/bin/bash

#admin email account
ADMIN="mymailid@domain.com"

# set usage alert threshold
THRESHOLD=95

#hostname
HOSTNAME=$(hostname)

#mail client
MAIL=/bin/mail

# store all disk info here
EMAIL=""

for line in $(df -hP | egrep '^/dev/' | awk '{ print $6 "_:_" $5 }')
do

        part=$(echo "$line" | awk -F"_:_" '{ print $1 }')
        part_usage=$(echo "$line" | awk -F"_:_" '{ print $2 }' | cut -d'%' -f1 )

        if [ $part_usage -ge $THRESHOLD -a -z "$EMAIL" ];
        then
                EMAIL="$(date): Running out of diskspace on $HOSTNAME\n"
                EMAIL="$EMAIL\n$part ($part_usage%) >= (Threshold = $THRESHOLD%)"

        elif [ $part_usage -ge $THRESHOLD ];
        then
                EMAIL="$EMAIL\n$part ($part_usage%) >= (Threshold = $THRESHOLD%)"
        fi
done

if [ -n "$EMAIL" ];
then
        echo -e "$EMAIL" | $MAIL -s "Alert: Partition(s) almost out of diskspace on $HOSTNAME" "$ADMIN"
fi

Script to Delete file older than 30 days in Linux


#! /bin/bash
find /backup/mysql/* -type f -mtime +30 -exec rm {} \;



Thursday, 27 March 2014

Determine the File System type in Linux


blkid /dev/sda1

blkid -t TYPE=ext4

sudo parted -l

file -s /dev/sda1

tune2fs -l /dev/sda1 | grep features

df -T

mount

cat /proc/mounts

cd /proc/fs and ls

cd /sys/fs and ls

cat /etc/fstab

dumpe2fs /dev/sdb1 | head -15 -- has_journal means it is ext3.

dumpe2fs /dev/sdb1 | head -15 -- has_journal means it is ext4.

Ref : - http://unix.stackexchange.com/questions/60723/how-do-i-know-if-a-partition-is-ext2-ext3-or-ext4

Thursday, 6 March 2014

Listing only Directory in Linux


The following commands will list all of the sub directories in the present directory,



ls -d */ | xargs -l basename

ls -d */ | cut -d/ -f1

ls -d */ | cut -f1 -d'/'

ls -p | grep "/" | cut -f1 -d'/'


echo */ | cut -f1 -d'/'


find . -maxdepth 1 -mindepth 1 -type d -printf %P\\n

find . -mindepth 1 -maxdepth 1 -type d  \( ! -iname ".*" \) | sed 's|^\./||g'

find [!.]* -maxdepth 0 -type d


for f in *;do if [[ -d $f  ]]; then echo $f;fi; done;


Thursday, 20 February 2014

Cygwin


Cygwin is a Unix-like environment and command-line interface for Microsoft Windows.
Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment.
Thus it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.


Ref: http://en.wikipedia.org/wiki/Cygwin
http://cygwin.com/install.html

Jenkins On RedHat

Jenkins Prerequisites

httpd
subversion
java

Installation
Add the Jenkins repository to the yum repos, and install Jenkins from here.
Installation of a stable version
Installation of Java
Jenkins requires Java in order to run, yet certain Fedora-based distros don't include this by default. To install the Open Java Development Kit (OpenJDK) run the following:
sudo yum install java

Start/Stop
 
  • sudo service jenkins start/stop/restart
  • sudo chkconfig jenkins on
What does this package do?
  • Jenkins will be launched as a daemon up on start. See /etc/init.d/jenkins for more details.
  • The 'jenkins' user is created to run this service. If you change this to a different user via the config file, you must change the owner of /var/log/jenkins, /var/lib/jenkins, and /var/cache/jenkins.
  • Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
  • /etc/sysconfig/jenkins will capture configuration parameters for the launch.
  • By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.  Note that the built-in firewall may have to be opened to access this port from other computers.  (See http://www.cyberciti.biz/faq/disable-linux-firewall-under-centos-rhel-fedora/ for instructions how to disable the firewall permanently)
  • A Jenkins RPM repository is added in /etc/yum.repos.d/jenkins.repo

IPtables and SELinux

sudo iptables –L
getenforce
Disabled

Port Listen Test

sudo netstat -tnlp | grep 8080
sudo netstat –tulpen
sudo lsof -i :8080

Run Jenkins

sudo locate jenkins.war
sudo java -jar /usr/lib/jenkins/jenkins.war

sudo ps -u jenkins
 PID TTY          TIME CMD
22623 ?        00:00:17 java

Error

WARNING: FAILED SelectChannelConnector@0.0.0.0:8080: java.net.BindException: Address already in use.
sudo netstat -tnlp | grep 8080
sudo ps -u jenkins
Check the firewall and network configuration, proxy or your antivirus etc.

Packages Installed

sudo rpm -qa | grep httpd
httpd-tools-2.2.15-29.el6_4.x86_64
httpd-2.2.15-29.el6_4.x86_64

sudo rpm -qa | grep subversion
subversion-1.6.11-9.el6_4.x86_64

sudo rpm -qa | grep java
tzdata-java-2013i-1.el6.noarch
java-1.7.0-openjdk-1.7.0.45-2.4.3.4.el6_5.x86_64

sudo rpm -qa | grep jenkins
jenkins-1.551-1.1.noarch

Ref:

Tuesday, 18 February 2014

Open Soruce Distributions and Applications of the Year 2013


Desktop Distribution - Ubuntu
Server Distribution - Slackware
Mobile Distribution - Android
Database - MariaDB
NoSQL Database - MongoDB

Office Suite - LibreOffice
Browser - Firefox
Desktop Environment - KDE
Window Manager - Openbox
Messaging Application - Pidgin

VoIP Application - Skype
Virtualization Product - VirtualBox
Audio Media Player Application - VLC
Video Media Player Application - VLC
Graphics Application - GIMP

Network Security Application - Wireshark
Host Security Application - SELinux
Network Monitoring Application - Nagios Core
IDE/Web Development Editor - Eclipse
Text Editor - vim

File Manager - Dolphin
Open Source Game - 0 A.D.
Programming Language - Python
Revision Control System - git
Backup Application - rsync

Open Source CMS/Blogging platform - Wordpress
Configuration Management Tool - Puppet
Open Source Web Framework - Django
X Terminal Emulator - Konsole
Privacy Solution - Adblock

Ref : www.linuxquestions.org

Friday, 31 January 2014

Recover MySQL root password


Stop the MySQL server process
 
/etc/init.d/mysql stop

Start again with no grant tables
 
mysqld_safe --skip-grant-tables &

Login to MySQL as root
 
mysql -u root

Set new password
 
mysql> use mysql;
mysql> update user set password=PASSWORD("password") where User='username';
mysql> flush privileges;

Exit MySQL and restart MySQL server

mysql> quit
/etc/init.d/mysql stop
/etc/init.d/mysql start

Set root password if there is no root password
OR
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
 
mysql>SET PASSWORD = PASSWORD('new_password');

Allow the user to connect to the server from localhost using the password

mysql>grant usage on *.* to 'username'@'%' identified by 'password';


Wednesday, 15 January 2014

Open Soruce Distributions and Applications

 Open-Source Software (OSS) is computer software with its source code made available and licensed with a license in which the copyright holder provides the rights to study, change and distribute the software to anyone and for any purpose. Open-source software is very often developed in a public, collaborative manner. Open-source software is the most prominent example of open-source development and often compared to user-generated content or open-content movements.

1. Desktop Distribution

Arch
Bodhi
Chakra
CrunchBang
Debian
Fedora
Fuduntu
Gentoo
Linux Mint
Mageia
Mandriva
Manjaro
MEPIS
openSuse
PClinuxOS
Puppy
Sabayon
Salix
Slackware
SolusOS
SparkyLinux
SUSE Linux
Ubuntu
VectorLinux
Zorin OS

2. Browser

Chrome
Chromium
Conkeror
Dillo
dwb
Epiphany
Firefox
Konqueror
links/elinks
Luakit
lynx
Midori
Opera
QupZilla
rekonq
SeaMonkey
SlimBoat
Uzbl
w3m

3. Open Source Web Framework

Apache Wicket
CakePHP
Cappuccino
CodeIgniter
Django
Express
Flask
Grails
Pyramid
Ruby on Rails
Sinatra
Spring
Struts
Symfony
web2py
Yii
Zend Framework
mojolicious
Laravel

4. IDE/Web Development Editor


Anjuta
Aptana Studio
Bluefish
Code::Blocks
Eclipse
Emacs
eric
Geany
IDLE
Kdevelop
Komodo
Kompozer
Lazarus
Leo
MonoDevelop
Netbeans
Qt Creator
Quanta
Quanta Plus
SeaMonkey Composer
Zend Studio

5. Audio Media Player Application

amaroK
Aqualung
aTunes
Audacious
Banshee
Clementine
cmus
DeaDBeef
Exaile
gmusicbrowser
MOC
MPD
mpg123
mpg321
Nightingale
Pogo
Quod Libet
RhythmBox
Sonata
VLC
XMMS
XMMS2

6. Video Media Player Application

Dragon Player
DVD-Player (XBMC)
FFplay
kaffeine
Miro
mplayer
mplayer2
Parole
Totem
VLC
xine

7. X Terminal Emulator

aterm
Eterm
GNOME Terminal
gtkterm
Guake
Konsole
Kuake
LilyTerm
LXTerminal
Roxterm
rxvt
Sakura
stjerm-terminal
Terminal (Xfce)
Terminator
Tilda
urxvt
xterm
Yakuake
Terminology
Termit

8. Mobile Distribution

Android
Chrome OS
CyanogenMod
Firefox OS
MeeGo
Mer
Replicant
Sailfish OS
Tizen
Ubuntu Phone
webOS

9. Programming Language

Ada
Assembly
AWK
C
C#
C++
Clojure
COBOL
Common Lisp
Erlang
Fortran
Free Pascal
Go
Haskell
Java
Javascript
Lua
Objective-C
Perl
PHP
Python
R
Ruby
Scala
Scheme
Tcl

10. Text Editor

Emacs
Geany
gedit
jEdit
joe
Kate
KWrite
leafpad
medit
Midnight Commander Editor
Mousepad
nano
Nedit
pico
RedCar
Scite
Scribes
vi
vim

11. Desktop Environment

Cinnamon
Gnome Shell
KDE
LXDE
MATE
Razor-qt
rox
Trinity-DE
Unity
Xfce

12. Virtualization Product

KVM
Linux-VServer
OpenVZ
Oracle VM
Parallels Workstation
QEMU
VirtualBox
VMware
Xen
LXC

13. File Manager

Caja
Dolphin
Double Commander
emelFM2
gentoo
Gnome Commander
Konqueror
Krusader
Midnight Commander
muCommander
Nautilus
Nemo
PCManFM
ranger
ROX-Filer
SpaceFM
Thunar
vifm
Worker
Xfe

14. Backup Application

AMANDA
Areca-Backup
Back In Time
BackupPC
Bacula
Clonezilla
cpio
Deja Dup
dump
Duplicity
FSArchiver
G4L
luckyBackup
partimage
rdiff-backup
Redo Backup and Recovery
rsnapshot
rsync
tar
Time Vault
Burp

15. Network Monitoring Application

Big Brother
Ganglia
GroundWork Monitor
Icinga
mon
monit
munin
Nagios Core
Nagios XI
NetXMS
OpenNMS
OpenQRM
Opsview
Shinken
Zabbix
Zenoss

16. Network Security Application

aircrack-ng
Bro IDS
ClamAV
dsniff
fail2ban
Firestarter
fwBuilder
Guarddog
kismet
Metasploit
Nessus
Nikto
Nmap Security Scanner
OpenVAS
p0f
Shorewall
snort
tcpdump
UFW/Gufw
Wireshark

17. Server Distribution

CentOS
Debian
Gentoo
Mandriva Enterprise Server
Oracle Enterprise Linux
Red Hat Enterprise Linux
Scientific Linux
Slackware
SUSE Linux Enterprise Server
Ubuntu LTS

18. Office Suite

Calligra
LibreOffice
OpenOffice.org

19. Window Manager

awesome
Compiz
dwm
Enlightenment
Fluxbox
FVWM
i3
IceWM
JWM
KWin
Marco
MetaCity
Mutter
Openbox
Ratpoison
Sawfish
spectrwm
Window Maker
wmii
xfwm4
xmonad
Notion
twm

20. Graphics Application

Art of Illusion
Blender
CinePaint
Darktable
GIMP
ImageMagick
Inkscape
Kolourpaint
Krita
LazPaint
LightZone
mtPaint
MyPaint
Pinta
RawTherapee
Scribus
Tux Paint
GrafX2
G'MIC

21. Open Source Game

0 A.D.
Armagetron Advanced
AssaultCube
Battle for Wesnoth
BZFlag
FlightGear
Freeciv
Frets On Fire
Frozen Bubble
GNU Chess
LBreakout2
MegaGlest
Minetest
NetHack
Neverball
Open Arena
OpenClonk
OpenTTD
Pingus
Pioneer
PokerTH
Red Eclipse
StepMania
SuperTux
SuperTuxKart
The Mana World
TORCS
Trigger Rally
Tux Racer
UFO: Alien Invasion
Ur Quan Masters
Warzone 2100
World of Padman
Xonotic
FreeOrion

22. Privacy Solution

Adblock Plus
Disconnect
Ghostery
GnuPG
NoScript
Privoxy
Tor Browser Bundle
TrueCrypt
LastPass
HTTPS Everywhere
PasswordMaker
DoNotTrackMe

23. Open Source CMS/Blogging platform

Alfresco
b2evolution
CMS Made Simple
Dotclear
DotNetNuke
Drupal
eZ Publish
Joomla!
MODx
Movable Type
Octopress
Plone
Roller
Serendipity
SilverStripe
Textpattern
TYPO3
WordPress
XOOPS
Ghost

24. VoIP Application

Blink Qt
Ekiga
Empathy
Jitsi
KPhone
Linphone
Mangler
Mumble
opensoftphone
QuteCom
SFLphone
Skype
TeamSpeak
Twinkle

25. Database

DB2
Drizzle
EnterpriseDB
Firebird
MariaDB
MySQL
Oracle
Percona
PostgreSQL
sqlite

26. Revision Control System

Bazaar
BitKeeper
CVS
Fossil
git
Mercurial
Perforce
Subversion

27. Messaging Application

aMSN
BitlBee
CenterIM
EKG2
Empathy
Finch
Gajim
Gwibber
Gyachi
Irssi
Jitsi
Kadu
KDE-Telepathy
KMess
konversation
Kopete
Pidgin
Psi
qutIM
WeeChat
XChat
Hexchat

28. Configuration Management Tool


Bcfg2
cdist
Cfengine
Chef
Puppet
Salt stack
Spacewalk
Ansible

29. Host Security Application

AIDE
AppArmor
Bastille
chkrootkit
grsecurity
Lynis
Osiris
OSSEC
Rootkit Hunter
Samhain
SELinux
TOMOYO
Tripwire

30. NoSQL Database

Cassandra
CouchDB
HBase
Hypertable
Membase Server
MongoDB
Redis
Riak
Voldemort
Neo4j
Couchbase

Ref:- http://www.linuxquestions.org


Friday, 3 January 2014

Immutable files in Linux

Chattr

chattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on many Linux filesystems.

touch filetest.txt

To display the attributes
lsattr filetest.txt
------------- filetest.txt

To set file attributes
chattr +i filetest.txt

lsattr filetest.txt
----i-------- filetest.txt

To test the functionality
mv filetest.txt file.txt
mv: cannot move `filetest.txt' to `file.txt': Operation not permitted

rm -rf filetest.txt
rm: cannot remove `filetest.txt': Operation not permitted

echo "HI" > filetest.txt
-bash: filetest.txt: Permission denied

To remove the immutable attribute
chattr -i filetest.txt
lsattr filetest.txt
------------- filetest.txt

To append operations
chattr +a filetest.txt
lsattr filetest.txt
-----a------- filetest.txt

test the functionality
rm -rf filetest.txt
rm: cannot remove `filetest.txt': Operation not permitted
mv filetest.txt file.txt
mv: cannot move `filetest.txt' to `file.txt': Operation not permitted
echo "replacing content" > filetest.txt
-bash: filetest.txt: Operation not permitted
echo "appending new content" >> filetest.txt
appending new content

To remove the immutable attribute
lsattr filetest.txt
------------- filetest.txt

How to Recursively change attributes of directories and their contents.

chattr -R +i test
lsattr test/filetest.txt
----i-------- test/filetest.txt

chattr -R -i test
lsattr test/filetest.txt
------------- test/filetest.txt

chattr -R +a test
lsattr test/filetest.txt
-----a------- test/filetest.txt
chattr -R -a test

Ref:- http://www.adminarticles.com/file-attributes/

Wednesday, 11 September 2013

Time Stamp of a file in Linux


Every Linux file is associated with timestamps, which specifies the last access time, last modification time and last change time.

To get the timestamp of a file "ls -l" and "stat".

1. Use -c option to avoid creating new files, but will change the timestamp by present time.

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-10-18 23:42:12.000000000 -0700
Modify: 2012-10-18 23:42:12.000000000 -0700
Change: 2013-09-11 08:49:16.509859887 -0700

touch -c tgs.txt

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-09-11 08:49:25.685239864 -0700
Modify: 2013-09-11 08:49:25.685239864 -0700
Change: 2013-09-11 08:49:25.685239864 -0700

2. Change File’s Access Time using -a.

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-09-11 08:10:44.783796541 -0700
Modify: 2013-09-11 08:10:44.783796541 -0700
Change: 2013-09-11 08:10:44.783796541 -0700

touch -a tgs.txt

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-09-11 08:13:14.824798981 -0700
Modify: 2013-09-11 08:10:44.783796541 -0700
Change: 2013-09-11 08:13:14.824798981 -0700

3. Change File’s Modification Time using -m.

touch -m *.o

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-09-11 08:13:14.824798981 -0700
Modify: 2013-09-11 08:10:44.783796541 -0700
Change: 2013-09-11 08:13:14.824798981 -0700

touch -m tgs.txt

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-09-11 08:13:14.824798981 -0700
Modify: 2013-09-11 08:16:36.600236392 -0700
Change: 2013-09-11 08:16:36.600236392 -0700

4. Modification time using -t and -d.

touch -t [CCYYMMDDHHMM.SS] filename

touch -t 201212312359.59 tgs.txt 
touch -a -m -t 201212312359.59 tgs.txt 

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-12-31 23:59:59.000000000 -0800
Modify: 2012-12-31 23:59:59.000000000 -0800
Change: 2013-09-11 08:30:24.706252619 -0700

touch -d "2012-10-19 12:12:12.000000000 +0530" tgs.txt

stat tgs.txt

  File: `tgs.txt'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 525402      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-10-18 23:42:12.000000000 -0700
Modify: 2012-10-18 23:42:12.000000000 -0700
Change: 2013-09-11 08:37:51.182799786 -0700

5. Copy the Time-stamp from Another File using -r.

ls -l
-rw-r--r--. 1 root root 0 Sep 11 08:43 test.txt
-rw-r--r--. 1 root root 0 Oct 19  2012 tgs.txt

touch test.txt -r tgs.txt

ls -l

-rw-r--r--. 1 root root 0 Oct 19  2012 test.txt
-rw-r--r--. 1 root root 0 Oct 19  2012 tgs.txt

ref: http://www.thegeekstuff.com/2012/11/linux-touch-command/

Executing Background Jobs in Linux

Manage Background Jobs in Linux

when you execute a find command that might take a lot time to execute, you can put it in the background as shown below.

Appending an ampersand ( & ) to the command runs the job in the background.

     find / -type f -mtime -1000 >> /root/filelist.log &

Sending the current foreground job to the background using Ctrl + Z.

     find / -type f -mtime -1000 >> /root/filelist.log
     Ctrl + Z
     bg

Taking a job from the background to the foreground.

     fg
     find / -type f -mtime -1000 >> /root/filelist.log
     Ctrl + Z

View all the background jobs.

     jobs

     [1]+  Stopped    find / -type f -mtime -1000 >> /root/filelist.log

Kill a specific background job.

     fg %1
     kill %1

ref: http://www.thegeekstuff.com/2010/05/unix-background-job/


Ganglia Monitoring System

Ganglia

Ganglia is a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.

Ganglia Installation and Configuration

yum -y install ganglia*

Edit gmetad.conf

vi /etc/ganglia/gmetad.conf

data_source "my cluster" localhost 192.168.1.100:8089

Edit ganglia.conf

vi /etc/httpd/conf.d/ganglia.conf

 Alias /ganglia /usr/share/ganglia
  <Location /ganglia>
     AllowOverride All
     DirectoryIndex index.php
  </Location>

Restart the services

/etc/init.d/httpd restart
/etc/init.d/gmetad restart
/etc/init.d/gmond restart

URL

 http://192.168.1.100/ganglia

ref: http://ganglia.sourceforge.net/


Saturday, 25 May 2013

Text Processing Tools in Linux

The following command are often used when writing scripts to automate tasks.

The diff command :- to compare the content of two files for differences.

diff file1.conf file2.conf > output.txt
cat output.txt
Options are -c, -u and -r.

The patch command :- ued to apply simple patch file to a single file.

patch -b file1.conf < output.txt

The grep command :- displays the lines in a files that match pattern.

grep root /etc/passwd
ps -aux | grep sshd
Options are -i, -n, -r, -c, -v and -l.

The cut command :- ued to cut fields or colomns of text from a file and display standard output.

cut -f3 -d: /etc/passwd
/sbin/ip addr | grep 'inet' | cut -d ' ' -f6 | cut -d / -f1
Options are -d, -f and -c.

The head command :- displays first few lines of a file.

head /etc/passwd
head -n 3 /etc/passwd
Options is -n.

The tail command :- displays last few lines of a file.

tail -n 3 /etc/passwd
tail -f /etc/passwd
tail -f will continue to show updates until Ctrl+c is pressed.

The wc command :- counts the number of lines(l), words(w), bytes(c) and characters(m) in a file.

wc -l file1.conf
ls /tmp | wc -l
Options are -l, -w, -c and -m.

The sort command :- used to sort text data.

grep bash /etc/passwd | cut -d: -f1 | sort
options are -n, -k and -t.

The uniq command :- removes duplicate adjacent lines from a file.

cut -d: -f7 /etc/passwd | sort | uniq -c
Options are -u and -d

The echo command :-  output strings.

echo This is a test.
echo This is a test. > output.txt
cat output.txt

The cat command :- output or concatenate files.

cat file1.conf > output.txt
cat output.txt
cat file1.conf file2.conf | less
Options are -b, -n, -s, -v, -t, -e and -A.

The paste command :- join multiple files horizontally.

paste file1.conf file2.conf
Options are -d and -s.

The split command :- split files based on context lines.

split -l 500 myfile segment
split -b 40k myfile segment
Options are -l (line no) and -b(bytes).

The comm command :- to compare two files for common and distinct lines.

comm file1.conf file2.conf

The dirname command :-  it will delete any suffix beginning with the last slash ('/') character and return the result.

dirname /etc/httpd/conf/httpd.conf

The fold command :- used for for making a file with long lines more readable on a limited width terminal.
fold -w 30 file.txt

The sed command :- reads text input, line by line, and allows midfication.

sed 'word;wordtoreplace' < file1.conf > output.txt
sed '/word/ d' filename > output.txt
sed 's/word/ /g' filename > output.txt
sed 's/firstword//g; s/secondword//g' yourfile > output.txt

The awk command :- used as a data extraction and reporting tool.

awk "/word/" filename > output.txt

The less command :- used to view the contents of a text file one screen at a time.

less /etc/passwd


Friday, 24 May 2013

How to scp, ssh and rsync without prompting for password


For example, login in to some host linux box as root 172.16.0.155 and pass the command as,

ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
35:50:28:70:2b:b0:9f:01:9a:8b:cb:0e:17:89:1d:a2 root@InVImFTSrv
The key's randomart image is:
+--[ RSA 2048]----+
|  o ... .o.      |
| o + .....       |
|+ o o ..  o      |
|o= + +   . .     |
|E + o   S        |
|.. .             |
|o..              |
|o.               |
| .               |
+-----------------+


now login to the host linux box as root 172.16.0.177 and copy,

scp -r root@172.16.0.155:/root/.ssh/id_rsa.pub /root/.ssh/

cd /root/.ssh/
cat id_rsa.pub >> authorized_keys
chmod 700 /root/.ssh/authorized_keys

now form 172.16.0.155 try ssh, scp or rsync as,

scp -r root@172.16.0.177:/usr/local/src/April /usr/local/src/

It won't prompt for any password.

Ref:-https://blogs.oracle.com/jkini/entry/how_to_scp_scp_and