≡ Menu

unix operating system

WebEx Linux

Q. Does WebEx works under Linux or UNIX operating system?
[click to continue…]

FreeBSD Install BASH Shell

I'd like to Bash shell under FreeBSD for bash programming. How do I install bash shell under FreeBSD UNIX operating system?
[click to continue…]

OpenBSD Install MySQL Server

Q. How do I install and run MySQL version 5 database Server under OpenBSD UNIX operating system?

A. OpenBSD has pkg_add command. It is used to install packages created with the pkg_create command. Selected packages containing pre-compiled applications from the /usr/ports tree can be found on the OpenBSD FTP site or on the official OpenBSD CD. pkg_add is the easiest way to install new packages, to replace existing packages with other flavors (option -r) or to update packages to newer versions option -u).

Install MySQL Database Server on OpenBSD

First setup installation mirror i.e. PKG_PATH using export command:
$ export PKG_PATH=ftp://mirror.planetunix.net/pub/OpenBSD/4.1/packages/`machine -a`/
Next install MySQL server, using pkg_add command, enter:
$ sudo pkg_add -i -v mysql-server
# pkg_add -i -v mysql-server

parsing mysql-server-5.0.33
Dependencies for mysql-server-5.0.33 resolve to: p5-DBD-mysql-3.0008, mysql-client-5.0.33 (todo: mysql-client-5.0.33,p5-DBD-mysql-3.0008)
mysql-server-5.0.33:parsing mysql-client-5.0.33
mysql-server-5.0.33:mysql-client-5.0.33: complete
mysql-server-5.0.33:parsing p5-DBD-mysql-3.0008
Dependencies for p5-DBD-mysql-3.0008 resolve to: mysql-client-5.0.33, p5-DBI-1.53 (todo: p5-DBI-1.53)
mysql-server-5.0.33:parsing p5-DBI-1.53
Dependencies for p5-DBI-1.53 resolve to: p5-PlRPC-0.2018p0 (todo: p5-PlRPC-0.2018p0)
mysql-server-5.0.33:parsing p5-PlRPC-0.2018p0
Dependencies for p5-PlRPC-0.2018p0 resolve to: p5-Net-Daemon-0.39 (todo: p5-Net-Daemon-0.39)
mysql-server-5.0.33:parsing p5-Net-Daemon-0.39
mysql-server-5.0.33:p5-Net-Daemon-0.39: complete
mysql-server-5.0.33:p5-PlRPC-0.2018p0: complete
mysql-server-5.0.33:p5-DBI-1.53: complete
mysql-server-5.0.33:p5-DBD-mysql-3.0008: complete
adding group _mysql
adding user _mysql
installed /etc/my.cnf from /usr/local/share/mysql/my-medium.cnf****************************************************************************************************     | 97%
mysql-server-5.0.33: complete
--- mysql-server-5.0.33 -------------------
The mysql-server package doesn't initialize a default database.
Please run /usr/local/bin/mysql_install_db to create one.

Install default MySQL database

By default MySQL database is not initialized, enter the following command to create a default database:
# /usr/local/bin/mysql_install_db

Installing all prepared tables
Fill help tables
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h openbsd.nixcraft.in password 'new-password'
See the manual for more instructions.

Start MySQL server

Now you have MySQL server installed. Start the server daemon, enter:
# /usr/local/bin/mysqld_safe &

[1] 7750
Starting mysqld daemon with databases from /var/mysql

Connect to MySQL server

Run mysql command to test if everything is working fine, enter:
# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.33-log OpenBSD port: mysql-server-5.0.33
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit

Set root password

You must set a password for the MySQL root user, enter:
# /usr/local/bin/mysqladmin -u root password 'YOUR-Secret-Password'
To access the MySQL server with password, enter:
$ mysql -u root -p

Create MySQL startup and stop script

Finally, you need a script to start and stop MySQL Server. In order to start MySQL server at boot time, enter following command in /etc/rc.conf.local file:
# vi /etc/rc.conf.local
Append following line:
Save and close the file. Now you need to edit /etc/rc.local file. It is use to specify site-specific startup actions, daemons, and other things which can be done AFTER your system goes into securemode:
# vi /etc/rc.local
Find out line which read as follows:
# Add your local startup actions here.
Append following code:

# MySQL startup
if [ X"${mysql}" == X"YES" -a -x /usr/local/bin/mysqld_safe ]; then
   echo -n " mysqld "
   /usr/local/bin/mysqld_safe --user=_mysql &

Save and close the file.

