Commands for Navigating the Linux Filesystems

The first thing you usually want to do when learning about the Linux filesystem is take some time to look around and see what’s there! These next few commands will: a) Tell you where you are, b) take you somewhere else, and c) show you what’s there. The following table describes the basic operation of the pwd, cd, and ls commands, and compares them to certain DOS commands that you might already be familiar with.

Linux Command DOS Command Description
pwd cd “Print Working Directory”. Shows the current location in the directory tree.
cd cd, chdir “Change Directory”. When typed all by itself, it returns you to your home directory.
cd directory cd directory Change into the specified directory name.
Example:cd /usr/src/linux
cd ~ “~” is an alias for your home directory. It can be used as a shortcut to your “home”, or other directories relative to your home.
cd .. cd.. Move up one directory. For example, if you are in /home/vic and you type “cd ..”, you will end up in /home
cd – Return to previous directory. An easy way to get back to your previous location!
ls dir /w List all files in the current directory, in column format.
ls directory dir directory List the files in the specified directory.
Example:ls /var/log
ls -l dir List files in “long” format, one file per line. This also shows you additional info about the file, such as ownership, permissions, date, and size.
ls -a dir /a List all files, including “hidden” files. Hidden files are those files that begin with a “.”, e.g. The .bash_history file in your home directory.
ls -ld directory A “long” list of “directory”, but instead of showing the directory contents, show the directory’s detailed information. For example, compare the output of the following two commands:

ls -l /usr/bin
ls -ld /usr/bin
ls /usr/bin/d* dir d*.* List all files whose names begin with the letter “d” in the /usr/bin directory.