This is dedicated to the linux users, system admins, open source enthusiastic, techs whoever is looking for solution, tricks & concept etc. Reader will apply concept or execute command at their own risk. Owner of these article is not responsible for any impact, damages or errors.
Thursday, April 29, 2010
Install xen virtual server on linux platform
.1 xenserver# rpm -qa |grep xen
xen-libs-3.1.0-13.el5
xen-3.1.0-13.el5
xenserver #rpm -qa |grep kernel-xen
kernel-xen-2.6.21-2950.el5
xenserver-dev #rpm –qa |fgrep virt-manager //for GUI
virt-manager-0.5.2-2.el5
Install :
1.
xenserver# yum install xen
xenserver # yum install kernel-xen
xenserver # yum install virt-manager
2. Edit default=1 in /boot/grub/grub.conf and make sure xen kernel will load.
3. Reboot system : [root@xenserver]# init 6
4. check kernel :
[root@xenserver]# uname -r
2.6.21-2950.el5xen
=====
To check if Xen is running use xm from command line:
[root@xensever]# xm list
Now you can create Xen virtual machines using Xen command lines or xen GUI (virt-manager):
[xenserver@ldev ~]# virt-manager
What is Ruby on Rails? Install on linux plat form
Ruby is a programming language just like Perl, Python or PHP. Rails is an open source Ruby framework for developing database-backed web applications. You could develop a web application at least ten times faster with Rails than you could with a typical Java framework. It is a web application framework written in the Ruby programming language.
We tried the installation of Ruby on Rails on a server with this configuration:
1. Red Hat Linux release 7.3
2. Plesk 5.0.5
3. Apache 1.3.27
4. PHP 4.3.4 # Run as an Apache Module
Install Ruby
Before installing Ruby, first check if zlib is installed in PHP. You can do this by running a simple script with this code.
Now you are all set to start the installation.
cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
tar xvzf ruby-1.8.2.tar.gz
cd ruby-1.8.2
./configure
make
make install
ruby rubytest.rb
If the installaiton is successful, then you will get a message “test succeeded”.
Install RubyGems
cd /usr/local/src
wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar xvzf rubygems-0.8.11.tgz
cd rubygems-0.8.11
ruby setup.rb all
This step involves execution of `ruby setup.rb` with arguments `config / setup / install` all together
gem query --local
OR
gem q -L
Listing all installed gems
Install Rails
gem install rails OR # (Enter Y for all dependencies)
gem install rails --include-dependencies
Install FastCGI
wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -xvzf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
Install mod_fastcgi
wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar -xvzf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
/path/to/apxs -o mod_fastcgi.so -c *.c
/path/to/apxs -i -a -n fastcgi mod_fastcgi.so
In Apache’s httpd.conf, add this line.
Include /path/to/httpd/conf/fastcgi.conf
Now, add this text to fastcgi.conf
cat > /path/to/httpd/conf/fastcgi.conf
User apache
Group apache
FastCgiConfig -idle-timeout 900
AddHandler fastcgi-script .fcgi .fpl .rb
FastCgiIpcDir /tmp/fastcgi_ipc/
FastCgiSuexec /usr/sbin/suexec
To make FastCGI run as suexec. Use path to suexec
Ctrl + D
mkdir /tmp/fastcgi_ipc/
chown -R apache.apache /tmp/fastcgi_ipc
chmod 700 /tmp/fastcgi_ipc/
service httpd restart
NOTE : In some systems, the ownership of fastcgi_ipc is done by Apache itself, but its safe to include these steps in your routine.
Related files: /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/dispatches/dispatch.fcgi # OR ~USER/
Install gem bindings
To install gem bindings for Fastcgi and MySQL
gem install fcgi
gem install mysql
Testing
1. Install Test Application
cd ~USER
rails testapp # Create a test application named 'testapp'
cd testapp/
./script/generate controller test
cd ~USER/httpdocs
ln -s ~USER/testapp/public rails
# In order to access the test application
'~USER/testapp/public' from the browser
In order to allow symlinks, enter the following in to ~USER/httpdocs/.htaccess
Options Indexes +FollowSymLinks
Now you need to set the correct ownership and permissions for the test application. I did the following for my project. You can learn from the example:
cd ~USER
chown -R USER.psacln testapp
chmod -R 755 testapp
chown -R USER.psacln httpdocs/rails
chmod -R 755 httpdocs/rails
Create Test Pages
cd ~USER
cd ~USER/testapp/app/controllers
Create a file called test_controller.rb and put in the following code:
cat > test_controller.rb
class TestController < ApplicationController
def hi
render :text => 'Hi world'
end
def hello
end
def index
render :text => 'Hi! This is the Index.'
end
end
Ctrl + D
Now create the test page.
cat > ~USER/testapp/app/views/test/hello.rhtml # The test page
Hello from Rails!
The current time is <%= Time.now %>
Various linux commands
grep -irl saqun.com * [i=case sensitive,allow both case. r=recursive, l=list out] // search domain in /hsphere/local/config/httpd/sites/
1.check php version: php -v
2.check which php: php -i // php -i |grep php.ini
3./usr/local/cpanel/logs // logs of cpanel
4./var/cpanel/userdata // gives the user data.
5.ctrl+] // to come out from established connection
Then q enter.
7.Search customer by name or by email id:-
8.vps # vzctl enter (id of domain) // to go to root of particular domain.
9.For neural customer search from database the details. Take user & password and login from www.emcwebhosting.com site.
10.cd /dir && command
11.ls /etc | pr -T9 -W$COLUMNS // print contents in 9 columns.pr=print T9=9 column W=width.
12.find -name '*.[ch]' | xargs grep -E 'expr' //Search 'expr' in this dir and below. See also findrepo
13.find -type f -print0 | xargs -r0 grep -F 'example' //Search all regular files for 'example' in this dir and below
14.find -maxdepth 1 -type f | xargs grep -F 'example' //Search all regular files for 'example' in this dir
15.find -type f ! -perm -444 ///Find files not readable by all (useful for web site)
16.find -type d ! -perm -111 //Find dirs not accessible by all (useful for web site)
17.grep --color kamal /etc/passwd //Highlight occurances of regular expression in dictionary
18. gpg -c file //Encrypt file
gpg file.gpg //Decrypt file
19. scp -p -r $USER@$HOST: file dir/ // Copy with permissions to $USER's home directory on $HOST
20.ssh -g -L 8080:localhost:80 root@$HOST //Forward connections to $HOSTNAME:8080 out to $HOST:80
ssh -R 1434:imap:143 root@$HOST //Forward connections from $HOST:1434 in to imap:143
21.
wget -c http://www.example.com/large.file //Continue downloading a partially downloaded file
wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/dir/ //Download a set of files to the current directory
22.
echo 'wget url' | at 01:00 //Download url at 1AM to current dir
wget --limit-rate=20k url //Do a low priority download (limit to 20KB/s in this case)
wget -o log url // faults r stored in log file . log=/x.txt
wget --dns-timeout=seconds url
--connect-timeout=seconds url
--read-timeout=seconds url
--limit-rate=amount url
--user=user url
--password=password url
23. ethtool eth1 // show status of ethernate 0 1
24.ip link show //List network interfaces
25.
ethtool eth0 //Show status of ethernet interface eth0
ethtool --change eth0 autoneg off speed 100 duplex full //Manually set ethernet interface speed
iwconfig eth1 //Show status of wireless interface eth1
iwconfig eth1 rate 1Mb/s fixed //Manually set wireless interface speed
iwlist scan //List wireless networks in range
ip link set dev eth0 name wan //Rename interface eth0 to wan
ip link set dev eth0 up //Bring interface eth0 up (or down)
ip addr show //List addresses for interfaces
ip addr add 1.2.3.4/24 brd + dev eth0 //Add (or del) ip and mask (255.255.255.0)
ip route show //List routing table
ip route add default via 1.2.3.254 //Set default gateway to 1.2.3.254
26.
netstat -tupl //List internet services on a system with it we can search anything by grep
netstat -tup //List active connections to/from system
27.
cal -3 // Display a calendar
cal 9 1752 // Display a calendar for a particular month year
date -d fri //What date is it this friday. See also day
28. ls -lSr ls -lS // show the file order in size.
29. df -h Show free space on mounted filesystems
• df -i Show free inodes on mounted filesystems
• fdisk -l Show disks partitions sizes and types (run as root)
30.lsof -p $$ //List paths that process id has open
tcpdump not port 22 //Show network traffic except ssh. See also tcpdump_not_me
ps -e -o pid,args --forest //List processes in a hierarchy
ps -p 1,2 //List info for particular process
watch -n.1 'cat /proc/interrupts' // Watch changeable data continuously IDs
=================================================
31.• uname -a //Show kernel version and system architecture
• head -n1 /etc/issue //Show name and version of distribution
• cat /proc/partitions //Show all partitions registered on the system
• grep MemTotal /proc/meminfo //Show RAM total seen by the system
• grep "model name" /proc/cpuinfo //Show CPU(s) info
• lspci -tv //Show PCI info
• lsusb -tv //Show USB info
• mount | column -t //List mounted filesystems on the system (and align output)
• grep -F capacity: /proc/acpi/battery/BAT0/info // Show state of cells in laptop battery
# dmidecode -q | less //Display SMBIOS/DMI information
# smartctl -A /dev/sda | grep Power_On_Hours //How long has this disk (system) been powered on in total
# hdparm -i /dev/sda //Show info about disk sda
# hdparm -tT /dev/sda //Do a read speed test on disk sda
# badblocks -s /dev/sda
=====================================================
32. pg
Used to display data one page (screenful) at a time. The command can take a number of filenames as arguments.
Pg [option] [filename] [filename2]…..
33.sort
Sort is a utility program that can be used to sort text files in numeric or alphabetical order
Sort [filename]
34.& - run a program in background mode.
=================================================
35. Get back windows admin password: "C:\Program Files\SWsoft\Plesk\admin\bin\plesksrvclient.exe" –get