Look around: pwd & ls
Whenever you land on a new machine, your first two questions are always the same: “Where am I?” and “What's here?” Two tiny commands answer them.
You will learn
pwd: print the folder you're inls,ls -l,ls -a: list what's there, with details, including hidden files- How to read the columns of
ls -l, and a small difference Rocky has
pwd: where am I?
pwd stands for print working directory. (“Directory” is the Linux word for folder.) It prints your exact location:
pwd
/home/student
That's your home folder. Every user gets one at /home/USERNAME, and it's where you land when you log in. Remember that ~ in the prompt means the same thing.
ls: what's here?
ls lists the contents of a folder. Folders are usually shown in blue.
ls # what's in the folder I'm in? ls /etc # what's in /etc? (you don't have to go there first) ls -l # long format: more details ls -a # all: include hidden files ls -la # both at once ls -lh # sizes like 4.0K and 2.1M instead of bytes
Hidden files
Any file or folder whose name starts with a dot (.bashrc, .ssh) is hidden. Plain ls skips it and ls -a shows it. Linux hides settings files this way so they don't clutter your view. They aren't secret or protected, just tidied away.
With -a you'll also see two strange entries: . means “this folder” and .. means “the folder above.” You'll use .. constantly in the next lesson.
Reading ls -l
Long format looks intimidating, but it's just a table without a header row:
- The first character is the type:
d= directory,-= regular file. - The next 9 characters are permissions in groups of three: what the owner, the owner's group, and everyone else can do.
r= read,w= write,x= execute (run it, or enter it if it's a folder). You'll meet them again later.
-rw-r--r--. 1 student student 332 readme.txt
See the dot after the permissions? It means the file has an SELinux security label. SELinux is an extra security guard that's switched on in the RHEL family.
-rw-r--r-- 1 student student 332 readme.txt
No dot. Ubuntu uses a different security guard, AppArmor, which doesn't show up in ls.
There's also a handy shortcut, ll. On Rocky it means ls -l. On Ubuntu it means ls -alF, which also shows hidden files and puts a / after folder names.
Try it
Quick check
1. Why doesn't ls show .bashrc?
✓ Right. A leading dot means hidden, not protected.
2. In ls -l output, a line starts with d. What is it?
✓ Yes. d = directory and - = regular file.
3. On Rocky, what does the . at the end of -rw-r--r--. mean?
✓ Correct. SELinux is part of what makes the RHEL family popular with banks and governments.