This lesson introduces the essential Linux commands for navigating, creating, modifying, and cleaning up files and directories. It is designed for a 3‑hour workshop (or a 1‑hour introductory class) and includes hands‑on exercises that reinforce learning.
cd, pwd, and lsmkdir, rmdir, rm, touchcp and mvchmod and chownfind, inspect disk usage with du & dfstudent)| Time | Activity |
|---|---|
| 0‑15 min | Welcome & agenda overview |
| 15‑30 min | Basic navigation (pwd, cd, ls) |
| 30‑45 min | Creating & removing directories (mkdir, rmdir) |
| 45‑60 min | File creation, deletion, and moving (touch, rm, cp, mv) |
| 60‑75 min | Permissions & ownership (chmod, chown) |
| 75‑90 min | Searching & disk usage (find, du, df) |
| 90‑105 min | Practice session – guided exercises |
| 105‑120 min | Q&A & wrap‑up |
pwd – Print Working DirectoryShows the absolute path of the current directory.
pwd /Users/student/Documents/Labs/Linux
pwd and verify the full path.pwd with echo to show the current path in a script.ls – List Directory ContentsDisplays files and directories in the current location.
ls README.md scripts logs
ls -l – long format (permissions, owner, size)ls -a – include hidden files (those starting with .)ls -lh – human‑readable sizesls -l drwxr-xr-x 3 student staff 96 Aug 12 09:30 scripts -rw-r--r-- 1 student staff 45 Aug 11 12:00 README.md
logs directory.cd – Change DirectoryMoves between directories.
cd /var/log cd ../home cd ~ cd -
/tmp, then back to the previous directory.cd ~ to return to the home directory from anywhere.mkdir – Make DirectoryCreates new directories.
mkdir newdir mkdir -p parent/child/grandchild mkdir -m 755 secure
project/src/docs in one command.750.rmdir – Remove Empty DirectoryDeletes an empty directory.
rmdir emptydir rmdir -p nested/empty/dir
rm – Remove Files & DirectoriesDeletes files or recursively removes directories.
rm file.txt rm -i file.txt rm -r dir rm -f /tmp/unwanted.log
-i.-r to delete a directory that contains files.-f that you do not own (observe the result).touch – Create or Update File TimestampsCreates an empty file or updates its last-modified time.
touch newfile.txt touch -a oldfile.txt touch -m -t 202309301200 newfile.txt
todo.txt.-t option.cp – Copy Files & DirectoriesCopies files or directories, optionally preserving attributes.
cp source.txt dest.txt cp -r src_dir/ dest_dir/ cp -p file1 file2
mv – Move or RenameMoves files or directories, or renames them.
mv oldname.txt newname.txt mv file.txt /tmp/ mv -i existing.txt newfile.txt
old.txt to new.txt.-i to confirm behavior.chmod – Change File PermissionsAlters read/write/execute permissions using numeric or symbolic modes.
chmod 644 file.txt chmod u=rwx,g=rx,o=r file.txt chmod -R 755 /var/www/html
read-only for the owner.755 permissions on a directory tree.chown – Change File Owner & GroupAssigns a new owner or group to files or directories.
chown alice file.txt chown alice:staff file.txt chown -R bob:developers /home/bob/projects
sudo if needed).staff.find – Search for Files & DirectoriesSearches based on name, type, size, modification time, etc.
find . -name "*.log"
find /var -type d -name "conf.d"
find /tmp -size +1M -exec rm {} \;
find . -mtime -7 -print
.sh files in the current directory tree./var/tmp.Feel free to adapt this plan to fit your learners’ pace and your institution’s schedule. Happy teaching!