Tag Archives: Linux

Install LAMP on CentOS 5

=== Install LAMP (Linux Apache MySQL and PHP) ===

yum install httpd php php-mysql mysql mysql-server
chkconfig httpd on
chkconfig mysqld on
/etc/init.d/httpd restart
/etc/init.d/mysqld restart

=== set MySQL root password ===
mysqladmin -u root -p password newpassword
mysqladmin -u root -p reload

=== change MySQL root password (just in case) ===
mysqladmin -u root -p’oldpass’ password ‘newpass’

=== install phpMyadmin ===
yum install phpmyadmin php-mysql php-mcrypt

config phpMyadmin
vi /usr/share/phpmyadmin/config.inc.php
#modify this line>> $cfg[‘blowfish_secret’] = ‘fgkswdflvjkasbvoiqweur’;

config apache for phpMyadmin
vi /etc/httpd/conf.d/phpmyadmin.conf

remark this line>> Deny from all
modify this line>> Allow from

reload apache
/etc/init.d/httpd reload

Shortcut keys for the bash shell

{| class=”wikitable sortable”
|+ Bash shell shortcut keys
!width=70 |Key
!width=auto | Description
|Ctrl + A || Go to the beginning current line
|Ctrl + E || Go to the end of current line
|Ctrl + L || Clears the Screen
|Ctrl + U || Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
|Ctrl + H || Same as backspace
|Ctrl + R || Search through previously used commands
|Ctrl + C || Kill whatever you are running
|Ctrl + D || Exit the current shell
|Ctrl + Z || Puts whatever you are running into a suspended background process. fg restores it.
|Ctrl + W || Delete the word before the cursor
|Ctrl + K || Clear the line after the cursor
|Ctrl + T || Swap the last two characters before the cursor
|Esc + T || Swap the last two words before the cursor
|Alt + F || Move cursor forward one word on the current line
|Alt + B || Move cursor backward one word on the current line
|Tab || Auto-complete files and folder names

Setup Putty for Linux

Software used:

Here is how I setup Putty to connect to CentOS, fix the problem of full screen tools (such as system-admin-network).

  • start Putty
  • Terminal > Keyboard > The Function keys and keypad : select Linux
  • Windows : set lines of scrollback to 2000 (or more)
  • Windows > Translation : change character set to UTF-8
  • Windows > Colours : change ANSI Blue to 100,100,255
  • Connection > Data : set Terminal-type string to “linux”

go back to Session, select Default Settings, cick Save

Install FreeNX on Centos 5.2

Software Used


  • CentOS 5.2 i386


  • NoMachine NX Client for Windows 3.2.0-13

On the linux box, install X Windows and Gnome first (if not installed yet)

su –
yum groupinstall “X Window System” “GNOME Desktop Environment”

and then issue these commands to install freenx

yum install nx freenx
nxsetup –install –setup-nomachine-key

On the client, download and install the nomachine client from www.nomachine.com

that’s it!

Linux filesystem hierarchy

As a Linux beginner, it is always hard to understand what all these directory names means. Here is a list of the directory hierarchy of CentOS 5.

/ the root of everything
/bin common linux commands. such as ls, cp, gzip, etc
/boot boot codes of Linux – not to touch it unless you are going to re-compile kernel/boot/grub – the boot loader
/dev device files – everything is a file (these files are not device drivers)
/dev/ttyS0 – first serial port (COM1)
/dev/lp0 – first parallel port (LPT1)
/dev/hda – first hard disk (IDE0)
/etc most configuration files
/etc/X11 – configuration files for X Windows
/home home directories for users
/lib shared library files (C libraries)
/lost+found stray files that is found after system crashes
/media mount point for removable media
/mnt mount point for temporary filesystems
/opt larger application softwares – such as OpenOffice
/proc virtual files for various process such as CPU, RAM, etc
/root home directory for the root user
/sbin commands for system users and many system configuration utilities
/selinux SElinux files
/srv data for services
/tmp temporary files
/usr a secondary hierarchy/usr/bin – some advanced commands and user installed commands
/usr/src – kernel source
/usr/local – used to install packaqes from source
/usr/sbin – system commands
/usr/doc – documentations
/usr/man – man pages
/var often changing files – system logs, print spoolers, mail spoolers, etc

WordPress – disable AutoCorrect

WordPress has a feature similiar to the AutoCorrect in MS Word. For example, it replace double hyphen (–) to a single hyphen (-).

It think it is a nice feature for most people, but It is also the worst thing for people who blog about programming or linux commands. This is how to disable this feature:

  • edit the file /wp-include/formatting.php
  • remark the following 2 lines (on my WP2.6 MU, they are on line 32 and 34)

//$curl = str_replace($static_characters, $static_replacements, $curl);
//$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);

Linux commands – chmod

chmod is used to change permissions on files and directories on a linux system.

An example file listing

ls -l
-rw-r--r-- 1 derek managers    0 Oct 10 19:11 myfile
drwxr-xr-x 2 derek managers 4096 Oct 10 19:11 myfolder
-rw-r--r-- 1 derek managers    0 Oct 10 19:11 myprogram

The permissions are indicated in the first column : d rwx rwx rwx

  • 1st letter – indicate whether it is a directory of a file (d means it is a directory)
  • 2nd-4th letters – indicate owner’s permission (e.g. derek can read/write/execute on myprogram)
  • 5th-7th letters – indicate group’s permission (e.g. managers can read/execute but not write on myprogram)
  • 8th-10th letters – indicate other’s permission (e.g. everyone else can read/execute but not write on myprogram)
  • an “x” on a directory means the folder is searchable

Continue reading

Install Webmin on Centos 5

Webmin is a powerful and popular web-based interface for system administration for Unix/Linux/BSD. Using any web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit configuration files and let you manage a system from the console or remotely.

Software Used

  • CentOS 5.2 i386
  • Webmin 1.430

Install Webmin

  • download lastest Webmin RPM from www.webmin.com

cd /tmp
wget http://prdownloads.sourceforge.net/webadmin/webmin-1.430-1.noarch.rpm
rpm -U webmin-1.430-1.noarch.rpm

  • start your browser, open https://myserver.mydomain.local:10000
  • accept the invalid certificate (because it is self signed)
  • login as root

Enable insecure http connection

  • this is not recommended if the server is on public internet
  • login Webmin (temporary accept the invalid certificate, do not add it)
  • go to Webmin > Webmin Configuration > SSL Encryption
  • Enable SSL if available? No
  • Save

Install NoMachine NX Server on CentOS 5

NX is a quick way to remote administrate my Linux servers (speed comparable to RDP or ARD).

The NoMachine NX Free Edition only allow 2 concurrent sessions (enough for administration purpose). If you need more concurrent sessions, you have to use the paid version or FreeNX server.

Software Used


  • CentOS 5.2 i386
  • NoMachine NX Free Edition for Linux 3.2.0-16


  • Windows Vista Business SP1
  • NoMachine NX Client for Windows 3.2.0-13

Install NX Server

  • login as root
  • startx
  • go to www.nomachine.com
  • Download the NX Free Edition for Linux i386 Client, Node and Server
  • double-click nxclient-3.*.i386.rpm to install the client
  • double-click nxnode-3.*.i386.rpm to install the node
  • double-click nxserver-3.*.i386.rpm to install the server

Continue reading

Integrate CentOS 5 and Active Directory using Winbind and Samba

Software used:

  • CentOS 5.2 i386
  • Active Directory server: Win2003 R2 SP2, native mode


You need a working CentOS 5 system and have Server and Server GUI installed.

Install samba and winbind if they are not installed yet

yum install samba samba-client winbind

In this example, change mydomain.local to your own domain name, and myserver.mydomain.local to your active directory domain controller (PDC) server, and to your PDC IP address.


  • use CAPITAL LETTERS in domain/realms etc, as shown in the examples.
  • check the date/time/timezone, make sure the linux and your AD server is in sync.

Continue reading