am a new FreeBSD version 6.x/7.x/8.x/9.x/10.x server user. How do I start / stop or restart MySQL server from a shell prompt over ssh session?
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:
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
set nocompatible " must be the first line
filetype indent on
filetype plugin on
set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P
Q. Iâ€™ve just moved from a Linux server to a new FreeBSD server. I’m confused with FreeBSD ports system. Can you tell me – how do I find a package file (port) and install the same?
A. Under Linux you use rpm / up2date / yum or apt-get command to install a package. Under FreeBSD you can use pkg_add command or ports system.
The FreeBSD Ports Collection is a package management system that provides an easy and consistent way of installing software packages on the FreeBSD. Usually ports is located at /usr/ports directory.
Task: Find out FreeBSD port name or package name
There are 3 different methods available to search a port name. Use any one of the following method only.
#1 : Using whereis command
If you know the exact name of the port, but just need to find out which category it is in, you can use the whereis(1) command. Simply type whereis file, where file is the program you want to install.
# whereis php5
# whereis lighttpd
#2: Using make command
Change directory to /usr/ports
# cd /usr/ports
To search type the command as follows:
# make search name="package-name"
For example search a package called lighttpd or php
# make search name="php"
# make search name="lighttpd"
Info: A secure, fast, compliant, and very flexible Web Server
Maint: [email protected]
B-deps: autoconf-2.59_2 libtool-1.5.22_4 m4-1.4.8_1 pcre-7.0_1 perl-5.8.8
#3: Using locate command
You can also use locate command:
# locate php
# locate php | grep php5
Task: Install FreeBSD port
Above output displays port Path – /usr/ports/www/lighttpd. Just change directory to /usr/ports/www/lighttpd
# cd /usr/ports/www/lighttpd
Now install a port:
# make; make install
Clean the source code tree:
# make clean