Jump to content

FreeBSD - Sysadmin cheatsheet


Recommended Posts

  • Premium

Hi guys,
 
I would like to collect here some useful commands to perform basic actions on our FreeBSD servers. You are invited to contributed your own, I just want to get the ball rolling.
 
We are assuming that you run a supported FreeBSD system (at the time of writing this, 8.4, 9.2 and 10.0) and are connected to the Internet. How this is done is covered elsewhere in this forum.
 
See your system clock

date

Sync your system clock


ntpdate pool.ntp.org

Change your server's timezone
 
The available timezones are found in /usr/share/zoneinfo. Copy the desired timezone to /etc/localtime. Example:


cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime

Will set your server timezone to CET. This does NOT change the server time; you have to do this yourself.
 
 
Find a file in the system
 
Build the locate database:

/usr/libexec/locate.updatedb

Search:

locate filename

Install the most recent updates for your system


freebsd-update fetch install

Upgrade to a newer version


freebsd-update -r release

Where release is the name on the release, ex: 9.2-RELEASE. Follow the instructions on screen (When asked if "this does look reasonable", just press y and enter unless you know what you are doing)
 
View the contents of a file

cat filename

Edit a text file


ee filename

Download a file

fetch <url>

Show what is being written to a log in real time:

tail -f <filename>

Delete a file


rm <filename>

Delete a directory with all its content 


rm -R <foldername>

Extract a tar.gz archive


tar xzvf <filename>

Create a tar.gz archive


tar czvf <destination filename> <file or folder to archive>

Example:

tar czvf /root/mysql.tgz /var/db/mysql

Transfer a file from a server to another


scp <filename> <user>@<host>:<path>

Example:

scp mysql.tgz [email protected]:/root/mysql.tgz

Reboot the system


reboot

Shut down the system


poweroff

(If this is a remote server, make sure your hosting package allows you to start it later on!)
 
 
Install 32 bit libraries on a 64 bit system

cd /tmp
fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/9.2-RELEASE/lib32.txz
tar xfp lib32.txz -C /

(Replace 9.2-RELEASE in the URL with your version as needed)

  • Love 5
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.