I just thought I’d quickly post up a post on how to install Nano (a really simple to use CLI text editor) on FreeBSD, Although I’ve tested on FreeBSD 9.0 it should work with other versions of FreeBSD too…
You will find that by default FreeBSD does not come with this installed, having mainly used Linux in the past I have mainly used Nano and vi, Nano however is my favourite, as its dead easy to use 🙂
So here goes, firstly make sure your logged into the server as ‘root’ then make sure your ports tree is up to date like so:-
portsnap fetch update
If you don’t have the ports tree installed on your server (maybe you are using an Amazon cloud image etc. or simply did not install the ports tree during the set-up process). you’ll need to install the ports tree like so:-
portsnap fetch extract update
If you are unsure if you do or don’t have the ports tree installed just try this command:-
cd /usr/ports
If the above doesn’t work (ie. the folder doesn’t exsits then this means you don’t appear to have the ports installed… therefore run the above command to download and extract so we can continue on with this tutorial)
Now we are ready to actually install (compile) Nano on our FreeBSD server, we do it like so:-
cd /usr/ports/editors/nano make install clean ln -s /usr/local/bin/nano /usr/bin/nano
Now you should be able to use Nano 🙂 – If when you execute the command:-
nano
doesn’t work, then type:
rehash
Then try again, this is because you are using ‘csh’ which requires you to reload the list of binarys available to execute from /usr/bin/X… Alternatively just logout and back in again and you should then have ‘nano’ fully added into the environmental variables path 🙂
If you wanted too, you can also set Nano as the servers default text editor, to do this, whilst being logged in as ‘root’, run this command (assuming you use the Corn Shell which is the default on FreeBSD as opposed to bash,sh etc.):-
nano .cshrc
Then change this line:-
setenv EDITOR ee
to:-
setenv EDITOR nano
Save the changes (CTRL+O) and logout of your session and back in again, now running:-
crontab -e
will now open and enable you to edit your crontab entries using Nano instead of ee.