TutsFx logo

Linux Command Line Basics

Navigating the Filesystem

2 min read Last updated 45 minutes ago

Moving between directories is the skill you will use more than any other on the command line. The command is cdchange directory.

The basics

bash
cd /etc          # go to /etc
cd ~             # go to your home directory
cd ..            # go up one level
cd -             # go back to the previous directory
!

Relative vs absolute paths

  • An absolute path starts with / and works from anywhere: cd /var/log
  • A relative path starts from where you are: cd Documents moves into the Documents folder inside your current directory

Shortcuts that save your fingers

Shortcut Meaning
~ Your home directory
. The current directory
.. The parent directory
- The last directory you were in
Tab Auto-completes file and folder names

Press Tab constantly. Type cd /et and press Tab — the shell completes it to cd /etc. When there are multiple matches, press Tab twice to see them all.

Finding your way around

A quick tour of common directories:

Path Purpose
/home Where normal users keep their files
/etc System configuration files
/var/log Log files (good for troubleshooting)
/tmp Temporary files, cleared on reboot
/usr/bin Most installed programs

Try it

  1. cd /etc then pwd — where are you?
  2. ls — can you spot hostname or hosts?
  3. cd ~ then cd /var/log then cd - — watch the prompt tell you where you are
Share:

We value your privacy

We use cookies to enhance your browsing experience, serve personalized ads, and analyze traffic. By clicking "Accept", you consent to our use of cookies. Read our Privacy Policy to learn more.