🎓 A1Learner
🔍
0 of 47 lessons completed

Bash Navigating

Navigating means moving between folders and checking what each folder holds. Bash keeps track of one current folder at all times.

Where am I?

The pwd command prints the path of the current folder. The path below is the folder this script runs in.

pwd

Make folders, then list them

Two mkdir commands make folders inside a new project folder. Listing project then shows both names in alphabetical order.

mkdir project
mkdir project/photos
mkdir project/docs
ls project

Move into a new folder

The cd command moves into the new project folder. The pwd output ends with the project name, proving the move.

mkdir project
cd project
pwd

Example

pwd
mkdir site
cd site
mkdir pages
mkdir images
ls
pwd

Key points

  • Folder: a place that groups files and other folders.
  • Current folder: the one folder Bash is working in right now.
  • pwd prints the full path of the current folder.
  • ls lists the names inside the current folder.
  • cd changes the current folder to another folder.
  • mkdir makes a new empty folder.

In this example, pwd first prints the starting folder. The mkdir command makes a folder named site. The cd command moves into site. Two more mkdir commands make pages and images inside it. The ls command lists both names, and the final pwd shows the new current folder.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which command lists the names inside the current folder?