Yesterday got confused how to see the hit ratio of byts new squid I install, will install mrtg cachti or males for a little kompnya jadul fitted with barely enough memory, especially if you install mrtg and cacti have to install a webserver and cgi.
But the results of the streets and searching on google I finally know there is a small and lightweight tools to see permformance squid. Without the hassle to install mrtg and cachti.
In squid that I use ubuntu machine running on the server. And the solution to see the performance and saw squid byts hit ratio was fairly easy. With SQUIDCLIENT, so the solution is to install the machine squidclient that we use.
apt-get install squidclient
wait until the installation is complete
and how to use it fairly easily in my squid as I type below, although there are many comments and orders of this squidclient I do not know
root @ ubuntu: ~ # squidclient 192.168.88.1-p 9988 mgr: info
the result as below
HTTP/1.0 200 OK
Date: Wed, 01 Jul 2009 12:59:49 GMT
Content-Type: text / plain
Expires: Wed, 01 Jul 2009 12:59:49 GMT
X-Cache: MISS from ProxyIP.net
X-Cache-Lookup: MISS from ProxyIP.net: 9988
Connection: close
Squid Object Cache: Version 2.7.STABLE3
Start Time: Wed, 01 Jul 2009 12:56:40 GMT
Current Time: Wed, 01 Jul 2009 12:59:49 GMT
Connection information for squid:
Number of clients accessing cache: 9
Number of HTTP requests received: 61
Number of ICP messages received: 0
Number of ICP messages sent: 0
Number of queued ICP replies: 0
Number of HTCP messages received: 0
Number of HTCP messages sent: 0
Request failure ratio: 0.00
Average HTTP requests per minute since start: 19.4
Average ICP messages per minute since start: 0.0
Select loop called: 13,795 times, 13,697 ms avg
Cache information for squid:
Request Hit Ratios: 5min: 38.5%, 60min: 38.5%
Byte Hit Ratios: 5min: 55.1%, 60min: 55.1%
Request Memory Hit Ratios: 5min: 0.0%, 60min: 0.0%
Request Disk Hit Ratios: 5min: 40.0%, 60min: 40.0%
Storage Swap size: 9215996 KB
Storage Mem size: 612 KB
Mean Object Size: 15.94 KB
Requests given to unlinkd: 19
Median Service Times (seconds) 5 min 60 min:
HTTP Requests (All): 0.80651 0.80651
Cache Misses: 0.80651 0.80651
Cache Hits: 0.03241 0.03241
Near Hits: 1.00114 1.00114
Not-Modified Replies: 0.00000 0.00000
DNS lookups: 0.00203 0.00203
ICP Queries: 0.00000 0.00000
Resource usage for squid:
UP Time: 188,953 seconds
CPU Time: 6310 seconds
CPU Usage: 3:34%
CPU Usage, 5 minute avg: 3:49%
CPU Usage, 60 minute avg: 3:49%
Process Data Segment Size via sbrk (): 57,604 KB
Maximum Resident Size: 0 KB
Page faults with physical i / O: 2
Memory usage for squid via mallinfo ():
Total space in arena: 57,604 KB
Ordinary blocks: 57527 KB 5 blks
Small blocks: 0 KB 0 blks
Holding blocks: 672 KB 3 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 76 KB
Total in use: 58,199 KB 100%
Total free: 76 KB 0%
Total size: 58,276 KB
Memory accounted for:
Total accounted: 43775 KB
memPoolAlloc calls: 2914245
memPoolFree calls: 1178428
File descriptor usage for squid:
Maximum number of file descriptors: 1024
Largest file desc currently in use: 55
Number of file desc currently in use: 52
Files queued for open: 0
Available number of file descriptors: 972
Reserved number of file descriptors: 100
Store Disk files open: 1
IO loop method: epoll
Internal Data Structures:
578,152 StoreEntries
43 StoreEntries with MemObjects
root @ ubuntu: ~ # squidclient-p 9988-u USERNAME-w 'secretePassword' mgr: info | grep 'files descri'
Result:
Maximum number of file descriptors: 1024
Available number of file descriptors: 858
Reserved number of file descriptors: 100
---------------------
Other commands:
squidclient mgr: info | grep 'files descri'
squidclient mgr: info | grep 'files descri'
squidclient-h host-p 80 mgr: utilization
squidclient-h host-p 80 mgr: 5min
squidclient-h host-p 80 mgr: 60min
Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts
Setting Up FTP server on FreeBsd or Linux
The original of this article you can find here.
The FTP service is simple to use and administer, which is why it is a good idea to begin with this step when configuring an Internet server. Chances are that your Linux installation already contains a functioning copy of an FTP server. The main steps of setting up an FTP server are as follows:
Installing the software Configuring the Internet superserver Configuring the FTP directories Managing the server
ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
The two command-line switches used install the server to log entries to the system log ( -l) and to use the ftpaccess file. This file is optional; if it exists, the FTP server uses it to establish configuration options. For more information, read the manual page ( man ftpaccess .)
ftp:x:14:50:FTP User:/home/ftp:
In /home/ftp, I found the following files and directories:
/home/ftp/bin/
/home/ftp/bin/gzip
/home/ftp/bin/ls
/home/ftp/bin/tar
/home/ftp/bin/zcat -> gzip
/home/ftp/etc/
/home/ftp/etc/group
/home/ftp/etc/passwd
/home/ftp/pub/
The presence of the tar and gzip utilities allows the FTP server to provide the contents of an entire directory in a single transaction. With the tar command the files are combined into an archive, and then optionally compressed using gzip. These commands are explained in detail in Chapter 17, "Backups." As you can see, the pub directory is currently empty. Usually, files that can be downloaded by anyone are placed in this directory.
The FTP service is simple to use and administer, which is why it is a good idea to begin with this step when configuring an Internet server. Chances are that your Linux installation already contains a functioning copy of an FTP server. The main steps of setting up an FTP server are as follows:
Server Installation
FTP servers usually come in the form of a single executable program, one that goes by names such as ftpd, in.ftpd, or something similar. It is typically located in the /sbin or /usr/sbin directory. On my test system, the FTP server was one of the components installed during the initial system setup. Caldera OpenLinux comes with one of the most commonly used FTP servers, developed at the University of Washington. This server's executable file is named in.ftpd and it is located in /usr/sbin/. Once installed, the FTP server provides access to files by users who have an account on your system. These users will be able to access the same files that they normally have access to, for instance when they log on to the system interactively. In other words, if you log on to a remote system via FTP using your username and password on that system, you'll be able to access files in your home directory for reading and writing. You might also be able to read (download) other files that you normally have read access to on that system.Configuring the Internet Superserver
Placing the FTP server executable on your computer is not sufficient by itself to provide FTP access. For this, you must also ensure that the FTP server is invoked when an incoming request arrives. Such incoming requests come in the form of connections to TCP port 21, the port reserved for FTP access. The standard method for invoking a server is through inetd, the Internet superserver. This server is configured through the file /etc/inetd.conf. On my test system, the Caldera OpenLinux installer placed the following entry in /etc/inetd.conf:ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
The two command-line switches used install the server to log entries to the system log ( -l) and to use the ftpaccess file. This file is optional; if it exists, the FTP server uses it to establish configuration options. For more information, read the manual page ( man ftpaccess .)
Configuring Anonymous Access
When a regular user logs on to the system via FTP, all the access privileges that normally apply to this user ID remain in effect throughout the FTP session. The user can retrieve any file or execute arbitrary commands on the system. In contrast, anonymous users cannot be allowed such a privilege. Unlike regular users who are trusted (why else would they have a password on your system?), anonymous users could turn out to be hostile intruders. As a result, their access must be limited to the downloading of publicly accessible files and optionally uploading files to public directories. In order for an FTP server to provide anonymous access, it is necessary to have a user account named ftp on your system. This user account is never used for interactive login, and does not require a valid password. However, when an anonymous FTP user connects to your system, the FTP server will use this account's access permissions for accessing files. Furthermore, anonymous users only see files that are located in the home directory associated with the ftp user ID. In addition to files anonymous users can download, this directory also contains special versions of commands such as ls, and a special copy of the etc directory. During an anonymous session, the FTP server uses the ftp home directory as its root directory; in other words, it can only see these copies of executable commands and files from /etc, not the originals. This prevents an anonymous user from accessing the real version of /etc/passwd (conceivably obtaining a copy of all your encrypted passwords if you're not using the shadow password suite; see Chapter 4, for more information) or executing other commands and exploiting them for security leaks. Most Linux distributions establish the ftp user ID and create its home directory during initial system installation. My test system is no exception: The ftp user ID and home directory were created by the Caldera OpenLinux installer. The file /etc/passwd contains the following entry:ftp:x:14:50:FTP User:/home/ftp:
In /home/ftp, I found the following files and directories:
/home/ftp/bin/
/home/ftp/bin/gzip
/home/ftp/bin/ls
/home/ftp/bin/tar
/home/ftp/bin/zcat -> gzip
/home/ftp/etc/
/home/ftp/etc/group
/home/ftp/etc/passwd
/home/ftp/pub/
The presence of the tar and gzip utilities allows the FTP server to provide the contents of an entire directory in a single transaction. With the tar command the files are combined into an archive, and then optionally compressed using gzip. These commands are explained in detail in Chapter 17, "Backups." As you can see, the pub directory is currently empty. Usually, files that can be downloaded by anyone are placed in this directory.
FTP Server Management
Once your FTP server is up and running, it requires very little attention. However, you may still want to monitor it from time to time to ensure proper operation and prevent abuse attempts. The principal means of monitoring server activity is through the transfer log file. This file, usually /var/log/xferlog, contains an entry for each successfully completed file transfer. The server also logs important messages to the standard system log. On most systems, these entries will end up in /var/log/messages.Tips and tric on freebsd
Here are some tips for freebsd users..
Having trouble using fetch through a firewall? Try setting the environment
variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
%
By pressing “Scroll Lock” you can use the arrow keys to scroll backward
through the console output. Press “Scroll Lock” again to turn it off.
%
Want colour in your directory listings? Use “ls -G”. “ls -F” is also useful,
and they can be combined as “ls -FG”.
%
If you need to ask a question on the FreeBSD-questions mailing list then
http://www.freebsd.org/doc/en_US.ISO8859-1/articles/
freebsd-questions/index.html
contains lots of useful advice to help you get the best results.
%
If you’d like to keep track of applications in the FreeBSD ports tree, take a
look at FreshPorts;
http://www.freshports.org/
%
To search for files that match a particular name, use find(1); for example
find / -name “*GENERIC*” -ls
will search ‘/’, and all subdirectories, for files with ‘GENERIC’ in the name.
– Stephen Hilton
%
In tcsh, you can `set autolist’ to have the shell automatically show
all the possible matches when doing filename/directory expansion.
%
You can `set autologout = 30′ to have tcsh log you off automatically
if you leave the shell idle for more than 30 minutes.
%
If you `set filec’ (file completion) in tcsh and write a part of the
filename, pressing TAB will show you the available choices when there
is more than one, or complete the filename if there’s only one match.
%
You can press up-arrow or down-arrow to walk through a list of
previous commands in tcsh.
%
You can disable tcsh’s terminal beep if you `set nobeep’.
%
If you `set watch = (0 any any)’ in tcsh, you will be notified when
someone logs in or out of your system.
%
Nice tcsh prompt: set prompt = ‘%m %# ‘
%
Nice tcsh prompt: set prompt = ‘%n@%m%# ‘
%
Nice tcsh prompt: set prompt = ‘%n@%m:%~%# ‘
%
Nice tcsh prompt: set prompt = ‘%n@%m:%/%# ‘
%
Nice tcsh prompt: set prompt = ‘[%B%m%b] %B%~%b%# ‘
%
Simple tcsh prompt: set prompt = ‘%# ‘
%
If you want df(1) and other commands to display disk sizes in
kilobytes instead of 512-byte blocks, set BLOCKSIZE in your
environment to ‘K’. You can also use ‘M’ for Megabytes or ‘G’ for
Gigabytes. If you want df(1) to automatically select the best size
then use ‘df -h’.
%
To change an environment variable in tcsh you use: setenv NAME “value”
where NAME is the name of the variable and “value” its new value.
%
To change an environment variable in /bin/sh use:
$ VARIABLE=”value”
$ export VARIABLE
%
You can use /etc/make.conf to control the options used to compile software
on this system. Example entries are in
/usr/share/examples/etc/defaults/make.conf.
%
To do a fast search for a file, try
locate filename
locate uses a database that is updated every Saturday (assuming your computer
is running FreeBSD at the time) to quickly find files based on name only.
%
In order to search for a string in some files, use ‘grep’ like this:
grep “string” filename1 [filename2 filename3 ...]
This will print out the lines in the files that contain the string. grep can
also do a lot more advanced searches - type ‘man grep’ for details.
%
You can use the ‘fetch’ command to retrieve files over ftp or http.
fetch http://www.freebsd.org/index.html
will download the front page of the FreeBSD web site.
%
In order to make fetch (the FreeBSD downloading tool) ask for
username/password when it encounters a password-protected web page, you can set
the environment variable HTTP_AUTH to ‘basic:*’.
%
You can permanently set environment variables for your shell by putting them
in a startup file for the shell. The name of the startup file varies
depending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use
.profile. When using bash, sh, ksh or zsh, don’t forget to export the
variable.
%
If you are running xterm, the default TERM variable will be ‘xterm’. If you
set this environment variable to ‘xterm-color’ instead, a lot of programs will
use colors. You can do this by
TERM=xterm-color; export TERM
in Bourne-derived shells, and
setenv TERM xterm-color
in csh-derived shells.
%
If you do not want to get beeps in X11 (X Windows), you can turn them off with
xset b off
%
You can look through a file in a nice text-based interface by typing
less filename
%
The default editor in FreeBSD is vi, which is efficient to use when you have
learned it, but somewhat user-unfriendly. To use ee (an easier but less
powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
%
If you accidentally end up inside vi, you can quit it by pressing Escape, colon
(:), q (q), bang (!) and pressing return.
%
You can use aliases to decrease the amount of typing you need to do to get
commands you commonly use. Examples of fairly popular aliases include (in
Bourne shell style, as in /bin/sh, bash, ksh, and zsh):
alias lf=”ls -FA”
alias ll=”ls -lA”
alias su=”su -m”
In csh or tcsh, these would be
alias lf ls -FA
alias ll ls -lA
alias su su -m
To remove an alias, you can usually use ‘unalias aliasname’. To list all
aliases, you can usually type just ‘alias’.
%
In order to support national characters for European languages in tools like
less without creating other nationalisation aspects, set the environment
variable LC_ALL to ‘en_US.ISO8859-1′.
%
You can search for documentation on a keyword by typing
apropos keyword
%
Man pages are divided into section depending on topic. There are 9 different
sections numbered from 1 (General Commands) to 9 (Kernel Developer’s Manual).
You can get an introduction to each topic by typing
man intro
In other words, to get the intro to general commands, type
man 1 intro
%
FreeBSD is started up by the program ‘init’. The first thing init does when
starting multiuser mode (ie, starting the computer up for normal use) is to
run the shell script /etc/rc. By reading /etc/rc, you can learn a lot about
how the system is put together, which again will make you more confident about
what happens when you do something with it.
%
If you want to play CDs with FreeBSD, a utility for this is already included.
Type ‘cdcontrol’ then ‘help’ to learn more. (You may need to set the CDROM
environment variable in order to make cdcontrol want to start.)
%
If you have a CD-ROM drive in your machine, you can make the CD-ROM that is
presently inserted available by typing ‘mount /cdrom’ as root. The CD-ROM
will be available under /cdrom/. Remember to do ‘umount /cdrom’ before
removing the CD-ROM (it will usually not be possible to remove the CD-ROM
without doing this.)
Note: This tip may not work in all configurations.
%
You can install extra packages for FreeBSD by using the ports system.
If you have installed it, you can download, compile, and install software by
just typing
# cd /usr/ports//
# make install && make clean
as root. The ports infrastructure will download the software, change it so
it works on FreeBSD, compile it, install it, register the installation so it
will be possible to automatically uninstall it, and clean out the temporary
working space it used. You can remove an installed port you decide you do not
want after all by typing
# cd /usr/ports//
# make deinstall
as root.
%
Nice bash prompt: PS1=’([$(tput md)]t [$(tput me)]) $(echo $?) $ ‘
– Mathieu
%
To see the output from when your computer started, run dmesg(8). If it has
been replaced with other messages, look at /var/run/dmesg.boot.
– Francisco Reyes
%
You can use “whereis” to locate standard binary, manual page and source
directories for the specified programs. This can be particularly handy
when you are trying to find where in the ports tree an application is.
Try “whereis netscape” and “whereis whereis”.
– Konstantinos Konstantinidis
%
You can press Ctrl-D to quickly exit from a shell, or logout from a
login shell.
– Konstantinos Konstantinidis
%
You can use “pkg_info” to see a list of packages you have installed.
– Konstantinos Konstantinidis
%
You can change the video mode on all consoles by adding something like
the following to /etc/rc.conf:
allscreens=”80×30″
You can use “vidcontrol -i mode | grep T” for a list of supported text
modes.
– Konstantinos Konstantinidis
%
Any user that is a member of the wheel group can use “su -” to simulate
a root login. You can add a user to the wheel group by editing /etc/group.
– Konstantinos Konstantinidis
%
Over quota? “du -s * | sort -n ” will give you a sorted list of your
directory sizes.
– David Scheidt
%
Handy bash(1) prompt: PS1=”u@h w !$ ”
– David Scheidt
%
Ever wonder what those numbers after command names were, as in cat(1)? It’s
the section of the manual the man page is in. “man man” will tell you more.
– David Scheidt
%
“man hier” will explain the way FreeBSD filesystems are normally laid out.
– David Scheidt
%
“man tuning” gives some tips how to tune performance of your FreeBSD system.
– David Scheidt
%
“man firewall” will give advice for building a FreeBSD firewall
– David Scheidt
%
You can often get answers to your questions about FreeBSD by searching in the
FreeBSD mailing list archives at
http://www.freebsd.org/search.html
%
You can adjust the volume of various parts of the sound system in your
computer by typing ‘mixer ‘. To get a list of what you can
adjust, just type ‘mixer’.
%
You can automatically download and install binary packages by doing
pkg_add -r
where you replace with the URL to the package. This will also
automatically install the packages the package you download is dependent on
(ie, the packages it needs in order to work.)
%
You can get a good standard workstation install by using the
instant-workstation port/package. If you have ports installed, you can
install it by doing
# cd /usr/ports/misc/instant-workstation
# make install && make clean
as root. This will install a collection of packages that is convenient to
have on a workstation.
%
You can get a good generic server install by using the
instant-server port/package. If you have ports installed, you can
install it by doing
# cd /usr/ports/misc/instant-server
# make install && make clean
as root. This will install a collection of packages that is appropriate for
running a “generic” server.
%
You can make a log of your terminal session with script(1).
%
“man ports” gives many useful hints about installing FreeBSD ports.
%
“man security” gives very good advice on how to tune the security of your
FreeBSD system.
%
Want to find a specific port, just type the following under /usr/ports,
or one its subdirectories:
“make search name=”
or
“make search key=”
%
Want to see how much virtual memory you’re using? Just type “swapinfo” to
be shown information about the usage of your swap partitions.
%
ports/net/netcat port is useful not only for redirecting input/output
to TCP or UDP connections, but also for proxying them. See inetd(8) for
details.
%
If other operating systems have damaged your Master Boot Record, you can
reinstall it either with /stand/sysinstall or with boot0cfg(8). See
“man boot0cfg” for details.
%
Need to see the calendar for this month? Simply type “cal”. To see the
whole year, type “cal -y”.
– Dru
%
Need to quickly return to your home directory? Type “cd”.
– Dru
%
To see the last time that you logged in, use lastlogin(8).
– Dru
%
To clear the screen, use “clear”. To re-display your screen buffer, press
the scroll lock key and use your page up button. When you’re finished,
press the scroll lock key again to get your prompt back.
– Dru
%
To save disk space in your home directory, compress files you rarely
use with “gzip filename”.
– Dru
%
To read a compressed file without having to first uncompress it, use
“zcat” or “zmore” to view it.
– Dru
%
To see how much disk space is left on your partitions, use
df -h
– Dru
%
To see the 10 largest files on a directory or partition, use
du /partition_or_directory_name | sort -rn | head
– Dru
%
To determine whether a file is a text file, executable, or some other type
of file, use
file filename
– Dru
%
Time to change your password? Type “passwd” and follow the prompts.
– Dru
%
Want to know how many words, lines, or bytes are contained in a file? Type
“wc filename”.
– Dru
%
Need to print a manpage? Use
man name_of_manpage | col -bx | lpr
– Dru
%
Need to remove all those ^M characters from a DOS file? Try
tr -d
<> newfile
– Originally by Dru
%
Forget what directory you are in? Type “pwd”.
– Dru
%
If you are in the C shell and have just installed a new program, you won’t
be able to run it unless you first type “rehash”.
– Dru
%
Need to leave your terminal for a few minutes and don’t want to logout?
Use “lock -p”. When you return, use your password as the key to unlock the
terminal.
– Dru
%
Need to find the location of a program? Use “locate program_name”.
– Dru
%
Forget how to spell a word or a variation of a word? Use
look portion_of_word_you_know
– Dru
%
To see the last 10 lines of a long file, use “tail filename”. To see the
first 10 lines, use “head filename”.
– Dru
%
To see how long it takes a command to run, type the word “time” before the
command name.
– Dru
%
To quickly create an empty file, use “touch filename”.
– Dru
%
To find out the hostname associated with an IP address, use
dig -x IP_address
– Dru
%
If you use the C shell, add the following line to the .cshrc file in your
home directory to prevent core files from being written to disk:
limit coredumpsize 0
– Dru
%
If you need a reminder to leave your terminal, type “leave +hhmm” where
“hhmm” represents in how many hours and minutes you need to leave.
– Dru
%
Need to do a search in a manpage or in a file you’ve sent to a pager? Use
“/search_word”. To repeat the same search, type “n” for next.
– Dru
%
Forget when Easter is? Try “ncal -e”. If you need the date for Orthodox
Easter, use “ncal -o” instead.
– Dru
%
Need to see your routing table? Type “netstat -rn”. The entry with the G
flag is your gateway.
– Dru
%
Need to see which daemons are listening for connection requests? Use
“sockstat -4l” for IPv4, and “sockstat -l” for IPv4 and IPv6.
– Dru
%
Can’t remember if you’ve installed a certain port or not? Try “pkg_info
-Ix port_name”.
%
To erase a line you’ve written at the command prompt, use “Ctrl-U”.
– Dru
%
To repeat the last command in the C shell, type “!!”.
– Dru
%
Need to quickly empty a file? Use “: > filename”.
– Dru
%
To see all of the directories on your FreeBSD system, type
ls -R / | more
– Dru
%
To see the IP addresses currently set on your active interfaces, type
“ifconfig -u”.
– Dru
%
To see the MAC addresses of the NICs on your system, type
ifconfig -a
– Dru
%
You can open up a new split-screen window in (n)vi with :N or :E and then
use ^w to switch between the two.
%
sh (the default Bourne shell in FreeBSD) supports command-line editing. Just
“set -o emacs” or “set -o vi” to enable it.
%
When you’ve made modifications to a file in vi(1) and then find that
you can’t write it, type “!rm -f %” then “:w!” to force the
write
This won’t work if you don’t have write permissions to the directory
and probably won’t be suitable if you’re editing through a symbolic link.
%
If you want to quickly check for duplicate package/port installations,
try the following pkg_info command.
pkg_info | sort | sed -e ’s/-[0-9].*$//’ |
uniq -c | grep -v ‘^[[:space:]]*1′
%
Want to use sed(1) to edit a file in place? Well, to replace every ‘e’ with
an ‘o’, in a file named ‘foo’, you can do:
sed -i.bak s/e/o/g foo
And you’ll get a backup of the original in a file named ‘foo.bak’, but if you
want no backup:
sed -i ” s/e/o/g foo
%
To obtain a neat PostScript rendering of a manual page, use “-t” switch
of the man(1) utility: “man -t ”. For example:
man -t grep > grep.ps # Save the PostScript version to a file
or
man -t printf | lp # Send the PostScript directly to printer
Having trouble using fetch through a firewall? Try setting the environment
variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
%
By pressing “Scroll Lock” you can use the arrow keys to scroll backward
through the console output. Press “Scroll Lock” again to turn it off.
%
Want colour in your directory listings? Use “ls -G”. “ls -F” is also useful,
and they can be combined as “ls -FG”.
%
If you need to ask a question on the FreeBSD-questions mailing list then
http://www.freebsd.org/doc/en_US.ISO8859-1/articles/
freebsd-questions/index.html
contains lots of useful advice to help you get the best results.
%
If you’d like to keep track of applications in the FreeBSD ports tree, take a
look at FreshPorts;
http://www.freshports.org/
%
To search for files that match a particular name, use find(1); for example
find / -name “*GENERIC*” -ls
will search ‘/’, and all subdirectories, for files with ‘GENERIC’ in the name.
– Stephen Hilton
%
In tcsh, you can `set autolist’ to have the shell automatically show
all the possible matches when doing filename/directory expansion.
%
You can `set autologout = 30′ to have tcsh log you off automatically
if you leave the shell idle for more than 30 minutes.
%
If you `set filec’ (file completion) in tcsh and write a part of the
filename, pressing TAB will show you the available choices when there
is more than one, or complete the filename if there’s only one match.
%
You can press up-arrow or down-arrow to walk through a list of
previous commands in tcsh.
%
You can disable tcsh’s terminal beep if you `set nobeep’.
%
If you `set watch = (0 any any)’ in tcsh, you will be notified when
someone logs in or out of your system.
%
Nice tcsh prompt: set prompt = ‘%m %# ‘
%
Nice tcsh prompt: set prompt = ‘%n@%m%# ‘
%
Nice tcsh prompt: set prompt = ‘%n@%m:%~%# ‘
%
Nice tcsh prompt: set prompt = ‘%n@%m:%/%# ‘
%
Nice tcsh prompt: set prompt = ‘[%B%m%b] %B%~%b%# ‘
%
Simple tcsh prompt: set prompt = ‘%# ‘
%
If you want df(1) and other commands to display disk sizes in
kilobytes instead of 512-byte blocks, set BLOCKSIZE in your
environment to ‘K’. You can also use ‘M’ for Megabytes or ‘G’ for
Gigabytes. If you want df(1) to automatically select the best size
then use ‘df -h’.
%
To change an environment variable in tcsh you use: setenv NAME “value”
where NAME is the name of the variable and “value” its new value.
%
To change an environment variable in /bin/sh use:
$ VARIABLE=”value”
$ export VARIABLE
%
You can use /etc/make.conf to control the options used to compile software
on this system. Example entries are in
/usr/share/examples/etc/defaults/make.conf.
%
To do a fast search for a file, try
locate filename
locate uses a database that is updated every Saturday (assuming your computer
is running FreeBSD at the time) to quickly find files based on name only.
%
In order to search for a string in some files, use ‘grep’ like this:
grep “string” filename1 [filename2 filename3 ...]
This will print out the lines in the files that contain the string. grep can
also do a lot more advanced searches - type ‘man grep’ for details.
%
You can use the ‘fetch’ command to retrieve files over ftp or http.
fetch http://www.freebsd.org/index.html
will download the front page of the FreeBSD web site.
%
In order to make fetch (the FreeBSD downloading tool) ask for
username/password when it encounters a password-protected web page, you can set
the environment variable HTTP_AUTH to ‘basic:*’.
%
You can permanently set environment variables for your shell by putting them
in a startup file for the shell. The name of the startup file varies
depending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use
.profile. When using bash, sh, ksh or zsh, don’t forget to export the
variable.
%
If you are running xterm, the default TERM variable will be ‘xterm’. If you
set this environment variable to ‘xterm-color’ instead, a lot of programs will
use colors. You can do this by
TERM=xterm-color; export TERM
in Bourne-derived shells, and
setenv TERM xterm-color
in csh-derived shells.
%
If you do not want to get beeps in X11 (X Windows), you can turn them off with
xset b off
%
You can look through a file in a nice text-based interface by typing
less filename
%
The default editor in FreeBSD is vi, which is efficient to use when you have
learned it, but somewhat user-unfriendly. To use ee (an easier but less
powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
%
If you accidentally end up inside vi, you can quit it by pressing Escape, colon
(:), q (q), bang (!) and pressing return.
%
You can use aliases to decrease the amount of typing you need to do to get
commands you commonly use. Examples of fairly popular aliases include (in
Bourne shell style, as in /bin/sh, bash, ksh, and zsh):
alias lf=”ls -FA”
alias ll=”ls -lA”
alias su=”su -m”
In csh or tcsh, these would be
alias lf ls -FA
alias ll ls -lA
alias su su -m
To remove an alias, you can usually use ‘unalias aliasname’. To list all
aliases, you can usually type just ‘alias’.
%
In order to support national characters for European languages in tools like
less without creating other nationalisation aspects, set the environment
variable LC_ALL to ‘en_US.ISO8859-1′.
%
You can search for documentation on a keyword by typing
apropos keyword
%
Man pages are divided into section depending on topic. There are 9 different
sections numbered from 1 (General Commands) to 9 (Kernel Developer’s Manual).
You can get an introduction to each topic by typing
man intro
In other words, to get the intro to general commands, type
man 1 intro
%
FreeBSD is started up by the program ‘init’. The first thing init does when
starting multiuser mode (ie, starting the computer up for normal use) is to
run the shell script /etc/rc. By reading /etc/rc, you can learn a lot about
how the system is put together, which again will make you more confident about
what happens when you do something with it.
%
If you want to play CDs with FreeBSD, a utility for this is already included.
Type ‘cdcontrol’ then ‘help’ to learn more. (You may need to set the CDROM
environment variable in order to make cdcontrol want to start.)
%
If you have a CD-ROM drive in your machine, you can make the CD-ROM that is
presently inserted available by typing ‘mount /cdrom’ as root. The CD-ROM
will be available under /cdrom/. Remember to do ‘umount /cdrom’ before
removing the CD-ROM (it will usually not be possible to remove the CD-ROM
without doing this.)
Note: This tip may not work in all configurations.
%
You can install extra packages for FreeBSD by using the ports system.
If you have installed it, you can download, compile, and install software by
just typing
# cd /usr/ports//
# make install && make clean
as root. The ports infrastructure will download the software, change it so
it works on FreeBSD, compile it, install it, register the installation so it
will be possible to automatically uninstall it, and clean out the temporary
working space it used. You can remove an installed port you decide you do not
want after all by typing
# cd /usr/ports//
# make deinstall
as root.
%
Nice bash prompt: PS1=’([$(tput md)]t [$(tput me)]) $(echo $?) $ ‘
– Mathieu
%
To see the output from when your computer started, run dmesg(8). If it has
been replaced with other messages, look at /var/run/dmesg.boot.
– Francisco Reyes
%
You can use “whereis” to locate standard binary, manual page and source
directories for the specified programs. This can be particularly handy
when you are trying to find where in the ports tree an application is.
Try “whereis netscape” and “whereis whereis”.
– Konstantinos Konstantinidis
%
You can press Ctrl-D to quickly exit from a shell, or logout from a
login shell.
– Konstantinos Konstantinidis
%
You can use “pkg_info” to see a list of packages you have installed.
– Konstantinos Konstantinidis
%
You can change the video mode on all consoles by adding something like
the following to /etc/rc.conf:
allscreens=”80×30″
You can use “vidcontrol -i mode | grep T” for a list of supported text
modes.
– Konstantinos Konstantinidis
%
Any user that is a member of the wheel group can use “su -” to simulate
a root login. You can add a user to the wheel group by editing /etc/group.
– Konstantinos Konstantinidis
%
Over quota? “du -s * | sort -n ” will give you a sorted list of your
directory sizes.
– David Scheidt
%
Handy bash(1) prompt: PS1=”u@h w !$ ”
– David Scheidt
%
Ever wonder what those numbers after command names were, as in cat(1)? It’s
the section of the manual the man page is in. “man man” will tell you more.
– David Scheidt
%
“man hier” will explain the way FreeBSD filesystems are normally laid out.
– David Scheidt
%
“man tuning” gives some tips how to tune performance of your FreeBSD system.
– David Scheidt
%
“man firewall” will give advice for building a FreeBSD firewall
– David Scheidt
%
You can often get answers to your questions about FreeBSD by searching in the
FreeBSD mailing list archives at
http://www.freebsd.org/search.html
%
You can adjust the volume of various parts of the sound system in your
computer by typing ‘mixer ‘. To get a list of what you can
adjust, just type ‘mixer’.
%
You can automatically download and install binary packages by doing
pkg_add -r
where you replace with the URL to the package. This will also
automatically install the packages the package you download is dependent on
(ie, the packages it needs in order to work.)
%
You can get a good standard workstation install by using the
instant-workstation port/package. If you have ports installed, you can
install it by doing
# cd /usr/ports/misc/instant-workstation
# make install && make clean
as root. This will install a collection of packages that is convenient to
have on a workstation.
%
You can get a good generic server install by using the
instant-server port/package. If you have ports installed, you can
install it by doing
# cd /usr/ports/misc/instant-server
# make install && make clean
as root. This will install a collection of packages that is appropriate for
running a “generic” server.
%
You can make a log of your terminal session with script(1).
%
“man ports” gives many useful hints about installing FreeBSD ports.
%
“man security” gives very good advice on how to tune the security of your
FreeBSD system.
%
Want to find a specific port, just type the following under /usr/ports,
or one its subdirectories:
“make search name=”
or
“make search key=”
%
Want to see how much virtual memory you’re using? Just type “swapinfo” to
be shown information about the usage of your swap partitions.
%
ports/net/netcat port is useful not only for redirecting input/output
to TCP or UDP connections, but also for proxying them. See inetd(8) for
details.
%
If other operating systems have damaged your Master Boot Record, you can
reinstall it either with /stand/sysinstall or with boot0cfg(8). See
“man boot0cfg” for details.
%
Need to see the calendar for this month? Simply type “cal”. To see the
whole year, type “cal -y”.
– Dru
%
Need to quickly return to your home directory? Type “cd”.
– Dru
%
To see the last time that you logged in, use lastlogin(8).
– Dru
%
To clear the screen, use “clear”. To re-display your screen buffer, press
the scroll lock key and use your page up button. When you’re finished,
press the scroll lock key again to get your prompt back.
– Dru
%
To save disk space in your home directory, compress files you rarely
use with “gzip filename”.
– Dru
%
To read a compressed file without having to first uncompress it, use
“zcat” or “zmore” to view it.
– Dru
%
To see how much disk space is left on your partitions, use
df -h
– Dru
%
To see the 10 largest files on a directory or partition, use
du /partition_or_directory_name | sort -rn | head
– Dru
%
To determine whether a file is a text file, executable, or some other type
of file, use
file filename
– Dru
%
Time to change your password? Type “passwd” and follow the prompts.
– Dru
%
Want to know how many words, lines, or bytes are contained in a file? Type
“wc filename”.
– Dru
%
Need to print a manpage? Use
man name_of_manpage | col -bx | lpr
– Dru
%
Need to remove all those ^M characters from a DOS file? Try
tr -d
<> newfile
– Originally by Dru
%
Forget what directory you are in? Type “pwd”.
– Dru
%
If you are in the C shell and have just installed a new program, you won’t
be able to run it unless you first type “rehash”.
– Dru
%
Need to leave your terminal for a few minutes and don’t want to logout?
Use “lock -p”. When you return, use your password as the key to unlock the
terminal.
– Dru
%
Need to find the location of a program? Use “locate program_name”.
– Dru
%
Forget how to spell a word or a variation of a word? Use
look portion_of_word_you_know
– Dru
%
To see the last 10 lines of a long file, use “tail filename”. To see the
first 10 lines, use “head filename”.
– Dru
%
To see how long it takes a command to run, type the word “time” before the
command name.
– Dru
%
To quickly create an empty file, use “touch filename”.
– Dru
%
To find out the hostname associated with an IP address, use
dig -x IP_address
– Dru
%
If you use the C shell, add the following line to the .cshrc file in your
home directory to prevent core files from being written to disk:
limit coredumpsize 0
– Dru
%
If you need a reminder to leave your terminal, type “leave +hhmm” where
“hhmm” represents in how many hours and minutes you need to leave.
– Dru
%
Need to do a search in a manpage or in a file you’ve sent to a pager? Use
“/search_word”. To repeat the same search, type “n” for next.
– Dru
%
Forget when Easter is? Try “ncal -e”. If you need the date for Orthodox
Easter, use “ncal -o” instead.
– Dru
%
Need to see your routing table? Type “netstat -rn”. The entry with the G
flag is your gateway.
– Dru
%
Need to see which daemons are listening for connection requests? Use
“sockstat -4l” for IPv4, and “sockstat -l” for IPv4 and IPv6.
– Dru
%
Can’t remember if you’ve installed a certain port or not? Try “pkg_info
-Ix port_name”.
%
To erase a line you’ve written at the command prompt, use “Ctrl-U”.
– Dru
%
To repeat the last command in the C shell, type “!!”.
– Dru
%
Need to quickly empty a file? Use “: > filename”.
– Dru
%
To see all of the directories on your FreeBSD system, type
ls -R / | more
– Dru
%
To see the IP addresses currently set on your active interfaces, type
“ifconfig -u”.
– Dru
%
To see the MAC addresses of the NICs on your system, type
ifconfig -a
– Dru
%
You can open up a new split-screen window in (n)vi with :N or :E and then
use ^w to switch between the two.
%
sh (the default Bourne shell in FreeBSD) supports command-line editing. Just
“set -o emacs” or “set -o vi” to enable it.
%
When you’ve made modifications to a file in vi(1) and then find that
you can’t write it, type “!rm -f %” then “:w!” to force the
write
This won’t work if you don’t have write permissions to the directory
and probably won’t be suitable if you’re editing through a symbolic link.
%
If you want to quickly check for duplicate package/port installations,
try the following pkg_info command.
pkg_info | sort | sed -e ’s/-[0-9].*$//’ |
uniq -c | grep -v ‘^[[:space:]]*1′
%
Want to use sed(1) to edit a file in place? Well, to replace every ‘e’ with
an ‘o’, in a file named ‘foo’, you can do:
sed -i.bak s/e/o/g foo
And you’ll get a backup of the original in a file named ‘foo.bak’, but if you
want no backup:
sed -i ” s/e/o/g foo
%
To obtain a neat PostScript rendering of a manual page, use “-t” switch
of the man(1) utility: “man -t ”. For example:
man -t grep > grep.ps # Save the PostScript version to a file
or
man -t printf | lp # Send the PostScript directly to printer
FreeBSD 8.0-CURRENT
1 Introduction
This distribution is a snapshot of FreeBSD 8.0-CURRENT, the latest point along the 8-CURRENT branch.
1.1 About FreeBSD
FreeBSD is an operating system based on 4.4 BSD Lite for AMD64 and Intel EM64T based PC hardware (amd64), Intel, AMD, Cyrix or NexGen “x86” based PC hardware (i386), Intel Itanium Processor based computers (ia64), NEC PC-9801/9821 series PCs and compatibles (pc98), and UltraSPARC® machines (sparc64). Versions for the ARM® (arm), MIPS® (mips), and PowerPC® (powerpc) architectures are currently under development as well. FreeBSD works with a wide variety of peripherals and configurations and can be used for everything from software development to games to Internet Service Provision.
This release of FreeBSD contains everything you need to run such a system, including full source code for the kernel and all utilities in the base distribution. With the source distribution installed, you can literally recompile the entire system from scratch with one command, making it ideal for students, researchers, or users who simply want to see how it all works.
A large collection of third-party ported software (the “Ports Collection”) is also provided to make it easy to obtain and install all your favorite traditional UNIX® utilities for FreeBSD. Each “port” consists of a set of scripts to retrieve, configure, build, and install a piece of software, with a single command. Over 20,000 ports, from editors to programming languages to graphical applications, make FreeBSD a powerful and comprehensive operating environment that extends far beyond what's provided by many commercial versions of UNIX. Most ports are also available as pre-compiled “packages”, which can be quickly installed from the installation program.
1.2 Target Audience
This snapshot is aimed primarily at early adopters and various other users who want to get involved with the ongoing development of FreeBSD. While the FreeBSD development team tries its best to ensure that each snapshot works as advertised, 8-CURRENT is very much a work-in-progress.
The basic requirements for using this snapshot are technical proficiency with FreeBSD and an understanding of the ongoing development process of FreeBSD 8-CURRENT (as discussed on the FreeBSD-CURRENT mailing list).
For those more interested in doing business with FreeBSD than in experimenting with new FreeBSD technology, formal releases (such as 7.0-RELEASE) are frequently more appropriate. Releases undergo a period of testing and quality assurance checking to ensure high reliability and dependability.
This distribution is a snapshot of FreeBSD 8.0-CURRENT, the latest point along the 8-CURRENT branch.
1.1 About FreeBSD
FreeBSD is an operating system based on 4.4 BSD Lite for AMD64 and Intel EM64T based PC hardware (amd64), Intel, AMD, Cyrix or NexGen “x86” based PC hardware (i386), Intel Itanium Processor based computers (ia64), NEC PC-9801/9821 series PCs and compatibles (pc98), and UltraSPARC® machines (sparc64). Versions for the ARM® (arm), MIPS® (mips), and PowerPC® (powerpc) architectures are currently under development as well. FreeBSD works with a wide variety of peripherals and configurations and can be used for everything from software development to games to Internet Service Provision.
This release of FreeBSD contains everything you need to run such a system, including full source code for the kernel and all utilities in the base distribution. With the source distribution installed, you can literally recompile the entire system from scratch with one command, making it ideal for students, researchers, or users who simply want to see how it all works.
A large collection of third-party ported software (the “Ports Collection”) is also provided to make it easy to obtain and install all your favorite traditional UNIX® utilities for FreeBSD. Each “port” consists of a set of scripts to retrieve, configure, build, and install a piece of software, with a single command. Over 20,000 ports, from editors to programming languages to graphical applications, make FreeBSD a powerful and comprehensive operating environment that extends far beyond what's provided by many commercial versions of UNIX. Most ports are also available as pre-compiled “packages”, which can be quickly installed from the installation program.
1.2 Target Audience
This snapshot is aimed primarily at early adopters and various other users who want to get involved with the ongoing development of FreeBSD. While the FreeBSD development team tries its best to ensure that each snapshot works as advertised, 8-CURRENT is very much a work-in-progress.
The basic requirements for using this snapshot are technical proficiency with FreeBSD and an understanding of the ongoing development process of FreeBSD 8-CURRENT (as discussed on the FreeBSD-CURRENT mailing list).
For those more interested in doing business with FreeBSD than in experimenting with new FreeBSD technology, formal releases (such as 7.0-RELEASE) are frequently more appropriate. Releases undergo a period of testing and quality assurance checking to ensure high reliability and dependability.