How to Get Started with FreeBSD



A high performative and secured operating system also suitable for several server roles is known as FreeBSD. This entire blog is intended to offer a general setup for FreeBSD servers, also at the same time you need to be aware of the fact that the various versions of FreeBSD may have various functionalities. The instructions provided here may not work depending on which version of FreeBSD your server is running. You will be getting information about some basic facts about how to get started with a FreeBSD.

Logging in with SSH

The very first step you need to take before beginning to configure your FreeBSD server is that you will have to log in. Then you must provide a public SSH key when creating a FreeBSD server on DigitalOcean. Allowing you to securely log in to your local machine, this key is added to the local machine. You will have to know your server’s public IP address in order to log in to your server. You will be able to find this information in the control panel in DigitalOcean Droplet’s case. FreeBSD is the main user account available on FreeBSD servers which is created through DigitalOcean. The sudo privileges configures this user account and it also allows you to complete administrative tasks. You need to use the ssh command in order to log in to your server. You will need to particularize the freebsd user account for with your server’s IP address:

Not Every One Focuses On Your Requirements! Get What You Want- Revenue & Ranking Both. Make Money While Stepping Up The Ladder Of SERPs.
We hate spam. Your email address will not be sold or shared with anyone else.
$ ssh freebsd@your_server_ip

After this you will be logged in and automatically authenticated and after this you will dropped into a command line interface.

Changing the Default Shell to tcsh

You will be presented with a very minimal command prompt, if you are logged into a DigitalOcean Droplet that is running FreeBSD 11. It will certainly look like this:


This prompt may seem bit unfamiliar to you, if you are new in working with FreeBSD. Here is an example for clarifying on which environment you will be working in. You need to run the following command in order to see what the default shell of your FreeBSD user is:

$ echo $SHELL

Here in this output you can see that the default shell for the freebsd user is sh. sh is often an alias for bash on Linux systems. It is a free software, a substitute for the Bourne Shell which also includes some more features. However its actually the classic shell program, and not an alias.

tcsh is the default command line shell for FreeBSD, however DigitalOcean Droplets use sh by default. If you want to set tcsh as your freebsd user’s default shell, then you need to run the following command:

$ sudo chsh -s /bin/tcsh freebsd

Now the next time you log in you will find that the tcsh is prompting instead of sh. By running the following you will be able to instigate the tcsh shell for the current session by running the following command:

$ tcsh

Immediately your prompt should change like the following:

freebsd@hostname:~ %

You can also get back to the sh command whenever you want to return to Bourne Shell with the sh command.

The tcsh command is typically the default shell for FreeBSD system there are some default settings which the users tend to twist on their own , such as editor, Default pager, then behavior of certain keys etc. In order to elucidate the method of changing some of these defaults, you will have to use the shell configuration file. Here is an example of a configuration file which already exists in the file system which you need to copy into your home directory so that you can later customize it as per your own requirements.

freebsd@hostname:~ % cp /usr/share/skel/dot.chsrc ~/.cshrc

After you have copied the file into your home directory, you can definitely customize it. vi the editor is by default in the system, however if you want an easy editor you can use the ee editor:

freebsd@hostname:~ % ee ~/.cshrc

You can decide what entries do you want to improve or modify on the way you go through this file. You may definitely want to change the setenv entries specifically in order to get some important defaults to which you are familiar with.

. . .

setenv EDITOR vi
setenv PAGER more

. . .

In case you are not accustomed with the vi editor and in case you want a more easy to use editing environment you can definitely change the editor environment variable to ee or something like that. The PAGER to is often more recommended than more by most of the users. Which allows you to scroll up and down in various pages by not exiting the pager:

. . .
setenv EDITOR ee
setenv PAGER less
. . .

Another thing that you will likely want to add to this configuration file is a block of code that will correctly map some of your keyboard keys inside the tcsh session. At the bottom of the file, add the following code. Without these lines, DELETE and other keys will not work correctly:

