BIP KB:
How To Get Started With FreeBSD 10.1
Article By jason
This tutorial is part 2 of 7 in the series: Getting Started with FreeBSD
![]() |
FreeBSD is a secure, high performance operating system that is suitable for a variety of server roles. In this guide, we will cover some basic information about how to get started with a FreeBSD server. |
Step One — Log In with SSH
The first step you need to take to begin configuring your FreeBSD server is to log in. On BIP media, you must provide a public SSH key when creating a FreeBSD server. This key is added to the server instance, allowing you to securely login from your home computer using the associated private key. To learn more about how to use SSH keys with FreeBSD on BIP media, follow this guide. To login to your server, you will need to know your server's public IP address. For BIP media Servers, you can find this information in the control panel. The main user account available on FreeBSD servers created through BIP media is called freebsd
. This user account is configured with sudo
privileges, allowing you to complete administrative tasks. To log into your FreeBSD server, use the ssh
command. You will need to specify the freebsd
user account along with your server's public IP address:
ssh freebsd@server_IP_address
You should be automatically authenticated and logged in. You will be dropped into a command line interface.Changing the tcsh Shell Prompt and Defaults (Optional)
When you are logged in, you will be presented with a very minimal command prompt that looks like this:
>
This is the default prompt for tcsh
, the standard command line shell in FreeBSD. In order to help us stay oriented within the filesystem as we move about, we will implement a more useful prompt by modifying our shell's configuration file. An example configuration file is included in our filesystem. We will copy it into our home directory so that we can modify it as we wish:
cp /usr/share/skel/dot.cshrc ~/.cshrc
After the file has been copied into our home directory, we can edit it. The vi
editor is included on the system by default. If you want a simpler editor, you can try the ee
editor:
vi ~/.cshrc
The file includes some reasonable defaults, including a more functional prompt. Some areas you might want to change are the setenv
entries:
. . .
setenv EDITOR vi
setenv PAGER more
. . .
If you are not familiar with the vi
editor and would like an easier editing environment, you should change the EDITOR
environmental variable to something like ee
. Most users will want to change the PAGER
toless
instead of more
. This will allow you to scroll up and down in man pages without exiting the pager:
setenv EDITOR ee
setenv PAGER less
The other item that we should add to this configuration file is a block of code that will correctly map some of our keyboard keys inside the tcsh
session. Without these lines, "Delete" and other keys will not work correctly. This information is found on this page maintained by Anne Baretta. At the bottom of the file, copy and paste these lines:
if ($term == "xterm" || $term == "vt100" \
|| $term == "vt102" || $term !~ "con*") then
# bind keypad keys for console, vt100, vt102, xterm
bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[7~" beginning-of-line # Home rxvt
bindkey "\e[2~" overwrite-mode # Ins
bindkey "\e[3~" delete-char # Delete
bindkey "\e[4~" end-of-line # End
bindkey "\e[8~" end-of-line # End rxvt
endif
When you are finished, save and close the file. To make your current session reflect these changes immediately, you can source the file now:
source ~/.cshrc
Your prompt should immediately change to look something like this:
freebsd@hostname:~ %
It might not be immediately apparent, but the "Home", "Insert", "Delete", and "End" keys also work as expected now. One thing to note at this point is that if you are using the tcsh
or csh
shells, you will need to execute the rehash
command whenever any changes are made that may affect the executable path. Common scenarios where this may happen are when installing or uninstalling applications. After installing programs, you may need to type this in order for the shell to find the new application files:
rehash
Changing the Default Shell (Optional)
The above configuration gives you a fairly good tcsh
environment. If you are more familiar with thebash
shell and would prefer to use that as your default shell, you can easily make that adjustment. First, you need to install the bash
shell by typing:
sudo pkg install bash
After the installation is complete, we need to add a line to our /etc/fstab
file to mount the file-descriptor file system, which is needed by bash
. You can do this easily by typing:
sudo sh -c 'echo "fdesc /dev/fd fdescfs rw 0 0" >> /etc/fstab'
This will add the necessary line to the end of your /etc/fstab
file. Afterward, we can mount the filesystem by typing:
sudo mount -a
This will mount the filesystem, allowing us to start bash
. You can do this by typing:
bash
To change your default shell to bash
, you can type:
sudo chsh -s /usr/local/bin/bash freebsd
The next time you log in, the bash
shell will be started automatically instead of the tcsh
. If you wish to change the default pager or editor in the bash
shell, you can do so in a file called~/.bash_profile
. This will not exist by default, so we will need to create it:
vi ~/.bash_profile
Inside, to change the default pager or editor, you can add your selections like this:
export PAGER=less
export EDITOR=vi
You can make many more modifications if you wish. Save and close the file when you are finished. To implement your changes immediately, source the file:
source ~/.bash_profile
Conclusion
By now, you should know how to log into a FreeBSD server and how to set up a reasonable shell environment. A good next step is to complete some additional recommended steps for new FreeBSD 10.1 servers. Once you become familiar with FreeBSD and configure it to your needs, you will be able to take advantage of its flexibility, security, and performance.
Tags: FreeBSD, Getting Started, Linux, FreeBSD 10.1, OS
Spin Up A VPS Server In No Time Flat
Simple Setup
Full Root Access
Straightforward Pricing
DEPLOY A SECURE VPS SERVER TODAY!Leave a Reply
Feedbacks
![]() This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. |