Linux Admin Blog

System Administration, Linux, Solaris, Backup, Networking, Security, Mysql, Script, Tips & Tricks

Call to undefined function: mysql_connect()

Posted by sanjaydalal4u on October 23, 2009

Solutions:

Solution 1)   Remove php5-mysql with “apt-get remove php5-mysql”  and install it again or

Solution 2)   Check your php.ini file to ensure it’s including the mysql.so library (extension=mysql.so)  or

Solution 3)   Type “dpkg-reconfigure php5-mysql” (For ubuntu and debian users)

Posted in Problems & Solutions | Leave a Comment »

Solaris and Linux Runlevel

Posted by sanjaydalal4u on September 30, 2009

Default Linux Run Level: Total 7 Run Level

RunLevel 0: Halt System – To shutdown the system
RunLevel 1: Single user mode
RunLevel 2: Basic multi user mode without NFS
RunLevel 3: Full multi user mode (text based)
RunLevel 4: unused
RunLevel 5: Multi user mode with Graphical User Interface
RunLevel 6: Reboot System

Default Solaris Run Level: Total 8 Run Level

RunLevel S: Single user state (useful for recovery)

RunLevel 0: Access Sun Firmware (ok> prompt)

RunLevel 1: System administrator mode

RunLevel 2: Multi-user w/o NFS

RunLevel 3: Multi-user with NFS

RunLevel 4: Unused

RunLevel 5: Completely shutdown the host (like performing a power-off)

RunLevel 6: Reboot but depend upon initdefault entry in /etc/inittab

Posted in Unix/Solaris | 1 Comment »

Update system

Posted by sanjaydalal4u on September 29, 2009

update

Posted in Update system | Leave a Comment »

Configure Services in CentOs5/RHEL5

Posted by sanjaydalal4u on September 29, 2009

1) List All services

listservices

2)  List Running services at Runlevel 3

listservices34

3) Start service

startservices

4)      Stop service

stopservice

5)   Start service on different RunLevel

stopservice

6)  Restart services

restartservice

7)  Add services

addservice

8 ) Remove Services

deleteservice

Posted in Configure Services | Leave a Comment »

CentOS5/RHEL5 User Administration

Posted by sanjaydalal4u on September 29, 2009

1) Add User

Useradd

2)      Delete user

Userdel

3)      Modify user

Usermod

4) Add Group

gpasswd

5) Delete group

groupdel

6) Modify group

groupmod

7) Add User to Group

Use useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. Syntax:

Syntax:

useradd -G {group-name1},{group-name2} username (for secondary group)

useradd -g {group-name} username (for primary group)

useradd1

Posted in User Administration | Leave a Comment »

Automated Installation of DenyHost on RedHat/Fedora

Posted by sanjaydalal4u on September 15, 2009

#Script

#!/bin/bash
# This script installs Deny Host on RedHat(RHEL) or Fedora.
################################################################################
# This script comes with no warranty or guarantee. Please review the script
# before you run it to ensure that it will not cause adverse effects on your
# system.
#
# If you have any questions or comments, please e-mail: sanjaydalal4u@gmail.com
################################################################################
sudo echo
if [ -f /etc/init.d/denyhosts ]; then
echo Removing existing init scripts
sudo /etc/init.d/denyhosts stop
sudo rm -rf /etc/init.d/denyhosts
sudo chkconfig –remove denyhosts
echo ‘*********************’
echo
fi
if [ -d /usr/share/denyhosts/ ]; then
echo Removing existing installation
sudo rm -rf /usr/share/denyhosts
echo ‘*********************’
echo
fi
echo Installing ‘python’ and dependencies.
sudo yum -y install python
echo ‘*********************’
echo
cd /root
echo Downloading DenyHost
wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz?use_mirror=biznetnetworks
echo ‘*********************’
echo
echo Unpacking DenyHost

#!/bin/bash

# This script installs Deny Host on RedHat(RHEL) or Fedora.

################################################################################

# This script comes with no warranty or guarantee. Please review the script

# before you run it to ensure that it will not cause adverse effects on your

# system.

# If you have any questions or comments, please e-mail: sanjaydalal4u@gmail.com

################################################################################

sudo echo

if [ -f /etc/init.d/denyhosts ]; then

echo Removing existing init scripts

sudo /etc/init.d/denyhosts stop

sudo rm -rf /etc/init.d/denyhosts

sudo chkconfig –remove denyhosts

echo ‘*********************’

echo

fi

if [ -d /usr/share/denyhosts/ ]; then

echo Removing existing installation

sudo rm -rf /usr/share/denyhosts

echo ‘*********************’

echo

fi

echo Installing ‘python’ and dependencies.

sudo yum -y install python

echo ‘*********************’

echo

cd /root

echo Downloading DenyHost

wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz?use_mirror=biznetnetworks

echo ‘*********************’

echo

echo Unpacking DenyHost

