Category Archives: Linux Tutorial

How to install Unix FreeBSD

Yes, this a little different the previous installation tutorials. FreeBSD installation is quite complicated and had quite a lot of questions asked during installation šŸ™ However, FreeBSD is quite a powerful system if you know how to manage it. It provides the best security system compared to others.

I’ll try to make the installation process as simple as I can. Proceed to below:

Continue reading

Reset Your Linux Password in Single Mode

This step will work on especially on CentOS, RedHat, and Fedora. Make sure you didn’t put any password for your GRUB during installation or this tutorial won’t be any help.

1) Turn on the server until the loading screen appears.

2) While on countdown, press any key to cancel the countdown

3) Select your current Linux kernel:

4) Select the Kernel, then press “e” to edit the line:

5) Go to the end of the line, press the spacebar once, then add the word “single” like below:

6) Press Enter and press “b” to boot that argument that you just modified

7) Wait till it finished loading, then you are able to start typing. Then you may change your password like below:

8) When done, type “reboot” and you are able to use the new password.

Malware Detector – Maldet

It is quite a common view that your server eventually will be the target of unethical hackers. They will try their best to hack into your server, inject their codes, and get the right to brag among their buddies (pathetic). There so many ways on how they gain access to the server but usually thanks to any accounts that used old scripts that often open for exploits.

You might often heard these terms:
1) trojan
2) mysql injection
3) shell script
4) rootkit

and a few more which only hackers know the way to hack your server. Well, today i’ll try to introduce a recommended application to scan possible malware codes that have been injected to your server, MALDET.

Upon login into ssh, type:
wget http://www.rfxn.com/downloads/maldetect-current.tar.gz

Extract the file:
tar xfz maldetect-current.tar.gz

Opens the folder:
cd maldetect-*

and install:
./install.sh

That’s it. Next is to scan the suspected folders in your server. For example:
maldet -a /home/username/public_html

The option -a means to scan all files and folders inside. You also can type -h for the available options.

When it finished, the link to the report will looks like this:
maldet –report 050910-1534.21135

Copy and paste the exact line in your ssh. If there were any hits, it will show in the report. Use it accordingly.

Disclaimer: Don’t fully depends on the maldet for malware detection. Maldet can’t detect every kind of malware, so some time the best way is to go through every files and check its modified date or suspicious file name.

Multi-tasking Screen in CentOS

Have you ever experience the needs to multi-task in a single screen while the current SSH screen already occupied with the current task?

Ever experience a sudden internet outrage after spending almost 4 hours on cPanel installation via SSH? When you got your connection back, you’ll found out that you had to start the installation back from zero.

Worry no more. Apparently there is a great tool that can be installed in the server that can ease up your life. Presenting, Screen (yes, it is an obvious name). By using Screen, you can create multiple screens that suits your need in a single main screen. You are able to run it simultaneously at the same time and don’t have to worry if your internet sudden disconnect when you are connecting via SSH. You can continue your screens back when you are back online.

First of all, lets install the screen by typing:
yum install screen

You can start using screen by just typing:
screen

To list out all available screen:
screen -ls

Then it will looks like this:
root@server [/home/]# screen -ls
There are screens on:
23513.pts-1.serverĀ Ā Ā Ā  (Detached)
18174.pts-2.serverĀ Ā Ā Ā  (Detached)

To re-attach the screen:
screen -r screenname

To detach the screen:
screen -d

Then this message will appear:
[detached]

Alternatively, you can use keyboard shortcuts to manipulate the screen.

Use this if you want to create new screen:
CTRL + a + c

Use this if you want to view the next screen:
CTRL + a + n

Use this if you want to view previous screen:
CTRL + a + p

Use this if you want to detach the screen:
CTRL + a + d

Finally, to terminate the screen, just type:
exit

Then it will appear this:
[screen is terminating]

Have fun!

Synchronizing Folders using Rsync

This is an alternative to the “mv” command (move) or cp (copy) but slightly with a added feature of doing it remotely from server to another server.

