This month’s column provides a suite of helpful utilities that save time and energy and avoid frustration.
Finding Things Faster with slocate
When looking for a file outside of their $PATH, many people will sit through a find / -name lookingforsomething 2/dev/null. While find works, the slocate utility accomplishes the same task much faster.
slocate uses a database of files — initially constructed by slocate -u and maintained nightly by updatedb (typically run from cron) — to record filenames, paths, and permissions. If you’re familiar with GNU locate, slocate is very similar, except it also stores file permissions and ownership so that users don’t see files they do not have access to.
Kill ‘em All with pkill
Many daemons can be stopped with an init script with the stop command or with kill `cat /path/to/pidfile`, where pidfile contains the process id (PID) of the daemon. For programs that don’t follow either of these standards you might be accustomed to running a command like ps auxw | grep commandname to get a PID, followed by kill PID to end the process. To save time, you can easily kill a process using pkill. By default, pkill sends a SIGTERM, but you can specify any signal that you’d pass to kill.
For example, pkill -HUP syslogd sends a SIGHUP signal to syslogd. pkill -u jeremy ssh sends a SIGTERM to all ssh processes owned by the user jeremy. And pkill -n bash…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: