Shell & Environment Settings on FreeBSD 7

Prerequisites:

FreeBSD (Base)
Bash Shell

Overview: Having the correct path and environment variables at the command line

 

Setting up a comfortable user friendly shell environment

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)

# Log in as root to make these changes

# Setting up an "/opt" directory
# ATTENTION: I install major applications into /opt (Just like Windows has "C:\Program Files" I use "/opt" in FreeBSD)
# Note: No need to do a separate dedicated partition for /opt since we can "symlink" it to /usr/opt
# You should only need to do this once and only if you don't already have a /opt directory
ln -sv /usr/opt /opt
cd /usr
mkdir opt
chmod -R 755 /opt
chmod -R 755 /usr/opt
# Test it out, these commands should now take you to the same place since /opt is symbolically linked to /usr/opt now
cd /opt
cd /usr/opt

 

# Setting up a "/opt/scripts" directory as a central locations for shared scripts
cd /opt
mkdir scripts
chmod a+r /opt/scripts
chmod a+x /opt/scripts
cd /opt/scripts
pwd

 

# An "auto export DISPLAY" script to make remote X11 apps via SSH easy!
# Change to the scripts directory
cd /opt/scripts
# Edit / create a new script
vi setdisplay.sh

# Set the script executable
chmod a+x /opt/scripts/setdisplay.sh
# Check the output
/opt/scripts/setdisplay.sh
# You should see something like IPAddress:0.0 or Hostname:0.0
# This script is designed to work inside the .profile in the next section
# The sole purpose is to automate the environment variable of:
# export DISPLAY=xyz:0.0
# as seen in step #4 in an example here

 

# Setting up your ".profile" to customize your bash shell environment
# Change to root's home directory
cd /root
# Edit your .profile (you can replace the generic default with this new stuff)
vi .profile

# Note: Each user account should fix up their unique .profile in their home directory
# vi /usr/share/skel/dot.profile


 

# Setting up "/etc/motd" for a custom "message of the day"
vi /etc/motd

# Make sure everyone can motd
chmod a+r /etc/motd
touch /etc/COPYRIGHT

 

# Setting up "/etc/ssh/banner" for a custom "message of the day"
# Add a line to the bottom of your sshd_config
vi /etc/ssh/sshd_config

# Edit / create the banner
vi /etc/ssh/banner

# Make sure everyone can read the banner
chmod a+r /etc/ssh/banner
# You will need to restart sshd or simply reboot for these changes to take effect