The dktools package is a collection of programs for advanced users and administrators.
What license applies to the package?
Which programs in the dktools package are dkapp-based?
kls, ksort, craetep, dklogger, showhex, dksavepw, text2lat, text2htm and rndbytes.Option
--help
How can I show the version number?
Option
--version
How can I configure permanent options?
Option
--configure <option>...
How can I inspect the permanent options?
Option
--show-configuration
How can I remove all permanent options?
Option
--unconfigure
How do I skip the permanent options for one program invokation?
Option
--reset <options for this invocation>
The kls program is an ls clone providing the following special features:
how do I configure output details?
Use the option ``-p string:output-details''. The output-details string contains a list of key characters identifying one output details per character. The following key characters can be used:
| n | file name | |
| s | file or directory size | |
| t | file type | |
| p | permissions | |
| x | messages digest (checksum) | |
| l | number of links | |
| c | creation time | |
| m | modification time | |
| a | access time | |
| u | owner UID | |
| g | owner GID | |
| d | device number | |
| r | relative device number | |
| i | inode number on device |
Example: The command "kls -p stn" shows size, type and name for each directory entry.
How do I configure message digests (checksums)?
Use the option ``-m string:checksum''. The following messages digests can be used:
| md5 | the RSA Data Security, Inc. MD5 Message-Digest | |
| sha-1 | SHA-1 message digest |
The OpenSSL library is used to create both message digests.
Example: The command
kls -p tmxn -m md5
shows file type, modification time, RSA Data Security, Inc. MD5 Message-Digest and file name of each directory entry in the current directory.
How do I list directories recursively?
Use the ``-r'' option.
Example: The command
kls -r -p stn
shows file size, type and name of each directory entry in the current directory and all subdirectories.
For recursive listings, how do I configure file types to view?
Use option ``-t string:file-types''. The file-types string contains a key character for each file type you are interested in. The following keys can be used:
| f | regular files | |
| d | directories | |
| p | pipes | |
| c | character special devices | |
| b | block special devices | |
| s | sockets | |
| o | all other file types (not listed before) |
Example: Use
kls -r -t sp -p tn
to list all sockets and pipes in the current directory and the subdirectories. For each directory entry found, report type and name.
For recursive listings, how can I stay on the current filesystem?
Use the ``-f'' option to stay on the original file system.
Example: Use
kls -p stn -r -f /
if the root file system goes towards out of space to find large files. Feed the programs output into ``sort -n'' or ``ksort -n'' to sort by size.
For recursive links, how do I restrict the number of symbolic links to follow?
Use the ``-l link-depth'' option. The link-depth argument is either a numeric
value (number of symblic links to follow) or the keyword ``unlimited''.
Note: Normally it is not necessary to restrict the number of symbolic links.
Some simple programs follow each symbolic link. If a symbolic link points back to a parent, grandparent...
directory these programs go into an infinite loop. The kls program doesn't. When traversing directories
recursively it keeps track of the parent, grandparent... directories already visited by
device number and inode number. Before opening a new directory, device and inode number are
checked and compared against all parent, grandparent... directories already in the search path.
Only those directories not yet visited are opened for inspection.
How do I enable/disable the summary report?
Use ``-s'' or ``-s-'' to turn the summary report on or off.
How can I identify the largest files and directories on a filesystem?
If -- for example -- you want to find the largest files and directories in a filesystem mounted as /var use
kls -r -psn -f /var | sort -n
or
kls -r -psn -f /var | ksort -b -d
How do I search for recently changed files?
To search for recently changed files in a directory -- i.e. /tmp -- run
kls -r -tf -pmtn -f /tmp | sort
How can I use kls for integrity checks?
Run
kls -r -psxn -m MD5 /some/directory
or
kls -r -psxn -m SHA-1 /some/directory
and save the output to a file and save the file.
To detect modified files run the command again and compare the output
against the saved file. Differences in size/checksums indicate changes
to files.
The ksort program sorts input line by line.
It is intended for Windows users which normally do not have a sort program
available (unless Cygwin or Win/U... is installed).
Compared against the sort program on most Linux/Unix systems the outstanding feature is
the comparison of float numbers at the beginning of a line.
How do I redirect ksort output to a file?
Use option ``-o file-name'' to specify an output file.
How do I ignore leading blanks?
Use the ``-b'' option.
How do I sort by numeric values on the beginning of lines?
Use option ``-d'' if the numeric values are decimal integers. Use ``-f'' if the numeric values are floating point numbers.
How do I invert the search order?
Use option ``-i'' to invert search order.
Use option ``-m'' to merge equal lines.
What's the purpose of createp?
Createp suggestes random passwords. Different password types may be defined
for different purposes (i.e. administrators may use more complex passwords
than average users).
As I experienced a weak point in security are user passwords. Some of my users
used their ec-card PIN (for non-europeans: an electronic credit card / cash card)
as password to access our faculties file servers. Other users used the same
password as they use for net based games in the Internet...
So I decided to assign each user a random password for access to our faculty
file server completeley independent
from all PINs and password he/she ever used before.
How do I create a new password type?
Use
createp -t admin -l 8-10 -d 2-4 -s 1-2 -k 1-2 createp -t default -l 6 -d 2 -s 0 -k 0
to create two classes:
How do I create a password for a user?
Use
createp -t admin joe createp -t default jim
to create a password for an administrator ``joe'' and an average user ``jim''.
If your WLAN router asks you to create and enter a key consisting of upper-case characters and digits (64 in summary), use
createp -c -t wlan-key -p -l 64 -xA0 createp -t wlan-key my-computer
If lower-case characters and special characters are acceptable too, use
createp -c -t wlan-key -p -l 64 -a createp -t wlan-key my-computer
What can I do if createp complains about OpenSSL PRNG not seeded?
How do I deny the use of OpenSSL PRNG seed files for all users except root?
In /etc/appdefaults (or /usr/local/etc/appdefaults, depending on your installation) create the entries
[*] /openssl/random-seed-file = $(user.home)/.rnd /openssl/allow-random-seed-file = no
and
[root] /openssl/allow-random-seed-file = yes
to deny the use of seed files for all users except root.
How do I configure createp to use an EGD socket?
If the entropy gathering daemon listens on the /var/run/my-egd-pool socket, write an entry
[*] /openssl/egd-socket = /var/run/my-egd-pool
to /etc/appdefaults (or /usr/local/etc/appdefaults, depending on your installation).
Alternatively you can set the EGDSOCKET environment variable to
EGDSOCKET=/var/run/my-egd-pool export EGDSOCKET
What's the purpose of dksavepw?
The dksavepw program asks the user for a password and saves the password into a
file. Keyboard echo is turned off while typing the password.
Some programs use password files for configuration, the dksaveps program
can be used to create these password files.
how can I turn newlines after password on/off?
Use the ``-n'' option to append a newline. By default, no newline is added. If you have a customized configuration to always append newlines, you can use ``-n-'' to override this setting and turn newline off.
What's the purpose of the dkloger program?
The dklogger program sends messages to syslog servers. It is intended for those systems where no logger program is available.
Use the preferences ``/syslog/host/000/destination'' ... ``/syslog/host/015/destination'', the values must be host names or IP addresses of syslog servers. Optionally you can add a port number, separate host name and port number by colon. If no port number is specified dklogger uses the default syslog port.
How do i specify feature and priority?
Use ``-p feature.priority'' to specify feature and priority.
The feature names are:
auth, authpriv, cron, daemon,
ftp, kern, lpr, mail, mark, news, security, syslog, user, uucp, local0, local1, local2,
local3, local4, local5, local6 or local7.
The priority names are:
alert, crit, debug, emerg, error, info, none, notice, panic and warning.
Example:
dklogger -p auth.notice User jim logged in.
What's the purpose of the showhex program?
The showhex program can be used to analyze binary files. It prints the contents of a file in hexadeciam or octal notation.
How can I show printable characters as text too?
Use the ``-t'' option to show printable characters additionally as text. Use ``-t-'' to turn this off.
Use ``-a'' to additionally print addresses (file position). The ``-a-'' option turns this feature off.
How can I switch output to octal mode?
Use ``-o'' to switch output to octal mode.
What's the purpose of the rndbytes program?
The rndbytes program creates a file consisting of random bytes. The OpenSSL PRNG is used to create random data.
How do I specify the block size?
Use the ``-b bytes'' option.
How do I specify the number of blocks to create?
Use the ``-n blocks'' option.
How can I create an ``endless'' sequence of blocks?
Use option ``-n 0'' (0 means no limit for the number of blocks).
Which sources are used for random data?
What can I do if createp complains about OpenSSL PRNG not seeded?
The OpenSSL PRNG must be seeded (initialized) before it can be used.
If there is no seed data at all or insufficient seed data available, the output
of the PRNG may be predictable.
The program attempts several sources for data to seed the PRNG:
How do I deny the fallback to the rand() function?
Use the ``-x'' option.
What's the purpose of echo2lat and text2lat program?
Both programs are made to ease up the input of LaTeX source files. Some characters/glyphs simply to type in plain text are represented by complicated encodings in LaTeX (i.e. a backslash ``\''is specified as ``\textbackslash{}'', an underscore ``_'' is specified as ``\textunderscore{}''). Both programs convert normal text to LaTeX source. Echo2lat converts the text specified as command line arguments, text2lat converts files specified by name or runs as a filter.
How do I use text2lat on the command line?
Run
text2lat [<options>] [<inputfile> [<outputfile>]]
For the options see the next three questions below.
How can I specify the input encoding?
Input files can be either ISO-LATIN-8859-1 encoded or UTF-8 encoded.
By default text2lat detects the encoding automatically by inspecting
the LANG environment variable for the appearance of ``.UTF-8''.
To specify an input encoding explicitly, use the options
-e latin-1
or
-e utf-8
The echo2lat program always inspects the LANG environment variable,
How do I convert all newlines to LaTeX newlines (``\\'')?
Use the
-nor
-n-
option to enable/disable newline replacement.
Echo2lat only processes command line arguments, there are no newlines.
How do I convert all spaces to LaTex non-breaking spaces (``~'')?
Use the<7p>
-s
or
-s-
option to enable/disable space replacement in text2lat.
Is there an example how to use echo2lat from vim (or other vi clones)?
Imagine you are writing a documentation for a software product, you want to typeset the text<7p>
Install the software to C:\Program Files\MyApp ...
In a LaTeX source this looks like
Install the software to C:\textbackslash{}Program Files\textbackslash{}MyApp ...
To enter this text, create an empty line, place the cursor on the empty line, change to on-text mode and run the colon-command
:r!echo2lat Install the software to C:\Program Files\MyApp ...
This adds the LaTeX code shown above.
Is there an example how to use text2lat from vim (or other vi clones)?
Image you are writing a documentation for a software library, you have just copied a number of prototypes from the header file into the documentation source:
int mylib_do_the_first_thing(void); ... long mylib_do_the_next_thing(int i);
As underscores are not allowed in normal mode, you need to replace them by \textunderscore. Find out the first and last line of the text block containing your prototypes (in the example we use 10 and 13) and run the colon-command
13,15!text2lat
to replace the lines by the converted text
int mylib\textunderscore{}do\textunderscore{}the\textunderscore{}first\textunderscore{}thing(void);
...
long mylib\textunderscore{}do\textunderscore{}the\textunderscore{}next\textunderscore{}thing(int i);
What does the error ``Missing encoding for ...'' mean?
The conversion of plain text to the LaTeX representation is based on
tables. The tables are in text files, typically in the
/usr/local/share/uc2lat-t directory tree. If UTF-8 decoding of an input character
results in 0x01234567 the programs attempt to read the translation table
/usr/local/share/uc2lat-t/01/23/45.dat and searches for entry 0x67.
The error message above means either the tables is missing or does not
contain the required entry.
By default the dklibs library contains only tables for characters
0x00000000...0x0000011F (English, German and some European languages
are supported).
To solve the problem create the table and/or add the entry (see below).
How do I create or modify a translation table?
After creating/modifying translation tables, should I share them?
Yes, please.
If you are willing to share a translation table under the conditions
of a BSD-style license (as used for dklibs and dktools) use the bug-tracking or
feature-requests mechanisms or the forums on Sourceforge,
i.e. at
http://sourceforge.net/projects/dklibs/.
What's the purpose of the text2htm program?
The text2htm program converts text to HTML.
How can I specify the input encoding?
Input files can be either ISO-LATIN-8859-1 encoded or UTF-8 encoded.
By default text2htm detects the encoding automatically by inspecting
the LANG environment variable for the appearance of ``.UTF-8''.
To specify an input encoding explicitly, use the options
-e latin-1
or
-e utf-8
How can I specify a title for the page?
Use the ``-t title'' option.
How can I specify a CSS style sheet to use?
Use the ``-s URL'' option.
How can I create a complete HTML file?
Use the ``-f'' option.
How can I create a complete HTML file with template code?
Do not use ``-f'' or ``-g''.
How can I create a HTML fragment?
Use the ``-f-'' option.
How do I convert all newlines to HTML newlines (``<br>'')?
Use the ``-b'' option.
What's the purpose of the filtmsql program?
The mysqldump produces very long lines. This might cause problems in some text editors. The filtmsql program inserts newlines after each record.
What's the purpose of the tape program?
The tape program can be used for backup media management. Backup media may be magnetic tapes, CD-RW, DVD-RW, floppy or any other removable media.
A backup set is a collection of files and directories which are backed up together. On UNIX/Linux systems you may for example decide to have two backup sets:
A tape set is a set of ten removable media, labeled ``1'', ``2'' ... ``10''. All the media are used for copies of the same backup set.
What is a backup scheme? Which scheme is used by the tape program?
A backup scheme is a ruleset specifying the order of media used for backup. A good backup scheme implements the following strategies:
What control files are used by tape?
Two types of control files are used:
How do I prepare a backup set control file?
If you have multiple backup sets, assign names to the sets, i.e. ``A'', ``B''...
If -- for example -- you use backup set ``A'' for user data and ``B'' for configuration
data, you may want to back up ``B'' once peer week and ``A'' all other days.
(We assume a working week of five days.)
Write a file ``bsctrl.txt'', it has only one line of contents:
A A A A B
How do I find the current backup set?
Run
tape sn <backup-set-control-file>
to print the name of the
backup set to be backed up.
After backing up successfully, run
tape sc <backup-set-control-file>
to confirm the current backup set.
How do I find the current tape number for a backup/tape set?
Run
tape tn <tape-set-control-file>
to print the current tape number.
After backing up successfully, run
tape tc <tape-set-control-file>
to confirm the current tape.
Is there an overview about the backup procedure?
tape sn <bsctrl.txt>to find the current backup set.
tape tn <tsctrl.txt.A>to find the current tape number.
tape tc <tsctrl.txt.A>to confirm the current backup to tape was successfully.
tape sc <bsctrl.txt>to confirm the current backup set was saved successfully.
Are there any additional suggestions?
It is not intended to do the procedure above manually. Instead you should use a script to do all the steps:
For my computer I created a Perl script. The script is started manually each day before lunch. After inserting the CD-RW there is no further interaction necessary, so I can go to lunch. When coming back the backup is finished successfully (in most cases).
What's the purpose of the uid program?
The uid program checks a range of user IDs on Unix/Linux systems and prints the first
unused UID. This UID can be used to create a new user account.
Run
uid 3111 4000
to find the first free UID in the range 3111...4000.
What's the purpose of the blksize program?
If you want to write a disk image from file to hard disk using the dd
program, dd expects blocks of a given size (512 bytes unless another
size is configured on the command line).
If the image file is provided to dd using a pipe of commands this pipe
may produce blocks of different sizes.
So we must correct the block size of the data stream before passing
the data stream to dd.
How do I specify the buffer size?
The buffer size is the first (and only) command line argument passed to blksize.
What's the purpose of the cona program?
The cona program is intended for use on Unix/Linux systems running Samba.
Windows allows filenames containing white spaces and special characters. Unix
commands and scripts do not always handle these file names properly.
The cona program (correct names) replaces white spaces and special
characters in file names.
Run
cona /data/samba/homes
to correct all file names in directory /data/samba/homes and all it's subdirectories.
What's the purpose of the klammern program?
The klammern program analyses a C file and prints a report of opening
and closing brackets.
Run
klammern myfile.c
to analyze the file myfile.c.
Note: Most modern editors have functions to search for corresponding brackets.
The klammern program is only useful if your editor doesn't have this functionality.
What's the purpose of the addctrld program?
The addctrld program passes input to output. If the last character of input is not a Ctrl-D, a Ctrl-D is appended. This program is intended for filtering in print systems.
What's the purpose of the tabrep program?
The tabrep program replaces tabulators by spaces. Each tabulator is replaced
by at least on space, further spaces are added until the current position on the
line is a multiple of 8.
The program was intended to prepare source code listing for inclusion into
a LaTeX verbatim environment. Learning about LaTeX packages I found out
that the listings package provides a much more comfortable way to
typeset source code than using tabrep and the verbatim environment.
What's the purpose of the dkpwd program?
The dkpwd program is a pwd clone mainly intended for use on Windows systems.
How do I convert backslashes to slashes?
Use
dkpwd -b
What's the purpose of the edbp program?
The edbp produces byte blocks containing different bit patterns. These byte blocks can be used to overwrite an entire hard disk or a partition multiple times.
Which command line arguments can be used?
edbp <pattern>or
edbp <pattern> <block-size>
| pattern number | pattern |
| 0 | 0x00 |
| 1 | 0xFF |
| 2 | 0x0F |
| 3 | 0xF0 |
| 4 | 0x33 |
| 5 | 0xCC |
| 6 | 0x55 |
| 7 | 0xAA |
To erase the sdb disk for example, run
edbp 7 4096 | dd of=/dev/sdb bs=4096 edbp 6 4096 | dd of=/dev/sdb bs=4096 edbp 5 4096 | dd of=/dev/sdb bs=4096 edbp 4 4096 | dd of=/dev/sdb bs=4096 edbp 3 4096 | dd of=/dev/sdb bs=4096 edbp 2 4096 | dd of=/dev/sdb bs=4096 edbp 1 4096 | dd of=/dev/sdb bs=4096 dd if=/dev/zero of=/dev/sdb bs=4096
The final ``dd'' pass write zeroes to the disk. An operating system's installation routine will recognize the disk as ``new from factory''.
For increased security you might want to use random patterns instead of static
patterns. For this purpose you can use the rndbytes program
instead.
Note: Using pseudo-random patterns instead of static patterns is
probably more secure but takes a significantly longer time.
What's the purpose of the rshdown program?
The rshdown program is a daemon for Unix/Linux. If one UPS is used for powering multiple computers, only one computer (the shutdown master) has a control connection to the UPS. If a power fail shutdown is necessary this computer must notify the other computers (shutdown slaves). The shutdown master uses netcat to send an UDP data packet to the slaves. On the slaves the rshdown daemon waits for UDP data packets. If a shutdown-related data packet is received the rshdown daemon checks the packet for integrity and shuts down the slave if necessary.
How do I create and distribute the data packet file?
Create a datafile containing up to 1500 bytes of random data (you can
use the rndbytes program to do so).
Use a secure mechanism (floppy or scp) to transfer the data packet file between master
and slaves. Make sure the data packet file is only readable by user root, other
users must not have any permissions to it.
How do I ensure that slaves are not shut down by aunauthorized persons?
Before rshdown shuts down the slave, the following tests are made:
How do I configure the shutdown master?
How do I configure the shutdown slaves?
/etc/powerfail-full > /dev/null 2>&1 &and make it executable. This script must return immediately, it can start longer processes in the background.
/usr/sbin/poweroffMake the file executable.
sender-ip 192.168.1.2 sender-port 2 receiver-ip 192.168.1.3 receiver-port 2 file /etc/rshdown-secret action /etc/powerfail-fast