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
  • Week 4
  • Week 5
  • Week 6
    • 1.The Three Modes of the vi Editor
    • 2.vi Search and Replace, and Other Editors
    • 3.Process Concepts and Types
    • 4.Process Commands and Job Scheduling
    • 5.Week 6 Comprehensive Review: Editors and Processes
  • 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 6/Day 5

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

Linux Master 2· AssociateWeek 6 · Day 5~16 min read

Day 5 - Week 6 Comprehensive Review: Editors and Processes

📌 Key Points

  • Only vi has modes. Command → i → insert, ESC → command, : → ex.
  • :%s/A/B/g — % is the whole file, g is everything within a line.
  • ps is one scene, top is real time. ps -ef (System V) / ps aux (BSD).
  • Signal 9 is forced, 15 is the default. For nice, -20 is the highest.
  • cron repeats (5 fields), at runs once.

Key Points Diagram

   Editors
     Line editors     ed · ex · sed
     Screen editors   vi(Bill Joy) · emacs(Stallman) · nano(pico improvement)
     Only vi has modes
 
     vi modes    command ──i a o──► insert ──ESC──► command ──:──► ex
     Save/quit   :w  :q  :wq  :q!(force)  ZZ
     Substitute  :%s/A/B/g        % whole file · g everything in a line
     Settings    ~/.vimrc (personal) · /etc/vimrc (global)
 
   Processes
     PID 1       init → systemd     ancestor of all processes
     Orphan      parent died first → PID 1 adopts it
     Zombie(Z)   ended but parent did not collect → disappears only when the parent is cleaned up
 
     Foreground ──Ctrl+Z──► stopped ──bg──► background
          ▲                                  │
          └──────────── fg ──────────────────┘
 
     Signals     1 HUP · 2 INT(Ctrl+C) · 9 KILL(forced) · 15 TERM(default)
     Priority    -20 ◄─ high ── 0 ── low ─► 19
 
   Scheduling
     cron  repeat  minute hour day month weekday   crontab -e
     at    once    at 22:00

Revisiting It Through Scenes

vi — Editing One Line of a Configuration File

Follow which mode you are in each time you press a key.

   What you press         What happens                              Mode
   ─────────────────────────────────────────────────────────────────────
   vi /etc/hosts          The file opens                            command
   /server1  Enter        Move to the line containing server1       command
   A                      Go to the end of that line and start input insert
    web1                  Characters are entered                    insert
   ESC                    Finish input                              command
   yy  p                  Copy that line and paste it below         command
   :s/web1/web2/  Enter   Change web1 to web2 on the pasted line    ex → command
   :set nu  Enter         Turn on line numbers to check             ex → command
   :wq  Enter             Save and quit                             ex
  • The only stretch spent in insert mode is from A to ESC. Everything else starts from command mode.
  • After p, the cursor is on the newly pasted line. That is why :s without a range changes only that line.
  • Search (/) and ex commands (:) are both entered on the bottom line of the screen, and when you press Enter you return to command mode.

Processes — Cleaning Up an Unresponsive Program

ps -ef | grep myapp          # ① check the PID and PPID
# user     3100    2314  5 10:10 pts/0    00:05:12 ./myapp
kill 3100                    # ② signal 15 (TERM) first — give it a chance to clean up
ps -p 3100                   # ③ see whether it is still there
kill -9 3100                 # ④ if it remains, signal 9 (KILL)
  • 15 first, 9 if that does not work. If you use 9 from the start, data that was being saved can be corrupted.
  • If the state in ① was Z (<defunct>), ② and ④ are useless. You must look at the PPID (here, 2314) side.
  • To end everything by name at once, use killall myapp; to have it merely yield instead of stopping it, use renice 10 -p 3100.

crontab Reading Practice

SettingMeaning
0 3 * * *Every day at exactly 3:00
30 3 * * 1Every Monday at 3:30
0 */2 * * *On the hour every 2 hours
*/15 * * * *Every 15 minutes
0 9 * * 1-59:00 on weekdays
0 3,15 * * *At 3:00 and 15:00
0 0 1 * *Midnight on the 1st of every month
0 0 1 1 *Midnight on January 1
* 3 * * *Every minute during the 3 o'clock hour — not "once at 3"
  • Point at minute, hour, day, month, weekday one field at a time from the left. A field with a number means "only then," and * means "every time."
  • Look first at whether the minute field is * or 0. Most traps are here.

Which Command for Which Situation

What you want to doCommand
View all processes onceps -ef or ps aux
See in real time what uses lots of CPUtop
Parent-child relationships as a treepstree
Find a PID by namepgrep
See the current shell's background jobsjobs
Terminate by PID / terminate by namekill / killall
Start with a lower prioritynice -n 10 command
Change the priority of something already runningrenice 10 -p PID
Keep running even after logoutnohup command &
Resume a stopped job in the background / foregroundbg / fg
Repeat periodicallycrontab -e
Once at a specified timeat time
List jobs / cancel a job (at)atq / atrm
List jobs / delete all (cron)crontab -l / crontab -r

Contrasting Easily Confused Pairs

