Friday, February 20, 2009

How to enable banner message (MOTD) in Ubuntu (Linux) Login

Edit /etc/motd.tail and put your welcome message in that file.
Enable ssh login to print welcome banner when user login:
Edit /etc/ssh/sshd_config
Find -> PrintMotd no and enable it -> PrintMotd yes
Save the file and restart ssh daemon.

Monday, February 9, 2009

Folder access restriction on IIS

I need to give restriction to one of folder in my website so it can be access only from my office network.

Go to Control Panel > Administrative Tools > IIS Manager
Browse your file and choose which folder that you want to give access restriction then right click > Properties > Directory Security
Find IP address and domain name restrictions section click Edit button.
Choose Denied access and click Add...
You can choose type of restrictions you need to be allow, what i want is allow my office network so i choose Group of computers
I key in
Network ID: 10.0.0.0 (my office network ip range)
Subnet mask: 255.255.0.0

How to create / build .deb packages

Came across the websites i found detail how to build .deb packages.

Another easy way to create .deb.
Install it and when you compile a software type "sudo checkinstall -D" instead of "sudo make install", it will install the software giving synaptic all the needed informations to see it and create a .deb.

How to reset password on Windows and Unix (Linux)

Resetting the Root Password on Windows Systems

Use the following procedure for resetting the password for any MySQL root accounts on Windows:

  1. Log on to your system as Administrator.

  2. Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager:

    Start Menu -> Control Panel -> Administrative Tools -> Services

    Then find the MySQL service in the list, and stop it.

    If your server is not running as a service, you may need to use the Task Manager to force it to stop.

  3. Create a text file and place the following statements in it. Replace the password with the password that you want to use.

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;

    The UPDATE and FLUSH statements each must be written on a single line. The UPDATE statement resets the password for all existing root accounts, and the FLUSH statement tells the server to reload the grant tables into memory.

  4. Save the file. For this example, the file will be named C:\mysql-init.txt.

  5. Open a console window to get to the command prompt:

    Start Menu -> Run -> cmd
  6. Start the MySQL server with the special --init-file option:

    C:\> C:\mysql\bin\mysqld --init-file=C:\mysql-init.txt

    If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.

    The server executes the contents of the file named by the --init-file option at startup, changing each root account password.

    You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.

    If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:

    C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld.exe"
    --defaults-file="C:\Program Files\MySQL\MySQL Server 5.1\my.ini"
    --init-file=C:\mysql-init.txt

    The appropriate --defaults-file setting can be found using the Services Manager:

    Start Menu -> Control Panel -> Administrative Tools -> Services

    Find the MySQL service in the list, right-click on it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.

  7. After the server has started successfully, delete C:\mysql-init.txt.

  8. Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.

You should now be able to connect to MySQL as root using the new password.

Resetting the Root Password on Unix Systems

Use the following procedure for resetting the password for any MySQL root accounts on Unix. The instructions assume that you will start the server so that it runs using the Unix login account that you normally use for running the server. For example, if you run the server using the mysql login account, you should log in as mysql before using the instructions. (Alternatively, you can log in as root, but in this case you must start start mysqld with the --user=mysql option. If you start the server as root without using --user=mysql, the server may create root-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups. If that happens, you will need to either change the ownership of the files to mysql or remove them.)

  1. Log on to your system as the Unix mysql user that the mysqld server runs as.

  2. Locate the .pid file that contains the server's process ID. The exact location and name of this file depend on your distribution, host name, and configuration. Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/. Generally, the file name has an extension of .pid and begins with either mysqld or your system's host name.

    You can stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the path name of the .pid file in the following command:

    shell> kill `cat /mysql-data-directory/host_name.pid`

    Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.

  3. Create a text file and place the following statements in it. Replace the password with the password that you want to use.

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    FLUSH PRIVILEGES;

    The UPDATE and FLUSH statements each must be written on a single line. The UPDATE statement resets the password for all existing root accounts, and the FLUSH statement tells the server to reload the grant tables into memory.

  4. Save the file. For this example, the file will be named /home/me/mysql-init. The file contains the password, so it should not be saved where it can be read by other users.

  5. Start the MySQL server with the special --init-file option:

    shell> mysqld_safe --init-file=/home/me/mysql-init &

    The server executes the contents of the file named by the --init-file option at startup, changing each root account password.

  6. After the server has started successfully, delete /home/me/mysql-init.

