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