Get your blog and much more!
sungun on desktoptwo
August 08, 2006
Command Action
File and Directory Manipulation
cd dirname Changes to the directory dirname. If the directory does not begin
with a /, it is assumed to be relative to the current directory. (For
instance, cd public_html changes to the public_html directory
within the current directory.) If it does begin with a /, it is assumed
to be an absolute path. (cd /usr takes you directly to /usr.)
ls Lists the contents of the current directory except for hidden files.
Add the option ?a if you want to list the hidden files as well.
cp file1 file2 Copies file1 to file2. Use the option ?r to recursively copy a directory
and all its files, and the ?i option to prevent the command from
clobbering existing files.
mv file1 file2 Moves file1 to file2. These can either be names of files or directories.
Like the cp command, -i can be used to prevent the command from
clobbering existing files.
rmdir dir1 Removes a directory from the FreeBSD file system. However, for
this command to work, the directory must be empty.
touch file1 Updates the last accessed time on the file. If the file does not already
exist, it will be created.
mkdir dir1 Creates a new directory named dirname.
ln file1 file2 Creates a link from file1 to file2. By default, it creates a hard link.
Use the ?s option to create a soft link.
chmod [permissions] file1 Changes the access permissions on the file.
chown username file1 Changes the ownership of the file to the user username. Usually only
root can change file ownership.
chgrp groupname file1 Changes the group that the file belongs to. Normal users can only
change the group to another group they belong to.
passwd Changes your login password. Normal users can only change their
own password. The root user can specify a name after the password
to change anyone?s password (for example, passwd frank).
Common Utilities
grep [pattern] file1 Searches the file for the specified pattern. This command should
only be used on text files, or on text output from other commands
(for example, cat /var/log/messages | grep ?httpd?).
more file1 Displays the contents of a file one screen at a time or the output of a
command that has been piped to it one screen at a time.
416 Appendix B
cat file1 Displays the contents of the file. Can also be used to combine two
files into one using redirections (for example, cat file1 file2 >
file3).
wc file1 Displays the number of words, characters, and lines in the file.
diff file1 file2 Compares the contents of the two files and displays the differences
between them.
fmt file1 Formats the file into a format that is suitable for emailing. By
default, it writes to STDOUT, which is normally the screen.
cut [option] file1 Allows you to display only a particular column or field of a file.
head file1 Displays the first 10 lines of a file.
tail file1 Displays the last 10 lines of a file.
sort file1 Sorts the contents of the file into alphabetical order and displays it to
STDOUT, which is normally the screen.
cal Displays a calendar for the current month.
date Displays the current date and time. The root user can also use this
command to set the date and time.
man command Displays the manual page for the command.
ee Invokes the FreeBSD Easy Editor text editor.
vi Invokes the vi text editor.
System Utilities and Maintenance
ps Displays a list of processes running on the system.
top Displays a list of processes and resource usage that is updated every
couple of seconds.
kill n Kills the process number specified by n.
killall process Kills a process by name instead of process number.
at Schedules a command or shell script to run at a specified time.
crontab Schedules a command or shell script to run periodically at a specified
time.
shutdown Shuts down the system in an orderly way and notifies users of the
shutdown.
Printer Related Commands
lpr Sends a print job to the printer.
lprm Removes a print job(s) from the queue.
FreeBSD Quick Reference 417
B
Command Action
Common Utilities
lpq Displays a list of jobs currently in the printer queue.
lpc Controls print daemons and print queues.
Software Installation and Removal
pkg_add name Installs a new software package on the system.
pkg_delete name Deletes a software package from the system.
pkg_info Gives information on software packages.
make If given from a directory in a ports tree, it downloads and builds the
necessary files for installing the software port.
make install Installs a software port that has already been built. If the port has not
yet been built, this command will usually obtain and build it first.
make deinstall Removes installed software from the system.
make clean Removes the work directory containing all the files created during
the port building process.
make distclean Removes the work files as well as the original archive of source code
that was downloaded.
Configuration Files
~/.profile Configuration file for bourne style shells (sh, ksh, bash).
~/.login Configuration file for C style shells (c, tcsh).
~/.cshrc Configuration file for C style shells that also applies to subshells.
~/.forward Email forwarding control file.
~/.xinitrc Controls X Window System configuration options on a per-user
basis.
/etc/rc.conf Main FreeBSD configuration file.
/etc/X11/XF86Config Main (global) configuration file for the X Window System.
418 Appendix B
Command Action
Common Utilities