tar -xzf DenyHosts-2.6.tar.gz
cd /root/DenyHosts-2.6
echo ‘*********************’
echo
echo Installing DenyHost
sudo python setup.py install
echo ‘*********************’
echo
cd /usr/share/denyhosts
echo Configuring DenyHost
sudo cp denyhosts.cfg-dist denyhosts.cfg
sudo sed -i.bak ’s/^\s*\(SECURE_LOG\s*=.*\)$/#\1/’ denyhosts.cfg
sudo sed -i.bak ’s/^\s*#\s*SECURE_LOG\s*=\s*\/var\/log\/secure/SECURE_LOG = \/var\/log\/secure/’ denyhosts.cfg
sudo sed -i.bak ’s/^\s*\(LOCK_FILE\s*=.*\)$/#\1/’ denyhosts.cfg
sudo sed -i.bak ’s/^\s*#\s*LOCK_FILE\s*=\s*\/var\/run\/denyhosts.pid/LOCK_FILE = \/var\/run\/denyhosts.pid/’ denyhosts.cfg
sudo sed -i.bak ’s/^\s*\(BLOCK_SERVICE\s*=.*\)$/#\1/’ denyhosts.cfg
sudo sed -i.bak ’s/^\s*#\s*BLOCK_SERVICE\s*=\s*ALL/BLOCK_SERVICE  = ALL/’ denyhosts.cfg
echo ‘*********************’
echo
echo Configuring executable
sudo cp daemon-control-dist daemon-control
sudo sed -i.bak ’s/^\(\s*DENYHOSTS_BIN\s*=\s\).*$/\1″\/usr\/bin\/denyhosts.py”/’ daemon-control
sudo sed -i.bak ’s/^\(\s*DENYHOSTS_LOCK\s*=\s\).*$/\1″\/var\/run\/denyhosts.pid”/’ daemon-control
sudo sed -i.bak ’s/^\(\s*DENYHOSTS_CFG\s*=\s\).*$/\1″\/usr\/share\/denyhosts\/denyhosts.cfg”/’ daemon-control
sudo chown root daemon-control
sudo chmod 700 daemon-control
echo ‘*********************’
echo
echo Adding ddclient to rc scripts
cd /etc/init.d
sudo ln -s /usr/share/denyhosts/daemon-control denyhosts
sudo chkconfig –add denyhosts
sudo chkconfig –level 35 denyhosts on
echo ‘*********************’
echo

Posted in Denyhost | Leave a Comment »

How to Open 7zip Files Under Ubuntu

Posted by sanjaydalal4u on August 1, 2009

Step 1 : Install application

#sudo apt-get install p7zip

Step 2 : Exectute this command

#p7zip -d filename.7z

Posted in Linux Commands | Leave a Comment »

Setup SAMBA server on Ubuntu 9.04

Posted by sanjaydalal4u on July 27, 2009

Step 1: Installation

#apt-get install samba

Step 2: Configuration

Configuration file : /etc/samba/smb.conf

  • Edit below section

Workgroup = EXAMPLE

…………

Security = user

  • Create a new section at the bottom of the file /etc/samba/smb.conf

[Samba Share]

Comment= Samba  File Server Share

Path=/path to directory

Browsable = yes

Guest ok = yes

Read only = no

Create mask = 0755

Step 3: Create directory and change permissions

#mkdir /path to directoy

#chown  -R nobody:nobody /path to directory

Step 4 : Restart Samba service

#/etc/init.d/samba restart

Enjoy!!!!!!!!!!!!

Posted in Samba server | Leave a Comment »

Open ports using IPTABLES

Posted by sanjaydalal4u on July 9, 2009

If you want your machine to respond to requests initiated from elsewhere on the internet you need to open the required ports. You need to know below details first:

1. Service name you want to open up
2. Is it a tcp or udp service?
3. Port number(s) uses by service?

Example:

To enable ssh access to your box from anywhere on for Class A networks, you could use something like

iptables -A allowed -p tcp –dport 22 -s 10.2.0.0/16 -j ACCEPT
iptables -A allowed -p udp –dport 22 -s 10.2.0.0/16 -j ACCEPT

iptables -A allowed -p tcp –dport 22 -s 10.8.0.0/16 -j ACCEPT
iptables -A allowed -p udp –dport 22 -s 10.8.0.0/16 -j ACCEPT

This allows both udp and tcp traffic from either of the two class A networks to access port 22 on your machine.

Posted in Iptables, Security | Leave a Comment »

Work with tcpwrappers hosts.deny and hosts.allow

Posted by sanjaydalal4u on July 9, 2009

You can use tcpwrappers to Block user,ip,daemon from outside or your inside newwork. For allow use host.allow file and to block use host.deny file.

Step 1. Use your favorite editor like vi.

Step 2. Type vi /etc/hosts.deny
Step 3. At the bottom line just type “ALL:ALL:deny” to restricted all of daemon process
Step 4. Save it.
Step 5. Open “/etc/hosts.allow” with vi editor
Step 6. At the buttom line “ALL :( some ip that you allow):allow” to allow anything from my IP address
Step 7. Save it.

Posted in Security | Leave a Comment »