List 20 largest files (larger than 5 MB) sorted by megabytes: find . -type f -size +10000 -exec du -m {} + | sort -nr | head -20 % You can keep specific rc.conf configurations in individual files under /etc/rc.conf.d/ where each file is named after the $name of the rc.d script. Some configurations may have different names than the script; see the $name variable to check. % You can see the total used buffers in megabytes with: vmstat -s | awk ' / bytes per page$/ { bpp = $1 } / cached file pages$/ { cfp = $1 } / cached executable pages$/ { cep = $1 } END { print((cfp + cep) * bpp / 1024 / 1024); }' % You can view a value of a variable in pkgsrc by using the show-var target, for example: make show-var VARNAME=MAINTAINER % You can view the basic order of your rc.d scripts with: rcorder /etc/rc.d/* % You can ask questions about NetBSD at the netbsd-users@NetBSD.org mailing list. Be sure to clearly explain your problem, what you tried, what results you had, and what you expected. % You can view your non-default Postfix settings with: postconf -n % To report about installed packages with known vulnerabilities, fetch the latest pkg-vulnerabilities file as the superuser with: pkg_admin fetch-pkg-vulnerabilities And then run: pkg_admin audit % The following shows an example of temporarily adding 10MB more swap space for virtual memory: dd if=/dev/zero of=/root/swapfile bs=1024 count=10240 chmod go= /root/swapfile swapctl -a /root/swapfile % If your console ever gets broken, you can try resetting it to its initial state with: printf "\033c" % If you installed a package, but don't know what the software is called or what executables to run, use pkg_info with the -L switch to list the package's files and search for /bin: pkg_info -L PACKAGE-NAME | grep /bin % A new user can be added by using the useradd tool with the -m switch to create the home directory. Then set the password. For example: useradd -m susan passwd susan % To modify user account information use the chpass or usermod tools. If you need to edit the user database directly, use the vipw command. % You can temporarily start the SSH server by running the following as root: /etc/rc.d/sshd onestart % Several NPF examples are available in the /usr/share/examples/npf/ directory. % Want to dual boot using a bluetooth mouse or keyboard? Use btkey(1) to store the link key in the hardware. % If you are having trouble connecting to a remote bluetooth device, try the btconfig(8) inquiry command. The kernel will retain some clock offset information that may help. % You can download files via HTTP using the ftp(1) command; for example: ftp http://www.NetBSD.org/images/NetBSD.png % The mtree(8) tool can be used to check permissions, ownerships, file changes, and more when compared against a specification. For example to check directory ownership and permissions for standard NetBSD directories, run: /usr/sbin/mtree -e -p / -f /etc/mtree/NetBSD.dist % If you need reminders on your console to leave, use the leave(1) tool. For example to receive reminders to leave in one hour: leave +0100 % To stop non-superuser logins until next boot, as root: touch /etc/nologin % When extracting distribution tar sets, be sure to use the pax -pe option or the tar -p switch to preserve the user and group and file modes (including setuid and setgid). This is needed, for example, so su(1) will work after extracting the base.tgz set. % Math can be done within the sh(1) and ksh(1) shells or with expr(1), dc(1), bc(1), or awk(1). Here are some simple examples: echo $((431 * 79)) expr 60 \* 60 \* 24 \* 7 % You can view network connections with the fstat, netstat -a, sockstat, and "systat netstat" commands. % Visit the NetBSD Security website to keep track of advisories: http://www.NetBSD.org/support/security/ Or join the security-announce mailing list for alerts: http://www.NetBSD.org/mailinglists/#security-announce % Here's an example of finding what package a file belongs to: pkg_info -Fe /usr/pkg/bin/inw % Many log files are checked for rotation every hour by newsyslog(8). It is configured in /etc/newsyslog.conf. % NetBSD's default cron jobs are defined in the /var/cron/tabs/root file. As the superuser, use "crontab -l" to view it. To edit it, use "crontab -e" (which defaults to using the vi(1) editor). % You can make sure that your system is stable and behaves correctly by running the tests in /usr/tests (which come from the tests.tgz set). To do so: vi /etc/atf/NetBSD.conf cd /usr/tests atf-run | atf-report % To share files from your NetBSD system, you can use the built-in httpd(8). Uncomment the 'http' lines in /etc/inetd.conf, reload inetd with service(8), and then any files in /var/www will be published to http://127.0.0.1/. % You can schedule simple periodic tasks for your NetBSD system to run without using cron(8) by editing the sh(1) scripts /etc/daily.local, /etc/weekly.local, and /etc/monthly.local. % NetBSD's tar(1) command can handle a wide range of file types, e.g. zip, 7z, and rar, and will autodetect the type of the file based on its extension. For example, to extract a zip file: tar xvf example.zip % You can use progress(1) to monitor the progress of data in a pipe: zcat example.tar.gz | progress tar xf - % Press CTRL+T to send SIGINFO and see the current status of the command running in the current terminal. % To enable the Multicast DNS responder, add mdnsd=YES to /etc/rc.conf. Your system will now be reachable on the network as hostname.local. To enable Multicast DNS lookups, add mdnsd to the 'hosts' field in /etc/nsswitch.conf. % NetBSD includes a tutorial on using vi(1), the classic BSD text editor: less /usr/share/doc/usd/vi/vitut.txt % A login shell will read initial commands from ~/.profile. When using the X Window System, initializing with 'startx' will read ~/.xinitrc. Initializing with xdm will read commands from ~/.xsession, but logins through xdm will not read ~/.profile. % After installing NetBSD, additional sets can be installed with sysinst(8). % Depending on the version of NetBSD, the system may raise the sysctl(8) variable kern.securelevel to 1 on boot. The system's securelevel may be raised by the superuser, but never lowered. To learn more about the different securelevel settings, see: man secmodel_securelevel % To learn more about the various security features in NetBSD, see: man 7 security % Network interface traffic can be monitored with the following command: sysstat ifstat % To list connected disk devices: sysctl hw.disknames % screenblank(1) can disable the framebuffer if the keyboard and mouse are idle for a period of time, and re-enables the framebuffer when keyboard or mouse activity resumes. % If you want to convert a Microsoft Windows text file to have Unix line endings, it's possible to achieve by simply stripping all of the carriage return characters from the file: tr -d '\r' < IN > OUT However, you might want to do this more carefully (i.e. only remove carriage returns that constitute a line ending). See "dos2unix" in pkgsrc. % Some useful X11 commands: xset s off # disable screen blanking xset -dpms # disable screen power saving xset b 0 # mute bell (beep) xset m 55/20 4 # mouse acceleration % Automatically run a make(1) job on each active CPU: alias make="make -j $(sysctl -n hw.ncpuonline)"