Ravindra BagaleCourses & study guides मराठी Track your progress

Guides

systemctl और journalctl से Troubleshooting कैसे करें

Amazon Linux/Ubuntu पर systemctl और journalctl से service troubleshoot।

Friends, never restart blind. Chala mitrano — status, logs, then restart.

Quick answer

Hold this vertical picture:

  1. status पहले।
  2. journalctl -u।
  3. मूल कारण।
  4. reload/restart।
  5. verify।

Language: English · मराठी · हिंदी

systemctl statusSee failed? journalctl -uRead why Fix config/diskRoot cause restart / reloadBring back verifycurl or ss
Service down path

systemctl और journalctl क्यों

EC2 पर दिल्ली customer site के लिए nginx 1 बजे गिरे तो guess समय बर्बाद। systemd status देता है; journal कारण।

Why: Structured control। What: is-active, status, journalctl, safe restart। How: Lab VM पर card अभ्यास।

Concept 1: State पूछें

Why: active/failed शब्द चाहिए। What: is-active, status, --failed। How: हर outage यहाँ शुरू।

Example 1: Is service active?

Type this:

systemctl is-active nginx 2>/dev/null || echo inactive-or-missing

You will see:

inactive-or-missing

What it means: active / inactive / failed are the words to learn.

Example 2: Full status

Type this:

systemctl status nginx --no-pager -l 2>&1 | head -n 5 || true

You will see:

Unit nginx.service could not be found.
...

What it means: Status shows load state and last lines.

Example 3: List failed

Type this:

systemctl --failed --no-pager

You will see:

0 loaded units listed
...

What it means: Start triage with --failed on big hosts.

Concept 2: Journal पढ़ें

Why: Status error line छुपाता है। What: journalctl -u, -b, -p, -f। How: Unit पर filter।

Example 4: Unit logs

Type this:

journalctl -u nginx -n 20 --no-pager 2>&1 | head -n 5 || true

You will see:

-- No entries --
...

What it means: -u selects one unit.

Example 5: Since boot

Type this:

journalctl -b -p err --no-pager 2>&1 | head -n 3 || true

You will see:

-- No entries --
...

What it means: -p err filters priority.

Example 6: Follow mind-set

Type this:

printf '%s\n' 'journalctl -u nginx -f   # Ctrl+C to stop'

You will see:

journalctl -u nginx -f   # Ctrl+C to stop

What it means: -f follows like tail -f.

Concept 3: सुरक्षित restart

Why: Blind restart loop कर सकता है। What: restart vs reload; is-enabled। How: पहले कारण ठीक करें।

Example 7: Restart safely

Type this:

printf '%s\n' 'sudo systemctl restart nginx' 'sudo systemctl is-active nginx'

You will see:

sudo systemctl restart nginx
sudo systemctl is-active nginx

What it means: Restart only after reading logs.

Example 8: Reload vs restart

Type this:

printf '%s\n' 'reload = pick new config if supported' 'restart = stop then start'

You will see:

reload = pick new config if supported
restart = stop then start

What it means: Prefer reload for nginx config when possible.

Example 9: Enable on boot

Type this:

systemctl is-enabled nginx 2>/dev/null || echo disabled-or-missing

You will see:

disabled-or-missing

What it means: enabled means starts at boot.

Concept 4: Distro + card

Why: Amazon Linux और Ubuntu दोनों systemd। What: same commands; outage card। How: पाँच कदम बोलें।

Example 10: Amazon Linux note

Type this:

printf '%s\n' 'Amazon Linux 2023 uses systemd' 'journalctl same as Ubuntu'

You will see:

Amazon Linux 2023 uses systemd
journalctl same as Ubuntu

What it means: Commands transfer across both.

Example 11: Permission tip

Type this:

printf '%s\n' 'Need logs as normal user? ask for systemd-journal group'

You will see:

Need logs as normal user? ask for systemd-journal group

What it means: Do not use world-writable modes on journals.

Example 12: Outage card

Type this:

printf '%s\n' '1 status 2 journalctl -u 3 fix config 4 restart 5 verify curl'

You will see:

1 status 2 journalctl -u 3 fix config 4 restart 5 verify curl

What it means: Say this card in Infosys interviews.

Outage card

  1. status
  2. journalctl -u
  3. fix
  4. restart
  5. verify

Accenture Ubuntu

Config duplicate listen। Fix + reload।

Ravindra Bagale's Tip

On Amazon Linux 2023 and Ubuntu used across TCS and Accenture projects, systemd is the service manager. Learn is-active, status, journalctl -u and safe restart.

Check yourself (quiz)

Q1. Unit logs?

journalctl -u NAME

Q2. reload vs restart?

reload config; restart stop/start।

Q3. Blind restart क्यों नहीं?

वही failure loop।

Q4. systemd कहाँ?

Amazon Linux 2023 और Ubuntu।

Q5. Outage order?

status → logs → fix → restart → verify।

Reading tracking

Mark this guide when you finish. Your browser remembers it on this device.

status → journalctl → fix → restart → verify। Did you understand? Let us try it once more.

Frequently asked questions

Command for unit logs?

journalctl -u NAME

reload vs restart?

reload picks new config if supported; restart stops then starts.

Why not blind restart?

You may loop the same failure.

Where is systemd used?

Amazon Linux 2023 and Ubuntu among others.

Interview outage order?

status → logs → fix → restart → verify.

How to list failed units?

systemctl --failed