-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathLinuxTOC.txt
More file actions
7078 lines (4425 loc) · 250 KB
/
LinuxTOC.txt
File metadata and controls
7078 lines (4425 loc) · 250 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
https://www.baeldung.com/linux/
Week 1: Linux Basics & Networking Foundations (RHEL 9)
Objective: Build foundational Linux and networking skills.
Week 1 can be reduced to 3-day course
Start with Notes-old.txt
------------------------
Day 1: Introduction to Linux
• What is Linux? History and distributions (RHEL 9, Ubuntu 24.04, Fedora)
--------------------------------------------------------------------------------
Linux
free and
open-source
operating system
based on the Unix operating system.
Powerful,
secure, and
flexible OS
widely used for
servers,
desktops,
mobile devices, and
embedded systems.
At its core is the Linux kernel, originally created by Linus Torvalds in 1991.
History of Linux
----------------
1969–1980s: Unix Origins
Unix was developed at Bell Labs and became popular for its portability, multitasking, and multi-user capabilities. However, it was proprietary.
1983: GNU Project
-----------------
Richard Stallman started the GNU Project to create a free Unix-like OS. Many components were developed (like compilers and shells), but a kernel was missing.
1991: Linux Kernel Released
---------------------------
Linus Torvalds, a Finnish student, wrote a new kernel and released it under the GNU General Public License (GPL). The combination of the Linux kernel and GNU tools formed a full operating system.
1990s–2000s: Rapid Growth
-------------------------
Linux gained traction among developers, hobbyists, and eventually enterprise users due to its reliability and cost-effectiveness.
What is a Linux Distribution?
-----------------------------
A Linux distribution (distro)
complete operating system
built around the Linux kernel,
may include
package managers,
graphical interfaces,
utilities, and
applications.
Each distro may focus on different goals:
user-friendliness,
performance,
stability, or
cutting-edge features.
Popular Linux Distributions
---------------------------
1. Red Hat Enterprise Linux (RHEL 9)
Developer:
Red Hat (now part of IBM)
Release:
RHEL 9 launched in May 2022
Use case:
Enterprise environments,
servers,
cloud infrastructure
Key features:
Stable and secure
Long-term support (10+ years)
Subscription-based with professional support
SELinux integration (advanced security)
Uses dnf for package management (RPM packages)
Certified for enterprise software (Oracle, SAP, etc.)
2. Ubuntu 24.04 LTS ("Noble Numbat")
Developer: Canonical Ltd.
Release:
April 2024
Use case:
Desktops,
servers,
cloud,
IoT
Key features:
Long-Term Support (LTS):
5 years of updates
Based on Debian
Uses apt for package management (DEB packages)
User-friendly with GUI options like GNOME
Widely used in education, web hosting, and development
3. Fedora (e.g., Fedora 40)
Developer:
Fedora Project (sponsored by Red Hat)
Use case:
Developers, open-source enthusiasts, desktop users
Key features:
Cutting-edge features and software
Community-driven and freely available
Shorter lifecycle (about 13 months)
Often a testing ground for RHEL features
Uses dnf (RPM-based like RHEL)
Comparison Table
-------------------------------------------------------------------------------
Feature RHEL 9 Ubuntu 24.04 LTS Fedora (e.g., 40)
-------------------------------------------------------------------------------
Based on Red Hat (RPM) Debian (DEB) Red Hat (RPM)
Release Type Stable, enterprise-grade Stable (LTS) Bleeding-edge
Package Manager dnf (RPM) apt (DEB) dnf (RPM)
GUI Option GNOME (default) GNOME (default), others GNOME (default), others
Target Users Enterprises General users, devs Developers, enthusiasts
Support Cycle ~10 years (with support) 5 years (LTS) ~13 months
License Subscription-based Free and open-source Free and open-source
-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
• Linux vs. Windows, cloud context (AWS EC2)
--------------------------------------------------------------------------------
Linux vs. Windows in a cloud context, especially for AWS EC2 (Elastic Compute Cloud):
☁️ Linux vs. Windows on AWS EC2
Feature/Aspect Linux Windows
Cost Free or low cost (license-free) Higher cost (Windows license fees apply)
Boot Time Fast Slower
Resource Usage Low memory and CPU overhead Higher system resource consumption
Instance Availability Widely available (Amazon Linux, Ubuntu, RHEL, etc.) Available but limited to certain AMIs
Security Strong, customizable (SELinux, iptables, etc.) Secure but closed-source; patch management is critical
SSH Access Native, easy setup Requires RDP setup
File System ext4, XFS, etc. NTFS
Customization Highly customizable More rigid, registry-based configuration
CLI (Command Line) Powerful and scripting PowerShell (advanced but different syntax)
Use Cases Web servers, containers, big data, dev/test Windows-native apps (.NET, IIS, Active Directory)
Software Ecosystem Open-source, flexible (Nginx, Apache, MySQL, etc.) Microsoft ecosystem (IIS, SQL Server, Exchange)
Automation Tools Ansible, Terraform, , cloud-init PowerShell DSC, Chocolatey, AWS Systems Manager
Market Share (AWS) ~70–75% of EC2 workloads run on Linux-based AMIs ~25–30% run on Windows-based AMIs
When to Use Linux on AWS
Best for:
Web apps (Nginx, Apache)
Containers (Docker, Kubernetes)
DevOps and automation
Python, Node.js, Java apps
High-performance computing (HPC)
Cost-sensitive workloads
Popular Linux AMIs:
Amazon Linux 2023
Ubuntu 24.04 LTS
RHEL 9
SUSE Linux Enterprise Server
Debian 12
When to Use Windows on AWS
Best for:
Applications built on .NET or ASP.NET
Microsoft SQL Server
top apps (RDP use)
Active Directory domain controllers
Legacy Windows workloads
Common Windows AMIs:
Windows Server 2019/2022 Base
Windows Server with SQL Server
Windows Server with Containers
Cost Example (as of 2025)
t3.micro Linux EC2 (Amazon Linux):
~$0.0104/hour (on-demand) – no OS license fee
t3.micro Windows EC2:
~$0.0200/hour (on-demand) – includes Windows license
Summary
Use Case Best Choice
Cost-effective, open-source stack Linux
Microsoft-based enterprise stack Windows
DevOps automation, containers Linux
RDP access to desktop apps Windows
SQL Server + IIS hosting Windows
Would you like help launching an EC2 instance with a specific OS, or automating setup with a tool like Terraform or Ansible?
--------------------------------------------------------------------------------
• Installation: RHEL 9 in VirtualBox or WSL2
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
• Shell basics: whoami, date, man, clear
--------------------------------------------------------------------------------
1. whoami — "Who am I?"
Description:
The whoami command shows the username of the current user.
Why is it useful?
When working on a system (especially remote servers), you might want to verify which user account you're currently using.
Syntax:
whoami
Example Output:
john
Related Commands:
id – Shows more details like UID, GID, and groups.
who – Shows who is logged into the system.
🔹 2. date — Show the current date and time
📌 Description:
Displays the current date, time, and timezone information. Can also be used to format or set system time (admin privileges required for setting).
✅ Basic Usage:
date
Example Output:
Thu Jul 24 22:12:08 IST 2025
🛠️ Formatting Examples:
Display only the date:
date +"%Y-%m-%d"
# Output: 2025-07-24
Display only the time:
date +"%H:%M:%S"
# Output: 22:12:08
Custom format with day:
date +"%A, %d %B %Y"
# Output: Thursday, 24 July 2025
🔧 Set the system date (admin only):
sudo date --set="25 July 2025 10:00:00"
📖 Full formatting options:
GNU date format specifiers
🔹 3. man — Manual pages
📌 Description:
The man command lets you view the manual (help documentation) for any Linux command.
✅ Basic Usage:
man command_name
Example:
man ls
This opens the manual for the ls command.
🔎 Navigation:
Space – Scroll down
b – Scroll up
/pattern – Search for "pattern"
n – Next search result
q – Quit
📘 Sections of man:
Manuals are divided into sections like:
Section Content
1 User commands
5 File formats and configuration
8 System administration
For example:
man 5 passwd
Shows the config file format of /etc/passwd.
4. clear — Clear the terminal
Description:
This command clears the terminal screen, making it clean and readable.
Usage:
Same as pressing Ctrl+L in most terminals.
Technical Note:
It just moves the terminal content up by sending ANSI escape sequences; it does not delete the command history.
Summary Table
Command Purpose Example
whoami Show current user whoami
date Show or set system date/time date +"%d/%m/%Y"
man View command manuals man ls, man 5 passwd
clear Clear terminal screen clear
--------------------------------------------------------------------------------
Lab: Install RHEL 9, navigate terminal.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Day 2: Filesystem and File Management
• Filesystem hierarchy: /etc, /var, /usr, /home
--------------------------------------------------------------------------------
Refer "The Hierarchy of the File System" section in Notes-old
--------------------------------------------------------------------------------
• Commands: ls, pwd, cd, file, mkdir, touch, cp, mv, rm, find
--------------------------------------------------------------------------------
find
https://www.geeksforgeeks.org/linux-unix/find-command-in-linux-with-examples/
ls, pwd, cd, file, mkdir, touch, cp, mv, rm, find
--------------------------------------------------------------------------------
• Wildcards: *, ?, relative vs. absolute paths
Lab: Create directories, manage files.
--------------------------------------------------------------------------------
*, ?, relative vs. absolute paths
Create directories, manage files
--------------------------------------------------------------------------------
Day 3: Permissions and Essential Commands
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
• Permissions: rwx, chmod, chown (RHCSA 4.14)
--------------------------------------------------------------------------------
Permissions: rwx, chmod, chown
--------------------------------------------------------------------------------
• Viewing files: cat, less, more, head, tail
--------------------------------------------------------------------------------
cat, less, more, head, tail
--------------------------------------------------------------------------------
• I/O: stdin, stdout, stderr, pipes, redirection (RHCSA 4.7)
--------------------------------------------------------------------------------
I/O: stdin, stdout, stderr, pipes, redirection
--------------------------------------------------------------------------------
• Monitoring: top, htop, vmstat, journalctl
--------------------------------------------------------------------------------
I/O: stdin, stdout, stderr, pipes, redirection
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
https://swac.blog/the-essential-guide-to-linux-system-monitoring-with-top-htop-and-vmstat/
1. top: The Classic Process Monitor
top (table of processes) is a traditional, powerful, and real-time command-line utility that provides a dynamic view of running processes. It displays information about CPU and memory usage, process ID (PID), user, and much more.
1.1 Basic Usage and Output Explained
Just type top in your terminal and press Enter.
top - 09:30:01 up 2 days, 16:30, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 200 total, 1 running, 199 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7987.9 total, 7000.0 free, 500.0 used, 487.9 buff/cache
MiB Swap: 4096.0 total, 4096.0 free, 0.0 used. 7200.0 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 169420 9980 6720 S 0.0 0.1 0:15.23 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.04 kthreadd
... (more processes)
Understanding the Output Sections:
Header (First 5 lines):
Line 1 (System Summary):
top - HH:MM:SS: Current system time.
up X days, Y hours/minutes: System uptime.
Z users: Number of users currently logged in.
load average: L1, L5, L15: Average number of processes waiting to run over the last 1, 5, and 15 minutes. High numbers indicate a busy system.
Line 2 (Tasks/Processes):
total: Total number of processes.
running: Number of processes currently executing.
sleeping: Processes waiting for an event (e.g., I/O).
stopped: Processes that have been stopped (e.g., by Ctrl+Z).
zombie: Zombie processes (terminated but parent hasn't reaped them; indicates a problem).
Line 3 (CPU Usage): Percentages of CPU time spent in various states.
us: User CPU time (processes running in user space).
sy: System CPU time (kernel operations).
ni: Nice CPU time (user processes with modified priority).
id: Idle CPU time.
wa: I/O Wait time (CPU waiting for disk or network I/O).
hi: Hardware Interrupts.
si: Software Interrupts.
st: Steal time (relevant in virtualized environments where CPU is "stolen" by the hypervisor).
Line 4 (Memory Usage - Physical RAM):
total: Total physical memory.
free: Unused memory.
used: Memory actively used by processes.
buff/cache: Memory used by kernel buffers and page cache (can be freed if needed).
Line 5 (Swap Usage):
total: Total swap space.
free: Unused swap space.
used: Used swap space.
avail Mem: Estimated available memory for new applications (free + reclaimable buff/cache).
Process List (Table):
PID: Process ID.
USER: User who owns the process.
PR: Priority (kernel-assigned).
NI: Nice value (user-assigned priority; lower is higher priority).
VIRT: Virtual memory used by the process (including swap and shared libraries).
RES: Resident Set Size (physical memory actually used by the process, not swapped out). This is a key metric for memory usage.
SHR: Shared memory (memory shared with other processes).
S: Process Status (S=sleeping, R=running, Z=zombie, T=stopped).
%CPU: Percentage of CPU time used since the last update.
%MEM: Percentage of total physical memory used.
TIME+: Total CPU time used by the task since it started.
COMMAND: The command name or command line of the process.
1.2 Interactive Commands within top
While top is running, you can press several keys to interact with it:
q: Quit top.
k: Kill a process (prompts for PID, then signal, e.g., 9 for KILL).
r: Renice a process (change its nice value/priority).
d or s: Change the update delay (in seconds).
z: Toggle color/bold mode.
b: Toggle bold highlighting of running processes.
x: Highlight sort column.
y: Highlight running tasks.
1: Toggle display of individual CPU cores.
m: Toggle memory display modes (percent, absolute, etc.).
P: Sort by %CPU (default).
M: Sort by %MEM.
T: Sort by TIME+.
u: Filter by user (prompts for username).
h or ?: Display help screen.
1.3 Running top with Options
You can also start top with command-line options:
top -d 2: Update every 2 seconds.
top -u username: Show processes for a specific user.
top -p PID: Monitor a specific process by PID.
top -n 1: Run once and exit (useful in scripts).
Example: Monitor the httpd process (assuming its PID is 12345):
top -p 12345
2. htop: The Enhanced Interactive Process Viewer
htop is an interactive, real-time process viewer that is an enhancement over top. It offers a more user-friendly interface, easier navigation, and more features. It's not usually installed by default on RHEL, but it's highly recommended.
2.1 Installation
sudo dnf install htop -y
2.2 Basic Usage and Output Explained
Just type htop in your terminal and press Enter.
CPU[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||50.0%]
Mem[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||600M/7.94G]
Swp[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||0K/4.00G]
Tasks: 60, 0 thr; 1 running
Load average: 0.00 0.01 0.05
Uptime: 2 days, 16:30:01
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1 root 20 0 169M 9.9M 6.7M S 0.0 0.1 0:15.23 /sbin/init
...
Key Improvements over top:
Visual CPU/Memory Meters: Clear, colored bar graphs for CPU, Memory, and Swap usage at the top.
Scrollable Process List: You can scroll up and down the process list using arrow keys.
Tree View: Press F5 to toggle a tree view, showing parent-child relationships between processes. This is incredibly useful for understanding process hierarchies.
Function Keys (F1-F10): Common actions are mapped to function keys at the bottom of the screen, making it much more intuitive.
Mouse Support: You can click on columns to sort, or on processes to select them.
2.3 Interactive Commands within htop
F1 or h: Help screen.
F2: Setup (customize what's displayed, meters, columns, colors).
F3: Search for a process.
F4: Filter processes by text.
F5: Tree view / flat view toggle.
F6: Sort by a different column.
F7: Nice - (increase priority, make it less nice).
F8: Nice + (decrease priority, make it nicer).
F9: Kill process (select process, then choose signal).
F10 or q: Quit htop.
Spacebar: Tag (select) multiple processes for batch operations.
u: Filter by user.
K: Toggle kernel threads.
H: Toggle user threads.
Example: Find all httpd processes, view them in a tree, and then kill one:
Type htop.
Press F3, type httpd, and press Enter.
Press F5 to see the hierarchy.
Navigate to the process you want to kill using arrow keys.
Press F9, select 9 SIGKILL, and press Enter.
3. vmstat: Virtual Memory Statistics
vmstat (virtual memory statistics) is a versatile command-line utility used to report information about processes, memory, paging, block I/O, traps, and CPU activity. It's particularly useful for diagnosing memory bottlenecks and overall system activity.
3.1 Basic Usage and Output Explained
vmstat without any options gives a single snapshot of average statistics since boot.
vmstat
Output:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 7000000 4879000 5000000 0 0 0 0 100 200 0 0 99 0 0
Understanding the Columns:
procs (Processes):
r: Number of processes waiting for CPU time (running or runnable). High r values indicate a CPU bottleneck.
b: Number of processes in uninterruptible sleep (waiting for I/O, often disk). High b values indicate an I/O bottleneck.
memory:
swpd: Amount of virtual memory used (swap space).
free: Amount of idle memory.
buff: Amount of memory used as buffers (for block devices).
cache: Amount of memory used as cache (for file system reads).
swap:
si: Amount of memory swapped in from disk (kb/s).
so: Amount of memory swapped out to disk (kb/s). High values here indicate heavy swapping, which points to a memory shortage.
io (Input/Output):
bi: Blocks received from a block device (e.g., disk reads) (blocks/s).
bo: Blocks sent to a block device (e.g., disk writes) (blocks/s).
system:
in: Number of interrupts per second.
cs: Number of context switches per second. High values can indicate high process activity.
cpu: (Similar to top's CPU line)
us: User time.
sy: System time.
id: Idle time.
wa: I/O Wait time.
st: Steal time.
3.2 Running vmstat with Options
vmstat is most useful when run in a continuous monitoring mode.
vmstat 1: Update every 1 second (continuous).
vmstat 1 5: Update every 1 second, but only 5 times.
vmstat -s: Display a table of event counters and memory statistics.
vmstat -a: Display active/inactive memory.
vmstat -d: Display disk statistics.
vmstat -p /dev/sda1: Display detailed partition statistics for /dev/sda1.
Example: Continuous monitoring of CPU and Memory every 2 seconds:
vmstat 2
Look for:
High r (processes waiting for CPU)
High b (processes waiting for I/O)
Significant si and so (swapping)
High wa in CPU (I/O wait)
These patterns can quickly point you to CPU, memory, or disk bottlenecks.
4. journalctl: Systemd Journal Logs
journalctl is the command-line utility used to query and display messages from the systemd journal. The journal is a centralized logging system introduced with systemd in modern Linux distributions like RHEL, replacing fragmented log files (like /var/log/messages, syslog, auth.log, etc.).
4.1 Basic Usage and Output Explained
Just type journalctl in your terminal.
journalctl
This will display all log messages from the oldest to the newest, which can be a very long output. It uses a pager (like less), so you can scroll, search, and navigate.
4.2 Important journalctl Options
journalctl -b:
Show logs from the current boot. This is one of the most frequently used options.
journalctl -b -1:
Show logs from the previous boot. (-b -2 for the boot before that, etc.).
journalctl -f:
Follow the journal in real-time (like tail -f). This is excellent for live debugging.
journalctl -u <unit_name>:
Show logs for a specific systemd unit (service).
Example: journalctl -u httpd.service (for Apache web server)
Example: journalctl -u sshd.service (for SSH daemon)
journalctl --since "YYYY-MM-DD HH:MM:SS": Show logs since a specific date/time.
journalctl --until "YYYY-MM-DD HH:MM:SS": Show logs up to a specific date/time.
journalctl --since "today" --until "now": Show today's logs.
journalctl --since "1 hour ago": Show logs from the last hour.
journalctl -p <priority>: Filter by message priority (e.g., emerg, alert, crit, err, warning, notice, info, debug).
Example: journalctl -p err -b (Show errors from current boot).
Example: journalctl -p warning -f (Follow warnings in real-time).
journalctl -k: Show only kernel messages.
journalctl -x: Add explanations to some log messages.
journalctl -n <num>: Show only the last num log entries. (Default is 10).
journalctl --disk-usage: Show how much disk space the journal logs are consuming.
4.3 Combining Options and Filtering
You can combine journalctl options for powerful filtering.
Examples:
Monitor Apache errors in real-time:
journalctl -u httpd.service -p err -f
See all warnings and errors from the previous boot:
journalctl -b -1 -p warning..err
(Note: warning..err means priority warning and higher, i.e., warning, err, crit, alert, emerg)
View kernel messages from the last 24 hours related to USB:
journalctl -k --since "24 hours ago" | grep -i usb
Check audit log denials (often redirected to journal):
journalctl -p err | grep "denied"
# Or specifically for SELinux (if auditd is sending to journal):
journalctl _COMM=auditd -g "AVC denied"
4.4 Journal Persistence
By default, the systemd journal might be volatile (stored in /run/log/journal/) and lost on reboot. To make it persistent (store logs across reboots in /var/log/journal/), you need to create the directory:
sudo mkdir -p /var/log/journal
sudo systemctl restart systemd-journald
The journal will then automatically start saving logs to this persistent location.
--------------------------------------------------------------------------------
Lab: Set permissions, redirect output.
Day 4: Networking Foundations
• Network types: LAN, WAN, SD-WAN (Basics Networking 1.1)
--------------------------------------------------------------------------------
https://www.youtube.com/watch?v=NyZWSvSj8ek
https://www.youtube.com/watch?v=R5TV6lO3-1M
https://www.youtube.com/watch?v=o5uWsnzqr18
-------------------------------------------------------------------------------------------------------------------------------
Comparison Table: LAN vs. WAN vs. SD-WAN
-------------------------------------------------------------------------------------------------------------------------------
Feature |LAN (Local Area Network) |WAN (Wide Area Network) |SD-WAN (Software-Defined WAN)
-------------------------------------------------------------------------------------------------------------------------------
Geographic |Small (single building, campus)| Large (cities, countries, global) |Large (global, connects distributed LANs)
Scope | | |
Ownership |Typically private |Private (devices/routers), |Private (management), uses mix of
| (single organization) | but relies on |private/public infrastructure
| | public/leased infrastructure |
Data Rates |Very High |Moderate to High (varies, |High (optimizes utilization
| (1Gbps, 10Gbps, 100Gbps | historically slower than LAN) | of available links)
| typical) | |
Latency/Errors |Low latency, very |Higher latency, higher error rates |Optimized for lower latency,
| low error rates | | robust against errors/loss
Primary Devices |Switches, Access Points, |Routers, Modems, Firewalls |SD-WAN Edge Appliances,
| End Devices | | Centralized Orchestrator
Core Concept |Interconnects devices in |Connects geographically |Centralized, software-driven management
| a confined area | dispersed LANs | & optimization of WAN links
Technology |Ethernet, Wi-Fi | MPLS, Leased Lines, Internet VPNs |Policy-based routing, VPNs, Application-aware
Focus | | |routing, Orchestration
Management |Device-by-device configuration | Router-by-router configuration, |Centralized, automated, single pane of glass
| (switches, APs) | complex to manage at scale |
Cost |Relatively low hardware cost |High cost for dedicated lines |Potential cost savings by leveraging broadband,
| for high speed | (MPLS); variable for | operational efficiency
| | Internet VPNs |
Security |Managed internally, |Edge firewalls, VPNs for tunnels |Integrated security, automated VPNs,
| firewalls at perimeter | | segmentation
----------------|-------------------------------|---------------------------------------|----------------------------------------
1. LAN (Local Area Network)
A Local Area Network (LAN) is a computer network that interconnects computers within a limited geographical area, such as a home, school, laboratory, university campus, or office building. LANs are characterized by their high data transfer rates and their relatively small geographic footprint.
1.1 Key Characteristics
Limited Geographic Scope: Typically covers a single building or a small cluster of buildings.
High Data Transfer Rates: Data transfer speeds are generally high, ranging from 10 Mbps (older) to 1 Gbps, 10 Gbps, or even 100 Gbps (modern enterprise LANs).
Private Ownership: Usually owned and managed by a single organization or individual.
Fewer Errors: Lower error rates due to shorter distances and controlled environments.
Technologies: Primarily uses Ethernet (wired) and Wi-Fi (wireless).
Devices: Computers, servers, printers, smartphones, IoT devices.
Networking Hardware: Switches, hubs (obsolete), wireless access points (APs).
1.2 How a LAN Works
At its core, a LAN allows devices to communicate with each other.
Physical Medium: Devices are connected via Ethernet cables (e.g., Cat5e, Cat6) or wirelessly via Wi-Fi signals.
Switches: In a modern LAN, an Ethernet switch is the central device.
It learns the MAC addresses of devices connected to its ports.
When a device sends a frame, the switch forwards it only to the specific port where the destination device is connected, minimizing unnecessary traffic.
Switches create separate collision domains for each port, eliminating collisions common in older hub-based networks.
Switches operate at Layer 2 (Data Link Layer) of the OSI model.
IP Addressing: Devices in a LAN are typically assigned IP addresses within the same subnet (e.g., 192.168.1.x). This allows them to communicate using IP.
Routers (for Internet Access): While a router is not strictly part of the LAN for internal communication, it is essential for connecting the LAN to the wider internet (a WAN). The router acts as the default gateway for all devices in the LAN.
Broadcast Domains: A LAN is typically a single broadcast domain by default. However, VLANs (Virtual LANs) can be used on switches to logically segment a single physical LAN into multiple smaller broadcast domains, improving security and manageability.
1.3 Components of a LAN
End Devices: Computers, laptops, servers, printers, VoIP phones, security cameras, smart TVs, etc.
Network Interface Cards (NICs): Hardware in each device to connect to the network (Ethernet ports or Wi-Fi adapters).
Cabling: Ethernet cables (twisted pair, fiber optic for backbone).
Switches: Connect devices within the LAN and forward data frames.
Wireless Access Points (APs): Allow wireless devices to connect to the wired LAN.
Routers: Connect the LAN to other networks (e.g., the Internet, other WANs).
1.4 Advantages of LANs
Resource Sharing: Share files, printers, internet connections, and applications among users.
Centralized Data: Easier to manage data centrally on servers.
Security: Easier to secure data within a confined network.
Cost-Effective: Sharing resources reduces overall hardware and software costs.
High Speed: Fast data transfer for local operations.
2. WAN (Wide Area Network)
A Wide Area Network (WAN) is a telecommunications network that extends over a large geographical area, such as across cities, states, or even countries. WANs are used to connect multiple LANs together, allowing organizations to link their distributed branches, or for individuals to connect to the internet.
2.1 Key Characteristics
Broad Geographic Scope: Covers vast distances, connecting geographically separated LANs.
Lower Data Transfer Rates (Historically): Traditionally slower than LANs, though modern WAN technologies (like fiber optics, high-speed leased lines) offer very high speeds.
Public/Leased Infrastructure: Typically relies on public telecommunication carriers (ISPs, telcos) for infrastructure (e.g., leased lines, MPLS, Internet VPNs).
Higher Latency & Error Rates: Due to longer distances and reliance on public infrastructure.
Technologies: MPLS, Fibre Channel over Ethernet (FCoE), various types of leased lines (T1/E1, OC-3, DS3), broadband internet, VPNs.
Networking Hardware: Routers are primary devices, along with modems, firewalls, and specialized WAN equipment (e.g., CSU/DSU for T1 lines).
2.2 How a WAN Works
WANs function by using different technologies to transmit data over long distances.
Routers: Routers are the fundamental building blocks of WANs. They connect different LANs to the WAN and are responsible for forwarding IP packets between networks based on IP addresses. Routers operate at Layer 3 (Network Layer) of the OSI model.
Service Providers: Organizations typically lease connectivity from telecommunication service providers (ISPs). These providers own the extensive infrastructure (fiber optic cables, satellites, microwave links, etc.) that spans large areas.
Connection Types:
Leased Lines: Dedicated, point-to-point connections (e.g., T1/E1, DS3). Provide guaranteed bandwidth but can be expensive.
MPLS (Multiprotocol Label Switching): A high-performance WAN technology that directs data from one network node to the next based on short path labels rather than long network addresses, improving speed and flexibility.
Broadband Internet (DSL, Cable, Fiber): Cost-effective for smaller branches, but offers variable performance and security requires VPNs.
VPNs (Virtual Private Networks): Create secure, encrypted tunnels over a public network (like the internet) to connect remote sites or users. This is a very common way to build a cost-effective WAN.
Satellite/Cellular: Used for remote locations where other options are unavailable.
2.3 Components of a WAN
Routers: Connect LANs to the WAN and route traffic.
Modems/CSU/DSU: Interface devices to connect to the service provider's network.
Firewalls: Essential for security at the WAN edge.
Service Provider Network: The underlying infrastructure owned by telcos/ISPs.
2.4 Advantages of WANs
Global Connectivity: Connects users and resources across vast distances.
Business Operations: Enables geographically dispersed businesses to operate as a single entity.
Data Exchange: Facilitates sharing of data and applications among different locations.
Centralized Resources: Allows users in remote offices to access centralized servers and databases.
3. SD-WAN (Software-Defined Wide Area Network)
SD-WAN (Software-Defined Wide Area Network) is a relatively new approach to managing and optimizing WAN connectivity. It virtualizes WAN connections, allowing organizations to use a mix of connection types (broadband, MPLS, 4G/5G) and intelligently route traffic over the most efficient path based on application requirements and network conditions.
Traditionally, WANs were hardware-centric and complex to manage, especially with multiple branch offices. SD-WAN abstracts the underlying network hardware, allowing central control and automation through software.
3.1 Key Characteristics
Centralized Control Plane: Network intelligence is moved from individual routers to a centralized controller. This allows for unified management and policy enforcement across the entire WAN.
Application-Aware Routing: SD-WAN can identify applications (e.g., VoIP, video conferencing, SaaS apps like Salesforce) and route them over the best available link based on real-time network conditions (latency, jitter, packet loss) and pre-defined business policies.
Network Abstraction: It abstracts the underlying transport services (broadband, MPLS, LTE) into a single logical "overlay" network.
Transport Independence: Can use any mix of WAN links.
Enhanced Security: Often includes integrated security features like VPNs, firewalls, and segmentation.
Cost Savings: By intelligently using cheaper broadband links for non-critical traffic, organizations can reduce reliance on expensive MPLS circuits.
Simplified Management: Centralized management console simplifies provisioning, configuration, and troubleshooting.
3.2 How SD-WAN Works
SD-WAN architecture typically involves three main components:
SD-WAN Edge Devices (CPEs - Customer Premises Equipment): These are physical or virtual appliances deployed at branch offices or data centers. They connect to the various WAN links (broadband, MPLS) and create encrypted tunnels (often IPSec VPNs) back to other SD-WAN edge devices or data centers. They perform application identification and policy enforcement.
SD-WAN Orchestrator/Controller: This is the centralized brain of the SD-WAN. It is a software component (often cloud-based) that:
Provides a single pane of glass for management.
Pushes policies to the edge devices.
Collects telemetry data from the network.
Determines the optimal path for different applications based on real-time network conditions and policies.
Automates configuration and deployment.
Optional: SD-WAN Gateway: Some SD-WAN solutions use cloud gateways to optimize connectivity to SaaS applications or cloud services.
3.3 Key Features and Benefits
Dynamic Path Selection: Automatically selects the best WAN link for each application's traffic in real-time. For example, VoIP traffic might be prioritized over a stable MPLS link, while web Browse might use a cheaper broadband link.
Load Balancing & Link Aggregation: Uses multiple WAN links concurrently, increasing total bandwidth and providing redundancy.
Failover: If one link fails, traffic is automatically rerouted over an active link without manual intervention.
Zero-Touch Provisioning (ZTP): New branch devices can be deployed easily with minimal on-site configuration, as the orchestrator handles most of the setup.
Improved Application Performance: Prioritization and intelligent routing ensure critical applications perform optimally.
Reduced Costs: Leverages cheaper internet links, reducing reliance on expensive private circuits.
Increased Agility: Faster deployment of new sites and easier policy changes.
3.4 SD-WAN Use Cases
Multi-Branch Enterprises: Connecting numerous branch offices efficiently and cost-effectively.
Cloud Connectivity: Optimizing access to cloud-based applications (SaaS, IaaS).
Digital Transformation: Supporting new bandwidth-intensive applications and distributed workforces.
Security Integration: Consolidating security functions (firewall, IDS/IPS) at the WAN edge.
--------------------------------------------------------------------------------
• OSI vs. TCP/IP models, IPv4/IPv6 (RHCSA 4.6)
--------------------------------------------------------------------------------
Refer Notes.txt
--------------------------------------------------------------------------------
• Commands: ip, nmcli, ss, ping, traceroute, dig (RHCSA 3.4)
--------------------------------------------------------------------------------
Let's explore six essential Linux networking commands: ip, nmcli, ss, ping, traceroute, and dig. These tools are fundamental for configuring, monitoring, and troubleshooting network connectivity on Linux systems.
1. ip: The Modern Network Configuration Tool