netbsd-tips revision 1.2
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.1Sreed download-vulnerability-list
391.1Sreed
401.1SreedAnd then run:
411.1Sreed
421.1Sreed audit-packages
431.1Sreed%
441.1SreedThe following shows an example of temporarily adding 10MB more swap
451.1Sreedspace for virtual memory:
461.1Sreed
471.1Sreed dd if=/dev/zero of=/root/swapfile bs=1024 count=10000
481.1Sreed swapctl -a /root/swapfile
491.1Sreed%
501.1SreedIf your console ever gets broken, you can try resetting it to its
511.1Sreedinitial state with:
521.1Sreed
531.1Sreed printf "\033c
541.1Sreed%
551.1SreedIf you installed a package, but don't know what the software is
561.1Sreedcalled or what executables, to run use the pkg_add with the -L
571.1Sreedswitch to list the package's files and search for /bin:
581.1Sreed
591.1Sreed pkg_add -L PACKAGE-NAME | grep /bin
601.1Sreed%
611.1SreedA new user can be added by using the useradd tool with the -m switch
621.1Sreedto create the home directory. Then set the password. For example:
631.1Sreed
641.1Sreed useradd -m susan
651.1Sreed passwd susan
661.1Sreed%
671.1SreedTo modify user account information use the chpass or usermod tools.
681.1SreedIf you need to edit the user database directly, use the vipw command.
691.1Sreed%
701.1SreedYou can temporarily start the SSH server by running the following
711.1Sreedas root:
721.1Sreed
731.1Sreed /etc/rc.d/sshd onestart
741.1Sreed%
751.1SreedSeveral IP Filter and ipnat examples are available in the
761.1Sreed/usr/share/examples/ipf/ directory.
771.1Sreed%
781.1SreedWant to dual boot using a bluetooth mouse or keyboard? Use btkey(1)
791.1Sreedto store the link key in the hardware.
801.1Sreed%
811.1SreedIf you are having trouble connecting to a remote bluetooth device,
821.1Sreedtry the btconfig(8) inquiry command. The kernel will retain some
831.1Sreedclock offset information that may help.
841.1Sreed%
851.1SreedYou can download files via HTTP using the ftp(1) command; for example:
861.1Sreed
871.1Sreed ftp http://www.NetBSD.org/images/NetBSD.png
881.1Sreed%
891.1SreedThe mtree(8) tool can be used to check permissions, ownerships,
901.1Sreedfile changes, and more when compared against a specification. For
911.1Sreedexample to check directory ownership and permissions for standard
921.1SreedNetBSD directories, run:
931.1Sreed
941.1Sreed  /usr/sbin/mtree -e -p / -f /etc/mtree/NetBSD.dist
951.1Sreed%
961.1SreedIf you need reminders on your console to leave, use the leave(1)
971.1Sreedtool. For example to receive reminders to leave in one hour:
981.1Sreed
991.1Sreed  leave +0100
1001.1Sreed%
1011.1SreedTo stop non-superuser logins until next boot, as root:
1021.1Sreed
1031.1Sreed  touch /etc/nologin
1041.1Sreed%
1051.1SreedWhen extracting distribution tar sets, be sure to use the pax -pe
1061.1Sreedoption or the tar -p switch to preserve the user and group and file
1071.1Sreedmodes (including setuid and setgid). This is needed, for example,
1081.1Sreedso su(1) will work after extracting the base.tgz set.
1091.1Sreed%
1101.1SreedMath can be done within the sh(1) and ksh(1) shells or with expr(1),
1111.1Sreeddc(1), bc(1), or awk(1). Here are some simple examples:
1121.1Sreed
1131.1Sreed echo $((431 * 79))
1141.1Sreed expr 60 \* 60 \* 24 \* 7
1151.1Sreed%
1161.2SreedYou can view network connections with the fstat, netstat -a, sockstat,
1171.2Sreedand "systat netstat" commands.
1181.2Sreed%
1191.2SreedVisit the NetBSD Security website to keep track of advisories:
1201.2Sreed  http://www.NetBSD.org/support/security/
1211.2SreedOr join the security-announce mailing list for alerts:
1221.2Sreed  http://www.netbsd.org/mailinglists/#security-announce
1231.2Sreed%
1241.2SreedHere's an example of finding what package a file belongs to:
1251.2Sreed
1261.2Sreed	pkg_info -Fe /usr/pkg/bin/inw
1271.2Sreed%
1281.2SreedMany log files are checked for rotation every hour by newsyslog(8).
1291.2SreedIt is configured in /etc/newsyslog.conf.
1301.2Sreed%
1311.2SreedNetBSD's default cron jobs are defined in the /var/cron/tabs/root
1321.2Sreedfile.  As the superuser, use "crontab -l" to view it. To edit it,
1331.2Sreeduse "crontab -e" (which defaults to using the vi(1) editor).
1341.2Sreed%
135