Locating Files And Directories - Red Hat ENTERPRISE LINUX 4 - STEP BY STEP GUIDE Manual

Table of Contents

Advertisement

Chapter 4. Shell Prompt Basics
cd ~ — Also returns you to your login directory
cd / — Takes you to the entire system's root directory.
cd /root — Takes you to the home directory of the root user. You must be the root user to access
this directory.
cd /home — Takes you to the home directory, where user login directories are usually stored
cd .. — Takes you to the directory one level up.
cd ~otheruser — Takes you to otheruser's home directory, if otheruser has granted you
permission.
Below are a few examples of the use of
cd /dir1/dir2/ — Regardless of which directory you are in, this absolute path takes you directly to
, a subdirectory of
dir2
cd ../../dir2/dir3/ — This relative path takes you up two directories, then to
its subdirectory
dir3/
If you attempt to
cd
to access that directory.
Denying access to the root and other users' accounts (or home directories) is one way your
Red Hat Enterprise Linux system prevents accidental or malicious tampering. Refer to
Section 4.11 Ownership and Permissions for more information.

4.7. Locating Files and Directories

There may be times when you know a file or directory exists but you do not know where to find it.
There are several commands you can use to search for it, including
4.7.1. Find
The format of the find command is:
find path pattern
If you do not specify a path,
rectories for the specified pattern.
The
command has many options that you can review by entering
find
The most common option is
string of letters in their name.
find . -name foo
The above command searches through the current working directory for all files with "foo" in their
name.
4.7.2. Locate
The format of the locate command is:
locate pattern
cd
.
/dir1/
.
into a directory you do not have permission to access, you are denied permission
starts in the current working directory and looks through all subdi-
find
, which tells find to search for all files and directories with a certain
-name
.
, and finally into
dir2/
,
, and
find
locate
which
at a shell prompt.
man find
57
.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 4

Table of Contents