1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
This fortune brought to you by:
$FreeBSD$
%
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 <kkonstan@duth.gr>
%
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.
%
Can't remember if you've installed a certain port or not? Try "pkg info
-x port_name".
%
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 <dscheidt@tumbolia.com>
%
Forget how to spell a word or a variation of a word? Use
look portion_of_word_you_know
-- Dru <genesis@istar.ca>
%
Forget what directory you are in? Type "pwd".
-- Dru <genesis@istar.ca>
%
Forget when Easter is? Try "ncal -e". If you need the date for Orthodox
Easter, use "ncal -o" instead.
-- Dru <genesis@istar.ca>
%
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 and the /etc/rc.d/ scripts,
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.
%
Handy bash(1) prompt: PS1="\u@\h \w \!$ "
-- David Scheidt <dscheidt@tumbolia.com>
%
Having trouble using fetch through a firewall? Try setting the environment
variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
%
If other operating systems have damaged your Master Boot Record, you can
reinstall it with boot0cfg(8). See
"man boot0cfg" for details.
%
If you accidentally end up inside vi, you can quit it by pressing Escape, colon
(:), q (q), bang (!) and pressing return.
%
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 <genesis@istar.ca>
%
If you do not want to get beeps in X11 (X Windows), you can turn them off with
xset b off
%
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.
%
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 <genesis@istar.ca>
%
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 write part of a filename in tcsh,
pressing TAB will show you the available choices when there
is more than one, or complete the filename if there's only one match.
%
If you `set watch = (0 any any)' in tcsh, you will be notified when
someone logs in or out of your system.
%
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 <genesis@istar.ca>
%
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'.
%
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'd like to keep track of applications in the FreeBSD ports tree, take a
look at FreshPorts;
http://www.freshports.org/
%
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:*'.
%
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.
%
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'.
%
"man firewall" will give advice for building a FreeBSD firewall
-- David Scheidt <dscheidt@tumbolia.com>
%
"man hier" will explain the way FreeBSD filesystems are normally laid out.
-- David Scheidt <dscheidt@tumbolia.com>
%
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 <number> intro
In other words, to get the intro to general commands, type
man 1 intro
%
"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.
%
"man tuning" gives some tips how to tune performance of your FreeBSD system.
-- David Scheidt <dscheidt@tumbolia.com>
%
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 <genesis@istar.ca>
%
Need to find the location of a program? Use "locate program_name".
-- Dru <genesis@istar.ca>
%
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 <genesis@istar.ca>
%
Need to print a manpage? Use
man name_of_manpage | col -bx | lpr
-- Dru <genesis@istar.ca>
%
Need to quickly empty a file? Use ": > filename".
-- Dru <genesis@istar.ca>
%
Need to quickly return to your home directory? Type "cd".
-- Dru <genesis@istar.ca>
%
Need to remove all those ^M characters from a DOS file? Try
tr -d \\r < dosfile > newfile
-- Originally by Dru <genesis@istar.ca>
%
Need to see the calendar for this month? Simply type "cal". To see the
whole year, type "cal -y".
-- Dru <genesis@istar.ca>
%
Need to see which daemons are listening for connection requests? Use
"sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6.
-- Dru <genesis@istar.ca>
%
Need to see your routing table? Type "netstat -rn". The entry with the G
flag is your gateway.
-- Dru <genesis@istar.ca>
%
Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
-- Mathieu <mathieu@hal.interactionvirtuelle.com>
%
Over quota? "du -s * | sort -n " will give you a sorted list of your
directory sizes.
-- David Scheidt <dscheidt@tumbolia.com>
%
nc(1) (or netcat) is useful not only for redirecting input/output to
TCP or UDP connections, but also for proxying them with inetd(8).
%
sh (the default Bourne shell in FreeBSD) supports command-line editing. Just
``set -o emacs'' or ``set -o vi'' to enable it.
%
Simple tcsh prompt: set prompt = '%# '
%
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
%
Time to change your password? Type "passwd" and follow the prompts.
-- Dru <genesis@istar.ca>
%
To change an environment variable in /bin/sh use:
$ VARIABLE="value"
$ export VARIABLE
%
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 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 <genesis@istar.ca>
%
To determine whether a file is a text file, executable, or some other type
of file, use
file filename
-- Dru <genesis@istar.ca>
%
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.
%
To erase a line you've written at the command prompt, use "Ctrl-U".
-- Dru <genesis@istar.ca>
%
To find the hostname associated with an IP address, use
drill -x IP_address
-- Allan Jude <allanjude@freebsd.org>
%
To obtain a neat PostScript rendering of a manual page, use ``-t'' switch
of the man(1) utility: ``man -t <topic>''. 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
%
To quickly create an empty file, use "touch filename".
-- Dru <genesis@istar.ca>
%
To read a compressed file without having to first uncompress it, use
"zcat" or "zless" to view it.
-- Dru <genesis@istar.ca>
%
To repeat the last command in the C shell, type "!!".
-- Dru <genesis@istar.ca>
%
To save disk space in your home directory, compress files you rarely
use with "gzip filename".
-- Dru <genesis@istar.ca>
%
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 <nospam@hiltonbsd.com>
%
To see all of the directories on your FreeBSD system, type
find / -type d | less
All the files?
find / -type f | less
%
To see how long it takes a command to run, type the word "time" before the
command name.
-- Dru <genesis@istar.ca>
%
To see how much disk space is left on your partitions, use
df -h
-- Dru <genesis@istar.ca>
%
To see the 10 largest files on a directory or partition, use
du /partition_or_directory_name | sort -rn | head
-- Dru <genesis@istar.ca>
%
To see the IP addresses currently set on your active interfaces, type
"ifconfig -u".
-- Dru <genesis@istar.ca>
%
To see the last 10 lines of a long file, use "tail filename". To see the
first 10 lines, use "head filename".
-- Dru <genesis@istar.ca>
%
To see the last time that you logged in, use lastlogin(8).
-- Dru <genesis@istar.ca>
%
To see the MAC addresses of the NICs on your system, type
ifconfig -a
-- Dru <genesis@istar.ca>
%
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 <lists@natserv.com>
%
Want colour in your directory listings? Use "ls -G". "ls -F" is also useful,
and they can be combined as "ls -FG".
%
Want to find a specific port, just type the following under /usr/ports
or one its subdirectories:
make search name=<port-name>
or
make search key=<keyword>
%
Want to know how many words, lines, or bytes are contained in a file? Type
"wc filename".
-- Dru <genesis@istar.ca>
%
Want to see how much virtual memory you're using? Just type "swapinfo" to
be shown information about the usage of your swap partitions.
%
Want to strip UTF-8 BOM(Byte Order Mark) from given files?
sed -e '1s/^\xef\xbb\xbf//' < bomfile > newfile
%
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
%
When you've made modifications to a file in vi(1) and then find that
you can't write it, type ``<ESC>!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.
%
You can adjust the volume of various parts of the sound system in your
computer by typing 'mixer <type> <volume>'. To get a list of what you can
adjust, just type 'mixer'.
%
You can automatically download and install binary packages by doing
pkg install <package>
This will also automatically install the packages that are dependencies
for the package you install (ie, the packages it needs in order to work.)
%
You can change the video mode on all consoles by adding something like
the following to /etc/rc.conf:
allscreens="80x30"
You can use "vidcontrol -i mode | grep T" for a list of supported text
modes.
-- Konstantinos Konstantinidis <kkonstan@duth.gr>
%
You can disable tcsh's terminal beep if you `set nobeep'.
%
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/<category>/<portname>
# 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/<category>/<portname>
# make deinstall
as root.
%
You can look through a file in a nice text-based interface by typing
less filename
%
You can make a log of your terminal session with script(1).
%
You can often get answers to your questions about FreeBSD by searching in the
FreeBSD mailing list archives at
http://www.FreeBSD.org/search/search.html
%
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.
%
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.
%
You can press Ctrl-D to quickly exit from a shell, or logout from a
login shell.
-- Konstantinos Konstantinidis <kkonstan@duth.gr>
%
You can press Ctrl-L while in the shell to clear the screen.
%
You can press up-arrow or down-arrow to walk through a list of
previous commands in tcsh.
%
You can search for documentation on a keyword by typing
apropos keyword
%
You can `set autologout = 30' to have tcsh log you off automatically
if you leave the shell idle for more than 30 minutes.
%
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'.
%
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/make.conf.
%
You can use "pkg info" to see a list of packages you have installed.
%
You can use the 'fetch' command to retrieve files over ftp, http or https.
fetch http://www.FreeBSD.org/index.html
will download the front page of the FreeBSD web site.
%
You can use "whereis" to search 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 firefox" and "whereis whereis".
-- Konstantinos Konstantinidis <kkonstan@duth.gr>
%
Want to run the same command again?
In tcsh you can type "!!"
%
Want to go the directory you were just in?
Type "cd -"
%
|