You should now be able to connect to MySQL as root using the new password.

Alternatively, on any platform, you can set the new password using the mysql client (but this approach is less secure):

  1. Stop mysqld and restart it with the --skip-grant-tables option.

  2. Connect to the mysqld server with this command:

    shell> mysql
  3. Issue the following statements in the mysql client. Replace the password with the password that you want to use.

    mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
    -> WHERE User='root';
    mysql> FLUSH PRIVILEGES;

You should now be able to connect to MySQL as root using the new password.

Sunday, February 8, 2009

How to fix drop down menu blocked by flash

In your swf code in the html, add the following to your OBJECT statement:
<param name="WMode" value="Transparent">

Then if you have an EMBED statement, add:
wmode="transparent"

Sample:
<param name="movie" value="file.swf">
<param name="quality" value="high">
<span style="font-weight: bold;"></span>
<param name="WMode" value="Transparent">
<embed src="tes.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="340" wmode="transparent"></embed>

Reload php.ini on IIS

Making changes to the php.ini file settings will not be seen until the IIS (Internet Information Services) reloads or re-caches the settings. To check the current php.ini file settings, create a page that displays the PHP info.

Sample PHP info page (phpinfo.php):

Open your IIS 6 manager, expand the Application Pools folder, right click on DefaultAppPool and press Recycle. It only takes a second.

Then reload the sample PHP info page (phpinfo.php). The new setting will be listed.

Friday, February 6, 2009

How to change ssh (login) welcome banner (message) in Ubuntu (Linux)

Simple:
Edit /etc/motd and change the text with your choosen welcome banner.

Detail:
Every time I connect to my Ubuntu development server through my ssh client, I receive the same message and I'm getting tired of seeing it, so I decided to change the message to something else.

Here's the message that I get every time:
Linux superfast 2.6.20-16-generic #2 SMP Thu Jun 7 19:00:28 UTC 2007 x86_64

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Last login: Mon Aug 13 01:05:46 2007 from ipaddress removed

geek@superfast:~$

Changing this message requires editing two different files. The first three sections can be modified by editing the following file:
/etc/motd
This file contains the linux build number as well as the Ubuntu warranty message. I don't find this particularly useful, so I removed all of it and replaced it with my own message.

