Linux Book
Linux Book
Basic Topics:
1. File Management
• Commands: ls, cp, mv, rm, touch
• Scenario: List all files in a directory, copy a file, move files between directories, and
delete files.
2. Directory Management
• Commands: mkdir, rmdir, cd, pwd
• Scenario: Create and navigate through directories, and remove empty directories.
3. File Permissions
• Commands: chmod, chown, chgrp
• Scenario: Change file permissions to control user access.
4. Viewing and Editing Files
• Commands: cat, less, more, vi, nano
• Scenario: View the contents of a file and edit it using text editors.
5. Managing Links
• Commands: ln, ln -s
• Scenario: Create hard and soft links to files.
6. Process Management
• Commands: ps, top, kill, htop, bg, fg, nice
• Scenario: Monitor running processes and terminate or change their priority.
7. Managing Users and Groups
• Commands: useradd, userdel, usermod, groupadd
• Scenario: Create, modify, and delete users and groups.
8. Package Management (Debian-based)
• Commands: apt-get, dpkg
• Scenario: Install, remove, and update packages on Debian-based systems.
9. Package Management (RHEL-based)
• Commands: yum, dnf, rpm
• Scenario: Install, update, and remove packages on Red Hat-based systems.
10. Disk Management
• Commands: df, du, fdisk, mount, umount
• Scenario: Check disk usage, partition a disk, and mount/unmount file systems.
11. Service Management
• Commands: systemctl, service, chkconfig
• Scenario: Start, stop, enable, and disable services on a system.
12. Networking Basics
• Commands: ip, ifconfig, ping, netstat, traceroute
• Scenario: Check network configuration, test connectivity, and display active
connections.
13. SSH and Remote Access
• Commands: ssh, scp, rsync
• Scenario: Securely connect to remote systems and transfer files between them.
14. Cron Jobs
• Commands: crontab
• Scenario: Schedule regular tasks to automate scripts or system commands.
15. System Logs
• Commands: journalctl, dmesg, tail, /var/log
• Scenario: View system logs for troubleshooting and auditing purposes.
16. Text Processing Tools
• Commands: grep, awk, sed, cut, sort
• Scenario: Search, filter, and modify text data from files or command output.
17. Archiving and Compression
• Commands: tar, gzip, gunzip, zip, unzip
• Scenario: Compress files into archives and extract them.
18. File Search
• Commands: find, locate
• Scenario: Locate files based on name, type, or modification date.
19. Basic Shell Scripting
• Commands: bash, sh
• Scenario: Automate tasks using simple shell scripts.
20. Environment Variables
• Commands: export, env, set
• Scenario: Set and manage environment variables.
Intermediate Topics:
Advanced Topics:
1. File Management
• Example:
2. Directory Management
• Example:
3. File Permissions
• Example:
• Example:
5. Managing Links
• Commands: ln, ln -s
• Example:
ln file1.txt file1_link # Create a hard link to file1.txt
6. Process Management
• Example:
• Example:
• Example:
apt-get update # Update package repository
• Example:
• Example:
• Example:
systemctl start httpd # Start Apache service
• Example:
• Example:
rsync -av /src/ /dest/ # Sync files between local and remote systems
• Example:
0 5 * * * /home/user/myscript.sh
• Example:
• Example:
awk '{print $1, $2}' file1.txt # Extract and print the first two columns
cut -d: -f1 /etc/passwd # Extract the first field from /etc/passwd
• Example:
• Example:
• Commands: bash, sh
• Example:
#!/bin/bash
• Example:
• Example:
• Example:
• Example:
• Example:
• Example:
firewall-cmd --zone=public --add-port=80/tcp --permanent # Open HTTP port 80
26. SELinux
• Example:
• Commands: mdadm
• Example:
• Example:
• Example:
• Example:
echo "/shared_dir 192.168.1.0/24(rw,sync,no_root_squash)" >> /etc/exports # Export a
directory over NFS
• Example:
path = /srv/samba/shared
read only = no
browsable = yes
• Example:
#!/bin/bash
function greet {
greet $user
done
• Example:
• Example:
• Example:
systemd-analyze blame # Show time taken for each service during boot
• Example:
• Example:
• Example:
• Example:
• Example:
• Commands: sysctl
• Example:
• Example:
• Example:
• Example:
---
- hosts: webservers
become: yes
tasks:
yum:
name: nginx
state: present
service:
name: nginx
state: started
• Example:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
• Example:
vi /etc/nginx/nginx.conf
http {
upstream backend {
server backend1.example.com;
server backend2.example.com;
server {
listen 80;
location / {
proxy_pass http://backend;
Scenario: Set up load balancing with Nginx to distribute traffic across multiple backend
servers.
• Example:
stages:
- build
- deploy
build_job:
stage: build
script:
- make build
deploy_job:
stage: deploy
script:
Scenario: Automate project build and deployment using Jenkins or GitLab CI pipelines.
filebeat.inputs:
- type: log
paths:
- /var/log/syslog
output.logstash:
hosts: ["localhost:5044"]
Scenario: Centralize and analyze logs using the ELK stack (Elasticsearch, Logstash, and
Kibana) with Filebeat for log collection.
• Example:
pcs status
Scenario: Set up a highly available cluster with Pacemaker and Corosync for failover of
critical resources like IP addresses or services.
• Example: