≡ Menu

pkg add command

OpenBSD: Install Firefox Web Browser

How do I install Mozilla Firefox which is a free and open source web browser under OpenBSD operating systems?
[click to continue…]

How do I install nmap network security and auditing tool under OpenBSD operating system?
[click to continue…]

FreeBSD Install Applications

Q. How do I install applications under FreeBSD operating systems?
[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
OR
# pkg_add -i -v mysql-server
Output:

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
Output:

Installing all prepared tables
Fill help tables
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
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 &
Output:

[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
Output:

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
Bye

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:
mysql=YES
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 &
fi

Save and close the file.

How do I stop MySQL server under OpenBSD?

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

FreeBSD install Perl language

Q. I need Perl programming language to run scripts. How do I install perl on FreeBSD operating system?

A. Practical Extraction and Report Language or Perl can be installed using FreeBSD ports or binary package system. Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It's also a good language for many system management tasks. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).

Install perl using FreeBSD ports

Perl5 port is located at /usr/ports/lang/perl5.8. Type the command as follows to install Perl5:
# cd /usr/ports/lang/perl5.8
# make;make install;make clean

Now perl will be installed and binary path to perl is /usr/local/bin/perl.

Install perl using FreeBSD pkg_add command

Just type the following command:
# pkg_add -v -r perl

OpenBSD Install BASH Shell Package Command

How do I install BASH shell package under OpenBSD operating system? How do I set bash as a default login shell under OpenBSD?
[click to continue…]

FreeBSD install VIM text editor

Q. Quick question – How do I install VIM text editor for my FreeBSD server? Currently it has old version of vi. I like vim as it is a highly configurable text editor and efficient one.

A. VIM (Vi IMproved ) is not installed by default under FreeBSD. Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs. You can install vim binary package or use FreeBSD's ports system.

Task: Install vim binary package

Type the following command to install vim lite version:
# pkg_add -r -v vim-lite

You can also use FreeBSD ports system to install vim:
# cd /usr/ports/editors/vim-lite/
# make install clean

To start vim type command:
$ vim

You can also create a alias using alias command:
$ alias vi='vim'

Add above alias to your shell start up file such as ~/.bashrc / ~/.cshrc

Task: Setup global vimrc file

You need to copy default vimrc file from /usr/local/share/vim/vim71/vimrc_example.vim to /usr/local/share/vim:
# cp /usr/local/share/vim/vim71/vimrc_example.vim /usr/local/share/vimrc

Task: Personal ~/.vimrc file

You can customize ~/.vimrc as per your requirements. Here is my own file:
$ cat ~/.vimrc
Sample output:

set nocompatible " must be the first line
filetype on
filetype indent on
filetype plugin on
set laststatus=2
set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P