Absolute Paths - Navigating from the Root
So far, we've been using relative paths - paths relative to our current location. Now, let's use an absolute path to move to a specific location, regardless of where we are.
- Type the following command and press Enter:
cd /etc
This is an absolute path, starting from the root directory (/
). The /etc
directory is an important system directory in Linux that contains configuration files. It's like giving your GPS the full address, starting from the country all the way down to the specific building.
- Check your location:
pwd
You should see:
/etc
You've navigated to a specific location using an absolute path! This directory exists on all Linux systems, so you should be able to access it without any errors.
- Let's take a quick peek at what's in this directory:
ls
You'll see a list of many configuration files and directories. Don't worry about understanding all of these now - we're just exploring!
- Now, let's return to our home directory using an absolute path:
cd /home/labex
This command will take you directly back to your home directory, no matter where you are in the file system.
Remember, using absolute paths is like using the full postal address - it works from anywhere, but it's often longer to type than relative paths.