netbsd-tips revision 1.1
1List 20 largest files (larger than 5 MB) sorted by megabytes:
2
3 find / -type f -size +10000 -print0 | xargs -0 du -m | sort -nr | head -20
4%
5You can keep specific rc.conf configurations in individual files
6under /etc/rc.conf.d/ where each file is named after the $name of
7the rc.d script. Some configurations may have different names than
8the script; see the $name variable to check.
9%
10You 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 }
16END { print((cfp + cep) * bpp / 1024 / 1024); }'
17%
18You can view a value of a variable in pkgsrc by using the show-var
19target, for example:
20
21 make show-var VARNAME=MAINTAINER
22%
23You can view the basic order of your rc.d scripts with:
24
25 rcorder /etc/rc.d/*
26%
27You can ask questions about NetBSD at the netbsd-users@NetBSD.org
28mailing list. Be sure to clearly explain your problem, what you
29tried, what results you had, and what you expected.
30%
31You can view your non-default Postfix settings with:
32
33 postconf -n
34%
35To report about installed packages with known vulnerabilities,
36fetch the latest pkg-vulnerabilities file as the superuser with:
37
38 download-vulnerability-list
39
40And then run:
41
42 audit-packages
43%
44The following shows an example of temporarily adding 10MB more swap
45space for virtual memory:
46
47 dd if=/dev/zero of=/root/swapfile bs=1024 count=10000
48 swapctl -a /root/swapfile
49%
50If your console ever gets broken, you can try resetting it to its
51initial state with:
52
53 printf "\033c
54%
55If you installed a package, but don't know what the software is
56called or what executables, to run use the pkg_add with the -L
57switch to list the package's files and search for /bin:
58
59 pkg_add -L PACKAGE-NAME | grep /bin
60%
61A new user can be added by using the useradd tool with the -m switch
62to create the home directory. Then set the password. For example:
63
64 useradd -m susan
65 passwd susan
66%
67To modify user account information use the chpass or usermod tools.
68If you need to edit the user database directly, use the vipw command.
69%
70You can temporarily start the SSH server by running the following
71as root:
72
73 /etc/rc.d/sshd onestart
74%
75Several IP Filter and ipnat examples are available in the
76/usr/share/examples/ipf/ directory.
77%
78Want to dual boot using a bluetooth mouse or keyboard? Use btkey(1)
79to store the link key in the hardware.
80%
81If you are having trouble connecting to a remote bluetooth device,
82try the btconfig(8) inquiry command. The kernel will retain some
83clock offset information that may help.
84%
85You can download files via HTTP using the ftp(1) command; for example:
86
87 ftp http://www.NetBSD.org/images/NetBSD.png
88%
89The mtree(8) tool can be used to check permissions, ownerships,
90file changes, and more when compared against a specification. For
91example to check directory ownership and permissions for standard
92NetBSD directories, run:
93
94  /usr/sbin/mtree -e -p / -f /etc/mtree/NetBSD.dist
95%
96If you need reminders on your console to leave, use the leave(1)
97tool. For example to receive reminders to leave in one hour:
98
99  leave +0100
100%
101To stop non-superuser logins until next boot, as root:
102
103  touch /etc/nologin
104%
105When extracting distribution tar sets, be sure to use the pax -pe
106option or the tar -p switch to preserve the user and group and file
107modes (including setuid and setgid). This is needed, for example,
108so su(1) will work after extracting the base.tgz set.
109%
110Math can be done within the sh(1) and ksh(1) shells or with expr(1),
111dc(1), bc(1), or awk(1). Here are some simple examples:
112
113 echo $((431 * 79))
114 expr 60 \* 60 \* 24 \* 7
115%
116