How do I stop MySQL server under OpenBSD?

Use mysqladmin command:
# mysqladmin -u root -p shutdown

Sun Solaris UNIX display list for loaded kenel device driver / modules

Q. How do I display information about loaded kernel modules under Sun Solaris UNIX operating system?

A. You need to use modinfo command which is a trivial program to display information about the loaded modules. The format of the information is as follows:

Id Loadaddr Size Info Rev Module Name

where Id is the module ID, Loadaddr is the starting text address in hexadecimal, Size is the size of text, data, and bss in hexadecimal bytes, Info is module specific information, Rev is the revision of the loadable modules system, and Module Name is the filename and description of the module.

Task: Displaying the status of kernel modules

Just enter modinfo command:
You can pass -c option to modinfo command to display the number of instances of the module loaded and the module's current state:
modinfo -c

Display information about particular module / driver only

You can also display information about particular module only by specifying its ID #:
modinfo -i 5
The above example displays the status of module # 5.

Read modinfo man page for other information and options.

HP-UX: Find Out If Recommend Security Patch Applied Or Not

How do I compare the HP-UX UNIX system output with the most current vendor recommended and security patches?
[click to continue…]

Find subnet mask on UNIX

Q. How do I find out subnet mask on UNIX operating system? Can you tell us the name of command and configuration file to store subnetmask under UNIX?

A. A subnetwork/ subnet is a range of logical addresses within the address space that is assigned to an organization. Subnetting is a hierarchical partitioning of the network address space of an organization (and of the network nodes of an autonomous system) into several subnets. Routers constitute borders between subnets. Communication to and from a subnet is mediated by one specific port of one specific router, at least momentarily.

Under UNIX / Linux, you need to use the ifconfig utility to assign an address to a network interface
and/or configure network interface parameters. Same command can display subnet. Just type command ifconfig:
$ ifconfig
$ /sbin/ifconfig
$ /sbin/ifconfig interface-name

lnc0: flags=108843 mtu 1500
        inet netmask 0xfffffff8 broadcast
        ether 00:0c:29:32:8a:8c
plip0: flags=108810 mtu 1500
lo0: flags=8049 mtu 16384
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet6 ::1 prefixlen 128
        inet netmask 0xff000000

Look for inet line you will see an IP address, followed by netmask.

Linux / UNIX: Print Current Working Directory with pwd command

Q. How do I display the absolute path to the current working directory under Linux or UNIX operating system?

A. The pwd command displays the absolute pathname of the current working directory to the computer screen.

Print name of current/working directory

Type pwd command:

Above command print the full filename of the current working directory i.e /home/vivek.

Display actual directory location

Use -P option to display the physical current working directory (all symbolic links resolved). For example, /home/lighttpd is /var/www/root/lighttpd:
cd /home/lighttpd



Now run with -P option
pwd -P


Apache server view performance status with mod_status configuration

Q. How do I view and verify Apache server performance status under Linux / UNIX operating system?

A. The Status module (mod_status) allows a server administrator to find out how well their server is performing. A HTML page is presented that gives the current server statistics in an easily readable form. If required this page can be made to automatically refresh.

The details given are:

* The number of children serving requests.
* The number of idle children.
* The status of each child, the number of requests that child has performed and the total number of bytes served by the child (*)
* A total number of accesses and byte count served (*).
* The time the server was started/restarted and the time it has been running for
* Averages giving the number of requests per second, the number of bytes served per second and the average number of bytes per request (*).
* The current percentage CPU used by each child and in total by Apache (*).
* The current hosts and requests being processed (*).

Details marked "(*)" are only available with ExtendedStatus On.

Configure Apache mod_status

Open your httpd.conf file:
# vi httpd.conf
Append / modify (or uncomment) directives as follows:
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from

Replace with your workstation IP address. Save and close the file. Restart httpd server:
# /etc/init.d/httpd restart
For full status report type:
# /etc/init.d/httpd fullstatus

To view status report type url - http://your.com/server-status.

You can now access server statistics by using a Web browser to access the page http://your.server.name/server-status


How can I restore a backup of a MySQL database?

Q. I made MySQL backup using mysqldump -u user -h localhost -ppassword forumdb | -gzip -9 > forumdb.sql.gz command. How do I restore MySQL database backup using a shell prompt under Linux / UNIX operating system?
[click to continue…]

Linux / Unix: Find All The Files Owned By a Particular User / Group

How do I list or find all the files owned by a particular system user or group under Linux or UNIX like operating systems using command line options?
[click to continue…]