freebsd-tips revision 78266
1This fortune brought to you by: 2$FreeBSD: head/games/fortune/datfiles/freebsd-tips 78266 2001-06-15 08:45:43Z nik $ 3% 4Having trouble using FTP through a firewall? Try setting the environment 5variable FTP_PASSIVE_MODE to yes, and see ftp(1) for more details. 6% 7By pressing "Scroll Lock" you can use the arrow keys to scroll backward 8through the console output. Press "Scroll Lock" again to turn it off. 9% 10Want colour in your directory listings? Use "ls -G". "ls -F" is also useful, 11and they can be combined as "ls -FG". 12% 13If you need to ask a question on the FreeBSD-questions mailing list then 14 15 http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\ 16 freebsd-questions/index.html 17 18contains lots of useful advice to help you get the best results. 19% 20If you'd like to keep track of applications in the FreeBSD ports tree, take a 21look at FreshPorts; 22 23 http://www.freshports.org/ 24% 25To search for files that match a particular name, use find(1); for example 26 27 find / -name "*GENERIC*" -ls 28 29will search '/', and all subdirectories, for files with 'GENERIC' in the name. 30 -- Stephen Hilton <nospam@hiltonbsd.com> 31% 32In tcsh, you can `set autolist' to have the shell automatically show 33all the possible matches when doing filename/directory expansion. 34 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 35% 36You can `set autologout = 30' to have tcsh log you off automatically 37if you leave the shell idle for more than 30 seconds. 38 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 39% 40If you `set filec' (file completion) in tcsh and write a part of the 41filename, pressing TAB will show you the available choices when there 42is more than one, or complete the filename if there's only one match. 43 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 44% 45You can press up-arrow or down-arrow to walk through a list of 46previous commands in tcsh. 47 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 48% 49You can disable tcsh's terminal beep if you `set nobeep'. 50 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 51% 52If you `set watch (0 any any)' in tcsh, you will be notified when 53someone logs in or out of your system. 54 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 55% 56Nice tcsh prompt: set prompt = '%m %# ' 57 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 58% 59Nice tcsh prompt: set prompt = '%n@%m%# ' 60 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 61% 62Nice tcsh prompt: set prompt = '%n@%m:%~%# ' 63 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 64% 65Nice tcsh prompt: set prompt = '%n@%m:%/%# ' 66 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 67% 68Nice tcsh prompt: set prompt = '[%B%m%b] %B%~%b%# ' 69% 70Simple tcsh prompt: set prompt = '%# ' 71 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 72% 73If you want df(1) and other commands to display disk sizes in 74kilobytes instead of 512-byte blocks, set BLOCKSIZE in your 75environment to 'K'. 76 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 77% 78To change an environment variable in tcsh you use: setenv NAME "value" 79where NAME is the name of the variable and "value" its new value. 80 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 81% 82To change an environment variable in /bin/sh use: 83 84 $ VARIABLE="value" 85 $ export VARIABLE 86 -- Giorgos Keramidas <keramida@ceid.upatras.gr> 87% 88/etc/make.conf contains overrides to /etc/defaults/make.conf, which 89controls the options used to compile software on this system. 90% 91To do a fast search for a file, try 92 93 locate filename 94 95locate uses a database that is updated every saturday (assuming your computer 96is running FreeBSD at the time) to quickly find files based on name only. 97 -- Eivind Eklund <eivind@FreeBSD.org> 98% 99In order to search for a string in some files, use 'grep' like this: 100 101 grep "string" filename1 [filename2 filename3 ...] 102 103This will print out the lines in the files that contain the string. grep can 104also do a lot more advanced searches - type 'man grep' for details. 105 -- Eivind Eklund <eivind@FreeBSD.org> 106% 107You can use the 'fetch' command to retrieve files over ftp or http. 108 109 fetch http://www.freebsd.org/index.html 110 111will download the front page of the FreeBSD web site. 112 -- Eivind Eklund <eivind@FreeBSD.org> 113% 114In order to make fetch (the FreeBSD downloading tool) ask for 115username/password when it encounter a password-protected web page, you can set 116the environment variable HTTP_AUTH to 'basic:*'. 117 -- Eivind Eklund <eivind@FreeBSD.org> 118% 119You can permanently set environment variables for your shell by putting them 120in a startup file for the shell. The name of the startup file varies 121depending on the shell - csh and tcsh uses .cshrc, bash uses .bashrc, zsh uses 122.zshrc, ksh uses .kshrc, and the Bourne shell (/bin/sh) uses .profile (and 123through a little bit of trickery in .profile also .shrc) 124Other shells will often also read .profile 125 -- Eivind Eklund <eivind@FreeBSD.org> 126% 127If you are running xterm, the default TERM variable will be 'xterm'. If you 128set this environment variable to 'xterm-color' instead, a lot of programs will 129use colors. You can do this by 130 131 TERM=xterm-color; export TERM 132 133in Bourne-derived shells, and 134 135 setenv TERM xterm-color 136 137in csh-derived shells. 138 -- Eivind Eklund <eivind@FreeBSD.org> 139% 140If you accidently drop into /bin/sh (e.g, due to a computer failure where you 141end up in single user mode), you can make the cursor keys work by typing 142 143 set -E 144 145The E represents the initial E in Emacs (for emacs keys). 146 -- Eivind Eklund <eivind@FreeBSD.org> 147% 148If you do not want to get beeps in X11 (X Windows), you can turn them off with 149 150 xset b off 151 -- Eivind Eklund <eivind@FreeBSD.org> 152% 153You can look through a file in a nice text-based interface by typing 154 155 less filename 156 -- Eivind Eklund <eivind@FreeBSD.org> 157% 158The default editor in FreeBSD is vi, which is efficient to use when you have 159learned it, but somewhat user-unfriendly. To use ee (an easier but less 160powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee 161 -- Eivind Eklund <eivind@FreeBSD.org> 162% 163If you accidently end up inside vi, you can quit it by pressing Escape, colon 164(:), q (q), bang (!) and pressing return. 165 -- Eivind Eklund <eivind@FreeBSD.org> 166% 167You can use aliases to decrease the amount of typing you need to do to get 168commands you commonly use. Examples of fairly popular aliases include (in 169bourne shell style, as in /bin/sh, bash, ksh, and zsh): 170 171 alias lf="ls -FA" 172 alias ll="ls -lA" 173 alias su="su -m" 174 175In csh or tcsh, these would be 176 177 alias lf ls -FA 178 alias ll ls -lA 179 alias su su -m 180 181To remove an alias, you can usually use 'unalias aliasname'. To list all 182aliases, you can usually type just 'alias'. 183 -- Eivind Eklund <eivind@FreeBSD.org> 184% 185In order to support national characters for european languages in tools like 186less without creating other nationalisation aspects, set the environment 187variable LC_ALL to 'en_US.ISO8859-1'. 188 -- Eivind Eklund <eivind@FreeBSD.org> 189% 190You can search for documentation on a keyword by typing 191 192 apropos keyword 193 -- Eivind Eklund <eivind@FreeBSD.org> 194% 195Man pages are divided into section depending on topic. There are 9 different 196sections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual). 197You can get an introduction to each topic by typing 198 199 man <number> intro 200 201In other words, to get the intro to general commands, type 202 203 man 1 intro 204 -- Eivind Eklund <eivind@FreeBSD.org> 205% 206FreeBSD is started up by the program 'init'. The first thing init does when 207starting multiuser mode (ie, starting the computer up for normal use) is to 208run the shell script /etc/rc. By reading /etc/rc, you can learn a lot about 209how the system is put together, which again will make you more confident about 210what happens when you do something with it. 211 -- Eivind Eklund <eivind@FreeBSD.org> 212% 213If you want to play CDs with FreeBSD, a utility for this is already included. 214Type 'cdcontrol' then 'help' to learn more. (You may need to set the CDROM 215environment variable in order to make cdcontrol want to start.) 216 -- Eivind Eklund <eivind@FreeBSD.org> 217% 218If you have a CD-ROM drive in your machine, you can make the CD-ROM that is 219presently inserted available by typing 'mount /cdrom' as root. The CD-ROM 220will be available under /cdrom/. Remember to do 'unmount /cdrom' before 221removing the CD-ROM (it will usually not be possible to remove the CD-ROM 222without doing this.) 223 224Note: This tip may not work in all configurations. 225 -- Eivind Eklund <eivind@FreeBSD.org> 226% 227You can install extra packages for FreeBSD by using the ports system. 228If you have installed it, you can download, compile, and install software by 229just typing 230 231 # cd /usr/ports/<category>/<portname> 232 # make install && make clean 233 234as root. The ports infrastructure will download the software, change it so 235it works on FreeBSD, compile it, install it, register the installation so it 236will be possible to automatically uninstall it, and clean out the temporary 237working space it used. You can remove an installed port you decide you do not 238want after all by typing 239 240 # cd /usr/ports/<category>/<portname> 241 # make deinstall 242 243as root. 244 -- Eivind Eklund <eivind@FreeBSD.org> 245% 246Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ ' 247 -- Mathieu <mathieu@hal.interactionvirtuelle.com> 248% 249To see the output from when your computer started, run dmesg(8). If it has 250been replaced with other messages, look at /var/run/dmesg.boot. 251 -- Francisco Reyes <lists@natserv.com> 252% 253You can use "whereis" to locate standard binary, manual page and source 254directories for the specified programs. This can be particularly handy 255when you are trying to find where in the ports tree an application is. 256 257Try "whereis netscape" and "whereis whereis". 258 -- Konstantinos Konstantinidis <kkonstan@duth.gr> 259% 260You can press Ctrl-D to quickly exit from a shell, or logout from a 261login shell. 262 -- Konstantinos Konstantinidis <kkonstan@duth.gr> 263% 264You can use "pkg_info" to see a list of packages you have installed. 265 -- Konstantinos Konstantinidis <kkonstan@duth.gr> 266% 267You can change the video mode on all consoles by adding something like 268the following to /etc/rc.conf: 269 270 allscreens="80x30" 271 272You can use "vidcontrol -i mode | grep T" for a list of supported text 273modes. 274 -- Konstantinos Konstantinidis <kkonstan@duth.gr> 275% 276Any user that is a member of the wheel group can use "su -" to simulate 277a root login. You can add a user to the wheel group by editing /etc/group. 278 -- -- Konstantinos Konstantinidis <kkonstan@duth.gr> 279