Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Wednesday, December 26, 2012

how to check open port on ubuntu

simply  run this CLI

netstat -anltp | grep "LISTEN"

Monday, May 14, 2012

Clean URL drupal for ubuntu


clean URL inside ubuntu for drupal

http://drupal.org/node/134439

Thursday, November 10, 2011

vi search

Vi: Search and Replace

Change to normal mode with .

Search (Wraped around at end of file):

  Search STRING forward :   / STRING.
Search STRING backward: ? STRING.

Repeat search: n
Repeat search in opposite direction: N (SHIFT-n)

Replace: Same as with sed, Replace OLD with NEW:
First occurrence on current line:      :s/OLD/NEW

Globally (all) on current line: :s/OLD/NEW/g

Between two lines #,#: :#,#s/OLD/NEW/g

Every occurrence in file: :%s/OLD/NEW/g

Wednesday, June 29, 2011

Enable htaccess on ubuntu

Found the solution!! Apache2 in general, or it might be specifically to Ubuntu, is configured slightly differently than Apache1.x.. at least from what I've seen in the default installs in RH, FC, Mandrake, etc (I'm not Linux or Apache expert).

I went to /etc/apache2/sites-available and edited the file default
There you'll find:

Code:
NameVirtualHost *

ServerAdmin admin@site.com

DocumentRoot /var/www/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
Default for AllowOverride is none, should be all
/etc/init.d/apache2 restart to restart apache and your .htaccess files should now work!! How frustrating, but educational

Credit to Ubuntu forum

Wednesday, June 15, 2011