. . .
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

After you have completed you need to save and close the file by clicking on CTRL+C, typing exit and then you will have to press ENTER.

In order to make your recent session show these changes right back you need to source the configuration file:

freebsd@hostname:~%source ~/.cshrc

It may not be obvious immediately, but the HomeInsertDelete, and End keys will work as they were intended to.

You need to keep a note at this point of time that you were using the tcsh or csh shells One thing to note at this point is that if you are using the tcsh or csh shells, you will need to deploy the rehash command if any changes effects the exit path. In general cases where this can happen especillly when you are installing or uninstalling applications.

Now after you install the programs you might have to type this for the shell in order to find the new application files:

freebsd@hostname:~ % rehash

The tcsh shell is set as your freebsd user’s default and is also gets much more user friendly with the implementation of that.

Setting bash as the Default Shell

In case you are more accustomed with bash shell, and if you find it more useful and want it to set as your default shell, you will be able to make it following these few steps. Also you need to keep in mind that bash is supported on FreeBSD 11.1 and the guide you will be receiving below may not help you out for this particular version.

The very first step you need to take is to install the bash shell by implementing the following command:

$ sudo pkg install bash

You will be asked to confirm that whether you want to download the package. You can do so by pressing y and then ENTER.

As soon as you complete the installation you can start bash by deploying the following:

$ bash

After this your shell prompt will be upgraded to show up like this:


In case you want to change freebsd’s default shell to bash you will have to type:

[freebsd@hostname~]$sudo chsh -s /usr/local/bin/bash freebsd

The bash shell will start automatically the next time you log in place of the current default.

If you want to the default pager or editor in the bash shell to be changed, that can be done in a file named ~/.bash_profile, also which will not be available by default and thus you will have to create it:

[freebsd@hostname~]$ ee ~/.bash_profile

If you want to change the default pager or editor inside you need to add selections:

export PAGER=less
export EDITOR=ee

After you have completed, you need to save and then close the file by inserting CTRL+C, typing exit, and then pressing ENTER.

Then you need to source the file if you want to deploy your changes as soon as possible:

<pre>freebsd@hostname~]$ source ~/.bash_profile</pre>

In order to make more changes in setting up special command aliases, setting environment variables or any other changes to your shell environment, you will be able to reopen the file and add on the new changes to it.

Setting a Root Password

ssh logins are not allowed for the root account by default in FreeBSD servers. This policy has been supplemented to tell the users to log in with the freebsd account on DigitalOcean. The root user account is not accessible on SSH which is relatively protective and safe in order to set it as a root account password. As you will not be able to use this while logging in via ssh, this password can help you out in logging in as root through the DigitalOcean web console. If you want to give a root password, you will have to type:

<pre>sudo passwd</pre>

you might be asked to select and then confirm a password for the root account. However, you won’t be able to use this for SSH authentication as mentioned above you will be asked to select and confirm a password for the root account as previously mentioned, but you can use it for the log in purpose through the DigitalOcean console.

for executing the following you need to click the Console button, which is in the upper right corner in your droplet’s page for bringing up the web console:

Image Courtesy:

Now if you select not to set up a password and somewhat you get locked out of your server (for instance if you accidentally set overly restrictive firewall rules), you can definitely set it later on by booting up your Droplet to single user mode.


Thus now by the end of this guide you know how to log into a FreeBSD server and also you know how to set up a bash shell environment. Now you are ready to get accustomed with with some FreeBSD basics as well as what differentiates it from Linux-based distributions.

Header Image courtesy:


Barry Davis is a Technology Evangelist who is joined to Webskitters for more than 5 years. A specialist in Website design, development & planning online business strategy. He is passionate about implementing new web technologies that makes websites perform better.


Interested in working with us?

We'd love to hear from you
Webskitters LLC
7950 NW 53rd St #337 Miami, Florida 33166
Phone: 732.218.7686