College Logo

Working with FreeBSD

If you're used to working at a command prompt in Windows then some things are very similar in FreeBSD but there are many things which are very different. The following are some of the commands which might be useful.

Listing files

The ls command lists files in a folder. It can take a number of switches:

ls -l

will list the contents of a folder in a long format - it shows the file name, its attributes and date and time stamps.

>
ls -lR

lists the contents of the current folder and those below it (similar to Windows dir /s).

Pipes

Windows allows you to pipe the output of one program to the input of another but few people use the facility regularly. Unix is built on using pipes; for example:

ls -l | more
will list the contents of a folder and pipe its output to the more command; this just pages the output of the command. There's also a less command - it's basically the same as more but with added features (you could say "less is more"...)

grep will search the text sent to it for a particular string;

ls -lR | grep ".conf"

will list all files with .conf in their name in the current folder and below. Note that by default grep is case sensitive

Finding files

find / -name MailScanner.conf
will search from the root folder for all files named MailScanner.conf Note again that this is case sensitive. You can also search using wildcards:
find / -name "MailScanner*"
will search for any files or folders with MailScanner in there name. There are other ways you can search apart from by name - see the man page for more info.

Listing running processes

The ps command lists running processes; to see if a particular process is running (including as a background process) you can use the following:

ps -ax | grep "postfix"

Note that you'll sometimes see the grep process in the list.

Shutting down the server

shutdown -r now

will shutdown the server immediately and then reboot it.

shutdown -p now 

will shutdown and power off (if the hardware supports it) or leave it ready for power off.

Archives

There are lots of ways of archiving files but the main ones are tar and zip. Tar (from Tape Archive) takes a group of files and puts them in a single archive; zip takes the archive and compresses it.

Getting more help

For any command you can type man command to load the manual page. Most commands can take many switches (all case sensitive) and this is where you can find lists of them and an attempt to describe what they do.