Where Am I? pwd and ls

pwd: print working directory

The directory you are in right now is called the working directory (or current directory). pwd prints its full path:

pwd

In the terminal

student@vulntech:~$ pwd
/home/student

ls: list

ls lists the working directory. Give it a path to list somewhere else:

ls
ls Documents
ls /

In the terminal

student@vulntech:~$ ls
Documents  Music  Pictures  todo.txt
student@vulntech:~$ ls Documents
school  work
student@vulntech:~$ ls /
bin   dev  home  media  opt   root  sbin  sys  usr
boot  etc  lib   mnt    proc  run   srv   tmp  var

Reading ls -l

ls -l

In the terminal

student@vulntech:~$ ls -l
total 2
drwxr-sr-x 4 student student  0 Oct 16 19:07 Documents
drwxr-sr-x 2 student student  0 Oct 16 19:07 Music
drwxr-sr-x 3 student student  0 Oct 16 19:07 Pictures
-rw-r--r-- 1 student student 19 Oct 16 19:07 todo.txt

Each line is one item. Take todo.txt:

ColumnExampleMeaning
Type and permissions-rw-r--r--The first character is the type: - file, d directory, l link. The rest are permissions (a later module)
Links1Number of links to it. You can ignore this for now
OwnerstudentThe user who owns it
GroupstudentThe group that owns it
Size19Size in bytes
ModifiedOct 16 12:30When it was last changed
Nametodo.txtThe name

More useful ls options

CommandShows
ls -aAll files, including hidden ones
ls -lhLong format with human-readable sizes (K, M, G)
ls -ltLong format, newest first
ls -RRecursively: every directory inside too
ls -d */Only directories

Sizes in bytes are hard to read for big files. Compare:

ls -l Pictures/2024
ls -lh Pictures/2024

In the terminal

student@vulntech:~$ ls -l Pictures/2024
total 2301
-rw-r--r-- 1 student student 2355200 Oct 16 19:07 beach.jpg
student@vulntech:~$ ls -lh Pictures/2024
total 2.3M
-rw-r--r-- 1 student student 2.3M Oct 16 19:07 beach.jpg

ls -R shows a whole branch of the tree:

ls -R Documents

In the terminal

student@vulntech:~$ ls -R Documents
Documents:
school  work

Documents/school:
maths.txt

Documents/work:
report.txt

For a nicer picture of a branch, use tree:

tree Documents

In the terminal

student@vulntech:~$ tree Documents
Documents
├── school
│   └── maths.txt
└── work
    └── report.txt

3 directories, 2 files

Tip: ls -la is one of the most typed commands on Linux: everything, with details.

Remember: pwd tells you where you are. ls shows what's there; -l for details, -a for hidden files, -h for readable sizes.

HOME LEARN COMMUNITY DASHBOARD
Practice terminal Starting…