To disable the last login message (which I don't recommend doing), you will need to edit the following file in sudo mode:
/etc/ssh/sshd_config
Find this line in the file and change the yes to no as shown:
PrintLastLog no
Now when you login, you'll get a blank prompt, although I wouldn't necessarily recommend it because it's useful to see the last login to the system for security reasons. This is my prompt now:

This is a superfast system. Please max out the cpu accordingly.
Last login: Mon Aug 13 01:24:14 2007 from ipaddress removed
geek@superfast:~$

Root login email notification in Linux All Variant

Edit /root/.bashrc or /root/.bash_profile
Put this code inside .bashrc
echo 'ALERT - Root Shell Access `hostname` on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" email@myhost.com

How to check whether IPV6 enabled or not?

root@master:/etc# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:1d:09:f2:56:d6
inet addr:172.16.188.155 Bcast:172.16.188.255 Mask:255.255.255.0
inet6 addr: fe80::21d:9ff:fef2:56d6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:380 errors:0 dropped:0 overruns:0 frame:0
TX packets:138 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:69003 (67.3 KB) TX bytes:30542 (29.8 KB)
Interrupt:16 Memory:f8000000-f8012100
That means your IPV6 is enabled. If your IPV6 disabled the result should like this:
root@master1:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:1d:09:f2:56:d6
inet addr:172.16.188.155 Bcast:172.16.188.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:186 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37514 (36.6 KB) TX bytes:8590 (8.3 KB)
Interrupt:16 Memory:f8000000-f8012100

You may read How to disable IPV6 if no longer in use?

Thursday, February 5, 2009

Send Automatic Email Notification When Security Upgrades Available (Debian / Ubuntu Linux)

Q. How do I force apt-get to send me email when upgrades or security updates available under Debian or Ubuntu Linux? Do I need to write a shell script which generates a mail with a list of all packages currently pending an upgrade?


A. No you don't have to write a shell script. You need to use apticron command / script for notification. apticron is mainly intended for automatic notification of pending security updates but can also be used in many other situations where timely updates are neccessary.

Install apticron

Type the following command at a shell prompt:
# apt-get update
# apt-get install apticron

Configure apticron to send email notifications

The default coniguration file is located at /etc/apticron/apticron.conf. Open file using text editor:
# vi /etc/apticron/apticron.conf
You need to set email address to email the notification as follows:
EMAIL="vivek@nixcraft.in"
My sample configuration file:

# apticron.conf
#
# set EMAIL to a list of addresses which will be notified of impending updates
#
EMAIL="admin@myhost.com"

#
# Set LISTCHANGES_PROFILE if you would like apticron to invoke apt-listchanges
# with the --profile option. You should add a corresponding profile to
# /etc/apt/listchanges.conf
#
# LISTCHANGES_PROFILE="apticron"

#
# Set SYSTEM if you would like apticron to use something other than the output
# of "hostname -f" for the system name in the mails it generates
#
# SYSTEM="foobar.example.com"

#
# Set IPADDRESSNUM if you would like to configure the maximal number of IP
# addresses apticron displays. The default is to display 1 address of each
# family type (inet, inet6), if available.
#
# IPADDRESSNUM="1"

#
# Set IPADDRESSES to a whitespace seperated list of reachable addresses for
# this system. By default, apticron will try to work these out using the
# "ip" command
#
# IPADDRESSES="192.0.2.1 2001:db8:1:2:3::1"

Save and close the file. /etc/cron.daily/apticron is the cron script for executing apticron daily and it will send you notfication when updates available.

Sample apticron email

Here is a sample email:

apticron report [Sun, 06 Jul 2008 07:07:23 +0000]
========================================================================

apticron has detected that some packages need upgrading on:

vip.clicklinux.org
[ 72.51.34.244 ::72.51.34.244 ]

The following packages are currently pending an upgrade:

libpcre3 6.7+7.4-4

========================================================================

Package Details:

Reading changelogs...
--- Changes for pcre3 (libpcre3) ---
pcre3 (6.7+7.4-4) stable-security; urgency=high

* Non-maintainer upload by the security team.
* Apply patch from Tavis Ormandy to fix a heap overflow in the compiler,
triggered by patterns which contain options and multiple branches
(CVE-2008-2371).

-- Florian Weimer Fri, 04 Jul 2008 21:15:19 +0200

========================================================================

You can perform the upgrade by issuing the command:

aptitude dist-upgrade

as root on vip.clicklinux.org

It is recommended that you simulate the upgrade first to confirm that
the actions that would be taken are reasonable. The upgrade may be
simulated by issuing the command:

aptitude -s -y dist-upgrade

-- apticron

You will get an email when security updates released by Debian / Ubuntu security team. I also suggest subscribing to Debian email security update notification and Ubuntu Linux security notification via RSS or email.

Source:
- http://www.cyberciti.biz/faq/apt-get-apticron-send-email-upgrades-available/
- http://www.debian-administration.org/articles/491

ubuntu upgrade vs dist-upgrade

  • apt-get dist-upgrade (smart upgrade in Synaptic):
this command upgrades packages trying to satisfy the dependencies in a "smart" way -- that might mean removing packages. It is not recommended to use it if you don't know exactly what you are doing.
  • apt-get upgrade (default upgrade in Synaptic):
this command upgrades only the upgradeable packages, it doesn't remove packages. From man apt-get: "New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version."

Wednesday, February 4, 2009

How to prompt user login and password in phpmyadmin

Edit config.inc.php
and the exact line is :
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
Change original auth_type "tcp" to "http".

Tuesday, February 3, 2009

Auto Log in in Ubuntu Desktop

I found it so troublesome when i should do log in every time i turn my pc on. I want it like windows that may do automatically log in so i don't need to type in username and password anymore.
1) Go to System > Administration > Login Window
2) Enter your password
3) Go to Security tab and check Enable automatic login
4) Enter your username and press Close
Other way, you may choose Log in automatically from Ubuntu Installation.

Restart your pc to find our whether the setting is working.