error : (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

I would like to state first of all I am a novice with Linux, but have working in IT for 15 years. I have been searching the web on this issue for almost 2 days (off and on), and have found that my particular issue was not the same as the norm for this particular error code. I would like to give back (if you will).

Apparently having a cert.key password protected will hang Apache2 (maybe Apache as well). The solution was to remove the password on the cert.key and that solved my problem.

The general consensus with resolving this issue did help me figure out that apache2 was running but waiting for password on boot-up. The following command which you will find everywhere out in the cloud is as follows:

sudo netstat -ltnp | grep ':80' (it is important to note that apache was hanging and it did not matter what port I decided to investigate)

This would return the following:
tcp6 0 0 :::80 :::* LISTEN 1047/apache2

Then I ran the following command:

sudo kill -9 1047 (the pid that appears on your particular instance)

I was able to restart Apache and everything was groovy until I rebooted.

I suspected the password and started researching the how to remove the passphrase off of the cert key and found the following article:

http://www.mnxsolutions.com/apache/r...n-ssl-key.html

The following part of the page actually helped me:

Always backup the original key first (just in case)!

# cp www.key www.key.origThen unencrypt the key with openssl. You’ll need the passphrase for the decryption process:

# openssl rsa -in www.key -out new.keyNow copy the new.key to the www.key file and you’re done. Next time you restart the web server, it should not prompt you for the passphrase.

I hope this helps and saves someone some valuable time.
credit to : hhabashy & http://ubuntuforums.org/showthread.php?t=1636667
Reply With Quote

Sunday, June 12, 2011

Change mysql directory on ubuntu 10.04

First you need to Stop MySQL using the following command

sudo /etc/init.d/mysql stop

Now Copy the existing data directory (default located in /var/lib/mysql) using the following command

sudo cp -R -p /var/lib/mysql /path/to/new/datadir

All you need are the data files, so delete the others with the command

sudo rm /path/to/new/datadir

Note:- You will get a message about not being able to delete some directories, but that’s what you want.

Now edit the MySQL configuration file with the following command

gksu gedit /etc/mysql/my.cnf

Look for the entry for “datadir”, and change the path (which should be “/var/lib/mysql”) to the new data directory.

Important Note:-From Ubuntu 7.10 (Gutsy Gibbon) forward, Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you’ll never be able to restart MySQL with the new datadir location.

In the terminal, enter the command

sudo gedit /etc/apparmor.d/usr.sbin.mysqld

Copy the lines beginning with “/var/lib/mysql”, comment out the originals with hash marks (“#”), and paste the lines below the originals.

Now change “/var/lib/mysql” in the two new lines with “/path/to/new/datadir”. Save and close the file.

Restart the AppArmor profiles with the command

sudo /etc/init.d/apparmor reload

Restart MySQL with the command

sudo /etc/init.d/mysql restart

Now MySQL should start with no errors, and your data will be stored in the new data directory location.

credit to : http://www.ubuntugeek.com/how-to-change-the-mysql-data-default-directory.html

Thursday, May 5, 2011

How to block port 80 on ubuntu

I just block my port 80 by using this CLI

iptables -A INPUT -j DROP -p tcp --destination-port 80 -i eth0

The code above will drop all tcp packets coming into your Linux computer on device eth0 on port 80. If your Internet connection runs through a device other than eth0, go ahead and make the adjustment.

To remove the iptables rule use the following code:

iptables -D INPUT -j DROP -p tcp --destination-port 80 -i eth0

credit to : foogazi


Wednesday, May 4, 2011

SSL on Ubuntu

I just install SSL configuration on my backup server for security reason & i have made it with Mr. Mike how to.

Currently my machine running on Ubuntu 10.10 with Apache2 & Backuppc

Below step by step how to :

Setting up SSL with Ubuntu 8.10 is a simple process but it does have a few gotchas that you need to be aware of. The setup has changed from 8.04. One issue is that the +CompatEnvVars is no longer used as it created a bug in 8.10 and you will have to enable the default-ssl site to get everything working.

First, log on to your server Install Apache:

sudo apt-get install apache2

Change to the /etc/apache2/mods-available directory and look at the available modules. Then change to the /etc/apache2/mods-enabled directory to see what modules are enabled:

cd /etc/apache2/mods-available
ls
cd /etc/apache2/mods-enabled
ls

Now, install and enable SSL:

sudo a2enmod ssl
sudo /etc/init.d/apache2 force-reload

Change to the default webserver directory, and create a simple web page:
cd /var/www
sudo vim index.html

Add the following content:


Save and exit. On your own local computer, open a tab or window for your web browser. For the URL, enter:

http://IP_address_of_my_server

You should be able to view your web page. Now, you’ll want to encrypt your site. Create the server encryption keys:

cd /etc/apache2
sudo openssl genrsa -des3 -out server.key 1024

Use this set of keys to create a certificate request:

sudo openssl req -new -key server.key -out server.csr

When asked to input data, use your imagination to create something appropriate. Be sure to write down your passphrase. Use this request to create your self-signed certificate:

sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Install the key and certificate:

sudo cp server.crt /etc/ssl/certs/
sudo cp server.key /etc/ssl/private/

Open the “defaults” file for editing:

cd /etc/apache2/sites-available
sudo vim default-ssl

This file is basically set up but you will want to uncomment the SSLOptions line and also change the SSLCertificate lines to reflect the location and name of your new information.

SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key

The port 443 is enabled when you use SSL so that is ready to go.

Enable the default SSL site:
sudo a2ensite default-ssl

If you do not enable the default-ssl you will get this error:
“ssl_error_rx_record_too_long apache”

Restart Apache.

sudo /etc/init.d/apache2 restart

You now be able to see your web site running on https

Thanks & credit to : http://beginlinux.com/blog/2009/01/ssl-on-ubuntu-810-apache2/ & Mr. Mike

Tuesday, April 19, 2011

This is for me.

copy mysql db to cloud

- dump your db
- mv to www server
- go to amazon aws server
- run this

sudo scp username@www.mediu.edu.my: ./


wait untuil it finish

Wednesday, April 6, 2011

format HDD on Ubuntu 10.10

After add HDD on your ubuntu box
check your hdd either its already present or not by using

fdisk -l

on your screen you will see

Disk /dev/cciss/c0d1: 1499.8 GB, 1499832039424 bytes
Disk /dev/cciss/c0d1 doesn't contain a valid partition table

after you know your OS HDD first hdd must be c0d0 and the number will increse on d example c0d0,c0d1,c0d2 etc

run this command to format your hdd, for this tutorial i will format ext3 for my HDD


mkfs.ext3 /dev/cciss/c0d1

wait for few minutes
now you done!



Tuesday, January 11, 2011

No Hup

Run nohup mysql

nohup mysql -uroot -pyourpasswddb --default-character-set=utf8 <> dump.log 2> error.log &

or

nohup mysql -uroot -pyourpasswddb --default-character-set=utf8 < namedb > error.log &

Thursday, November 4, 2010

How To Monitor Mysql using Zenoss

On the Zenoss server ensure your device has the Mysql zenpack

On the mysql server you plan to monitor do the following;

Add a user to Mysql so that zenoss can connect.

mysql -u root -p

grant ALL PRIVILEGES ON *.* TO ‘zenoss’@'yourzenossdomain’ IDENTIFIED BY ‘yourpassword’;

FLUSH PRIVILEGES;

Don’t forget to open port 3306 on the firewall of the Mysql server if necessary.

On the Zenoss server add the mysql user and password to zproperties of the device.

If Mysql version <5> 5

You can test that your monitored server can authenticate from your Zenoss server by

mysql -u zenoss -p -h yourmonitoredserverip


credit to http://www.how-to-linux.com

Friday, October 29, 2010

Downgrade PHP on ubuntu Server

go to /usr/local/sbin

create this script

nano downgrade.sh

enter

#!/bin/bash
# by Ruben Barkow (rubo77) http://www.entikey.z11.de/

# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here's how to do the Apt magic to get PHP packages from the karmic repositories:

echo "Am I root? "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
echo " NO!

Error: You must be root to run this script.
Enter
sudo su
"
exit 1
fi
echo " OK";


# finish all apt-problems:
apt-get -f install

# remove all your existing PHP packages. You can list them with dpkg -l| grep php
PHPLIST=$(for i in $(dpkg -l | grep php|awk '{ print $2 }' ); do echo $i; done)
echo these pachets will be removed: $PHPLIST
# you need not to purge, if you have upgraded from karmic:
aptitude remove $PHPLIST
# on a fresh install, you need purge:
# aptitude remove --purge $PHPLIST


#Create a file each in /etc/apt/preferences.d like this (call it for example /etc/apt/preferences.d/php5_2);
#
#Package: php5
#Pin: release a=karmic
#Pin-Priority: 991
#
#The big problem is that wildcards don't work, so you will need one such stanza for each PHP package you want to pull from karmic:

echo ''>/etc/apt/preferences.d/php5_2
for i in $PHPLIST ; do echo "Package: $i
Pin: release a=karmic
Pin-Priority: 991
">>/etc/apt/preferences.d/php5_2; done

# duplicate your existing sources.list replacing lucid with karmic and save it in sources.list.d:
#sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list

# better exactly only the needed sources, cause otherwise you can get a cachsize problem:
echo "# needed sources vor php5.2:
deb http://de.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic main restricted

deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates main restricted

deb http://de.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic universe
deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates universe

deb http://de.archive.ubuntu.com/ubuntu/ karmic multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic multiverse
deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates multiverse

deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted
deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
deb http://security.ubuntu.com/ubuntu karmic-security multiverse
deb-src http://security.ubuntu.com/ubuntu karmic-security multiverse
" >> /etc/apt/sources.list.d/karmic.list

aptitude update

apache2ctl restart

echo install new from karmic:
aptitude -t karmic install $PHPLIST

# at the end retry the modul libapache2-mod-php5 in case it didn't work the first time:
aptitude -t karmic install libapache2-mod-php5

apache2ctl restart

chmod +x /usr/local/sbin/downgrade.sh
run the script
sh downgrade/sh

wait until it finish
now you done

Thursday, July 22, 2010

Mysql Replication

Follow this step to create / install a replication DB for mysql

http://www.howtoforge.com/mysql_database_replication

if uo have an error after / fini9sh installation using thie replication try this :

error 1 =

>LOAD DATA FROM MASTER;
Query OK, 0 rows affected, 1 warning (0.12 sec)
>

try to run this :

mysql> GRANT RELOAD on *.* to repl@'%' identified by 'your_password';
OR
mysql> GRANT SUPER on *.* to repl@'%' identified by 'your_password';



Reference : http://www.linuxismybff.com/howto/mysql/mysql-basic-replication-setup/

if you still have this warning error try to run this :

mysql -u root -p
Enter password:
SLAVE STOP;

CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slave_user', MASTER_PASSWORD='
', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;

START SLAVE;
quit;

Monday, June 28, 2010

Install SNMPD on Ubuntu

1.Installation

root@ibsen:~# sudo apt-get install snmpd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libmpich1.0gf libdc1394-22 genisoimage linux-headers-2.6.27-7 libgfortran2 dvd+rw-tools linux-headers-2.6.27-7-generic libcarp-clan-perl libxml-xql-perl libparse-yapp-perl
rdate python-xml localechooser-data gcc-4.2-base libimage-size-perl libdebconfclient0 libvisual-0.4-0 libmyth-python perlmagick libvisual-0.4-plugins libavdevice52
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libperl5.10 libsensors3 libsnmp-base libsnmp15
Suggested packages:
lm-sensors
The following NEW packages will be installed:
libperl5.10 libsensors3 libsnmp-base libsnmp15 snmpd
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 2463kB of archives.
After this operation, 7987kB of additional disk space will be used.
Do you want to continue [Y/n]?

answer y

2. Configuration

Move existing /etc/snmp/snmpd.conf configuration file to /etc/snmp/snmpd.conf.org

mv /etc/snmp/snmpd.conf  /etc/snmp/snmpd.conf.org

Create a new /etc/snmp/snmpd.conf file:

rocommunity  public
syslocation "PDC, Peters DataCenter"
syscontact peter@it-slav.net

Make snmpd use the newly created file and make it listen to all interfaces:

Edit /etc/default/snmpd

Change from:

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

To:

# snmpd options (use syslog, close stdin/out/err).
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

and restart snmpd

/etc/init.d/snmpd restart


Credit to http://www.it-slav.net/blogs/2009/02/05/install-and-configure-snmp-on-ubuntu/

Sunday, June 13, 2010

How to Lock / Unlock User in ubuntu

For Locking User from command Line

$ sudo usermod -L waxs This will Lock user account named waxs

For Locking User from command Line

$ sudo usermod -U waxs This will UnLock user account named waxs

Thursday, June 3, 2010

list all installed application on ubuntu

list all installed application on ubuntu

dpkg --get-selections