Local Server
rsync -avzp /source-address/* /destination-address/

Remote Server
rsync -avzp -e ‘ssh -p portnumber’ /source-address/* root@ipaddress:/destination-address/

*Note*
source-address = the source of the folder/files eg:
/home/test/

destination-address = the destination to sync the files from the source eg:
/home/robot/

portnumber = the ssh port number, default is:
22

ipaddress = the ip address of the destination server of the hosname eg:
202.111.111.202 or yahoo.domain.com

Lastly, don’t forget to change the file ownership, example like below:
chown username.username *

============================================
================== Edit 1 ===================
============================================

If you noticed, some files won’t be copied over using the Rsync, especially like the .htaccess file. As an alternative you can use this coding to copy those special file like example below:
scp -P portnumber /home/username/public_html/.htaccess root@ipaddress:/home/username/public_html/

If a folder that can’t be transfered, you can use as below, but make sure to create a folder at server B also, for example as below:
scp -P portnumber /home/username/public_html/.smileys/* root@ipaddress:/home/username/public_html/.smileys/

Don’t forget to change the ownership again.

============================================
================== Edit 2 ===================
============================================

When moving website that have a database, make sure to properly configure the data base when transferring it.

Let say now our current situation, server A is transferring to server B. After the files have been transferred to server B, log into server A PhpMyAdmin and find the account name.

Click to open the database (_testdb).
Username
|
|—-_testdb

Click Export
Select compression = gzipped
Click Go

Then just save it any place in your pc.

Ok then, next is a bit tricky part. Go to server B, and the folder where you upload the file and try to open:
nano configuration.php

The content of the file as below:
$mosConfig_offline = ‘0’;
$mosConfig_host = ‘localhost’;
$mosConfig_user = ‘username_testdb’;
$mosConfig_password = ‘xxxxx’;
$mosConfig_db = ‘username_testdb’;

$mosConfig_dbprefix = ‘mos_’;
$mosConfig_absolute_path = ‘/home/username/public_html/’;
$mosConfig_live_site = ‘http://domain.com’;
$mosConfig_sitename = ‘Testing Website’;
$mosConfig_shownoauth = ‘0’;
$mosConfig_useractivation = ‘1’;
$mosConfig_uniquemail = ‘1’;
$mosConfig_usecaptcha = ‘0’;
$mosConfig_offline_message = ‘This site is down for maintenance.<br /> Please check back again soon.’;
$mosConfig_error_message = ‘This site is temporarily unavailable.<br /> Please notify the System Administrator’;
$mosConfig_debug = ‘0’;
$mosConfig_lifetime = ‘900’;
$mosConfig_MetaDesc = ‘This Software Site Is Under Serverfreak’;
$mosConfig_MetaKeys = ”;
$mosConfig_MetaAuthor = ‘1’;
$mosConfig_MetaTitle = ‘1’;
$mosConfig_lang = ‘english’;
$mosConfig_locale = ‘en’;
$mosConfig_charset = ‘utf-8’;
$mosConfig_locale_debug = ‘0’;
$mosConfig_locale_use_gettext = ‘0’;
$mosConfig_offset = ‘0’;
$mosConfig_hideAuthor = ‘1’;
$mosConfig_hideCreateDate = ‘1’;
$mosConfig_hideModifyDate = ‘1’;
$mosConfig_hidePdf = ‘0’;
$mosConfig_hidePrint = ‘0’;
$mosConfig_hideEmail = ‘0’;
$mosConfig_enable_log_items = ‘0’;
$mosConfig_enable_log_searches = ‘0’;
$mosConfig_enable_stats = ‘0’;
$mosConfig_sef = ‘0’;
$mosConfig_vote = ‘0’;
$mosConfig_gzip = ‘0’;
$mosConfig_multipage_toc = ‘1’;
$mosConfig_allowUserRegistration = ‘0’;
$mosConfig_link_titles = ‘0’;
$mosConfig_error_reporting = ‘-1’;
$mosConfig_register_globals = ‘1’;
$mosConfig_list_limit = ’50’;
$mosConfig_caching = ‘0’;
$mosConfig_cachepath = ‘/home/username/public_html/cache’;
$mosConfig_cachetime = ‘900’;
$mosConfig_mailer = ‘mail’;
$mosConfig_mailfrom = ‘[email protected]’;
$mosConfig_fromname = ”;
$mosConfig_sendmail = ‘/usr/sbin/sendmail’;
$mosConfig_smtpauth = ‘0’;
$mosConfig_smtpuser = ”;
$mosConfig_smtppass = ”;
$mosConfig_smtphost = ‘localhost’;
$mosConfig_back_button = ‘0’;
$mosConfig_item_navigation = ‘0’;
$mosConfig_secret = ‘xxxxxx’;
$mosConfig_pagetitles = ‘1’;
$mosConfig_readmore = ‘1’;
$mosConfig_hits = ‘1’;
$mosConfig_icons = ‘1’;
$mosConfig_favicon = ‘favicon.ico’;
$mosConfig_fileperms = ”;
$mosConfig_dirperms = ”;
$mosConfig_mbf_content = ‘0’;
$mosConfig_helpurl = ‘http://docs.mambo-foundation.org’;

The parts I bold above are the part you need to pay attention.
$mosConfig_user = ‘username_testdb’;
$mosConfig_password = ‘xxxxx’;
$mosConfig_db = ‘username_testdb’;
$mosConfig_absolute_path = ‘/home/username/public_html/’;
$mosConfig_cachepath = ‘/home/username/public_html/cache’;

So now assuming that our database name and the user is username_testdb, while the password is xxxxx

Go to the the account’s cPanel. Under Database, select the MySQL Databases. Under Create New Database, fill in the BOLD part as below:
New Database:Ā Ā  username_testdb
and then click the Create Database button.

Next, go to the Add New User, then fill in as below:
Username:username_testdb
Password:xxxxx
Password (Again):xxxxx
Click Create User button afterward.

Then, go to Add User To Database section, select as below:
User: username_testdb
Database: username_testdb
and click on the Add button.
It will bring to a new page. This page is quite important. Make sure to Tick the ALL PRIVILEGES checkbox and then click the Make Changes button.

============================================
==================== End ====================
============================================

Ok then, the database part is finished. Make sure to test run and check whether got any error message or not. By the way, this were all tested in a cPanel-based hosting. The Rsync and the scp part will work on any hosting, but the database part might be slightly different.

Happy Trails.

Compile PHP 5.3 via CustomBuild in Direct Admin

This is the step on how to compile your PHP into the latest version (or vice versa, according to your preferences) using CustomBuild in Direct Admin servers.

Note: This same procedure also can be applied with any other supported modules in Direct Admin. Just type “./build” to list out the things that you are able to update.

First, go to this folder:
/usr/local/directadmin/custombuild

Then modify the option.conf:
nano options.conf

Try to find this string:
php5_ver=

In my case, my current php is 5.2 and i need to recompile it to 5.3, so my current option.conf should looks like this:
php5_ver=5.2

and modified to this:
php5_ver=5.3

Save and close it.

Next, to download the updated version, type:
./build update

After the download is done, then finally we can start compiling by typing this:
./build php n

The compiling process should take a while. But just in case you ran into this kind of error:
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/tm2unixtime.lo] Error 1
make: *** Waiting for unfinished jobs….
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/parse_tz.lo] Error 1
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/parse_date.lo] Error 1

So you are running out of RAM. Make sure too add enough RAM for the process to proceed.

Finally when finished, it will restart the httpd by itself. You can check the php version by typing “php -v” and the result as below will appear:
Before:
[root@server custombuild]# php -v
PHP 5.2.13 (cli) (built: JulĀ  7 2010 01:09:45)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

and after:
[root@server custombuild]# php -v
PHP 5.3.2 (cli) (built: JulĀ  8 2010 07:36:44)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Happy compiling.