Linux Fundamentals - Lesson 01 (ls)
Lesson 01 - list files with ls
Goal
Learn ls deeply enough to:
- list files and directories confidently,
- reveal hidden files,
- sort by time and size,
- format output for human reading and scripts.
Quick Commands
ls
ls -l
ls -a
ls -al
ls -lt
ls -lS
ls -lh
ls -1
ls --format=commas
ls --help
Core Concepts
1) What is ls
ls is a core Linux/Unix command to list directory contents.
2) Arguments style
-xmeans short argument (single-letter style)--wordmeans long argument (full-word style)
Important clarification:
- It is not "single vs multiple arguments".
- It is mostly "short option name vs long option name".
- Example:
ls -l -ais same asls -la(multiple short options can be combined). - Example:
ls --color=autouses one long option.
3) Long listing (ls -l) columns
- permissions
- hard link count
- owner
- group
- size
- last modification time
- filename
4) Hidden files
- dotfiles start with
. .means current directory..means parent directory
5) File times
atime: last accessmtime: last content modificationctime: last metadata change
Guided Practice
Paste your real terminal output under each section.
Practice A - first look
ls
ls --color=no
ls --color=yes
ls --color=auto .
Output:
root@ubuntu:~$ ls
File-01.txt file-01 file-01.txt file-02 filesystem notmyfile notmyfile2 testDir testdir
root@ubuntu:~$ ls --color=no
File-01.txt file-01 file-01.txt file-02 filesystem notmyfile notmyfile2 testDir testdir
root@ubuntu:~$ ls --color=yes
File-01.txt file-01 file-01.txt file-02 filesystem notmyfile notmyfile2 testDir testdir
root@ubuntu:~$ ls --color=auto .
File-01.txt file-01 file-01.txt file-02 filesystem notmyfile notmyfile2 testDir testdir
Mentor note:
- Great run. You proved color behavior correctly.
--color=nodisables color.--color=yesforces color.--color=autoshows color when output is a terminal.
Image (your screenshot):

