The apt-file program allows you to search the contents of all debian packages (installed and not installed) for files that you may need. For example, if you're compiling a program and need a header file but don't know which package provides the file, you can use apt-file to find out which package you should install to fix the problem:
# apt-get install apt-file # apt-file update # apt-file search foo.h
Be sure to run apt-file update periodically to update the file listing cache just as you also run apt-get update. The last command above will list any packages whose files match the specified search string, as well as the files that matched:
$ apt-file search bin/lsof lsof: usr/bin/lsof lsof: usr/sbin/lsof
aptapt-fileapt-getcommandsdebianlsofneatutilities
Use the apg utility to generate strong mnemonic passwords:
$ apg -st Please enter some random data (only first 8 are significant) (eg. your old password):> Coydgoceuk6 (Coyd-goc-euk-SIX) Caculpyep7 (Cac-ulp-yep-SEVEN) otevDet6 (ot-ev-Det-SIX) Jiwacwarj6 (Ji-wac-warj-SIX) gurkOnRyet1 (gurk-On-Ryet-ONE) EbTarIv0 (Eb-Tar-Iv-ZERO)
apgcommandsgeneratemnemonicneatpasswordsecurityutilities
Use slocate to build a database of files on your machine and use locate to find them:
# slocate -u # Rebuilds file database by scanning all filesystems # locate foobar # finds all files with 'foobar' somewhere in the path
commandsdiagnosticfindslocateutilities
This is a particularly tasty utility that will tell you what a site is (and has been) running along with hosting and DNS lookup information. Just replace www.google.com with the URL of your choosing.
http://toolbar.netcraft.com/site_report?url=http://www.google.com/
diagnosticdnsonlinetoolurlutilities
You can use the lsof (LiSt Open Files) utility to view information about which processes own file handles on a system. Since sockets map to file descriptors, lsof will show you which processes own socket connections. If you see that your machine is connected to another on TCP port 6234 (source or dest) and you want to find out which process(es) are responsible for the connection, run:
# lsof -ni tcp:6234
Note that when run as an unprivileged user, lsof will only show you file descriptors that you have permission to see. You must run lsof as root to see everything in the kernel.
commandsconnectionsdebuggingdescriptorsfilesystemlsofmonitoringnetworkpermissionsprocesssocketsutilities
If you have packages on your system upon which no others depend, you easily can find out what they are by running the deborphan program. This command will uninstall them:
$ deborphan | xargs apt-get remove
(The --yes switch can be used with apt-get to continue with the removal instead of asking for confirmation.)
apt-getcleanupcommandsdebiandeborphanutilities
You can use the tee program to save the contents of a pipe to a file while also viewing it on standard out:
# tail -0f /var/log/httpd/error_log | tee ~/newest_errors.txt
Note: tail -0 instructs tail to begin at the very end of the file (the default is to show the last ten lines), and -f means tail will periodically check the file for additional data and print the data to standard out.
commandsdebuggingmonitoringpipeshellstdouttailteeutilities
Given an executable /path/to/EXEC:
$ ldd /path/to/EXEC
commandsdependenciesdiagnosticexecutablelddlibrariesutilities
Netcat is handy little utility for scripting all manners of network functionality. Here we're making sure a web server is responding as we'd expect:
$ (echo "GET / HTTP/1.1"; echo "Host: www.xinu.org"; echo) | nc www.xinu.org 80
commandsdebuggingmonitoringnetcatnetworkshellutilities