Saturday, August 17, 2013

How to setup auto logout time in a CLI

We can set up automatic logout for root session so that session gets logged off, if it is idle for a while. It is important to know this as any sneaker can misuse the situation, when a root user leaves the session idle. The method is very simple and as follows:

01. Locate the system file

[root@daddylinux~]#nano .bashrc

02. Go to under the #user specific aliases and functions line and then type
TMOUT=60

03. Save this file
Ctrl + O

04. Exit the file
Ctrl + X

Here TMOUT is an environment variable which instructs the bash shell to exit if the session is idle. Here timeout is set as 300 seconds (5 minutes).

Installing cPanel & WHM on CentOS (4.x, 5.x, 6.x)

To install cPanel & WHM, follow these 6 steps:

Demos of cPanel and WebHost Manager are available Click here
source : docs.cpanel.net

Assigning multiple Virtual IPs to a NIC

Assigning a virtual IPs to a NIC is a very easy task either you use the system-config-network tool or just do some text file editing. The script ifconfig can also be used to create a virtual network interface, but this would not be permanent since the changes ifconfig makes do not survive a reboot. Here we will use text based method to assign multiple IPs.

My default network configuration file is located at /etc/sysconfig/network-scripts/ifcfg-eth0 and looks like as below:


DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.0.255
HWADDR=00:00:00:00:00:00
IPADDR=192.168.0.1
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.0.254
Before editing network configuration file, take backup of it.

# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0 ifcfg-eth0:1

eth0:1 is an alias of the eth0 interface. Now, let’s assign a different IP address to eth0:1. Other NIC aliases could be named eth0:2, eth0:3 etc.

# nano ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
BROADCAST=192.168.0.255
HWADDR=00:00:00:00:00:00
IPADDR=192.168.0.2
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.0.254

Save the file and copy it to /etc/sysconfig/networking/devices/:
# cp ifcfg-eth0:1 /etc/sysconfig/networking/devices/

Also, copy it to your default network profile or whichever profile you use:
# cp ifcfg-eth0:1 /etc/sysconfig/networking/profiles/default/

Now, bring up the new interface using the ifup script:
# ifup eth0:1

Running ifconfig, the new interface should be listed. You can also check it by pinging:
# ping 192.168.0.2

Note: You can now assign a host name on this virtual interface, by updating your local DNS server’s zone files or by adding it to the /etc/hosts files on all your locally connected systems.

Mounting a ROM & USB


Mounting a ROM drive


01. Create a mount point – A place to load the data structure of the storage device (One time only)

[root@daddylinux~]# mkdir /media/cdrom

02. See a mount point
[root@daddylinux~]# ls -l /media

03. Verify the device driver assigned to your ROM
[root@daddylinux~]# ls -l /dev/cd*
eg - /dev/scd0 , /dev/scd1 , /dev/scd2

04. Mounting the ROM
[root@daddylinux~]# mount /dev/scd0 /media/cdrom

05. See the ROM data
[root@daddylinux~]# cd /media/cdrom
[root@daddylinux~]# ls –l

06. To take out the media
[root@daddylinux~]# cd
[root@daddylinux~]# eject
[root@daddylinux~]# eject /dev/scd0

07. To take in the media
[root@daddylinux~]# eject –t
[root@daddylinux~]# eject -t /dev/scd0
 
 
==================================================================== 


Mounting a USB pen

01. Create a mount point – A place to load the data structure of the storage device (One time only)
[root@daddylinux~]# mkdir /media/usb

02. See a mount point
[root@daddylinux~]# ls -l /media

03. Fix the pen and verify the device driver assigned (sdb, sdc, sdd)

04. Mounting the USB
[root@daddylinux~]# mount /dev/sdb1 /media/usb

05. See the pen drive data
[root@daddylinux~]# cd /media/usb
[root@daddylinux~]# ls –l

06. Before you unplug the pen
[root@daddylinux~]# cd
[root@daddylinux~]# umount /dev/sdb1

Update Ubuntu Linux

Update Repositori adalah hal sangat di butuhkan pada sistem operasi ubuntu, apalagi bagi yang terbiasa suka bongkar pasang software "Anyar". Dimana biasanya software anyar tersebut sering gagal saat di install. nah tuh tanda-tanda kalau repositori anda perlu di update...


Cara mengupdate repositori ubuntu sebenar nya cukup mudah
Jalankan perintah

#sudo gedit /etc/apt/sources.list
kemudian hapus semua, dan isikan sesuai dengan berikut
deb http://kambing.ui.edu/ubuntu hardy main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu hardy-updates main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu hardy-security main restricted universe multiverse
deb http://kambing.ui.edu/ubuntu hardy-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy universe
deb http://kambing.ui.edu/ubuntu hardy-proposed main restricted universe multiverse
Maka akan terlihat seperti gambar berikut



Kemudian jalankan Perintah update

#sudo apt-get update
jika berhasil akan tampak seperti gambar berikut



#selesai... ;)

Install Squid Proxy Server on Debian and ubuntu


This is not a tutorial to install squid, this is a notes from my experience when install squid on Debian Etch

#apt-get install squid3 vim

if no error when instalation, continued with make squid configuration. the name of file configuration is squid.conf

back-up your old squid.conf

#cd /etc/squid3
#mv squid.conf squid.conf.old
#vim squid.conf


hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 6 MB
cache_swap_low 98
cache_swap_high 99
maximum_object_size 128 MB
maximum_object_size_in_memory 32 KB
fqdncache_size 2048
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
store_dir_select_algorithm round-robin
cache_mgr upt@amikom.ac.id
cache_dir ufs /cache1 3000 8 256
cache_dir ufs /cache2 3000 8 256
cache_log /dev/null
cache_store_log /dev/null
mime_table /usr/local/squid/etc/mime.conf
pid_filename /usr/local/squid/var/logs/squid.pid
emulate_httpd_log off
log_mime_hdrs off
log_fqdn off
log_ip_on_direct off
logfile_rotate 1
log_icp_queries off
client_netmask 255.255.255.255
unlinkd_program /usr/local/squid/libexec/unlinkd
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
refresh_pattern ^ftp: 10080 95% 241920 reload-into-ims override-lastmod
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 180 95% 120960 reload-into-ims override-lastmod
quick_abort_min 0
quick_abort_max 0
quick_abort_pct 98
memory_pools off
reload_into_ims on
pipeline_prefetch on
vary_ignore_expire on
cache_effective_user squid
cache_effective_group squid
#coredump_dir /usr/local/squid/var/cache
visible_hostname cache.campus.edu
acl all src 0.0.0.0/0.0.0.0
acl lab src 202.9.56.3/24
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow manager
http_access allow lab
http_access deny all
icp_access allow all

#squid3 -k parse
#squid3 -z
#/etc/init.d/squid restart





#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 10.10.10.1:8080
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
#iptables-save

then look the view log squid with tail command

#tail -f /var/log/squid/access.log

if succes will show log your client access internet

Wednesday, August 14, 2013

Magento installation script

#!/bin/bash

clear

stty erase '^?'

echo "To install Magento, you will need a blank database ready with a user assigned to it."

echo

echo -n "Do you have all of your database information? (y/n) "

read dbinfo

if [ "$dbinfo" == "y" ] ; then

echo

echo -n "Database Host (usually localhost): "
read dbhost


echo -n "Database Name: "
read dbname


echo -n "Database User: "
read dbuser

echo -n "Database Password: "

read dbpass

echo -n "Store URL: "
read url


echo -n "Admin Username: "
read adminuser


echo -n "Admin Password: "
read adminpass

echo -n "Admin First Name: "

read adminfname

echo -n "Admin Last Name: "
read adminlname


echo -n "Admin Email Address: "
read adminemail


echo -n "Include Sample Data? (y/n) "
read sample

if [ "$sample" = "y" ] ; then

echo
echo "Now installing Magento with sample data..."


echo
echo "Downloading packages..."
echo


wget http://www.magentocommerce.com/downloads/assets/1.2.0.1 /magento-1.2.0.1.tar.gz

wget http://www.magentocommerce.com/downloads/assets/1.2.0/magento-sample-data-1.2.0.tar.gz


echo
echo "Extracting data..."
echo


tar -zxvf magento-1.2.0.1.tar.gz
tar -zxvf magento-sample-data-1.2 .0 .tar.gz


echo
echo "Moving files..."

echo