Practice B - more details
clear
ls -l .
ls -n
What to observe:
- names vs UID/GID output
- each
-lcolumn meaning
Output:
root@ubuntu:~$ ls -l
total 168
-rw-r--r-- 1 root root 149370 Mar 21 10:58 File-01.txt
-rw-r--r-- 1 root root 0 Mar 21 10:58 file-01
-rw-r--r-- 1 root root 18 Mar 21 10:58 file-01.txt
-rw-r--r-- 1 root root 0 Mar 21 10:58 file-02
lrwxrwxrwx 1 root root 1 Mar 4 09:06 filesystem -> /
-rw-r--r-- 1 testuser testuser 18 Mar 21 10:58 notmyfile
-rw-r--r-- 1 otheruser otheruser 19 Mar 21 10:58 notmyfile2
drwxr-xr-x 2 root root 4096 Mar 21 10:58 testDir
drwxr-xr-x 3 root root 4096 Mar 21 10:58 testdir
root@ubuntu:~$ ls -n
total 168
-rw-r--r-- 1 0 0 149370 Mar 21 10:58 File-01.txt
-rw-r--r-- 1 0 0 0 Mar 21 10:58 file-01
-rw-r--r-- 1 0 0 18 Mar 21 10:58 file-01.txt
-rw-r--r-- 1 0 0 0 Mar 21 10:58 file-02
lrwxrwxrwx 1 0 0 1 Mar 4 09:06 filesystem -> /
-rw-r--r-- 1 1001 1001 18 Mar 21 10:58 notmyfile
-rw-r--r-- 1 1002 1002 19 Mar 21 10:58 notmyfile2
drwxr-xr-x 2 0 0 4096 Mar 21 10:58 testDir
drwxr-xr-x 3 0 0 4096 Mar 21 10:58 testdir
Mentor note:
- Perfect observation.
clearonly clears visible terminal screen; it does not delete command history.-l= long format (human-friendly owner/group names).-n= numeric owner/group IDs (UID/GID numbers).
Practice C - hidden files
ls
ls -a
ls .
ls ..
ls -A .
ls -al .
What to observe:
- why
-areveals dotfiles - difference between
-aand-A
Output:
root@ubuntu:~$ ls
File-01.txt file-01 file-01.txt file-02 filesystem notmyfile notmyfile2 testDir testdir
root@ubuntu:~$ ls -a
. .bash_history .hidden-file .ssh .vimrc File-01.txt file-01.txt filesystem notmyfile2 testdir
.. .bashrc .profile .theia .wget-hsts file-01 file-02 notmyfile testDir
root@ubuntu:~$ ls .
File-01.txt file-01 file-01.txt file-02 filesystem notmyfile notmyfile2 testDir testdir
root@ubuntu:~$ ls ..
bin bin.usr-is-merged boot dev etc home lib lib.usr-is-merged lib64 lost+found media mnt opt proc run root sbin sbin.usr-is-merged snap srv swapfile sys tmp usr var
root@ubuntu:~$ ls -A
.bash_history .hidden-file .ssh .vimrc File-01.txt file-01.txt filesystem notmyfile2 testdir
.bashrc .profile .theia .wget-hsts file-01 file-02 notmyfile testDir
root@ubuntu:~$ ls -al
total 204
drwx------ 6 root root 4096 Mar 21 10:58 .
drwxr-xr-x 22 root root 4096 Mar 4 09:06 ..
-rw------- 1 root root 10 Feb 10 2025 .bash_history
-rw-r--r-- 1 root root 3234 Mar 4 09:07 .bashrc
-rw-r--r-- 1 root root 0 Mar 21 10:58 .hidden-file
-rw-r--r-- 1 root root 161 Apr 22 2024 .profile
drwxr-xr-x 2 root root 4096 Mar 4 09:05 .ssh
drwxr-xr-x 2 root root 4096 Mar 4 09:07 .theia
-rw-r--r-- 1 root root 109 Mar 4 09:07 .vimrc
-rw-r--r-- 1 root root 165 Mar 4 09:07 .wget-hsts
-rw-r--r-- 1 root root 149370 Mar 21 10:58 File-01.txt
-rw-r--r-- 1 root root 0 Mar 21 10:58 file-01
-rw-r--r-- 1 root root 18 Mar 21 10:58 file-01.txt
-rw-r--r-- 1 root root 0 Mar 21 10:58 file-02
lrwxrwxrwx 1 root root 1 Mar 4 09:06 filesystem -> /
-rw-r--r-- 1 testuser testuser 18 Mar 21 10:58 notmyfile
-rw-r--r-- 1 otheruser otheruser 19 Mar 21 10:58 notmyfile2
drwxr-xr-x 2 root root 4096 Mar 21 10:58 testDir
drwxr-xr-x 3 root root 4096 Mar 21 10:58 testdir
Learner interpretation:
ls -ashows all files including hidden files..is current directory and..is parent directory.ls -Ais almost all (excludes.and..).ls -alcombines all files with long listing details.
Mentor feedback:
- Excellent interpretation.
- "Parent directory" is the best term (more precise than parent folder).
- Your command-combination explanation is correct:
-alis combined short options.
Practice D - sort by time
date +%s
date
ls -lt
ls -ltu
ls -ltc
touch theNewestFile
ls -ltu
ls -ltc
echo "hello world!" > file-02
ls -ltu
ls -ltc
chmod 444 file-01
ls -ltu
ls -ltc
What to observe:
- when order changes for
-u - when order changes for
-c
Learner interpretation (checkpoint before running):
ctimeis metadata change time (permissions, moving/renaming, ownership, etc.).atimeis last access time.mtimeis last content modification time.
Mentor feedback:
- Excellent. That model is correct and ready for the next exercise.
Output:
root@ubuntu:~$ date +%s
1774094082
root@ubuntu:~$ date
Sat Mar 21 11:54:42 UTC 2026
root@ubuntu:~$ ls -ltu
...
drwxr-xr-x 2 root root 4096 Mar 21 11:54 testDir
drwxr-xr-x 3 root root 4096 Mar 21 11:54 testdir
...
root@ubuntu:~$ touch theNewestFile
root@ubuntu:~$ ls -ltu
...
-rw-r--r-- 1 root root 0 Mar 21 11:54 theNewestFile
...
root@ubuntu:~$ echo "hello world!" > file-02
root@ubuntu:~$ ls -ltc
...
-rw-r--r-- 1 root root 13 Mar 21 11:54 file-02
...
root@ubuntu:~$ chmod 444 file-01
root@ubuntu:~$ ls -ltc
...
-r--r--r-- 1 root root 0 Mar 21 11:54 file-01
...
Learner interpretation:
theNewestFilewent to the top aftertouchbecause it was just created.ls -ltuis about access time (atime).ls -ltcmoved files after metadata changes, likechmod.
Mentor feedback:
- Great analysis.
- Important correction:
ls -ltcusesctimefor sorting/display, not bothmtimeandctime. - Baseline behavior is
ls -lt(mtime). Then-uswitches to atime, and-cswitches to ctime.
Checkpoint Q/A:
- Q: If you run
echo "x" >> file-01.txt, which one should reflect it most directly:-lt,-ltu, or-ltc? - Learner answer:
-ltbecause it modifies file content. - Mentor validation: Correct. Content append updates
mtime, sols -ltis the primary one to watch.
Practice E - sort by size
ls -s
ls -ls
ls -lS
ls -lh
ls -l --si
ls -lSh
What to observe:
- extra blocks column from
-s - case-sensitive behavior of
-svs-S
Output:
root@ubuntu:~$ ls -s
total 168
144 File-01.txt 4 file-01.txt 0 filesystem 4 notmyfile2 4 testdir
0 file-01 4 file-02 4 notmyfile 4 testDir 0 theNewestFile
root@ubuntu:~$ ls -ls
total 168
144 -rw-r--r-- 1 root root 144907 Mar 21 11:53 File-01.txt
0 -r--r--r-- 1 root root 0 Mar 21 11:53 file-01
4 -rw-r--r-- 1 root root 18 Mar 21 11:53 file-01.txt
4 -rw-r--r-- 1 root root 13 Mar 21 11:54 file-02
0 lrwxrwxrwx 1 root root 1 Mar 4 09:06 filesystem -> /
4 -rw-r--r-- 1 testuser testuser 18 Mar 21 11:53 notmyfile
4 -rw-r--r-- 1 otheruser otheruser 19 Mar 21 11:53 notmyfile2
4 drwxr-xr-x 2 root root 4096 Mar 21 11:53 testDir
4 drwxr-xr-x 3 root root 4096 Mar 21 11:53 testdir
0 -rw-r--r-- 1 root root 0 Mar 21 11:54 theNewestFile
root@ubuntu:~$ ls -lS
total 168
-rw-r--r-- 1 root root 144907 Mar 21 11:53 File-01.txt
drwxr-xr-x 2 root root 4096 Mar 21 11:53 testDir
drwxr-xr-x 3 root root 4096 Mar 21 11:53 testdir
-rw-r--r-- 1 otheruser otheruser 19 Mar 21 11:53 notmyfile2
-rw-r--r-- 1 root root 18 Mar 21 11:53 file-01.txt
-rw-r--r-- 1 testuser testuser 18 Mar 21 11:53 notmyfile
-rw-r--r-- 1 root root 13 Mar 21 11:54 file-02
lrwxrwxrwx 1 root root 1 Mar 4 09:06 filesystem -> /
-r--r--r-- 1 root root 0 Mar 21 11:53 file-01
-rw-r--r-- 1 root root 0 Mar 21 11:54 theNewestFile
root@ubuntu:~$ ls -lh
total 168K
-rw-r--r-- 1 root root 142K Mar 21 11:53 File-01.txt
...
root@ubuntu:~$ ls -l --si
total 173k
-rw-r--r-- 1 root root 145k Mar 21 11:53 File-01.txt
...
root@ubuntu:~$ ls -lSh
total 168K
-rw-r--r-- 1 root root 142K Mar 21 11:53 File-01.txt
drwxr-xr-x 2 root root 4.0K Mar 21 11:53 testDir
drwxr-xr-x 3 root root 4.0K Mar 21 11:53 testdir
...
Learner interpretation:
-sshows size blocks.-Ssorts by size.-hmakes output easier to read.- Preferred readable command:
ls -lSh.
Mentor feedback:
- Correct and solid.
- Precision note:
-sshows allocated disk blocks, while-lsize column shows byte size (or human-readable with-h). -lShis a strong practical default when quickly finding large files.
Practice F - formatting
ls -1
ls --format=commas
ls -m
ls --format=long
ls -lQ
ls -l --time-style=locale
ls -l --time-style=iso
ls -l --time-style=full-iso
Output:
root@ubuntu:~$ ls -1
File-01.txt
file-01
file-01.txt
file-02
filesystem
notmyfile
notmyfile2
testDir
testdir
theNewestFile
root@ubuntu:~$ ls --format=commas
File-01.txt, file-01, file-01.txt, file-02, filesystem, notmyfile, notmyfile2, testDir, testdir, theNewestFile
root@ubuntu:~$ ls -m
File-01.txt, file-01, file-01.txt, file-02, filesystem, notmyfile, notmyfile2, testDir, testdir, theNewestFile
root@ubuntu:~$ ls --format=long
total 168
-rw-r--r-- 1 root root 144907 Mar 21 11:53 File-01.txt
...
root@ubuntu:~$ ls -lQ
total 168
-rw-r--r-- 1 root root 144907 Mar 21 11:53 "File-01.txt"
...
root@ubuntu:~$ ls -l --time-style=locale
total 168
-rw-r--r-- 1 root root 144907 Mar 21 11:53 File-01.txt
...
root@ubuntu:~$ ls -l --time-style=iso
total 168
-rw-r--r-- 1 root root 144907 03-21 11:53 File-01.txt
...
root@ubuntu:~$ ls -l --time-style=full-iso
total 168
-rw-r--r-- 1 root root 144907 2026-03-21 11:53:47.235283758 +0000 File-01.txt
...
Learner interpretation:
ls -1prints one entry per line; with-lthis is usually unnecessary.ls --format=commasandls -mlook the same.-Qquotes file names.locale,iso, andfull-isochange date/time formatting.
Mentor feedback:
- Excellent read.
- Correction:
-mis not modification-related; it is a formatting alias for comma-separated output. localemeans system locale format,isois compact ISO-style, andfull-isoincludes full date, seconds precision, and timezone.
Practice G - extra useful options
ls -al --author
ls -ald
ls -ali
ls -alR
ls -alr
ls -alSr
ls --version
ls --help
Output:
[paste output here]
Quiz + Answers
Q1. Whole command for long list in current directory?
- Answer:
ls -l .
Q2. Argument for sorting by time?
- Answer:
-t
Q3. For long color argument, use --, -, or .?
- Answer:
--(example:ls --color=auto)
Q4. UID represents?
- Answer: User identifier
Q5. How to list parent directory?
- Answer:
ls ..
Q6. I have ls -lt. What to add to see content modification order?
- Answer: nothing;
-twith default long list already usesmtime
Q7. Full command for long + human readable sizes?
- Answer:
ls -lh
Q8. Full command for comma-separated short list (not -m)?
- Answer:
ls --format=commas
Q9. Short list, one per line, with quotes?
- Answer:
ls -1Q
Reflection
- Easiest part:
- Most confusing part:
- 3 commands I will keep using:
- What I will practice tomorrow: