1 1.1 reed List 20 largest files (larger than 5 MB) sorted by megabytes: 2 1.1 reed 3 1.16 nia find . -type f -size +10000 -exec du -m {} + | sort -nr | head -20 4 1.1 reed % 5 1.1 reed You can keep specific rc.conf configurations in individual files 6 1.1 reed under /etc/rc.conf.d/ where each file is named after the $name of 7 1.1 reed the rc.d script. Some configurations may have different names than 8 1.1 reed the script; see the $name variable to check. 9 1.1 reed % 10 1.1 reed You can see the total used buffers in megabytes with: 11 1.1 reed 12 1.1 reed vmstat -s | awk ' 13 1.1 reed / bytes per page$/ { bpp = $1 } 14 1.1 reed / cached file pages$/ { cfp = $1 } 15 1.1 reed / cached executable pages$/ { cep = $1 } 16 1.1 reed END { print((cfp + cep) * bpp / 1024 / 1024); }' 17 1.1 reed % 18 1.1 reed You can view a value of a variable in pkgsrc by using the show-var 19 1.1 reed target, for example: 20 1.1 reed 21 1.1 reed make show-var VARNAME=MAINTAINER 22 1.1 reed % 23 1.1 reed You can view the basic order of your rc.d scripts with: 24 1.1 reed 25 1.1 reed rcorder /etc/rc.d/* 26 1.1 reed % 27 1.1 reed You can ask questions about NetBSD at the netbsd-users (a] NetBSD.org 28 1.1 reed mailing list. Be sure to clearly explain your problem, what you 29 1.1 reed tried, what results you had, and what you expected. 30 1.1 reed % 31 1.1 reed You can view your non-default Postfix settings with: 32 1.1 reed 33 1.1 reed postconf -n 34 1.1 reed % 35 1.1 reed To report about installed packages with known vulnerabilities, 36 1.1 reed fetch the latest pkg-vulnerabilities file as the superuser with: 37 1.1 reed 38 1.8 leot pkg_admin fetch-pkg-vulnerabilities 39 1.1 reed 40 1.1 reed And then run: 41 1.1 reed 42 1.8 leot pkg_admin audit 43 1.1 reed % 44 1.1 reed The following shows an example of temporarily adding 10MB more swap 45 1.1 reed space for virtual memory: 46 1.1 reed 47 1.3 reed dd if=/dev/zero of=/root/swapfile bs=1024 count=10240 48 1.3 reed chmod go= /root/swapfile 49 1.1 reed swapctl -a /root/swapfile 50 1.1 reed % 51 1.1 reed If your console ever gets broken, you can try resetting it to its 52 1.1 reed initial state with: 53 1.1 reed 54 1.7 leot printf "\033c" 55 1.1 reed % 56 1.1 reed If you installed a package, but don't know what the software is 57 1.5 wiz called or what executables to run, use pkg_info with the -L switch 58 1.5 wiz to list the package's files and search for /bin: 59 1.1 reed 60 1.5 wiz pkg_info -L PACKAGE-NAME | grep /bin 61 1.1 reed % 62 1.1 reed A new user can be added by using the useradd tool with the -m switch 63 1.1 reed to create the home directory. Then set the password. For example: 64 1.1 reed 65 1.1 reed useradd -m susan 66 1.1 reed passwd susan 67 1.1 reed % 68 1.1 reed To modify user account information use the chpass or usermod tools. 69 1.1 reed If you need to edit the user database directly, use the vipw command. 70 1.1 reed % 71 1.1 reed You can temporarily start the SSH server by running the following 72 1.1 reed as root: 73 1.1 reed 74 1.1 reed /etc/rc.d/sshd onestart 75 1.1 reed % 76 1.6 maxv Several NPF examples are available in the /usr/share/examples/npf/ 77 1.6 maxv directory. 78 1.1 reed % 79 1.1 reed Want to dual boot using a bluetooth mouse or keyboard? Use btkey(1) 80 1.1 reed to store the link key in the hardware. 81 1.1 reed % 82 1.1 reed If you are having trouble connecting to a remote bluetooth device, 83 1.1 reed try the btconfig(8) inquiry command. The kernel will retain some 84 1.1 reed clock offset information that may help. 85 1.1 reed % 86 1.1 reed You can download files via HTTP using the ftp(1) command; for example: 87 1.1 reed 88 1.1 reed ftp http://www.NetBSD.org/images/NetBSD.png 89 1.1 reed % 90 1.1 reed The mtree(8) tool can be used to check permissions, ownerships, 91 1.1 reed file changes, and more when compared against a specification. For 92 1.1 reed example to check directory ownership and permissions for standard 93 1.1 reed NetBSD directories, run: 94 1.1 reed 95 1.1 reed /usr/sbin/mtree -e -p / -f /etc/mtree/NetBSD.dist 96 1.1 reed % 97 1.1 reed If you need reminders on your console to leave, use the leave(1) 98 1.1 reed tool. For example to receive reminders to leave in one hour: 99 1.1 reed 100 1.1 reed leave +0100 101 1.1 reed % 102 1.1 reed To stop non-superuser logins until next boot, as root: 103 1.1 reed 104 1.1 reed touch /etc/nologin 105 1.1 reed % 106 1.1 reed When extracting distribution tar sets, be sure to use the pax -pe 107 1.1 reed option or the tar -p switch to preserve the user and group and file 108 1.1 reed modes (including setuid and setgid). This is needed, for example, 109 1.1 reed so su(1) will work after extracting the base.tgz set. 110 1.1 reed % 111 1.1 reed Math can be done within the sh(1) and ksh(1) shells or with expr(1), 112 1.1 reed dc(1), bc(1), or awk(1). Here are some simple examples: 113 1.1 reed 114 1.1 reed echo $((431 * 79)) 115 1.1 reed expr 60 \* 60 \* 24 \* 7 116 1.1 reed % 117 1.2 reed You can view network connections with the fstat, netstat -a, sockstat, 118 1.2 reed and "systat netstat" commands. 119 1.2 reed % 120 1.2 reed Visit the NetBSD Security website to keep track of advisories: 121 1.2 reed http://www.NetBSD.org/support/security/ 122 1.2 reed Or join the security-announce mailing list for alerts: 123 1.11 nia http://www.NetBSD.org/mailinglists/#security-announce 124 1.2 reed % 125 1.2 reed Here's an example of finding what package a file belongs to: 126 1.2 reed 127 1.2 reed pkg_info -Fe /usr/pkg/bin/inw 128 1.2 reed % 129 1.2 reed Many log files are checked for rotation every hour by newsyslog(8). 130 1.2 reed It is configured in /etc/newsyslog.conf. 131 1.2 reed % 132 1.2 reed NetBSD's default cron jobs are defined in the /var/cron/tabs/root 133 1.2 reed file. As the superuser, use "crontab -l" to view it. To edit it, 134 1.2 reed use "crontab -e" (which defaults to using the vi(1) editor). 135 1.2 reed % 136 1.4 jmmv You can make sure that your system is stable and behaves correctly by 137 1.4 jmmv running the tests in /usr/tests (which come from the tests.tgz set). 138 1.4 jmmv To do so: 139 1.4 jmmv 140 1.4 jmmv vi /etc/atf/NetBSD.conf 141 1.4 jmmv cd /usr/tests 142 1.4 jmmv atf-run | atf-report 143 1.4 jmmv % 144 1.9 nia To share files from your NetBSD system, you can use the built-in 145 1.9 nia httpd(8). Uncomment the 'http' lines in /etc/inetd.conf, reload inetd 146 1.9 nia with service(8), and then any files in /var/www will be published to 147 1.9 nia http://127.0.0.1/. 148 1.9 nia % 149 1.9 nia You can schedule simple periodic tasks for your NetBSD system to run 150 1.9 nia without using cron(8) by editing the sh(1) scripts /etc/daily.local, 151 1.9 nia /etc/weekly.local, and /etc/monthly.local. 152 1.9 nia % 153 1.9 nia NetBSD's tar(1) command can handle a wide range of file types, e.g. 154 1.9 nia zip, 7z, and rar, and will autodetect the type of the file based 155 1.9 nia on its extension. For example, to extract a zip file: 156 1.9 nia 157 1.9 nia tar xvf example.zip 158 1.9 nia % 159 1.9 nia You can use progress(1) to monitor the progress of data in a pipe: 160 1.9 nia 161 1.9 nia zcat example.tar.gz | progress tar xf - 162 1.10 nia % 163 1.10 nia Press CTRL+T to send SIGINFO and see the current status of the 164 1.10 nia command running in the current terminal. 165 1.12 nia % 166 1.12 nia To enable the Multicast DNS responder, add 167 1.12 nia 168 1.12 nia mdnsd=YES 169 1.12 nia 170 1.12 nia to /etc/rc.conf. Your system will now be reachable on the network as 171 1.12 nia hostname.local. 172 1.12 nia 173 1.12 nia To enable Multicast DNS lookups, add mdnsd to the 'hosts' field in 174 1.12 nia /etc/nsswitch.conf. 175 1.12 nia % 176 1.12 nia NetBSD includes a tutorial on using vi(1), the classic BSD text 177 1.12 nia editor: 178 1.12 nia 179 1.12 nia less /usr/share/doc/usd/vi/vitut.txt 180 1.12 nia % 181 1.12 nia A login shell will read initial commands from ~/.profile. 182 1.12 nia 183 1.12 nia When using the X Window System, initializing with 'startx' will 184 1.12 nia read ~/.xinitrc. Initializing with xdm will read commands from 185 1.12 nia ~/.xsession, but logins through xdm will not read ~/.profile. 186 1.12 nia % 187 1.12 nia After installing NetBSD, additional sets can be installed with 188 1.12 nia sysinst(8). 189 1.12 nia % 190 1.12 nia Depending on the version of NetBSD, the system may raise the sysctl(8) 191 1.12 nia variable kern.securelevel to 1 on boot. The system's securelevel may be 192 1.12 nia raised by the superuser, but never lowered. 193 1.12 nia 194 1.12 nia To learn more about the different securelevel settings, see: 195 1.12 nia 196 1.12 nia man secmodel_securelevel 197 1.12 nia % 198 1.12 nia To learn more about the various security features in NetBSD, see: 199 1.12 nia 200 1.12 nia man 7 security 201 1.12 nia % 202 1.12 nia Network interface traffic can be monitored with the following 203 1.12 nia command: 204 1.12 nia 205 1.12 nia sysstat ifstat 206 1.13 nia % 207 1.13 nia To list connected disk devices: 208 1.13 nia 209 1.13 nia sysctl hw.disknames 210 1.14 nia % 211 1.14 nia screenblank(1) can disable the framebuffer if the keyboard and mouse are 212 1.14 nia idle for a period of time, and re-enables the framebuffer when keyboard 213 1.14 nia or mouse activity resumes. 214 1.15 nia % 215 1.15 nia If you want to convert a Microsoft Windows text file to have Unix line 216 1.15 nia endings, it's possible to achieve by simply stripping all of the carriage 217 1.15 nia return characters from the file: 218 1.15 nia 219 1.15 nia tr -d '\r' < IN > OUT 220 1.15 nia 221 1.15 nia However, you might want to do this more carefully (i.e. only remove 222 1.15 nia carriage returns that constitute a line ending). See "dos2unix" in pkgsrc. 223 1.15 nia % 224 1.15 nia Some useful X11 commands: 225 1.15 nia 226 1.15 nia xset s off # disable screen blanking 227 1.15 nia xset -dpms # disable screen power saving 228 1.15 nia xset b 0 # mute bell (beep) 229 1.15 nia xset m 55/20 4 # mouse acceleration 230 1.15 nia % 231 1.15 nia Automatically run a make(1) job on each active CPU: 232 1.15 nia 233 1.15 nia alias make="make -j $(sysctl -n hw.ncpuonline)" 234