Ict-innovation/LPI/104.7

From Wikibooks, open books for an open world
< Ict-innovation/LPI
Jump to: navigation, search

104.7 Finding and Placing Files within the File Hierarchy Standard[edit]

Candidates should be thoroughly familiar with the Filesystem Hierarchy Standard (FHS), including typical file locations and directory classifications.


Key Knowledge Areas

  • Understand the correct locations of files under the FHS.
  • Find files and commands on a Linux system.
  • Know the location and propose of important file and directories as define in the FHS.


The Linux File System[edit]

In general Linux filesystem layout is consistent across distributions, with minor variations. The consistency is largely due to the existence of the Filesystem Hierarchy Standard (FHS) project, which aims to provided a recommended standard layout for Linux and Unix like operating systems.

Below is a listing of a the most important directories, and a brief explanation of their purpose, commonly found on Linux systems:

  • /bin and /sbinContain binaries needed to boot up the system and essential commands.
  • /dev Location for device or special files
  • /etcHost specific configuration files
  • /libShared libraries for binaries in /bin and /sbin. Also contains kernel modules
  • /mnt/ or /media Mount point for external filesystems
  • /proc Kernel information. Read-only except for /proc/sys/
  • /boot Contains the Linux kernel, the system maps and the “second stage” bootloaders.
  • /home The directories for users. Initially contains the contents from /etc/skel/
  • /root The directory for user root
  • /tmp Temporary files
  • /usr User Specific Resource. Mainly static and shareable content
  • /usr/local or /opt (optional) Add-on software applications. Can also contain shared libraries for add-on software.
  • /var/www, /var/ftp/ Location for HTML pages and anonymous FTP directories.
  • /var Variable data, such as spools and logs. Contains both shareable (eg. /var/spool/mail) and non-shareable (eg. /var/log/) subdirectories.

Finding Files and Directories[edit]

We will describe the find, which, whereis and locate utilities. (

The find command was covered in topic 103.3)

locate

Syntax:

locate <STRING>

When using locate all files and directories that match the expression are listed.

# locate X11R

The search is much faster than find. In fact locate queries the /var/lib/slocate/slocate.db database. This database is kept up to date via a daily cron job which runs updatedb.

When running updatedb from the command line the /etc/updatedb.conf file is read to determine pruned files systems (e.g NFS) and directories (e.g /tmp)

which

Syntax:

which string

This tool will return the full path to the file called string by scanning the directories defined in the user's PATH variable only. As a result which is only used to find commands.

whereis

Syntax

whereis string

This tool will return the full path to source or binaries as well as documentation files matching string by scanning the PATH variable as well as a number of well known locations

Getting the most from ls

Most common options for ls
-I show inode
-h print human readable sizes
-n list UIDs and GIDs
-p append descriptor (/=@) to list
-R recursively display content of directories
-S sort by file size
-t sort by modification time (similar to -c)
-u show last access time



Used files, terms and utilities:* find

  • locate
  • updatedb
  • whereis
  • which
  • type


Previous Chapter | Next Chapter