Thursday, March 5, 2015

How to make your Unix prompts more useful and interesting


Credit: Sandra Henry-Stocker

Had enough of $ and #? You can make your bash prompts far more interesting and likely a lot more useful by customizing them. You can even change the font color or set up your prompt to change depending on where you're sitting in the file system, what system you're working on, or what time it is.

A customized prompt can serve as a gentle reminder of what system you're working on -- especially helpful if you often find yourself logged into 3-4 systems at a time, window hopping to get several things done at the same time. or if you log in with different accounts. A customized prompt can help if you like to be reminded where you are sitting in the file system or prefer *not* to be reminded where you are in the file system (a full path can take up quite a bit of screen space when you're seven levels deep into /home/username/apps/docs/...).
All you need to do to define your PS1 variable and save it in your .bashrc or .bash_profile file. As it turns out, however, you have a lot of flexibility on what you put into that prompt.
The primary prompt PS1 can be set interactively, but is generally set in one of your dot files. The default is generally just a $, but some admins will customize this to include such things as the system name or your current location in the file system. Don't like that? Override it with seeintgs or your own. The default is usually just a > sign.
You can also set the PS2 command to change the way you're prompted when you're in a loop. You can display this value using the echo \ command.
$ echo \
Your prompt should be set up to provide the most interesting and or valuable indicator.
Can't remember what day it is? Set your prompt to the date:
$ PS1='\d> '
Sat Feb 28>
Want to be sure that you don't want to forget what time it is and end up working until midnight? Set your prompt to the current time.
$ PS1="\@> "
08:47 PM>
You can set your prompt to to include seconds as well. This can be useful if you want to get a feel for how long individual commands that you run are taking to process.
$ PS1="\D{}> "
08:48:40 PM>
If you prefer the 24 hour format, use \A or \t.
$ PS1="\A> "
PS1="\t> "
NOTE: The > at the end of these prompts and the blank that follows are optional, but my preference. I like these characters separating my prompts from my commands.
Have trouble remembering what system you're logged into?
$ PS1='\h> '
Want to feel bad because it takes you so many commands to complete a task?
$ PS1='\#> '
Use ! if you want to see where you are with respect to your history buffer.
11> PS1='\!> '
If you can't remember where you are, the w setting will show your path relative to your home directory. The ~, of course, is your home itself.
PS1='\w '

$ PS1=':-) '
When you have amnesia or just want to be reminded what account you're logged into:
PS1="\u> "
You can expand this to show both the username and system name like this:
PS1="\u@\h "
$ PS1="\u@\h> "
Any of the following can be use din your prompt, though I suspect that few of us will hear the bell even if we use that character string in our prompts.
\a     an ASCII bell character (07)
\d     the date  in  "Weekday  Month  Date"  format (e.g.,
       "Tue May 26")
