CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
  • Week 1
    • 1.Operating Systems and the Kernel: What Linux Does
    • 2.The Birth of Linux: From Unix to Linus
    • 3.Free Software and Open Source: What a License Decides
    • 4.Distributions: The Unit That Bundles the Kernel and Tools for Sale
    • 5.Week 1 Review: The Identity Behind the Name Linux
  • Week 2
  • Week 3
    • 1.First Steps in the Shell: How to Read a Single Command Line
    • 2.Working with Directories and Files
    • 3.Viewing and Finding Contents
    • 4.User and Account Management
    • 5.Week 3 Review: The Commands on One Page
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← Linux Master 2/Week 3/Day 5

Based on the Linux Master 2 exam syllabus·Report an error

Linux Master 2· AssociateWeek 3 · Day 5~17 min read

Day 5 - Week 3 Review: The Commands on One Page

📌 Key Takeaways

  • Read a command as command [options] [arguments], and a path starting with / is absolute.
  • Tell apart what needs -r (recursive) and what doesn't — cp -r and rm -r need it, mv doesn't.
  • find finds files, grep finds contents. This one sentence separates the two commands.
  • /etc/passwd is 7 colon-separated fields, UID 0 = root, and passwords are in /etc/shadow.
  • su switches users (target's password), sudo runs one command (your own password) — memorize them as a pair.

The Commands on One Page

  Location      pwd · cd · ls
    │
  Viewing       cat (all) · less (page through) · head (first 10) · tail (last 10) · tail -f (real time)
    │
  Create/delete touch · mkdir (-p) · rmdir (empty only) · rm (-r, -f)
    │
  Copy/move     cp (-r needed) · mv (-r not needed, also renames) · ln (-s symbolic)
    │
  Finding       find (files, path first) · locate (index, fast) · grep (contents)
    │
  Counting/chaining  wc -l · | (pipe)
    │
  Accounts      useradd (-m) · passwd · usermod (-aG) · userdel (-r) · id · su · sudo

Gathering the Meanings of Option Letters

The same letter is used with similar meanings across several commands.

LetterMeaningWhere it's used
-aall — everythingls -a (include hidden), usermod -aG (append)
-r / -Rrecursive — through subdirectoriescp -r, rm -r, grep -r, ls -R
-iThree meanings ⚠️cp -i (confirm), grep -i (ignore case), ls -i (inode)
-llong / linels -l (detailed), wc -l (line count)
-nnumberhead -n (line count), grep -n (line numbers)
-fforce / follow ⚠️rm -f (force), tail -f (follow)
-pparents / preserve ⚠️mkdir -p (intermediate paths), cp -p (preserve attributes)
-vinvertgrep -v (lines that don't match)

⚠️ The ones marked have different meanings in each command. -f is force in rm but follow in tail. Spots like these show up as trick questions.

Options That Split by Case

Even the same letter, uppercase and lowercase are completely different options. Some questions give four choices that differ only in case.

LowercaseUppercase
ls -r reverse sortls -R recursive through subdirectories
ls -a everything including . and ..ls -A everything except . and ..
ls -s show block countls -S sort by size
useradd -g primary groupuseradd -G secondary group
usermod -l change login nameusermod -L lock account
grep -i ignore casegrep -E extended regular expressions
man -k keyword search (apropos)man -f one-line description by name (whatis)

Practice Reading a Command Line to the End

This week's content comes down to whether you can read a command by breaking it into chunks. Try splitting the lines below from the left.

find /var/log -type f -name "*.log" -mtime -7
  • find the command / /var/log the starting path / -type f files only / -name "*.log" whose name ends in .log / -mtime -7 modified within the last 7 days.
  • Conditions written side by side give only what satisfies all of them (AND). The - before a number means "more recent than that," and + means "older than that."
grep -v "^#" /etc/fstab | wc -l
  • grep -v lines that don't match / "^#" that start with # / /etc/fstab in this file / | pass that result along / wc -l count the lines.
  • Read in plain terms, it is "how many lines are not comments?" ^ is the start of a line and $ is the end of a line.
cp -rp /home/user/docs /backup/ && ls -ld /backup/docs
  • cp -rp copy the directory through its subdirectories (-r), preserving permissions and times (-p) / && if it succeeds / ls -ld look at the detailed info of the directory itself.
  • Since /backup is an existing directory, the result becomes /backup/docs.
sudo useradd -m -g dev -G wheel -s /bin/bash kim
  • sudo just this one command with administrator privileges / useradd -m along with a home directory / -g dev the primary group is dev / -G wheel the secondary group is wheel / -s /bin/bash login shell / kim the name of the account to create.
  • After running it, a line of the form kim:x:UID:GID of dev::/home/kim:/bin/bash appears in /etc/passwd. Each option fills one of the seven fields.

Files and Directories That Appeared This Week

PathWhatWhat to remember
/etc/passwdBasic account info7 fields, readable by anyone
/etc/shadowEncrypted passwords and expiry policy9 fields, only root can read
/etc/groupGroup info4 fields, members separated by commas
/etc/sudoerssudo permission settingsEdit with visudo
/etc/skelDefault files copied into a new home directoryUsed by useradd -m
/etc/login.defsDefaults for UID range and password policy
/sbin/nologinA shell that blocks loginField ⑦ of system accounts
/home/userA regular user's home~
/rootroot's homeDifferent from / (the root directory)

Separating the "Finding" Commands from the "Asking" Commands

What you want to knowCommand
Where are the files matching conditionsfind path conditions
Quickly find by name alonelocate name (refresh the index with updatedb)
Is that text inside the filegrep pattern file
Where is the executable of this commandwhich command
The executable plus even the manual locationwhereis command
Is this name a builtin or an aliastype command
The usage of this commandman command, command --help
What this command is in one linewhatis command
Which command does this kind of jobapropos keyword
Who am Iwhoami, id
Who is connectedwho, w

What You Must Be Able to Read Right Off the Screen

[root@www ~]# ls -l /etc/passwd /tmp -d
-rw-r--r--.  1 root root 2104 Sep  3 09:00 /etc/passwd
drwxrwxrwt. 12 root root 4096 Sep  3 09:10 /tmp
SlotHow to read it
root · # in the promptLogged in as root. It would be $ for a regular user
~ in the promptThe current location is the home directory (/root, since it's root)
- / d at the start of the lineRegular file / directory (l link, b block device, c character device)
The number 1 / 12Hard link count
root rootOwner / owning group
2104Size (bytes). With -h it looks like 2.1K
Sep 3 09:00Last modified time
KeyResult
Ctrl + CEnds the running command
Ctrl + ZSuspends the command (it hasn't ended)
Ctrl + DSignals the end of input / logs out at an empty prompt
TabAuto-complete; press twice for a list of candidates
qQuit man and less

Contrasting Easily Confused Pairs

ComparisonABDeciding criterion
find vs grepFinds filesFinds contentsIs the target a file or a line
find vs locateDirect search, accurateIndex search, fastFreshness vs speed
cp -r vs mvNeeds -rDoesn't need -rHow directories are handled
rmdir vs rm -rEmpty onlyDeletes with contentsWhether it's OK with contents inside
cat vs lessDumps everythingPages throughFile length
head vs tailFirst 10 linesLast 10 linesWhich end
/etc/passwd vs /etc/shadowAccount info, anyonePasswords, root onlyRead permission
su vs sudoSwitch user, target's passwordOne command, your own passwordWhat you enter
su vs su -Keeps environmentSwitches the environment tooPresence of the hyphen
usermod -G vs -aGOverwritesAppendsPreserving existing groups
Hard link vs symbolic linkSame inodePath shortcutWhen the original is deleted

Commonly Missed Points

  1. You have to add -r to mv → No. mv simply moves directories too. -r is needed for cp and rm.
  2. find -name "*.txt" /home → The path comes first. find /home -name "*.txt".
  3. Adding a group with usermod -G → It wipes out the existing secondary groups. You must use -aG.
  4. UID 1 is root → It is 0.
  5. Deleting a non-empty directory with rmdir → It doesn't work. You must use rm -r.
  6. The password is in /etc/passwd → It is in /etc/shadow. The x in passwd is the marker for that.
  7. Your own password for su → It is the target account's password. Using your own is sudo.
  8. Hidden files are a separate attribute → No. Their name just starts with ..

Values That Appear on the Exam Exactly

ValueWhat
7Number of fields in /etc/passwd
:Delimiter of /etc/passwd
0root's UID
1000Where regular user UIDs start (500 on some distributions)
10Default line count of head and tail
xpasswd field 2 — marker that the password is in shadow

Next week is about permissions attached to files — we will cover rwx and octal, ownership, and special permissions.

📖 Glossary

  • Recursive : The action of walking through subdirectories. The -r/-R options.
  • Pager : A program that breaks long output into screen-sized pieces. less, more.
  • Pipe (|) : A symbol that passes the output of the previous command as the input of the next command.
  • UID / GID : Numbers that identify users and groups. UID 0 is root.
  • System account : An account for running daemons. Its login shell is usually /sbin/nologin.
  • Principle of least privilege : The security principle of giving only as much privilege as needed. It is the reason sudo is recommended.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which of the following commands does not need a recursive option when moving a directory?

Question 2

Which of the following commands finds a specific string in the file contents, not in file names?

Question 3

Which of the following commands deletes a non-empty directory along with its contents?

Question 4

What does the x in the second field of the /etc/passwd file mean?

Question 5

Which of the following commands switches users while also applying that user's environment variables and working directory?

Question 6

Which of the following commands prints only the first 5 lines of a file?

PreviousUser and Account ManagementWeek 3 · Day 4Next The Structure of Permissions: rwx and OctalWeek 4 · Day 1

Official references

  • Linux Master 2 official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • The Commands on One Page
  • Gathering the Meanings of Option Letters
  • Options That Split by Case
  • Practice Reading a Command Line to the End
  • Files and Directories That Appeared This Week
  • Separating the "Finding" Commands from the "Asking" Commands
  • What You Must Be Able to Read Right Off the Screen
  • Contrasting Easily Confused Pairs
  • Commonly Missed Points
  • Values That Appear on the Exam Exactly
  • Glossary
  • Practice Questions