Linux Classes
Linux Classes
Share This With a Friend
LINUX CLASSES - FILES

How Do I Navigate the File System?

Tree Climbing

You can move from one directory to another using the cd command. For example, if you are in your home directory (/home/hermie) and want to switch to the recipes directory (/home/hermie/recipes), the following command does the trick: cd recipes

To switch back to your home directory, you could type

cd /home/hermie

but there are two shortcuts you will find useful. The first is the double-dot (..) notation, as in

cd ..

This will move you one level up, to the parent directory. You can even enter something like

cd ../secrets

to move up to the parent and then go back down to a directory that is at the same level as the current one. This double-dot notation is not specific to the cd command, though. You can use it with any Linux command that needs a file name as input. You might also see the single-dot (.) notation, which means "this directory." It wouldn't make much sense to enter cd . because you'd still be in the same directory, but there are other commands (notably, the find command, described in the "Important Linux Commands" section). where it's convenient to use the single dot as shorthand for the current directory name.

Another directory navigation shortcut involves using $HOME. No matter what directory you are in, the following command will return you to your personal recipes directory:

cd $HOME/recipes

And if you want to change to another user's home directory, you can use the tilde (~) notation. In the following examples, the tilde character is shorthand for "the home directory of." You must put the name of a user on your system immediately after the tilde.

For example, cd ~sigmund means "change to sigmund's home directory;"

cd ~edbo/stuff means "change to edbo's stuff directory."

The single-dot, double-dot, and tilde notations are useful in conjunction with the cd command, but they can also be used in any Linux command where you need to enter a file or directory name.

TIP: One common mistake people make in navigating Linux directories is using a slash in front of file names when it is not needed. Suppose you have a bin directory under your home directory. If you were at /home/hermie and you entered cd /bin, you'd end up at the bin underneath the root directory--oops. (Linux understands the slash before bin as telling it to go to the root directory first and then to the bin directory just below the root.) The correct way to reach the bin directory under /home/hermie is to type from within your home directory (/home/hermie) cd bin. Don't use a leading slash unless you're sure you want to start at the top (root) of the file tree.

Previous Lesson: Directory Terminology
Next Lesson: Listing Linux Files

[ RETURN TO INDEX ]



Comments - most recent first
(Please feel free to answer questions posted by others!)

Harshit (21 Mar 2012, 05:16)
cd - (cd dash)

this command is back us on that directory where we lastly typed 'pwd' command.
Jay Easy (02 Mar 2012, 08:01)
Thanks!!
Pranava (09 Oct 2011, 13:55)
@varda -: These commands are to be typed in the terminal. All Linux distros have a terminal.
varda (20 Sep 2011, 17:18)
hi. i am very very much of a rooky and feel embarrassed even to ask. but where do i type cd etc. what place do i go to. is there a monitor allowing that. where do i find it
Pete (28 Aug 2011, 00:09)
I am pretty sure the CD alone won't go home for all distributions...

I am also sure that all of them do support

CD ~

And this will take you to your home directory for sure.
Thomas (16 Jan 2011, 01:07)
You can also just type: "cd" with no arguments to get back to your home directory.
Bob Rankin (21 Apr 2010, 13:11)
Environment variables start with a "$" to indicate that the value of the variable should be substituted there. It seems a bit odd to have a file or directory starting with "$" but you can do it. Just be sure to escape the "$" with a backslash or put the name in single quotes. For example:

mkdir \$myfolder
mkdir '$myfolder'
Meg (21 Apr 2010, 13:04)
Quick question (I hope): what is the significance of the $ sign in front of the directory name? It's used above with the cd command and was used previously on the Environment Variables page. I'm trying to install a model where I have to create directories with names starting with a $ sign, and I can't figure out what means. Sure, I can just follow the directions and hope for the best, but it would be nice to actually know what I'm doing. ;) Haven't been able to find the answer online. Thanks for the great site.
Arye Hartmann (22 Mar 2010, 04:24)
Hi Bob
i need to access a disk-on-key that contains
Microsoft word/Excell files.
When i insert a disk-on-key on the usb port my (year 2000) pentium 3 computer does not seem to notice.
What is the quick one time solution ?
What is the long term/permanent solution ?
Arye


I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But don't ask me to send what you already have. :-)

NO SPAM! If you post garbage, it will be deleted, and you will be banned.
*Name:
Email:
Notify me about new comments on this page
Hide my email
*Text:




Copyright © by - Privacy Policy
All rights reserved - Redistribution is allowed only with permission.

Popular Linux Topics

Linux Intro
Linux Files
Linux Commands
Change Password
Copy Files
Linux Shell Basics

Linux Tutorial

Who is Doctor Bob?
What is Linux?
History of Unix
Operating Systems
What's Next?

Linux Basics

Living in a Shell
Root and Other Users
Virtual Consoles
Logoff and Shutdown
Choosing a Shell
The Command Prompt
Wildcards
Command History
Aliases
Redirection
Pipelines
Processes
Stopping a Program
Environment Variables
Help!

Linux Files

The Linux File System
Linux File Names
Linux Directories
Directory Terminology
Navigating the File System
Listing Linux Files
Displaying Linux Files
Copying and Renaming Files
Creating Files and Directories
Deleting Files and Directories
Linux Files - Wildcards
The Nine Deadly Keystrokes
Linux File Permissions
Changing File Permissions

Linux Commands

Important Linux Commands
Changing Your Password
Switching Users
Who is Logged In?
Date and Time
The Echo Command
Spell Checking
Printing Linux Files
Joining Files
Searching for Files
Comparing Files
Task Scheduling
Linking Files

Linux Editors

The Vi Editor
The Emacs Editor
The Pico Editor

Linux Data Manipulation

Slicing & Dicing
Heads or Tails?
Sorting Data
Eliminating Duplicates
Selecting Columns
Selecting Records
Search & Replace
Crunching Data
Finding Files
Pipe Fitting

Linux Shell Programming

Linux Shell Scripts
Executing a Script
Shell Script Variables
Shell Script Logic
Shell Script Looping
Shell Script Debugging

Perl Programming

Perl Basics
Perl Variables
Perl Arguments
Perl Logic
Perl Looping
Perl and Files
Perl Pattern Matching

Linux and Email

Sending Email
Reading Email
Other Mail Commands
Using Pine for Email
The Pine Inbox
Pine Email Basics
Pine Email Folders
Pine for Power Users

Compression and Encoding

Linux File Compression
Archiving With Tar
Compression With Gzip
Compress and Zcat
Zmore and Zless
Zip and Unzip
Encoding and Decoding
Encryption

Linux Does DOS

Accesing DOS Files
Accesing DOS Partitions
Running DOS Programs

Managing Linux

Updating Your Linux System
Installing Packages with RPM
Uninstalling Packages w/ RPM
Upgrading Packages with RPM
Querying Packages with RPM

AltStyle によって変換されたページ (->オリジナル) /