CategoryABDistinguishing criterion
Line vs screen editorsed, exvi, emacs, nanoUnit it works on
vi vs emacsBill JoyRichard StallmanCreator
vi vs nanoHas modesNo modesCan you type right after launch?
i vs aBefore the cursorAfter the cursorInsertion position
o vs ONew line belowNew line aboveCase
dd vs yyCutCopyDoes the original remain?
:q vs :q!Refuses if there are changesForce quitExclamation mark
% vs gWhole fileEverything in a lineRange vs count
ps vs topPrints onceRefreshes in real timeWhether it refreshes
ps -ef vs ps auxSystem VBSD (no hyphen)Notation style
9 vs 15Forced, cannot be ignoredNormal termination request (default)Chance to wrap up
Ctrl+Z vs Ctrl+CStopTerminateCan it be revived?
Orphan vs zombieThe parent diedThe child diedWho died first
cron vs atRepeatsOnceNumber of runs
standalone vs inetdResident, fastWhen needed, saves memoryHow it waits

Commonly Missed Points

  1. Opening vi lets you type right away → No. It starts in command mode.
  2. :q can always exit → It is refused if you made edits. Use :q!.
  3. :s/A/B/ replaces everything → It replaces only the first one on that line. For the whole file use :%s/A/B/g.
  4. emacs and nano also have modes → They do not. Only the vi family has modes.
  5. ps -aux → The BSD style is ps aux without a hyphen.
  6. kill defaults to 9 → It is 15 (TERM). 9 must be specified explicitly.
  7. Kill a zombie with kill -9 → It is already dead, so that is useless. You must clean up the parent.
  8. The larger the nice value, the higher the priority → It is the opposite. -20 is the highest.
  9. The first crontab field is hour → It is minute. The order is minute, hour, day, month, weekday.
  10. at runs repeatedly → Only once. Repeating is cron.
  11. ZZ is an ex-mode command → You press it without a colon in command mode.
  12. N always searches upward → It is the opposite of the direction first searched. If you searched with ?, it goes downward.
  13. Pressing r enters insert mode → It changes one character and stays in command mode.
  14. The program ended with Ctrl+Z → It was only stopped. It remains in jobs as Stopped.
  15. Adding only nohup sends it to the background → No. You must use & together.
  16. The numbers for nice and renice mean the same thing → nice is the amount to add, and renice is the value itself.
  17. You give a PID to killall → You give it a process name. PIDs go with kill.
  18. crontab -r deletes one line → It deletes everything. To delete just one line, open with -e and edit.
  19. An orphan process is a dead process → It is alive and running. The dead one is the zombie.
  20. disable = no turns the service off → The opposite. It means enabled.

Values That Appear on the Exam as They Are

ValueWhat it is
3Number of vi modes
1 / 2 / 9 / 15SIGHUP / SIGINT / SIGKILL / SIGTERM
15The default signal of kill
-20 to 19Range of the nice value (default 0)
5Number of crontab fields
0 and 7Sunday in the crontab weekday field
1PID of init / systemd
ZZombie state indicator in ps
PersonWhat they created
Bill Joyvi, csh
Richard Stallmanemacs, GNU

Files at a Glance

FileOne-line role
~/.vimrcvim personal settings
/etc/vimrcvim global settings (/etc/vim/vimrc on the Debian family)
/etc/crontabSystem crontab — has one extra user field after the time fields
/var/spool/cron/Where per-user crontabs are stored
/etc/cron.allow · /etc/cron.denyPermit / forbid use of cron
/etc/at.allow · /etc/at.denyPermit / forbid use of at
/etc/xinetd.d/Per-service configuration files that xinetd handles
nohup.outThe file where the output of commands run with nohup accumulates

Save and Quit Keys at a Glance

EditorSaveQuitQuit without saving
vi:w:q:q!
emacsCtrl+X Ctrl+SCtrl+X Ctrl+CAnswer no to saving when quitting
nanoCtrl+OCtrl+XCtrl+X then N

Next week is software and devices. We cover package management such as RPM, YUM, DEB, and APT, plus printers, sound, and scanners.

📖 Glossary

  • Mode : The state by which vi distinguishes input from commands. There are three: command, insert, and ex.
  • Zombie process : A process that has terminated but remains in the table because the parent has not collected it.
  • Signal : A notification sent to a process. Delivered with kill, and the default is 15.
  • nice value : Process priority. The smaller, the higher, and the range is -20 to 19.
  • cron / at : A recurring scheduling tool / a one-time scheduling tool.
  • standalone / inetd : The method of keeping a daemon resident / the method of launching it on request.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which of the following commands copies the line the cursor is on in the vi editor?

Question 2

Which of the following is the signal delivered by default when the kill command is used without a signal number?

Question 3

Which of the following is a process whose parent terminated first and which is adopted by the PID 1 process?

Question 4

Which of the following is the crontab setting that runs a job every day at 3 AM?

Question 5

Which of the following is an editor that has distinct editing modes?

Question 6

Which of the following is the BSD-style ps notation that also shows a process's CPU and memory usage?

PreviousProcess Commands and Job SchedulingWeek 6 · Day 4Next Package Management (1): RPM and YUMWeek 7 · Day 1

Official references

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

On this page

  • Key Points
  • Key Points Diagram
  • Revisiting It Through Scenes
  • vi — Editing One Line of a Configuration File
  • Processes — Cleaning Up an Unresponsive Program
  • crontab Reading Practice
  • Which Command for Which Situation
  • Contrasting Easily Confused Pairs
  • Commonly Missed Points
  • Values That Appear on the Exam as They Are
  • Files at a Glance
  • Save and Quit Keys at a Glance
  • Glossary
  • Practice Questions