Bash Shortcuts Quick Reference | |
Ctrl-a | Move to the start of the line. |
Ctrl-e | Move to the end of the line. |
Ctrl-b | Move back one character. |
Alt-b | Move back one word. |
Ctrl-f | Move forward one character. |
Alt-f | Move forward one word. |
Ctrl-] x | Where x is any character, moves the cursor forward to the next occurance of x. |
Alt-Ctrl-] x | Where x is any character, moves the cursor backwards to the previous occurance of x. |
Ctrl-u | Delete from the cursor to the beginning of the line. |
Ctrl-k | Delete from the cursor to the end of the line. |
Ctrl-w | Delete from the cursor to the start of the word. |
Esc-Del | Delete previous word (may not work, instead try Esc followed by Backspace) |
Ctrl-y | Pastes text from the clipboard. |
Ctrl-l | Clear the screen leaving the current line at the top of the screen. |
Ctrl-x Ctrl-u | Undo the last changes. Ctrl-_ does the same |
Alt-r | Undo all changes to the line. |
Alt-Ctrl-e | Expand command line. |
Ctrl-r | Incremental reverse search of history. |
Alt-p | Non-incremental reverse search of history. |
!! | Execute last command in history |
!abc | Execute last command in history beginning with abc |
!abc:p | Print last command in history beginning with abc |
!n | Execute nth command in history |
!$ | Last argument of last command |
!^ | First argument of last command |
^abc^xyz | Replace first occurance of abc with xyz in last command and execute it |
Monday, October 1, 2012
Bash Terminal shortcuts
Wednesday, September 26, 2012
LAMP installation and configuration
#Configuring LAMP-LINUX APACHE MYSQL PHP
#1.LINUX here i use machine preinstalled with rhel 6 desktop kde gnome packages
#installing the LAMP to /LAMP folder /LAMP/http /LAMP/mysql /LAMP/php
#First remove the installed packages
#yum erase http*
#yum erase mysql*
yum erase php*
#installing and configuring APACHE----
#The Package we use are httpd-2.4.3.tar.gz
-->tarxvf httpd-2.4.3.tar.gz
-->cd httpd-2.4.3
-->./configure --prefix=/LAMP/http/ --enable-module=so
#Now an error will occur asking for apr version-1.4 or greater
#Download the apr from http://apr.apache.org/download.cgi
#here i use apr-1.4.6.tar.gz apr-util-1.4.1.tar.gz
-->tar xvf apr-1.4.6.tar.gz
-->tar xvf apr-util-1.4.1.tar.gz
-->mv apr-1.4.6 /lamp/http/httpd-2.4.3/srclib/apr
-->mv apr-util-1.4.1 /lamp/http/httpd-2.4.3/srclib/apr-util
-->./configure --prefix=/LAMP/http/ --enable-module=so--enable-rewrite=shared --with-included-apr
##now if it will ask for pcre packages
-->yum install -y pcre*
-->./configure --prefix=/LAMP/http/ --enable-module=so--enable-rewrite=shared --with-included-apr
-->make
-->make install
-->ls /LAMP/http
#lists the installed files
#to start and stop the service
-->/LAMP/http/bin/apachectl start
-->/LAMP/http/bin/apachectl stop
#
#MYSQL
#
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
#Package- mysql-5.5.16.tar.gz
-->tar -xvf mysql-5.5.16.tar.gz
-->cd mysql-5.5.16
-->yum install make
-->yum install cmake
-->cmake -DCMAKE_INSTALL_PREFIX=/LAMP/mysql
-->yum install -y *curses*
-->cmake -DCMAKE_INSTALL_PREFIX=/LAMP/mysql
-->rm -rf CMakeCache.txt
-->cmake -DCMAKE_INSTALL_PREFIX=/LAMP/mysql
-->yum install bison
-->cmake -DCMAKE_INSTALL_PREFIX=/LAMP/mysql
-->rm -rf CMakeCache.txt
-->cmake -DCMAKE_INSTALL_PREFIX=/LAMP/mysql
-->make
-->make install
-->updatedb
-->locate mysql_install_db
-->cd /LAMP/mysql/
-->./scripts/mysql_install_db
-->./scripts/mysql_install_db --user mysql
-->cat /etc/ld.so.conf
-->echo "/LAMP/mysql/lib/" >> /etc/ld.so.conf
--->cat /etc/ld.so.conf
-->ldconfig
-->cd /LAMP/
-->cd mysql/
-->ls
-->cp support-files/mysql.server /etc/rc.d/init.d/mysql
-->/etc/rc.d/init.d/mysql start
-->touch /tmp/mysql.sock
-->chown mysql:mysql /tmp/mysql.sock
-->./support-files/my-medium.cnf /etc/my.cnf
##in case of any error like cannot manage pid file etc do as following
-->/LAMP/mysql/scripts/mysql_install_db --user=mysql --ldata=/LAMP/mysql/data
-->/LAMP/mysql/bin/mysqld_safe --datadir=/LAMP/mysql/data --user-mysql
#that should solve the error
testing
mysqladmin -u root password new-password
mysql -u root -p
mysql>
drop database test;
use mysql;
delete from db;
delete from user where not (host="localhost" and user="root");
flush privileges;
update user set user="sqladmin" where user="root";
flush privileges;
create database foo;
You should see the result:
Query OK, 1 row affected (0.04 sec)
mysql>
Delete the database:
drop database foo;
You should see the result:
Query OK, 0 rows affected (0.06 sec)
mysql>
To exit from mysql enter \q:
\q
#
#PHP
#
#Package php-5.4.7.tar.gz
-->tar xvf php-5.4.7.tar.gz
-->cd php-5.4.7
-->./configure --prefix=/LAMP/php/ --with-zlibs-dir=/usr/lib --with-xml --enable-mm=shared --with-apxs=/LAMP/http/bin/apxs
-->./configure --prefix=/LAMP/php/ --with-zlibs-dir=/usr/lib --with-xml --enable-mm=shared --with-apxs2=/LAMP/http/bin/apxs
-->yum install libxml
-->yum install libxml*
-->./configure --prefix=/LAMP/php/ --with-zlibs-dir=/usr/lib --with-xml --enable-mm=shared --with-apxs2=/LAMP/http/bin/apxs
-->make
-->232 make test
-->make install
-->cp php.ini-development /LAMP/php/lib/php.ini
-->ln -s /LAMP/php/lib/php.ini /etc/php.ini
#
#Adding php to apache
#
-->vim /LAMP/http/conf/httpd.conf
#To ensure your PHP files are properly interpreted add in httpd.conf
------AddType application/x-httpd-php .php
------AddType application/x-httpd-php-source .phps
------AddType application/x-tar .tgz
-->/LAMP/http/bin/apachectl restart
-->/LAMP/http/bin/apachectl start
-->touch /LAMP/http/htdocs/index.php
-->rm -rf /LAMP/http/htdocs/index.html
-->/LAMP/http/bin/apachectl restart
Tuesday, September 25, 2012
Amanda 3.3 configuration in Rhel 6
#first configure dhcp and dns before this
#packages needed are amanda and xinetd
#steps are
#1.setting up the server
#2.setting up the client
#3.verifying the connection
#4.taking the backup
#5.recovering the backup
#package installations
#xinetd packages are available in the package set of the os cd/DVD
#you can get the amanda server and client rpm from Following link
http://www.zmanda.com/downloads/community/Amanda/3.3.2/Redhat_Enterprise_6.0/
#there will be two files one for server and another for client
#amanda-backup_server-3.3.2-1.rhel6.x86_64.rpm
#amanda-backup_client-3.3.2-1.rhel6.x86_64.rpm
#1.setting up the server
#->install the rpm
-------->yum -y install amanda-backup-server-3.3.2-1.rhel6.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
Setting up Install Process
Examining /root/Downloads/amanda-backup_server-3.3.2-1.rhel6.x86_64.rpm: amanda-backup_server-3.3.2-1.rhel6.x86_64
Marking /root/Downloads/amanda-backup_server-3.3.2-1.rhel6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package amanda-backup_server.x86_64 0:3.3.2-1.rhel6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================
Package Arch Version Repository Size
=========================================================
Installing:
amanda-backup_server
x86_64 3.3.2-1.rhel6 /amanda-backup_server-3.3.2-1.rhel6.x86_64 8.8 M
Transaction Summary
===========================================================
Install 1 Package(s)
Total size: 8.8 M
Installed size: 8.8 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : amanda-backup_server-3.3.2-1.rhel6.x86_64 1/1
Amanda installation log can be found in '/var/log/amanda/install.log'.
duration: 196(ms)
Installed products updated.
Installed:
amanda-backup_server.x86_64 0:3.3.2-1.rhel6
Complete!
#-------->set password for the amandabackup user
passwd amandabackup
****
****
#Create a directory for our vtapes, and set its ownership and permissions:
mkdir -p /data/amanda/vtape/DailySet1
chown amandabackup:disk /data/amanda/vtape/DailySet1
chmod -R 750 /data/amanda/vtape/DailySet1
# Change to the amandabackup user:
su – amandabackup
# As amandabackup user, run amserverconfig to create a vtape configuration:
#the backup will be at /data/amanda/vtape/DailySet1
-bash-4.1$ amserverconfig DailySet1 –template harddisk –tapedev /data/amanda/vtape/DailySet1 –mailto root@localhost –dumpcycle 1week –runspercycle 5 –tapecycle 12 –runtapes 1
Logging to /var/log/amanda/amserverconfig.20120925120547.debug
mkdir /etc/amanda/DailySet1
mkdir /etc/amanda/template.d
/etc/amanda/template.d directory created
/var/lib/amanda/gnutar-lists directory exists
/etc/amanda/DailySet1/advanced.conf created and updated
mkdir /etc/amanda/DailySet1/curinfo
mkdir /etc/amanda/DailySet1/index
curinfo and index directory created
tapelist file created
disklist file created
Creating custom configuration using templates
custom amanda.conf created
creating vtape directory
amlabel vtapes
mkdir slot1
mkdir slot11
mkdir slot12
changer is reset
/var/lib/amanda/example/xinetd.amandaserver contains the latest Amanda server daemon configuration.
Please merge it to /etc/xinetd.d/amandaserver.
/var/lib/amanda/.ssh/client_authorized_keys created. Please append to /var/lib/amanda/.ssh/authorized_keys file on Amanda clients
DONE.
--------->cp /var/lib/amanda/example/xinetd.amandaserver /etc/xinetd.d/amandaserver
###
#####Go to client machine and install client rpm
####
---->>yum -y install amanda-backup_client-3.3.2-1.rhel6.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
Setting up Install Process
Examining /root/Downloads/amanda-backup_client-3.3.2-1.rhel6.x86_64.rpm: amanda-backup_client-3.3.2-1.rhel6.x86_64
Marking /root/Downloads/amanda-backup_client-3.3.2-1.rhel6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package amanda-backup_client.x86_64 0:3.3.2-1.rhel6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================
Package Arch Version Repository Size
========================================================
Installing:
amanda-backup_client
x86_64 3.3.2-1.rhel6 /amanda-backup_client-3.3.2-1.rhel6.x86_64 8.2 M
Transaction Summary
===================================================
Install 1 Package(s)
Total size: 8.2 M
Installed size: 8.2 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : amanda-backup_client-3.3.2-1.rhel6.x86_64 1/1
Non-fatal POSTIN scriptlet failure in rpm package amanda-backup_client-3.3.2-1.rhel6.x86_64
Amanda installation log can be found in '/var/log/amanda/install.log'.
warning: %post(amanda-backup_client-3.3.2-1.rhel6.x86_64) scriptlet failed, exit status 4
uration: 1112(ms)
Installed products updated.
Installed:
amanda-backup_client.x86_64 0:3.3.2-1.rhel6
Complete!
#------------>set password for amandabackup
passwd amandabackup
* * *
* * *
##To recover on a Linux client, you must first specify the tape device on the server to use. In each Linux clients we change the file /etc/amanda/amanda-client.conf. Change this line:
tapedev “tape:/dev/YOUR-TAPE-DEVICE-HERE” # your tape device
to this:
tapedev “file://data/amanda/vtape/DailySet1″ # your tape device
#---------->add the amanda server to clients /etc/hosts
192.168.122.1 server.example.com
###NOW got to server and add the client
##at server.example.com
#we are going to add the client 192.168.122.99 to backup the /root for #client to DailySet1 tapes
----->-bash-4.1$ amaddclient --config DailySet1 --client 192.168.122.99 --diskdev /root --dumptype comp-user-tar
Logging to /var/log/amanda/amaddclient.20120925122047.debug
/etc/amanda/DailySet1/disklist updated
updating /var/lib/amanda/.amandahosts on server.example.com
Attempting to update /var/lib/amanda/.amandahosts on 192.168.122.99
#The authenticity of host '192.168.122.99 (192.168.122.99)' cant be established.
RSA key fingerprint is a3:be:8d:07:a8:f8:0b:af:25:bb:a5:b2:57:55:c5:14.
Are you sure you want to continue connecting (yes/no)? yes
#Warning: Permanently added '192.168.122.99' (RSA) to the list of known hosts.
#amandabackup@192.168.122.99's password:
amandahosts 100% 72 0.1KB/s 00:00
#amandabackup@192.168.122.99's password:
amandahosts.tmp 100% 112 0.1KB/s #00:00
192.168.122.99:/var/lib/amanda/.amandahosts updated successfully
#Creating amanda-client.conf for 192.168.122.99
Creating /etc/amanda/DailySet1 on 192.168.122.99
#amandabackup@192.168.122.99's password:
#amandabackup@192.168.122.99's password:
amanda-client.conf-192.168.122.99 100% 388 0.4KB/s 00:00
Copy /var/lib/amanda/amanda-client.conf-192.168.122.99 to 192.168.122.99 successfully
File /var/lib/amanda/example/xinetd.amandaclient contains the latest Amanda client daemon configuration.
Please merge it to /etc/xinetd.d/amandaclient.
------>cp /var/lib/amanda/example/xinetd.amandaclient /etc/xinetd.d/amandaclient
##adding client to servers amandahost
---->echo "client99.example.com root amindexd amidxtaped" >> /var/lib/amanda/.amandahosts
##adding cliennt to servers /etc/hosts
--->echo "192.168.122.99 client99.example.com" >> /etc/hosts
##
##
##Verifying the connection
##
---->-bash-4.1$ amcheck DailySet1
Amanda Tape Server Host Check
-----------------------------
found in slot 1: volume 'DailySet1-1'
slot 1: volume 'DailySet1-1'
Will write to volume 'DailySet1-1' in slot 1.
NOTE: skipping tape-writable test
NOTE: host info dir /etc/amanda/DailySet1/curinfo/192.168.122.99 does not exist
NOTE: it will be created on the next run.
NOTE: index dir /etc/amanda/DailySet1/index/192.168.122.99 does not exist
NOTE: it will be created on the next run.
Server check took 0.189 seconds
Amanda Backup Client Hosts Check
---------------------------------
Client check: 1 host checked in 2.101 seconds. 0 problems found.
(brought to you by Amanda 3.3.2)
##if its 0 problem found then its correct
####taking the backup
-bash-4.1$ amdump DailySet1
##it will be at /data/amanda/vtape/DailySet1/
###
###to recove a file
###
#adding client to servers amandahosts
--->echo "client99.example.com root amindexd amidxtaped" >> /var/lib/amanda/.amandahosts
###got to client
# backup will be at /data/amanda/vtape/DailySet1/
as user root
--->>
---->> amrecover DailySet1
AMRECOVER Version 3.1.0. Contacting server on server.example.com …
#to list the back up
amrecover> listdisk
#use set disk to load the folder
amrecover> setdisk /srv/www/htdocs/
# list the file
amrecover> ls
#add the needed file
amrecover> add *
#extract the added files
amrecover> extract
#exiting
amrecover> exit
200 Good bye.