netbsd-tips revision 1.14
11.1SreedList 20 largest files (larger than 5 MB) sorted by megabytes:
21.1Sreed
31.1Sreed find / -type f -size +10000 -print0 | xargs -0 du -m | sort -nr | head -20
41.1Sreed%
51.1SreedYou can keep specific rc.conf configurations in individual files
61.1Sreedunder /etc/rc.conf.d/ where each file is named after the $name of
71.1Sreedthe rc.d script. Some configurations may have different names than
81.1Sreedthe script; see the $name variable to check.
91.1Sreed%
101.1SreedYou can see the total used buffers in megabytes with:
111.1Sreed
121.1Sreed vmstat -s | awk '
131.1Sreed/ bytes per page$/ { bpp = $1 }
141.1Sreed/ cached file pages$/ { cfp = $1 }
151.1Sreed/ cached executable pages$/ { cep = $1 }
161.1SreedEND { print((cfp + cep) * bpp / 1024 / 1024); }'
171.1Sreed%
181.1SreedYou can view a value of a variable in pkgsrc by using the show-var
191.1Sreedtarget, for example:
201.1Sreed
211.1Sreed make show-var VARNAME=MAINTAINER
221.1Sreed%
231.1SreedYou can view the basic order of your rc.d scripts with:
241.1Sreed
251.1Sreed rcorder /etc/rc.d/*
261.1Sreed%
271.1SreedYou can ask questions about NetBSD at the netbsd-users@NetBSD.org
281.1Sreedmailing list. Be sure to clearly explain your problem, what you
291.1Sreedtried, what results you had, and what you expected.
301.1Sreed%
311.1SreedYou can view your non-default Postfix settings with:
321.1Sreed
331.1Sreed postconf -n
341.1Sreed%
351.1SreedTo report about installed packages with known vulnerabilities,
361.1Sreedfetch the latest pkg-vulnerabilities file as the superuser with:
371.1Sreed
381.8Sleot pkg_admin fetch-pkg-vulnerabilities
391.1Sreed
401.1SreedAnd then run:
411.1Sreed
421.8Sleot pkg_admin audit
431.1Sreed%
441.1SreedThe following shows an example of temporarily adding 10MB more swap
451.1Sreedspace for virtual memory:
461.1Sreed
471.3Sreed dd if=/dev/zero of=/root/swapfile bs=1024 count=10240
481.3Sreed chmod go= /root/swapfile
491.1Sreed swapctl -a /root/swapfile
501.1Sreed%
511.1SreedIf your console ever gets broken, you can try resetting it to its
521.1Sreedinitial state with:
531.1Sreed
541.7Sleot printf "\033c"
551.1Sreed%
561.1SreedIf you installed a package, but don't know what the software is
571.5Swizcalled or what executables to run, use pkg_info with the -L switch
581.5Swizto list the package's files and search for /bin:
591.1Sreed
601.5Swiz pkg_info -L PACKAGE-NAME | grep /bin
611.1Sreed%
621.1SreedA new user can be added by using the useradd tool with the -m switch
631.1Sreedto create the home directory. Then set the password. For example:
641.1Sreed
651.1Sreed useradd -m susan
661.1Sreed passwd susan
671.1Sreed%
681.1SreedTo modify user account information use the chpass or usermod tools.
691.1SreedIf you need to edit the user database directly, use the vipw command.
701.1Sreed%
711.1SreedYou can temporarily start the SSH server by running the following
721.1Sreedas root:
731.1Sreed
741.1Sreed /etc/rc.d/sshd onestart
751.1Sreed%
761.6SmaxvSeveral NPF examples are available in the /usr/share/examples/npf/
771.6Smaxvdirectory.
781.1Sreed%
791.1SreedWant to dual boot using a bluetooth mouse or keyboard? Use btkey(1)
801.1Sreedto store the link key in the hardware.
811.1Sreed%
821.1SreedIf you are having trouble connecting to a remote bluetooth device,
831.1Sreedtry the btconfig(8) inquiry command. The kernel will retain some
841.1Sreedclock offset information that may help.
851.1Sreed%
861.1SreedYou can download files via HTTP using the ftp(1) command; for example:
871.1Sreed
881.1Sreed ftp http://www.NetBSD.org/images/NetBSD.png
891.1Sreed%
901.1SreedThe mtree(8) tool can be used to check permissions, ownerships,
911.1Sreedfile changes, and more when compared against a specification. For
921.1Sreedexample to check directory ownership and permissions for standard
931.1SreedNetBSD directories, run:
941.1Sreed
951.1Sreed  /usr/sbin/mtree -e -p / -f /etc/mtree/NetBSD.dist
961.1Sreed%
971.1SreedIf you need reminders on your console to leave, use the leave(1)
981.1Sreedtool. For example to receive reminders to leave in one hour:
991.1Sreed
1001.1Sreed  leave +0100
1011.1Sreed%
1021.1SreedTo stop non-superuser logins until next boot, as root:
1031.1Sreed
1041.1Sreed  touch /etc/nologin
1051.1Sreed%
1061.1SreedWhen extracting distribution tar sets, be sure to use the pax -pe
1071.1Sreedoption or the tar -p switch to preserve the user and group and file
1081.1Sreedmodes (including setuid and setgid). This is needed, for example,
1091.1Sreedso su(1) will work after extracting the base.tgz set.
1101.1Sreed%
1111.1SreedMath can be done within the sh(1) and ksh(1) shells or with expr(1),
1121.1Sreeddc(1), bc(1), or awk(1). Here are some simple examples:
1131.1Sreed
1141.1Sreed echo $((431 * 79))
1151.1Sreed expr 60 \* 60 \* 24 \* 7
1161.1Sreed%
1171.2SreedYou can view network connections with the fstat, netstat -a, sockstat,
1181.2Sreedand "systat netstat" commands.
1191.2Sreed%
1201.2SreedVisit the NetBSD Security website to keep track of advisories:
1211.2Sreed  http://www.NetBSD.org/support/security/
1221.2SreedOr join the security-announce mailing list for alerts:
1231.11Snia  http://www.NetBSD.org/mailinglists/#security-announce
1241.2Sreed%
1251.2SreedHere's an example of finding what package a file belongs to:
1261.2Sreed
1271.2Sreed	pkg_info -Fe /usr/pkg/bin/inw
1281.2Sreed%
1291.2SreedMany log files are checked for rotation every hour by newsyslog(8).
1301.2SreedIt is configured in /etc/newsyslog.conf.
1311.2Sreed%
1321.2SreedNetBSD's default cron jobs are defined in the /var/cron/tabs/root
1331.2Sreedfile.  As the superuser, use "crontab -l" to view it. To edit it,
1341.2Sreeduse "crontab -e" (which defaults to using the vi(1) editor).
1351.2Sreed%
1361.4SjmmvYou can make sure that your system is stable and behaves correctly by
1371.4Sjmmvrunning the tests in /usr/tests (which come from the tests.tgz set).
1381.4SjmmvTo do so:
1391.4Sjmmv
1401.4Sjmmv  vi /etc/atf/NetBSD.conf
1411.4Sjmmv  cd /usr/tests
1421.4Sjmmv  atf-run | atf-report
1431.4Sjmmv%
1441.9SniaTo share files from your NetBSD system, you can use the built-in
1451.9Sniahttpd(8).  Uncomment the 'http' lines in /etc/inetd.conf, reload inetd
1461.9Sniawith service(8), and then any files in /var/www will be published to
1471.9Sniahttp://127.0.0.1/.
1481.9Snia%
1491.9SniaYou can schedule simple periodic tasks for your NetBSD system to run
1501.9Sniawithout using cron(8) by editing the sh(1) scripts /etc/daily.local,
1511.9Snia/etc/weekly.local, and /etc/monthly.local.
1521.9Snia%
1531.9SniaNetBSD's tar(1) command can handle a wide range of file types, e.g.
1541.9Sniazip, 7z, and rar, and will autodetect the type of the file based
1551.9Sniaon its extension.  For example, to extract a zip file:
1561.9Snia
1571.9Snia	tar xvf example.zip
1581.9Snia%
1591.9SniaYou can use progress(1) to monitor the progress of data in a pipe:
1601.9Snia
1611.9Snia	zcat example.tar.gz | progress tar xf -
1621.10Snia%
1631.10SniaPress CTRL+T to send SIGINFO and see the current status of the
1641.10Sniacommand running in the current terminal.
1651.12Snia%
1661.12SniaTo enable the Multicast DNS responder, add
1671.12Snia
1681.12Snia	mdnsd=YES
1691.12Snia
1701.12Sniato /etc/rc.conf.  Your system will now be reachable on the network as
1711.12Sniahostname.local.
1721.12Snia
1731.12SniaTo enable Multicast DNS lookups, add mdnsd to the 'hosts' field in
1741.12Snia/etc/nsswitch.conf.
1751.12Snia%
1761.12SniaNetBSD includes a tutorial on using vi(1), the classic BSD text
1771.12Sniaeditor:
1781.12Snia
1791.12Snia	less /usr/share/doc/usd/vi/vitut.txt
1801.12Snia%
1811.12SniaA login shell will read initial commands from ~/.profile.
1821.12Snia
1831.12SniaWhen using the X Window System, initializing with 'startx' will
1841.12Sniaread ~/.xinitrc.  Initializing with xdm will read commands from
1851.12Snia~/.xsession, but logins through xdm will not read ~/.profile.
1861.12Snia%
1871.12SniaAfter installing NetBSD, additional sets can be installed with
1881.12Sniasysinst(8).
1891.12Snia%
1901.12SniaDepending on the version of NetBSD, the system may raise the sysctl(8)
1911.12Sniavariable kern.securelevel to 1 on boot.  The system's securelevel may be
1921.12Sniaraised by the superuser, but never lowered.
1931.12Snia
1941.12SniaTo learn more about the different securelevel settings, see:
1951.12Snia
1961.12Snia	man secmodel_securelevel
1971.12Snia%
1981.12SniaTo learn more about the various security features in NetBSD, see:
1991.12Snia
2001.12Snia	man 7 security
2011.12Snia%
2021.12SniaNetwork interface traffic can be monitored with the following
2031.12Sniacommand:
2041.12Snia
2051.12Snia	sysstat ifstat
2061.13Snia%
2071.13SniaTo list connected disk devices:
2081.13Snia
2091.13Snia	sysctl hw.disknames
2101.14Snia%
2111.14Sniascreenblank(1) can disable the framebuffer if the keyboard and mouse are
2121.14Sniaidle for a period of time, and re-enables the framebuffer when keyboard
2131.14Sniaor mouse activity resumes.
214