Home Web Hosting Linux Tutorials Checking Current Dir & Parent Directory in Linux Tutorial

Checking Current Dir & Parent Directory in Linux Tutorial

checking current & Parent directories in Linux
checking current & Parent directories in Linux

When it comes to checking the current directory within Linux. Or just simply moving up to the main parent folder.

We will start inside our testfolder

made 2 new folders in linux
made 2 new folders in linux

First, we will type # ls -a to check for all directories

# ls -a

This is what we will see on our screen

checking current location ls -a command linux

If we type

# cd .

Note that there is a “white space between cd and the dot”

In UNIX, the dot [.] means your current directory, this is something we may not be sure about using at the moment but definitely something we will use later on, it will make

if we type

# cd ..

This will simply move us out from the current folder into the main parent folder

moving back to parent directory in linux
moving back to parent directory in linux

let’s do a quick breakdown of what has happened above;

  1. We are in the main “testfolder“, which contains 2 subfolders “test1” and “test2”
  2. We used UNIX command # cd .. which will move up 1 directory (it’s like clicking back)
  3. We use # ls -a to view the current directory (-a shows hidden files) this is to make sure we moved back.
  4. We can see the main current directory (we moved back from “testfolder” up to the main home root since “testfolder” is located at the home root folder)

it’s simple as that moving back to the main parent folder

We hope you guys enjoy this easy to follow step by step tutorial in Linux

More Linux Tutorials on directories with Linux UNIX commands

LEAVE A REPLY

Please enter your comment!
Please enter your name here