\e     an ASCII escape character (033)
\h     the hostname up to the first `.'
\H     the hostname
\j     the  number of jobs currently managed by the shell
\l     the basename of the shell's terminal  device name
\n     newline
\r     carriage return
\s     the  name  of  the shell, the basename of $0 (the
       portion following the final slash)
\t     the current time in 24-hour HH:MM:SS format
\T     the current time in 12-hour HH:MM:SS format
\@     the current time in 12-hour am/pm format
\u     the username of the current user
\v     the version of bash (e.g., 2.00)
\V     the release of bash,  version  +  patch level (e.g.,
\w     the current working directory
\W     the  basename  of the current working directory
\!     the history number of this command
\#     the command number of this command
\$     if the effective UID is 0, a #, otherwise a $
\nnn   the  character  corresponding  to  the octal number nnn
\\     a backslash
\[     begin a sequence of non-printing characters, which could
       be used to embed a terminal control
       sequence into the prompt
\]     end a sequence of non-printing characters
You can also put other information into your prompt, but there's a catch. Unless you're using one of the bash prompt escape sequences (like \d and \@), the prompt is set up when you define PS1 and not updated. Set PS1 to the output of the date command and your prompt will display that date and time until you log off.
PS1="`date`> "
Sun Mar  1 18:45:32 EST 2015>
If you're feeling blue, you can even change the color of your prompt:
$ PS1="\e[34m\]\u@\h "
Many other colors are possible:
  • 30m: Black
  • 31m: Red
  • 32m: Green
  • 33m: Yellow
  • 34m: Blue
  • 35m: Purple
  • 36m: Cyan
  • 7m: White
You can even use multiple colors in the same prompt by doing something like this:
PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;35m\]\w\[\e[m\]> '
Note the \[ and \] around the color codes. You can also alter the look of the fonts that you use as in the examples shown below.
0=regular 0;31m
1=bold 1:35m
4=underline 4:32m
Here's a cute little trick that involves your prompt. You can put the current time in right hand corner of your terminal window and change your prompt to a "> " with a setting like this:
PS1="> \[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\[\033[u\]"
Or, if you prefer, display the day of week:
PS1="> \[\033[s\]\[\033[1;\$((COLUMNS-8))f\]\$(date +%A)\[\033[u\]"
System prompts aren't the most exciting part of working on the Unix command line, but they provide helpful information if you take the time to set them up.

IBM DB2 Installation on Red Hat Enterprise Linux

IBM DB2 database can be installed on Linux, UNIX or Window operating systems. We are going to install DB2 Version 10.1 on Red Hat Enterprise Linux Server from command interface. IBM DB2 is a next generation data platform for transactional and analytical operations.
Step 1 : Download IBM DB2 Package for Red Hat Linux from following URL. You can use IBM DB2 database for 90 days without any cost.
We have downloaded the package DB2_ESE_10_Linux_x86-64.tar.gz under /opt directory.
[root@Server opt]# ls
Step 2 : Extract IBM DB2 downloaded package as shown below.
[root@Server opt]# tar -xvzf DB2_ESE_10_Linux_x86-64.tar.gz

[root@Server opt]# ls
DB2_ESE_10_Linux_x86-64.tar.gz ese
Step 3 : Now install IBM DB2 Package
[root@Server opt]# cd ese
[root@Server opt]# ls
db2 db2ckupgrade db2_deinstall db2_install db2ls db2preregcheck db2setup ibm_im installFixPack n1pack
[root@Server ese]# ./db2_install

 Support of the db2 install command is deprecated. For
 more information, see the DB2 Information Center.
 Default directory for installation of products - /opt/ibm/db2/V10.1
 Install into default directory (/opt/ibm/db2/V10.1) ? [yes/no]

yes (Press Enter)

Specify one of the following keywords to install DB2 products.


Enter "help" to redisplay product names.
 Enter "quit" to exit.
 Do you want to install the DB2 pureScale Feature? [yes/no]

DB2 installation is being initialized.
 Total number of tasks to be performed: 46
 Total estimated time for all tasks to be performed: 1673 second(s)
 Task *1 start
 Description: Checking license agreement acceptance
 Estimated time 1 second(s)
 Task *1 end
 Task *2 start
 Description: Base Client Support for installation with root privileges
 Estimated time 3 second(s)
 Task *2 end
 Task *3 start
 Description: Product Messages - English
 Estimated time 13 second(s)
 Task *3 end
 Task *4 start
 Description: Base client support




For more information see the DB2 installation log at

Step 4 : Now check which DB2 packages are installed on your server. To check installed packages you can read log files (db2_install.log.xxxxx) under /tmp directory.
DB2 Setup log file started at:  Thu Feb 26 22:23:43 2015 IST
Operating system information: Linux 2.6.32-220.el6.x86_64.#1 SMP Wed Feb x 08:03:13 EST 2015 x86_64
WARNING: Notification SMTP server has not been specified. Notifications cannot be 
sent to contacts in your contact list until this is specified. For more information
see the DB2 administration documentation.
Product to install:                        DB2 Enterprise Server Edition
Previously Installed Components:
Selected Components:
Base client support
Java support
SQL procedures
Base server support
Connect support
DB2 data source support
Spatial Extender server support
IBM Software Development Kit (SDK) for Java(TM)
DB2 LDAP support
DB2 Instance Setup wizard
Integrated Flash Copy Support
Spatial Extender client
Communication support – TCP/IP
Tivoli SA MP
Base application development tools
DB2 Update Service
Replication tools
Sample database source
DB2 Text Search
Informix data source support
First Steps
Installing DB2 file sets :…….Success
DBI1514I  The DB2 High Availability (HA) scripts for the IBM Tivoli System 
Automation for Multiplatforms (SA MP) were successfully installed.
You need DB2 HA scripts to use SA MP with the DB2 HA feature.
These DB2 HA scripts are located at /usr/sbin/rsct/sapolicies/db2. 
The DB2 installer detects whether these DB2 HA scripts
need to be installed or updated.

User response:
No action is required.
Installing or updating DB2 HA scripts for IBM Tivoli System Automation for 
Multiplatforms (Tivoli SA MP) :…….Success
Executing control tasks :…….Success
Updating global registry :…….Success
Starting DB2 Fault Monitor :…….Success
Updating the db2ls link :…….Success
Registering DB2 licenses :…….Success
Setting default global profile registry variables :…….Success
Initializing instance list :…….Success
Registering DB2 Update Service :…….Success
Updating global profile registry :…….Success
Post Install Recommendations
Required steps:
Set up a DB2 instance to work with DB2.
Optional steps:
To validate your installation files, instance, and database functionality,
run the Validation Tool, /opt/ibm/db2/V10.1/bin/db2val. For more information, 
see “db2val” in the DB2 Information Center.

Open First Steps by running “db2fs” using a valid user ID such as the DB2 instance 
owner’s ID. You will need to have DISPLAY set and a supported web browser in the 
path of this user ID.

Verify that you have access to the DB2 Information Center based on the choices you 
made during this installation. If you performed a typical or a compact installation,
verify that you can access the IBM Web site using the internet. If you performed a 
custom installation, verify that you can access the DB2 Information Center location
 specified during the installation.

Ensure that you have the correct license entitlements for DB2 products and features
installed on this machine. Each DB2 product or feature comes with a license certificate 
file (also referred to as a license key) that is distributed on an Activation CD, 
which also includes instructions for applying the license file. If you purchased 
a base DB2 product, as well as, separately priced features, you might need to 
install more than one license certificate. The Activation CD for your product or 
feature can be downloaded from Passport Advantage if it is not part of the physical
 media pack you received from IBM. For more information about licensing, search the 
Information Center ( 
using terms such as “license compliance”, “licensing” or “db2licm”.

DB2 Setup log file finished at:  Thu x Feb 2015 10:25:26 PM IST
Step 5 : Now create db2 instance and fenced user.
[db2inst1@Server ~]# id db2inst1
uid=500(db2inst1) gid=500(db2igrp1) groups=500 (db2igrp1)

[db2inst1@Server ~]# id db2fenc1
uid=501(db2fenc1) gid=500(db2fgrp1) groups=500 (db2fgrp1)
Step 6 : Now Create db2 instance.
[root@Server instance]# ./db2icrt -a SERVER_ENCRYPT -p DB2_db2inst1 -s ese -u db2fenc1 db2inst1
DBI1446I  The db2icrt command is running, please wait.
DB2 installation is being initialized.
Total number of tasks to be performed: 4
Total estimated time for all tasks to be performed: 309 second(s)
Task #1 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #1 end
Task #2 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #2 end
Task #3 start
Description: Configuring DB2 instances
Estimated time 300 second(s)
Task #3 end
Task #4 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #4 end
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.48480". 
DBI1070I  Program db2icrt completed successfully.
Step 8 : Create a Sample database.
[db2inst1@Server ~] db2 “create database sample”
Your IBM DB2 database is ready to use.

A List Of Free And Open Source Control Panels


To manage your businesses and your websites remotely you need to use control panel. With such tool you will have the possibility to manage all your web services under the same location which is very fantastic. Without control panel, you will need to install or compile specific tools such as: Php, MySQL and others on your host server which is not usually recommended with normal people. Since they need to have technical knowledge. With control panel, no expert knowledge of server administration is needed, just install it and benefit of its features. These web based control panels offers you the possibility also to manage your emails accounts, FTP accounts, disk space, bandwidth and many others.
The most known and powerful control panels are cPanel and Plesk. Unfortunately they are paid softwares and a monthly fee will be demanded to install them on the suitable server. But don’t worry, there are other alternative open source control panels available for every one with the same features and no fees are required. You will discover those tools in our article then later you can give us your attitudes.


ISPconfig is Open source, BSD-licensed, hosting control panel for Linux, designed to manage Apache, BIND, FTP, and databases, supporting many Linux distributions.With the ISPConfig Monitor App, you can check your server status and find out if all services are running as expected. You can check TCP and UDP ports and ping your servers. ISPConfig is multiserver-capable, you can check all servers that are controlled from your ISPConfig master server.
Concerning its features we can list the following:
  • Manage one or more servers from one control panel.
  • Supports Many Linux Distributions
  • Support For Many Daemons
  • Managed Services
  • Translated In More Than 20 Languages
For download and usage instructions, please visit the official website.


ZPanel is a free and complete web hosting control panel for Microsoft® Windows™ and POSIX (Linux, UNIX and MacOSX) based servers. ZPanel is written in PHP and uses several open-source (or freely available) software packages to provide a secure, web hosting system.
ZPanel comes with a core set of ‘essential’ modules to help you run a web hosting service these range from Server resource monitoring to DNS management.
The core comes includes Apache Web Server, hMailServer,FileZilla Server, MySQL, PHP, Webalizer, RoundCube, phpMyAdmin, phpSysInfo, FTP Jailing and many more.
For download and usage instructions, please visit the official website


OpenPanel is a is another free open source control panel. It has lots of functionality, an attractive interface and is very user friendly. OpenPanel is a platform for developers. Because it is extremely open and modular it can be utilized to control any process on a Linux server. The OpenPanel graphical user interface is a modern JavaScript application with a a simple, modern design.
We can list the following features of OpenPanel:
  • Inviting and attractive interface
  • Easy-to-use Command Line Interface
  • Full control over all technical processes
  • Easy to add modules in order to provision new services
For download and usage instructions, please visit the official website


Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.
We can list the following features of Webmin
  • Configure and create virtual server on Apache.
  • Manage, install or delete a software packages (RPM format).
  • For security you can set up firewall.
  • Modify DNS settings, IP address, routing configuration.
  • Manage database, tables and fields on MySQL.
For download and usage instructions, please visit the official website.


Sentora provides the most common control panel features ‘out of the box’ but when you need more head over to our ‘add-ons store’ and download third-party modules, translations and even theme sets.
Sentora is based on the solid foundations of ZPanel and developed by the original team, Sentora provides a robust open-source web hosting control panel for small to medium ISPs.
Sentora is designed to simplify web hosting management, it gives your clients the ability to quickly and easily manage their web hosting. Sentora Add-ons store provides  users with a central repository to install, rate, sell and publish modules, themes and localisations.
For download and usage instructions, please visit the official website.

CentOS Web Panel CWP

CentOS Web Panel CWP – Free Web Hosting control panel is designed for quick and easy management of (Dedicated & VPS) servers without of need to use ssh console for every little thing. There is lot’s of options and features for server management in this control panel.
CentOS Web Panel come with lots of features and free services:
  • Automatically installs full LAMP on your server
  • Apache Web Server (Mod Security + OWASP rules optional)
  • Varnish Cache server (improve your server performances by 3x)
  • DoS protection from the Slow-Loris attacks
For more information, you can visit the official website.
The description of our selected free and open source control panels systems in this article now is finished. Of course, there are other tools we don’t mention, if you want to include them in our article please feel free to leave a comment here with a brief description of the suggested tools. Thank you for reviewing our article and please don’t forget to share it.