mv magento-sample-data-1.2.0/media/* magento/media/

mv magento-sample-data-1.2.0 /magento_sample_data_for_1.2.0.sql magento/data.sql
mv magento/* magento/.htaccess .


echo
echo "Setting permissions..."
echo

chmod o+w var var/.htaccess app/etc
chmod -R o+w media

echo
echo "Importing sample products..."
echo


mysql -h $dbhost -u $dbuser -p$dbpass $dbname < data.sql


echo
echo "Initializing PEAR registry..."

echo

./pear mage-setup .


echo
echo "Downloading packages..."

echo

./pear install magento-core/Mage_All_Latest


echo
echo "Cleaning up files..."

echo

rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*

rm -rf magento/ magento-sample-data-1.2.0 /
rm -rf magento-1.2.0.1.tar.gz magento-sample-data-1.2.0.tar.gz

rm -rf index.php.sample .htaccess.sample php.ini.sample LICENSE.txt STATUS.txt data.sql

echo

echo "Installing Magento..."
echo


php-cli -f install.php --
--license_agreement_accepted "yes"
--locale "en_US"

--timezone "America/Los_Angeles"
--default_currency "USD"
--db_host "$dbhost"

--db_name "$dbname"
--db_user "$dbuser"
--db_pass "$dbpass"

--url "$url"
--use_rewrites "yes"
--use_secure "no"

--secure_base_url ""
--use_secure_admin "no"
--admin_firstname "$adminfname"

--admin_lastname "$adminlname"
--admin_email "$adminemail"
--admin_username "$adminuser"

--admin_password "$adminpass"

echo

echo "Finished installing Magento"
echo


exit
else
echo "Now installing Magento without sample data..."


echo
echo "Downloading packages..."

echo

wget http://www.magentocommerce.com/downloads/assets/1.2.0.1 /magento-1.2.0.1.tar.gz


echo
echo "Extracting data..."

echo

tar -zxvf magento-1.2.0.1.tar.gz


echo
echo "Moving files..."

echo

mv magento/* magento/.htaccess .


echo
echo "Setting permissions..."

echo

chmod o+w var var/.htaccess app/etc

chmod -R o+w media

echo

echo "Initializing PEAR registry..."
echo


./pear mage-setup .

echo

echo "Downloading packages..."
echo


./pear install magento-core/Mage_All_Latest

echo

echo "Cleaning up files..."
echo


rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
rm -rf magento/ magento-1.2.0.1.tar.gz
rm -rf index.php.sample .htaccess.sample php.ini.sample LICENSE.txt STATUS.txt


echo
echo "Installing Magento..."

echo

php-cli -f install.php --

--license_agreement_accepted "yes"
--locale "en_US"
--timezone "America/Los_Angeles"

--default_currency "USD"
--db_host "$dbhost"
--db_name "$dbname"

--db_user "$dbuser"
--db_pass "$dbpass"
--url "$url"

--use_rewrites "yes"
--use_secure "no"
--secure_base_url ""

--use_secure_admin "no"
--admin_firstname "$adminfname"
--admin_lastname "$adminlname"

--admin_email "$adminemail"
--admin_username "$adminuser"
--admin_password "$adminpass"


echo
echo "Finished installing Magento"


exit
fi
else

echo
echo "Please setup a database first. Don't forget to assign a database user!"

exit

Setting up Network (Red Hat based System)

Segment 1
The easiest way to setup network is by using the following commands-
# setup > network settings

Used for setting up network parameters
# system-config-network

Used for setting up network parameters
# service network restart
Restarts the network service
# ifconfig
Check the network parameters

Network related files

/etc/sysconfig/network-scripts/

This directory contains a single file for each network adapter named ifcfg-eth0, ifcfg-eth1, ifcfg-eth2 and so on. The contents of the file are:
NAME= eth0
name of the device
DEVICE=eth0
Device id
BOOTPRO= none/static/dhcp
none/static are used for static IP address.dhcp is used for automatic IP address.
IPADDR= X.X.X.X
4 bit IP address
NETMASK= X.X.X.X
Netmask of the provided IP address
GATEWAY= X.X.X.X
IP address of the gateway server/router
USERCTL= yes/no
Whether normal users are able to change IP address

/etc/resolv.conf

DNS IP is set in this file. Keep in mind that the there are some International free DNS that can be used such as 4.2.2.1, 4.2.2.2, 8.8.8.8.
nameserver X.X.X.X

/etc/sysconfig/network

This file is primarily used to set hostname.
HOSTNAME = stationX.example.com

/etc/hosts

This file is used in case the hostname has to be resolved locally. The following line should be added-
IP
FQDN
Hostname
X.X.X.X
stationX.exaple.com
stationX

Troubleshooting

When troubleshooting any network, the following commands can be used.
mii-tool
Note that there is no space in the command. Used for checking whether the cable is connected to the Network Interface Card.
ping X.X.X.X
If physical connection is okay, you should get a reply with information like latency and TTL.
# traceroute X.X.X.X
Used for tracing the path to a specific IP or domain.
                 
Segment 2

Virtual Interfaces

Each NIC card in Linux can be used to create virtual interfaces which contain separate IP addresses. As a result, one can use a single LAN card to create multiple virtual LAN cards with specific IP address.

Procedure:

1.     Create a copy of the LAN card configuration file and make changes as necessary. The following example contains minimum configuration-
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-eth0  ifcfg-eth0:1
# vim ifcfg-eth0:1
                 
      NAME=eth0:1
      DEVICE=eth0:1
      IPADDR= Y.Y.Y.Y
      SUBNET= Y.Y.Y.Y
2.  # service network restart

Check whether you can find the IP address of the virtual interface with ifconfig. If you’re successful, try pinging the IP address from local, as well as remote machines.