Mainframe Path Start learning free
Beginner7 min readLesson 1 of 5

The shell, the prompt and moving around

The shell is the program that reads the commands you type and runs them. Everything on Linux lives in one tree of folders that starts at /, and three commands get you around it: pwd shows where you are, ls shows what is there, and cd moves you.

What you are looking at

When you open a terminal or connect to a server, a shell starts and shows a prompt. Bash is the most common shell on Linux. The prompt usually shows your user name, the machine and the folder you are in, then $ for a normal user or # for the all-powerful root user. You type a command, press Enter, and the shell runs it.

A first look around
asha@build01:~$ pwd
/home/asha
asha@build01:~$ ls
notes.txt  projects  scripts
asha@build01:~$ cd projects
asha@build01:~/projects$ ls -la
drwxr-xr-x 4 asha devs 4096 Oct  9 10:02 .
drwxr-xr-x 9 asha devs 4096 Oct  9 09:40 ..
-rw-r--r-- 1 asha devs  220 Oct  9 09:41 .gitignore
drwxr-xr-x 3 asha devs 4096 Oct  9 10:02 payroll

One tree, starting at /

Linux has no drive letters. Everything hangs off a single root directory written /. Folders are separated by forward slashes, so /home/asha/projects means the folder projects, inside asha, inside home, inside the root. Names are case-sensitive: Report.txt and report.txt are two different files.

You typeIt means
/The root of the whole file system
~Your home directory, for example /home/asha
.The directory you are in now
..The parent directory, one level up
/var/log/app.logAn absolute path: starts with / and works from anywhere
logs/app.logA relative path: starts from wherever you are now

The three commands you use most

Getting help

Most commands explain themselves. man ls opens the manual page for ls (press q to quit), and ls --help prints a shorter summary. Options usually come in a short form with one dash (-a) and sometimes a long form with two (--all). Short options can be combined: ls -la is the same as ls -l -a.

TRY IT YOURSELF

You are in /home/asha/projects/payroll. Which command takes you up to /home/asha/projects?

Show a hint

Two dots mean the parent directory.

Show the solution

cd .. moves up one level. cd /home/asha/projects or cd ~/projects would also work.

Examples are for learning. Run commands and jobs only on a system you are authorised to use, such as a training or test system, and never on production without approval.

Common mistakes

Mixing up / and ~

/ is the root of the whole system and ~ is your own home directory. cd / and cd ~ take you to very different places.

Forgetting that names are case-sensitive

Build.sh and build.sh are different files. If a file 'is not there', check the capital letters first.

Working as root out of habit

A # prompt means you are root, and nothing will stop a mistake. Use your own account and sudo for the single command that needs it.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
Files, folders and permissions →