Skip to Main Content
Linux Pocket Guide
book

Linux Pocket Guide

by Daniel J. Barrett
February 2004
Beginner content levelBeginner
200 pages
5h 40m
English
O'Reilly Media, Inc.
Content preview from Linux Pocket Guide

File Location

find

Locate files in a directory hierarchy

slocate

Create an index of files, and search the index for string

which

Locate executables in your search path (command)

type

Locate executables in your search path (bash builtin)

whereis

Locate executables, documentation, and source files

Linux systems can contain tens or hundreds of thousands of files easily. How can you find a particular file when you need to? The first step is to organize your files logically into directories in some thoughtful manner, but there are several other ways to find files, depending what you’re looking for.

For finding any file, find is a brute-force program that slogs file-by-file through a directory hierarchy to locate a target. slocate is much faster, searching through a prebuilt index that you generate as needed. (Fedora generates the index nightly by default.)

For finding programs, the which and type commands check all directories in your shell search path. type is built into the bash shell (and therefore available only when running bash), while which is a program (normally /usr/bin/which); type is faster and can detect shell aliases.[12] In contrast, whereis examines a known set of directories, rather than your search path.

[12] The tcsh shell performs some trickery to make which detect aliases.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Pocket Guide, 2nd Edition

Linux Pocket Guide, 2nd Edition

Daniel J. Barrett
Linux in a Nutshell, 6th Edition

Linux in a Nutshell, 6th Edition

Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins

Publisher Resources

ISBN: 9780596806347Errata Page