Update linux roadmap content

This commit is contained in:
Kamran Ahmed
2025-06-15 01:36:35 +01:00
parent 9de76da66f
commit c8b47634ea
43 changed files with 37 additions and 600 deletions
@@ -1,20 +1,3 @@
# Adding Disks
Adding disks in Linux involves partitioning, creating filesystems, and mounting. Use `lsblk` to list devices, `fdisk /dev/sdX` to create partitions, `mkfs.ext4 /dev/sdX1` to create filesystems, and `mount /dev/sdX1 /mount/point` to mount. This process prepares new storage devices for seamless integration into the Linux filesystem hierarchy.
The following are common commands to manage disks:
- Use `lsblk` to list all block devices (disk and partitions).
- Use `fdisk /dev/sdX` to create a new partition on a disk.
- Use `mkfs.ext4 /dev/sdX1` to create a new filesystem on a partition.
- Use `mount /dev/sdX1 /mount/point` to mount a filesystem to a directory.
```shell
# example commands to add new disk
lsblk # list all disks and partitions
sudo fdisk /dev/sdb # let's suppose new disk is /dev/sdb
sudo mkfs.ext4 /dev/sdb1 # make filesystem(e.g., ext4) on partition 1
sudo mount /dev/sdb1 /mnt # mount new filesystem to /mnt directory
```
Remember to replace `/dev/sdb` and `/dev/sdb1` with your actual disk and partition identifiers. The mount point `/mnt` may also be replaced with any other directory as per your system's structure and preference.
Adding disks in Linux involves partitioning, creating filesystems, and mounting. Use `lsblk` to list devices, `fdisk /dev/sdX` to create partitions, `mkfs.ext4 /dev/sdX1` to create filesystems, and `mount /dev/sdX1 /mount/point` to mount. This process prepares new storage devices for seamless integration into the Linux filesystem hierarchy.
@@ -2,13 +2,3 @@
Evaluating available memory is crucial for Linux system health monitoring. Use command-line tools like `free`, `vmstat`, and `top` to track memory usage and performance metrics. The `free -h` command shows total, used, free, shared, buffer/cache, and available memory in human-readable format. Essential for maintaining optimal server performance and troubleshooting resource issues.
The `free` command, for instance, gives a summary of the overall memory usage including total used and free memory, swap memory and buffer/cache memory. Here's an example:
```bash
$ free -h
total used free shared buff/cache available
Mem: 15Gi 10Gi 256Mi 690Mi 5.3Gi 4.2Gi
Swap: 8.0Gi 1.3Gi 6.7Gi
```
In this output, the '-h' option is used to present the results in a human-readable format. Understanding the state of memory usage in your Linux server can help maintain optimal server performance and troubleshoot any potential issues.
@@ -2,13 +2,6 @@
Boot loaders load the OS kernel into memory when systems start. Common Linux boot loaders include GRUB (modern, feature-rich with graphical interface) and LILO (older, broader hardware support). Boot loaders initialize hardware, load drivers, start schedulers, and execute init processes. Use `sudo update-grub` to update GRUB configuration. Enable multi-OS booting on single machines.
```bash
# This command updates the GRUB bootloader
sudo update-grub
```
Irrespective of the type of Boot Loader used, understanding and configuring them properly is essential for maintaining an efficient, stable and secure operating system. Boot loaders also allow users to switch between different operating systems on the same machine, if required.
Visit the following resources to learn more:
- [@article@comprehensive documentation of Bootloader - archlinux wiki](https://wiki.archlinux.org/title/Arch_boot_process#Boot_loader)
- [@article@What Is GRUB Bootloader in Linux?](https://phoenixnap.com/kb/what-is-grub)
@@ -1,14 +1,3 @@
# Booting Linux
Linux booting involves several stages: POST, MBR, GRUB, Kernel, Init, and GUI/CLI. The bootloader loads the kernel into memory, which detects hardware, loads drivers, mounts filesystems, starts system processes, and presents login prompts. GRUB configuration is managed through `/etc/default/grub` with settings like timeout and default boot options.
Here is an example of the GRUB configuration file `/etc/default/grub` which is used to configure the GRUB bootloader options:
```bash
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
```
This is a basic introduction to booting Linux. However, the specifics may vary depending on the Linux distribution and the specific configurations of your system.
Linux booting involves several stages: POST, MBR, GRUB, Kernel, Init, and GUI/CLI. The bootloader loads the kernel into memory, which detects hardware, loads drivers, mounts filesystems, starts system processes, and presents login prompts. GRUB configuration is managed through `/etc/default/grub` with settings like timeout and default boot options.
@@ -2,20 +2,3 @@
Linux system logs provide chronological records of events for debugging and troubleshooting, stored in `/var/log` directory. Use `dmesg` for kernel messages and `journalctl` for systemd logs. `journalctl -u service_name` shows logs for specific services. Essential skill for system administration, monitoring, and effective troubleshooting in Linux environments.
Checking Logs Under Service Management in Linux plays a vital role in systems administration and troubleshooting procedures. Logs are fundamental for an in-depth understanding of what's going on inside a Linux system. These records provide a chronological record of events related to your system for use in debugging and troubleshooting problems.
Several essential logs generated by system processes, users and administrator actions can be found in `/var/log` directory. Logs can be accessed and viewed using several commands. For example, the `dmesg` command can be used to display the kernel ring buffer. Most system logs are managed by `systemd` and can be checked using the command `journalctl`.
```shell
journalctl
```
This command will show the entire system log from the boot to the moment you're calling the journal.
To display logs for a specific service, the `-u` option can be used followed by the service's name.
```shell
journalctl -u service_name
```
Remember, understanding and monitoring your system logs will provide you a clear view of what's going on in your Linux environment. It is a vital skill worth developing to effectively manage and troubleshoot systems.
@@ -1,30 +1,6 @@
# Command Help
Command help in Linux is an essential feature that enables users to navigate through Linux shell commands with ease. This feature displays brief information on how to use these commands. For instance, typing 'man' before any command brings up the manual entry for that command which explains what the command does, its syntax and the available options. Another popular command is 'help' which is more suited for shell built-in functions, giving a brief description about each. These command line services are extremely beneficial for beginners trying to learn how to use the Linux shell, as well as seasoned users who may need to look up the specifics of seldom used commands. You can also get a TLDR of a command with example usage by using the TLDR package.
To view the manual entry for any command, use:
```bash
man [command]
```
For built-in shell functions, use:
```bash
help [command]
```
Moreover, you can add the *--help* flag to almost any command to get more information about it.
For example:
```bash
date --help
```
To view examples with TLDR, use:
```bash
tldr [command]
```
Linux command help provides documentation and usage information for shell commands. Use `man command` for detailed manuals, `help command` for shell built-ins, `command --help` for quick options, and `tldr command` for practical examples. Essential for learning command syntax, parameters, and functionality in Linux terminal environments.
Learn more from the following resources:
@@ -1,23 +1,3 @@
# Conditionals
Shell conditionals allow scripts to make decisions based on conditions using `if`, `elif`, and `else` statements. These control process flow by evaluating string variables, arithmetic tests, or process status. Conditions are checked sequentially - if true, the corresponding code block executes; otherwise, it moves to the next condition until finding a match or reaching `else`.
Here's a simple illustration of how they work:
```bash
#!/bin/sh
a=10
b=20
if [ $a -lt 20 ]
then
echo "a is less than b"
elif [ $a -gt 20 ]
then
echo "a is greater than b"
else
echo "a is equal to b"
fi
```
In the above script, the condition inside the `if` statement is being checked. If the condition is `true`, then the code block inside the `if` statement gets executed, otherwise, it moves to the `elif` condition and so on. If none of those conditions is satisfied, then the code block inside the `else` statement will be executed.
Shell conditionals allow scripts to make decisions based on conditions using `if`, `elif`, and `else` statements. These control process flow by evaluating string variables, arithmetic tests, or process status. Conditions are checked sequentially - if true, the corresponding code block executes; otherwise, it moves to the next condition until finding a match or reaching `else`.
@@ -1,39 +1,6 @@
# Creating Files
# Creating and Deleting Files
Creating files in Linux is about making new blank or filled files on your computer. You can use commands like `touch` to create an empty file, `echo` to make a file with some text inside, or `cat` to type directly into a new file. These commands help you set up and save your documents or data.
Here's an example of file creation with the `touch` command:
```bash
touch newfile.txt
```
and with `cat` command:
```bash
cat > newfile.txt
```
Both these commands create a new "newfile.txt" if it does not already exist.
# Deleting Files
Deleting files in Linux means getting rid of unwanted or unnecessary files from your computer. You use the `rm` command to delete a file, and it's permanent, so be careful. You can also use `rm -i` (interactive) to ask for confirmation before deleting, which helps prevent accidental loss of important files.
```bash
# Deletes the file named example.txt
rm example.txt
```
```bash
# Ask for confirmation
rm -i [filename]
```
```bash
# Removes an empty directory
rmdir [directory]
```
Linux file operations include creating files with `touch` (empty files) or `cat > filename` (with content) and deleting with `rm filename`. Use `rm -i` for confirmation prompts and `rmdir` for empty directories. File deletion is permanent - no recycle bin. Essential commands for basic file management and system administration.
Learn more from the following resources:
@@ -1,39 +1,6 @@
# Creating Files
Creating files in Linux is about making new blank or filled files on your computer. You can use commands like `touch` to create an empty file, `echo` to make a file with some text inside, or `cat` to type directly into a new file. These commands help you set up and save your documents or data.
Here's an example of file creation with the `touch` command:
```bash
touch newfile.txt
```
and with `cat` command:
```bash
cat > newfile.txt
```
Both these commands create a new "newfile.txt" if it does not already exist.
# Deleting Files
Deleting files in Linux means getting rid of unwanted or unnecessary files from your computer. You use the `rm` command to delete a file, and it’s permanent, so be careful. You can also use `rm -i` (interactive) to ask for confirmation before deleting, which helps prevent accidental loss of important files.
```bash
# Deletes the file named example.txt
rm example.txt
```
```bash
# Ask for confirmation
rm -i [filename]
```
```bash
# Removes an empty directory
rmdir [directory]
```
Linux file creation uses `touch` for empty files, `echo "text" > filename` for text files, or `cat > filename` for interactive input. Commands like `mkdir` create directories. File creation is immediate and permanent. Essential for organizing data, scripts, and configuration files in Linux systems.
Learn more from the following resources:
@@ -2,28 +2,3 @@
Creating Linux services involves setting up background applications using systemd service files. Services run continuously performing essential tasks like web servers, databases, and mail servers. Create `.service` files in `/etc/systemd/system/` with Unit, Service, and Install sections. Control services using `systemctl` commands. Best practice: avoid running services as root for security.
In Linux, service management refers to starting, stopping, enabling, and managing software services. Understanding how to control services is crucial for controlling a Linux server or desktop.
Typically, a service is an application that runs in the background waiting to be used, or carrying out essential tasks. Common kinds of services include web servers, database servers, and mail servers.
Creating services in Linux would thus refer to the process of setting up these background applications to run and perform the desired tasks. This process often includes writing service files (script) that specify how to start, stop, and restart the service using a service management system.
The most common service management system in modern Linux distributions is systemd. With systemd, services are defined by placing service unit files in specific directories.
For instance, we could create a simple `my_service.service` file:
```
[Unit]
Description=My Custom Service
After=network.target
[Service]
ExecStart=/path/to/your/executable
[Install]
WantedBy=multi-user.target
```
This service file can be placed under `/etc/systemd/system/` to make systemd recognize it. You would then control the service using `systemctl`, systemd's command tool.
Note that best practices in Linux dictate that we should not run services as root whenever possible, for security reasons. Instead, we should create a new user to run the service.
@@ -1,6 +1,6 @@
# DHCP
Dynamic Host Configuration Protocol (DHCP) automatically allocates IP addresses and network configuration to clients within a network. DHCP servers manage IP distribution ensuring unique addresses for each client machine. In Linux, install with `sudo apt-get install isc-dhcp-server` and configure via `/etc/dhcp/dhcpd.conf`. DHCP servers should have static IPs for effective management.
DHCP (Dynamic Host Configuration Protocol) automatically allocates IP addresses and network configuration to clients, ensuring unique addresses for each machine. In Linux, install with `sudo apt-get install isc-dhcp-server` and configure via `/etc/dhcp/dhcpd.conf`. DHCP servers require static IPs for effective management and can handle DNS and network data.
The DHCP server effectively manages the IP addresses and information related to them, making sure that each client machine gets a unique IP and all the correct network information.
@@ -1,17 +1,3 @@
# DNS Resolution
DNS (Domain Name System) converts hostnames to IP addresses, enabling users to access websites without remembering numeric addresses. Linux systems use `/etc/resolv.conf` to configure DNS resolution. Applications consult the DNS resolver, which communicates with DNS servers for address translation. Use `nslookup` or `dig` commands to query DNS and troubleshoot network connectivity issues.
Below command is used to query DNS and fetch IP addresses:
```bash
nslookup www.example.com
```
Or using dig command:
```bash
dig www.example.com
```
Getting a good understanding of the DNS resolution process provides a solid base for tasks like network troubleshooting and web server setup on a Linux system.
DNS (Domain Name System) converts hostnames to IP addresses, enabling users to access websites without remembering numeric addresses. Linux systems use `/etc/resolv.conf` to configure DNS resolution. Applications consult the DNS resolver, which communicates with DNS servers for address translation. Use `nslookup` or `dig` commands to query DNS and troubleshoot network connectivity issues.
@@ -1,16 +1,8 @@
# File Permissions
Linux file permissions control who can read (r), write (w), or execute (x) files and directories. Permissions are set for owner, group, and others using octal notation or symbolic format. The format `-rwxr--r--` shows file type and permissions. Use `chmod` to change permissions, `chown` for ownership, and `chgrp` for group ownership. Proper permissions ensure system security.
Linux file permissions control read (r), write (w), and execute (x) access for owner, group, and others using octal or symbolic notation. Format `-rwxr--r--` shows file type and permissions. Use `chmod` to change permissions, `chown` for ownership, `chgrp` for group ownership. Essential for system security and proper access control.
Let's have a look at an example:
```bash
-rwxr--r-- 1 root root 4096 Jan 1 12:00 filename
```
From the above example, the first character `-` indicates if it is a regular file(`-`) or directory(`d`). The following group of three characters(`rwx`) represents the permissions for the file owner. The next three characters(`r--`) represent permissions for the group and the last set of three characters(`r--`) represents permissions for others.
The `r` indicates that the file can be read, `w` indicates that the file can be written to, and `x` indicates that the file can be executed.
Learn more from the following resources:
@@ -1,11 +1,3 @@
# File Transfer
Linux file transfer involves copying or moving files between systems over networks. Command-line tools support protocols like FTP, HTTP, SCP, SFTP, and NFS. Common commands include `scp`, `rsync`, and `wget`. Example: `scp /local/file username@remote:/destination` copies files to remote systems. These tools make network file sharing streamlined, easier, and more secure.
For instance, when transferring a file from a local machine to a remote server, the `scp` command can be utilized as follows:
```bash
scp /path/to/local/file username@remote:/path/to/destination
```
This command would copy the file to the designated remote system.
Understanding and efficiently using these tools can make the task of file sharing over networks streamlined, easier, and more secure.
Linux file transfer involves copying or moving files between systems over networks. Command-line tools support protocols like FTP, HTTP, SCP, SFTP, and NFS. Common commands include `scp`, `rsync`, and `wget`. Example: `scp /local/file username@remote:/destination` copies files to remote systems. These tools make network file sharing streamlined, easier, and more secure.
@@ -2,20 +2,3 @@
Linux package managers like `apt`, `yum`, and `dnf` automate software installation, upgrading, configuring, and removal. Debian-based systems: `sudo apt-get update && sudo apt-get install package-name`. Fedora/CentOS: `sudo dnf update && sudo dnf install package-name`. Package management eliminates manual compilation from source code. Root permissions required for installation.
It's important to understand how package management works in Linux, because it significantly simplifies the process of software management, eliminating the need to manually download, compile, and install software from source code.
For example, on a Debian-based system like Ubuntu you would use `apt` or `apt-get` to install a new package like so:
```
sudo apt-get update
sudo apt-get install package-name
```
While in a Fedora or CentOS you would use `dnf` or `yum`:
```
sudo dnf update
sudo dnf install package-name
```
Note that you should replace `package-name` with the name of the package you want to install. Remember that you will need appropriate permissions (often root) to install packages in a Linux system.
@@ -2,19 +2,7 @@
GREP (Global Regular Expression Print) is a powerful text search utility that finds and filters text matching specific patterns in files. It searches line by line and prints matching lines to the screen. Essential for shell scripts and command-line operations. Example: `grep "pattern" fileName` searches for specified patterns. Alternative: `ripgrep` offers enhanced performance and features.
An essential part of many shell scripts, bash commands, and command-line operations, GREP is a versatile tool that comes pre-installed with every Linux distribution. It embodies three main parts - format, action and regex. Over the years, it had been effectively utilized in multiple programming languages and data science applications.
Here is an example of a simple GREP command:
```bash
grep "pattern" fileName
```
This command will search for the specified pattern within the file and prints the line to the terminal.
There is also an alternative to `grep` - `ripgrep`.
`ripgrep` is an extremely fast text processor that supports all the features of `grep` and extends it.
Visit the following resources to learn more:
@@ -1,12 +1,3 @@
# ICMP
Internet Control Message Protocol (ICMP) is a supportive protocol used by network devices to communicate error messages and operational information. Essential for Linux network troubleshooting, ICMP enables tools like `ping` and `traceroute` to diagnose network connectivity and routing issues. Use `ping www.google.com` to send ICMP echo requests and test network reachability effectively.
In Linux systems, common command-line tools related to ICMP include `ping` and `traceroute`, both used to diagnose the state of the network and often part of troubleshooting efforts.
```bash
# Use of ICMP via the ping command to send an echo request to a specific host
ping www.google.com
```
This simple yet effective tool should not be missed out in any Linux network troubleshooting arsenal.
Internet Control Message Protocol (ICMP) is a supportive protocol used by network devices to communicate error messages and operational information. Essential for Linux network troubleshooting, ICMP enables tools like `ping` and `traceroute` to diagnose network connectivity and routing issues. Use `ping www.google.com` to send ICMP echo requests and test network reachability effectively.
@@ -2,14 +2,3 @@
Linux package management handles installing, removing, and upgrading pre-compiled software modules. Different distributions use specific package managers: `apt` (Debian/Ubuntu), `yum`/`dnf` (Fedora/RHEL/CentOS), `zypper` (SUSE). Example installation: `sudo apt-get install packagename`. Each manager has specific commands for removal and upgrades. Critical skill for effective Linux system administration.
Managing packages in a Linux system is one of the critical tasks that every Linux user and system administrator must be familiar with. Packages in Linux are pre-compiled software modules that include executables and files required to run and use the software. Linux distributions use different package managers such as `apt` for Debian/Ubuntu based distributions, `yum` and `dnf` for Fedora/RHEL/CentOS, and `zypper` for SUSE.
Managing packages includes tasks like installing new software packages, removing unused packages, and upgrading existing packages to newer versions. All these tasks can be performed using command-line instructions specific to each package manager.
A typical package management task such as installing a new package using `apt` would involve executing a command like:
```bash
sudo apt-get install packagename
```
However, the exact command varies depending on the package manager in use. Similarly, removing and upgrading packages also utilize command-line instructions specific to each package manager. Detailed understanding of these tasks is crucial for effective Linux system administration.
@@ -1,13 +1,3 @@
# IP Routing
IP routing in Linux involves configuring routing tables and network routes for packet forwarding across networks. The kernel handles route selection to send packets to their destinations. Use the `ip` command (replacing deprecated `ifconfig`) for network configuration. Example: `ip route show` displays all kernel-known routes for network troubleshooting and management.
This task is carried out using various command-line tools and the networking configuration files. The principle command-line tool for network configuration in Linux used to be `ifconfig`, but it has now been mostly replaced by the `ip` command.
For example, to view the routing table in Linux, the following command is used:
```bash
$ ip route show
```
This command returns a list of all routes that are known to the kernel.
IP routing in Linux involves configuring routing tables and network routes for packet forwarding across networks. The kernel handles route selection to send packets to their destinations. Use the `ip` command (replacing deprecated `ifconfig`) for network configuration. Example: `ip route show` displays all kernel-known routes for network troubleshooting and management.
@@ -2,12 +2,3 @@
The `kill` command terminates processes manually by sending specific signals to Process IDs (PIDs). Used when processes behave unexpectedly due to system bugs or accidental initiation. Syntax: `kill [signal or option] PID(s)`. Essential for Linux process management, allowing administrators to stop, pause, or terminate problematic processes and maintain system stability.
'Kill' in Linux is a built-in command that is used to terminate processes manually. You can use the `kill` command to send a specific signal to a process. When we use the `kill` command, we basically request a process to stop, pause, or terminate.
Here's a basic illustration on how to use the `kill` command in Linux:
```bash
kill [signal or option] PID(s)
```
In practice, you would identify the Process ID (PID) of the process you want to terminate and replace PID(s) in the above command. The signal or option part is optional, but very powerful allowing for specific termination actions.
@@ -1,28 +1,6 @@
# Listing and Finding Processes (proc)
# Listing and Finding Processes
In Linux, processes form the backbone of any functioning system - running various tasks and executing different operations. In order to effectively manage your Linux system, it's crucial to be able to list and find the currently running processes. This aids in monitoring system performance, tracking down any issues, and in controlling resource allocation.
The `proc` filesystem is an extremely powerful tool in this respect. Available in all Unix-like operating systems, `proc` is a virtual file system that provides detailed information about running processes, including its PID, status, and resource consumption.
With commands like `ps`, `top`, and `htop`, we can quickly list out the running processes on the Linux system. Specifically, the `ps` command offers an in-depth snapshot of currently running processes, whereas `top` and `htop` give real-time views of system performance.
```bash
# list all running processes
ps -ef
# display ongoing list of running processes
top
# alternatively, for a more user-friendly interface
htop
```
Exploring the proc directory (`/proc`), we dive even deeper, enabling us to view the system's kernel parameters and each process's specific system details.
```bash
# view specifics of a particular PID
cat /proc/{PID}/status
```
In short, 'Finding and Listing Processes (proc)' in Linux is not just a core aspect of process management, but also a necessary skill for enhancing system performance and resolution of issues.
Linux processes can be monitored using the `proc` virtual filesystem and commands like `ps`, `top`, and `htop`. Use `ps -ef` for process snapshots, `top`/`htop` for real-time views. The `/proc` directory contains detailed process information. View specific process details with `cat /proc/{PID}/status`. Essential for system performance monitoring and troubleshooting.
Visit the following resources to learn more:
@@ -1,17 +1,3 @@
# Literals
Shell literals are fixed values in source code including string literals (enclosed in quotes), numeric literals (sequences of digits), and boolean literals (1=true, 0=false). String examples: 'Hello, world!' or "Hello, world!". Numeric examples: 25, 100, 1234. Understanding literals is fundamental for shell scripting readability and functionality in Linux programming.
```bash
#!/bin/bash
# Example of literals in shell script
StringLiteral="This is a string literal"
NumericLiteral=125
echo $StringLiteral
echo $NumericLiteral
```
In this example, `StringLiteral` and `NumericLiteral` are literals and `echo` is used to print them.
Always remember, a good understanding of literals is fundamental when it comes to shell scripting in Linux.
Shell literals are fixed values in source code including string literals (enclosed in quotes), numeric literals (sequences of digits), and boolean literals (1=true, 0=false). String examples: 'Hello, world!' or "Hello, world!". Numeric examples: 25, 100, 1234. Understanding literals is fundamental for shell scripting readability and functionality in Linux programming.
@@ -1,15 +1,3 @@
# System Logs
Linux maintains logs documenting system activities, errors, and kernel messages. Boot logs record all operations during system startup for troubleshooting. Use `dmesg` to view kernel ring buffer messages in real-time, or access logs in `/var/log`. Systemd uses `journalctl` for logging. Log levels range from emergency (system unusable) to debug messages.
The "logs under booting" in Linux refers to the messages and information that are generated during the boot process. These logs record all operations and events that take place while the system is booting, which might assist in diagnosing a system issue or understanding system behavior.
Linux utilizes various log message levels from `emerg` (the system is unusable) to `debug` (debug-level messages). During the boot process, messages from various components of the system like kernel, init, services, etc., are stored. Many Linux distributions use systemd logging system, `journalctl`, which holds the logs of the boot process.
Viewing boot messages can occur in real-time with the `dmesg` command. It's used to read and print the kernel ring buffer. Or they can be accessed via the logging setup of your system, which often includes text files in `/var/log`.
```shell
dmesg | less
```
This command presents the boot logs in a less direct format with the ability to scroll up and down. The kernel ring buffer only has a certain size, so old messages will be discarded after some time.
Linux maintains logs documenting system activities, errors, and kernel messages. Boot logs record all operations during system startup for troubleshooting. Use `dmesg` to view kernel ring buffer messages in real-time, or access logs in `/var/log`. Systemd uses `journalctl` for logging. Log levels range from emergency (system unusable) to debug messages.
@@ -1,26 +1,5 @@
# Loops
Shell loops automate repetitive tasks by executing code blocks based on conditions. Three types exist: `for` (iterates over item lists), `while` (executes while condition is true), and `until` (runs until condition becomes true). Example: `for i in 1 2 3; do echo "$i"; done` outputs each number. Loops enhance script efficiency and enable effective automation.
Shell loops automate repetitive tasks with three types: `for` (iterates over lists), `while` (executes while condition true), `until` (runs until condition true). Example: `for i in 1 2 3; do echo "$i"; done` outputs each number. Essential for script efficiency, automation, and effective Linux shell programming.
In Linux, shell scripts commonly use three types of loops - for, while, and until.
- `for` loop iterates over a list of items and performs actions on each of them.
- `while` loop executes commands as long as the control condition remains true.
- `until` loop runs commands until the control condition becomes true.
Here is a simple sample for loop in bash/shell:
```bash
for i in 1 2 3
do
echo "$i"
done
```
This will output:
```
1
2
3
```
This is just the surface of looping in shell programming in Linux. These structures, when used wisely, can enhance your scripts and open up many areas for effective scripting and automation.
@@ -1,14 +1,3 @@
# LVM (Logical Volume Manager)
LVM provides logical volume management through device mapper framework, offering flexible disk management with resizing, mirroring, and moving capabilities. Three levels: Physical Volumes (PVs - actual disks), Volume Groups (VGs - storage pools), and Logical Volumes (LVs - carved portions). Create with `pvcreate`, `vgcreate`, and `lvcreate` commands. Essential for enterprise storage systems.
To create an LVM, you need to follow these steps in Linux:
```bash
pvcreate /dev/sdb1
vgcreate my-vg /dev/sdb1
lvcreate -L 10G my-vg -n my-lv
```
In the above commands, we create a physical volume on `/dev/sdb1`, then create a volume group named `my-vg`. Finally, we carve out a 10GB logical volume from the volume group and name it `my-lv`.
These features, collectively, provide great ease in managing storage systems especially for large enterprise class systems where a large array of disks are typically used.
LVM provides logical volume management through device mapper framework, offering flexible disk management with resizing, mirroring, and moving capabilities. Three levels: Physical Volumes (PVs - actual disks), Volume Groups (VGs - storage pools), and Logical Volumes (LVs - carved portions). Create with `pvcreate`, `vgcreate`, and `lvcreate` commands. Essential for enterprise storage systems.
@@ -1,13 +1,4 @@
# Netfilter
Netfilter is a Linux kernel framework for manipulating and filtering network packets. It provides hooks at various stages (prerouting, input, forward, output, postrouting) for custom functions. Primary applications include firewalls and NAT management. Works with iptables for configuration. Essential for traffic control, packet modification, logging, and intrusion detection in Linux systems.
Netfilter is a Linux kernel framework for manipulating and filtering network packets with hooks at various stages (prerouting, input, forward, output, postrouting). Used for firewalls and NAT management with iptables configuration. Essential for traffic control, packet modification, logging, and intrusion detection in Linux networking systems.
The structure of netfilter allows for custom functions, often referred to as hooks, to be inserted into the kernel's networking stack. These hooks can manipulate or inspect packets at various stages like prerouting, local in, forward, local out, and postrouting.
A common tool used in conjunction with netfilter is iptables, which provides a mechanism to configure the tables in the kernel provided by the Netfilter Framework.
Here is an example of using iptables with netfilter module to create a simple firewall rule:
```bash
iptables -A INPUT -i eth0 -s 192.168.0.0/24 -m netfilter --netfilter-name example --action drop
```
In this command, '-A INPUT' is adding a new rule to the 'INPUT' chain. '-i eth0' is specifying the network interface, and '-s 192.168.0.0/24' is designating the IP address range for the rule. '-m netfilter' is calling the netfilter module, '--netfilter-name example' is naming the rule, and '--action drop' is specifying how to handle the matching packets (In this case, dropping them).
@@ -1,12 +1,3 @@
# Netstat
Netstat is a command-line tool for network troubleshooting and performance measurement in Linux. It provides network statistics, open ports, routing table information, and protocol details. Use options like `-n` for numerical addresses, `-c` for continuous monitoring, and `-t`/`-u` for specific protocols. Example: `netstat -n` lists all connections with numerical values.
Its functionality is extended owing to various command-line options it supports, which could be used singularly or combinedly to fine-tune the output. These might include displaying numerical addresses instead of names (`-n`), continuous monitoring (`-c`), or spotting connections on a specific protocol (`-t`, `-u`).
Here is a brief snippet of how netstat may typically be used:
```bash
# List all connections with numerical values.
netstat -n
```
Netstat is a command-line tool for network troubleshooting and performance measurement in Linux. It provides network statistics, open ports, routing table information, and protocol details. Use options like `-n` for numerical addresses, `-c` for continuous monitoring, and `-t`/`-u` for specific protocols. Example: `netstat -n` lists all connections with numerical values.
@@ -1,6 +1,6 @@
# Networking
Linux networking enables systems to connect and share resources across different platforms. It provides robust tools for managing network interfaces, troubleshooting, and automation. Network configurations are stored in files like `/etc/network/interfaces`. Common commands include `ifconfig` (deprecated) and `ip` for interface management. Linux networking supports various protocols and scales well.
Linux networking enables system connections and resource sharing across platforms with robust management tools. Network configurations stored in `/etc/network/interfaces`. Key commands include `ifconfig` (deprecated) and `ip` for interface management. Supports various protocols with excellent scalability. Essential for system connectivity and network troubleshooting.
Linux adopts a file-based approach for network configuration, storing network-related settings and configurations in standard files, such as /etc/network/interfaces or /etc/sysconfig/network-scripts/, depending on the Linux distribution.
@@ -1,11 +1,3 @@
# Packet Analysis
Packet analysis is a key Linux network troubleshooting skill involving capturing and analyzing network traffic to identify performance issues, connectivity problems, and security vulnerabilities. Tools like tcpdump and Wireshark provide packet-level details for network diagnostics. Use `sudo tcpdump -i eth0` to capture packets on the eth0 interface for debugging network protocols.
A basic example of using tcpdump to capture packets in a Linux system command might look like this:
```sh
sudo tcpdump -i eth0
```
This command captures and displays packets being transmitted or received over the `eth0` network interface.
Packet analysis is a key Linux network troubleshooting skill involving capturing and analyzing network traffic to identify performance issues, connectivity problems, and security vulnerabilities. Tools like tcpdump and Wireshark provide packet-level details for network diagnostics. Use `sudo tcpdump -i eth0` to capture packets on the eth0 interface for debugging network protocols.
@@ -1,8 +1,3 @@
# Ping
The `ping` command is essential for Linux network troubleshooting, checking connectivity between your host and target machines. It sends ICMP ECHO_REQUEST packets and listens for ECHO_RESPONSE returns, providing insights into connection health and speed. Use `ping <target IP or hostname>` to diagnose network connectivity issues and identify reachability problems efficiently.
```bash
ping <target IP or hostname>
```
If there is any issue reaching the target host, `ping` can identify this and provide feedback, making it an essential component in troubleshooting network issues. In many cases, it is the first tool a Linux user will turn to when diagnosing network connectivity problems.
The `ping` command is essential for Linux network troubleshooting, checking connectivity between your host and target machines. It sends ICMP ECHO_REQUEST packets and listens for ECHO_RESPONSE returns, providing insights into connection health and speed. Use `ping <target IP or hostname>` to diagnose network connectivity issues and identify reachability problems efficiently.
@@ -2,27 +2,3 @@
Process forking uses the `fork()` system call to create child processes from parent processes, enabling concurrent execution. Child processes are nearly perfect copies of parents with different PIDs. Changes in child processes don't affect parents. Essential for understanding Linux process creation and control in multi-processing environments.
Here's a basic code snippet of proc forking in C:
```c
#include<sys/types.h>
#include<unistd.h>
#include<stdio.h>
int main()
{
pid_t child_pid;
// Try creating a child process
child_pid = fork();
// If a child is successfully created
if(child_pid >= 0)
printf("Child created with PID: %d\n", child_pid);
else
printf("Fork failed\n");
return 0;
}
```
In this snippet, `fork()` is used to created a new child process. If the process creation is successful, fork() returns the process ID of the child process. If unsuccessful, it returns a negative value.
@@ -2,28 +2,3 @@
Linux treats every running program as a process. Process management commands help view, control, and manipulate these processes. Key commands: `ps aux` shows running processes, `top` provides live system view, `kill -SIGTERM pid` gracefully stops processes, `kill -SIGKILL pid` forcefully terminates processes. Essential for understanding and controlling Linux system operations effectively.
Process management is integral part of any operating system and Linux is no different. Every program running on Linux, be it an application or a system operation, is treated as a process. These processes perform different tasks but work together to provide a seamless operating experience.
In Linux, users can interact and manage these processes by using different commands for various process management tasks such as viewing the currently running processes, killing processes, changing the priority of a process, and so on. Understanding these commands and how to use them effectively is essential to Linux process management.
The ps command for example, provides information about the currently running processes:
```bash
ps aux
```
This will list out all the currently running processes with information such as the process ID, the user running that process, the CPU and memory it's consuming, the command that started the process, and more.
`top` is another common command. It provides a live, updating view of the current state of the system including processes:
```bash
top
```
Yet another powerful tool is `kill`, which can send specific signals to processes. For example, you can gracefully stop a process with `SIGTERM` (15) or forcefully stop one with `SIGKILL` (9):
```bash
kill -SIGTERM pid
kill -SIGKILL pid
```
(note: you replace `pid` with the process ID you want to stop)
@@ -1,19 +1,3 @@
# Linux Package Management: Repositories
# Repositories
Package management in Linux involves handling packages or modules of software, streamlining the process of installing, upgrading, and configuring Linux distributions. At the crux of pack management are repositories, critical components that store and manage collections of software packages.
Repositories are storage locations containing collections of software packages for Linux distributions. They store thousands of compiled packages specific to each distribution (.deb for Debian/Ubuntu, .rpm for Fedora/CentOS). Repositories ensure secure, tested software with proper dependencies. Update commands: `sudo apt update` (Ubuntu), `sudo yum update` (CentOS/Fedora). Essential for secure software management.
The specific repository used depends on the Linux distribution (like Ubuntu, Fedora, etc.) and the package format the distribution uses (like .deb in Debian and Ubuntu or .rpm in Fedora and CentOS).
Repositories provide a method of updating the tools and applications on your Linux system, and they also ensure all updates and dependencies work together and are tested for integration before they are released.
There is no standard way to use the repositories across various distributions, each comes with its pre-configured set of repositories.
```
sudo apt update # command to update the repository in Ubuntu
sudo yum update # command to update the repository in CentOS or Fedora
raco pkg update # command in Racket to update all installed packages
```
These repositories are what make Linux a force to reckon with when it comes to software management with an element of security ensuring that the users only install software that is secure and reliable.
Repositories are storage locations containing collections of software packages for Linux distributions. They store thousands of compiled packages specific to each distribution (.deb for Debian/Ubuntu, .rpm for Fedora/CentOS). Repositories ensure secure, tested software with proper dependencies. Update commands: `sudo apt update` (Ubuntu), `sudo yum update` (CentOS/Fedora). Essential for secure software management.
@@ -2,12 +2,3 @@
Service status shows the current state of Linux services including network processes, backend servers, and background applications. Use `systemctl status service_name` to check service states through systemd manager. Example: `systemctl status apache2.service` shows Apache web server status. Essential for diagnosing problems, maintaining performance, and preventing service downtimes.
The command `systemctl` is the predominantly used command for controlling the `systemd` system and service manager. The `status` command in conjunction with `systemctl` is particularly useful for checking the state of the service. This command allows administrators to query and control the state of a systemd system and service manager.
Here's a simple example of how to use the `systemctl` command to check the status of a service:
```bash
systemctl status apache2.service
```
This command would give status information about Apache2, the popular web server.
By managing service statuses efficiently, Linux administrators can diagnose and rectify system problems, maintain optimum performance levels, and prevent service downtimes.
@@ -1,14 +1,5 @@
# Services Running
# Running Services
Linux servers are popular for their stability and flexibility, factors that make them a preferred choice for businesses and organizations when it comes to managing various services. Services that run under a Linux server can range from web services to database services, DNS servers, mail servers, and many others.
Linux servers run various services including web, database, DNS, and mail servers. System administrators use tools like `systemctl`, `service`, `netstat`, `ss`, and `lsof` to manage and monitor services. Use `systemctl --type=service` to list all active services with their status. Essential for server management, resource monitoring, and troubleshooting.
As a Linux system administrator, it's important to periodically review these running services to manage resources, check their statuses, and troubleshoot issues, ensuring the health and performance of the server.
Linux has a variety of tools to achieve this, such as: `systemctl`, `service`, `netstat`, `ss` and `lsof`.
For example, the command `systemctl` is widely used on Linux systems to list all running services:
```bash
systemctl --type=service
```
This command will show a list of all active services along with their current status. It is a necessity for server management and should be part of any Linux system administrator's toolbox.
Linux has a variety of tools to achieve this, such as: `systemctl`, `service`, `netstat`, `ss` and `
@@ -1,13 +1,4 @@
# SSH (Secure Shell)
# SSH
SSH is a cryptographic network protocol for secure remote access, command execution, and data communication between networked computers. It provides confidentiality, integrity, and security during transmission, replacing insecure protocols like Telnet. Use `ssh username@server_ip_address` to connect to remote Linux servers. Essential for secure system administration and remote management.
SSH (Secure Shell) is a cryptographic network protocol providing secure remote access, command execution, and data communication between networked computers. Replaces insecure protocols like Telnet with confidentiality, integrity, and security. Use `ssh username@server_ip_address` to connect to remote Linux servers. Essential for secure system administration and remote management.
Given its importance and widespread usage, a solid understanding of its functionality is essential for anyone looking to navigate Linux operating systems and manage networks efficiently.
Here is an example of using SSH to connect from your local machine to a remote server:
```bash
ssh username@server_ip_address
```
In the above command, 'username' represents the remote user account name and 'server_ip_address' is the IP address of the remote server you are trying to access. Once you've entered this command, you'll be prompted to enter the password for the specified user's account. After successful verification, you'll be logged into the remote Linux server.
@@ -1,15 +1,3 @@
# Subnetting
Subnetting divides networks into smaller subnets to improve performance and security in Linux networking. It organizes IP addresses within IP addressing schemes, preventing conflicts and efficiently utilizing address ranges. Use `route -n` to view routing tables and `route add -net xxx.xxx.xxx.x/xx gw yyy.yyy.yyy.y` to add subnets. Essential for complex networking environments.
Generally, the following commands are used in Linux for subnetting:
```shell
# Display current routing table
$ route -n
# Add a new subnet
$ route add -net xxx.xxx.xxx.x/xx gw yyy.yyy.yyy.y
```
Please replace the `xxx.xxx.xxx.x/xx` with your desired subnet address and network mask and replace `yyy.yyy.yyy.y` with the intended default gateway for the subnet.
Subnetting divides networks into smaller subnets to improve performance and security in Linux networking. It organizes IP addresses within IP addressing schemes, preventing conflicts and efficiently utilizing address ranges. Use `route -n` to view routing tables and `route add -net xxx.xxx.xxx.x/xx gw yyy.yyy.yyy.y` to add subnets. Essential for complex networking environments.
@@ -2,16 +2,5 @@
Swap space extends physical memory by using disk storage when RAM is full. Inactive memory pages move to swap, freeing RAM but with performance impact due to slower disk access. Swap can exist as dedicated partitions or regular files. Create with `fallocate`, `mkswap`, and `swapon` commands. Critical for memory management and system stability optimization.
For instance, to add a swap file, we might use the fallocate command to create a certain sized file for swap and the mkswap command to make it suitable for swap usage.
```
fallocate -l 1G /swapfile # creates a swap file
chmod 600 /swapfile # secures the swap file by preventing regular users from reading it
mkswap /swapfile # sets up the Linux swap area
swapon /swapfile # enables the file for swapping
```
Remember that the decision of where to place your swap space, how much swap space to have, and how to utilize swap space are all important considerations in optimizing your system's performance.
- [@article@Swap - Arch Wiki](https://wiki.archlinux.org/title/Swap)
- [@article@zram (alternative) - Arch Wiki](https://wiki.archlinux.org/title/Zram)
@@ -2,13 +2,3 @@
TCP/IP (Transmission Control Protocol/Internet Protocol) forms the backbone of internet communication, allowing computers to connect and transfer data. It comprises four layers: Network Interface, Internet, Transport, and Application. Essential for Linux networking, enabling hosts to interact across networks. Use `netstat -at` to view active TCP/IP connections. Crucial for network management and troubleshooting.
The TCP/IP (Transmission Control Protocol/Internet Protocol) forms the backbone of internet protocols. Essentially, it is a set of networking protocols that allows two or more computers to communicate. In the context of Linux, TCP/IP networking is a fundamental part of the operating system's functionality. It provides a platform for establishing connections and facilitating data transfer between two endpoints.
TCP/IP serves a vital role in enabling a host, given a correct IP configuration, to connect and interact with other hosts on the same or different networks. It is comprised of a four layers model, including the Network Interface, Internet, Transport, and Application layers. Understanding TCP/IP, its structure and how it works are crucial for effectively managing and troubleshooting Linux networks.
Below is a basic command using TCP/IP protocol in Linux:
```bash
# To view all active TCP/IP network connections
netstat -at
```
@@ -1,10 +1,3 @@
# Traceroute
Traceroute is a Linux network diagnostic tool that displays the path packets take from your system to a destination. It identifies routing problems, measures latency, and reveals network structure as packets traverse the internet. Each hop is tested multiple times with round-trip times displayed. Use `traceroute www.example.com` to discover packet routes and diagnose failures.
Each jump along the route is tested multiple times (the default is 3 but this can be changed), and the round-trip time for each packet is displayed. If certain packets are failing to reach their destination, traceroute can help diagnose where the failure is occurring.
Tracing route in Linux can be achieved by executing the `traceroute` command which allows you to discover the routes that internet protocol packets follow when traveling to their destination.
```bash
$ traceroute www.example.com
```
Traceroute is a Linux network diagnostic tool that displays the path packets take from your system to a destination. It identifies routing problems, measures latency, and reveals network structure as packets traverse the internet. Each hop is tested multiple times with round-trip times displayed. Use `traceroute www.example.com` to discover packet routes and diagnose failures.
@@ -1,9 +1,3 @@
# Troubleshooting
Linux troubleshooting involves identifying and resolving system errors, hardware/software issues, network problems, and resource management challenges. Key skills include using command-line tools, inspecting log files, understanding processes, and interpreting error messages. Tools like `top` provide real-time process monitoring to identify resource-heavy processes causing performance issues efficiently.
```bash
# example of using a command-line tool for troubleshooting
top
```
The `top` command is a commonly used troubleshooting tool that provides a dynamic, real-time view of the processes running on a system. It can be particularly useful for identifying resource-heavy processes that could be causing performance issues.
Linux troubleshooting involves identifying and resolving system errors, hardware/software issues, network problems, and resource management challenges. Key skills include using command-line tools, inspecting log files, understanding processes, and interpreting error messages. Tools like `top` provide real-time process monitoring to identify resource-heavy processes causing performance issues efficiently.
@@ -1,19 +1,8 @@
# Uptime Load
# Uptime and Load
When managing a Linux server, one critical metric deserving close scrutiny is the "uptime". The `uptime` command in Linux gives information about how long the system has been running without shutting down or restarting, and the system load average.
The `uptime` command shows system running time and load averages for 1, 5, and 15-minute intervals. Load average indicates computational work and processes waiting for CPU time. High load suggests insufficient resources or misconfigurations. Example: `uptime` shows "2 days, 20 min" uptime and "0.00, 0.01, 0.05" load averages. Essential for performance monitoring and capacity planning.
The system load average is an important indicator that illustrates the amount of computational work that a computer system performs. It's a reflection of how many processes are waiting in line to get CPU time. The system load average is typically shown for 1, 5, and 15 minutes durations.
By consistently analyzing the uptime and load on a Linux server, administrators can identify system usage patterns, diagnose possible performance issues, and determine an efficient capacity planning strategy. If a server has a high load average, it may suggest that the system resources are not sufficient or are misconfigured, leading to possible slow performance or system unresponsiveness.
Here is an example of the `uptime` command and its output:
```bash
$ uptime
10:58:35 up 2 days, 20 min, 1 user, load average: 0.00, 0.01, 0.05
```
In the output above, "2 days, 20 min" tells us how long the system has been up, while "0.00, 0.01, 0.05" shows the system's load average over the last one, five, and fifteen minutes, respectively.
Learn more from the following resources:
@@ -1,11 +1,3 @@
# Variables
Shell variables store system or user-defined data that can change during script execution. Two categories exist: System Variables (PATH, HOME, PWD) created by Linux, and User-Defined Variables created by users. Define variables with `=` operator and retrieve values with `$` prefix. Example: `MY_VARIABLE="Hello World"` then `echo $MY_VARIABLE` prints the value.
```bash
# Create a User-Defined Variable
MY_VARIABLE="Hello World"
# Print the value of the Variable
echo $MY_VARIABLE # Output: Hello World
```
Shell variables store system or user-defined data that can change during script execution. Two categories exist: System Variables (PATH, HOME, PWD) created by Linux, and User-Defined Variables created by users. Define variables with `=` operator and retrieve values with `$` prefix. Example: `MY_VARIABLE="Hello World"` then `echo $MY_VARIABLE` prints the value.