# Red Hat Certified System Administrator

## **Day 1: Introduction to RHCSA & Installation**

### **What is RHCSA?**

**RHCSA** stands for **Red Hat Certified System Administrator**.

### **Why RHCSA is Important**

* Industry-recognized Linux certification
    
* Required for **Linux system administration jobs**
    
* Builds strong foundation in:
    
    * Linux OS
        
    * Users & permissions
        
    * Filesystems
        
    * Networking
        
    * Services & processes
        
* Useful for **DevOps, SysAdmin, Cloud, and Server roles**
    

### **How We Install Linux for Practice**

We do **not** install Linux directly on our main system. Instead, we use **Virtualization**.

### **Virtual Machine (VM)**

* We use **VMware** (or VirtualBox)
    
* A VM allows us to run an **OS inside another OS**
    
* Example:
    
    * Host OS: Windows
        
    * Guest OS: RHEL / CentOS / Rocky Linux
        

### **Installation Steps (High Level)**

1. Install VMware
    
2. Create a new Virtual Machine
    
3. Attach Linux ISO file
    
4. Allocate:
    
    * RAM
        
    * CPU
        
    * Disk
        
5. Install Linux OS inside VM
    

✅ **This method is safe and widely used for learning and testing**

---

## **Day 2: Linux Directory Structure & Basic Commands**

### **Root Directory** `/`

Linux has a **single root directory** `/`. Everything starts from here.

### **Important System Directories**

| Directory | Purpose |
| --- | --- |
| `/` | Root of the filesystem |
| `/root` | Home directory of **root user** |
| `/home` | Home directories of normal users |
| `/bin` | Essential user commands (ls, cp, mv) |
| `/sbin` | System/admin commands |
| `/etc` | Configuration files |
| `/var` | Logs, mail, variable data |
| `/tmp` | Temporary files |
| `/boot` | Bootloader & kernel files |

---

### **Basic Commands Learned**

```plaintext
whoami
```

➡ Shows **current logged-in user**

```plaintext
ls
```

➡ Lists files and directories

```plaintext
cd
```

➡ Changes directory

Examples:

```plaintext
cd /etc
cd ..
cd ~
```

---

### **Linux Terminal Prompt Explained**

Example:

```plaintext
hassan@server1:/home/hassan$
```

| Part | Meaning |
| --- | --- |
| `hassan` | Username |
| `server1` | Hostname |
| `/home/hassan` | Current directory |
| `$` | Normal user |
| `#` | Root user |

✅ **Correction:**

* `$` → normal user
    
* `#` → root (admin) user
    

---

## **Day 3: How Linux OS Boots + File Commands**

### **How Operating System Works (Boot Process)**

Correct boot order:

1. **BIOS / UEFI**
    
    * Initializes hardware
        
2. **Bootloader (GRUB2)**
    
    * Loads the kernel
        
    * Allows selecting different OS
        
3. **Kernel**
    
    * Core of OS
        
    * Manages CPU, memory, devices
        
4. **init / systemd**
    
    * Starts services
        
5. **Login Screen**
    
    * OS is ready to use
        

✅ **Correction:**

* BIOS **does not load the OS directly**
    
* BIOS/UEFI loads the **bootloader**
    
* Bootloader loads the **kernel**
    
* Kernel starts the OS
    

### **Multiple OS Concept**

* If multiple OS are installed
    
* GRUB menu allows choosing which OS to boot
    

# 🧠 One-Line Memory Trick

* **Linux:**  
    `UEFI → GRUB → Kernel → systemd → Services → Ready`
    
* **Windows:**  
    `UEFI → Boot Manager → Kernel → Services → Login → Ready`
    

---

### **File Commands**

```plaintext
cp source destination
```

➡ Copy files or directories

Examples:

```plaintext
cp file1 file2
cp -r dir1 dir2
```

```plaintext
mv source destination
```

➡ Move or rename files

Examples:

```plaintext
mv file1 /tmp
mv oldname newname
```

---

### **Change Hostname**

Temporary:

```plaintext
hostname newname
```

Permanent (Recommended):

```plaintext
hostnamectl set-hostname newname
```

---

## **Day 4: BIOS vs UEFI, Editors & Practice Tasks**

### **BIOS vs UEFI**

| BIOS | UEFI |
| --- | --- |
| Old technology | Modern |
| Slow boot | Fast boot |
| MBR partition | GPT partition |
| Limited disk size | Supports large disks |
| Text-based | GUI support |

✅ **UEFI is used in modern systems**

---

### **Text Editors**

Linux has command-line editors.

#### **Nano (Easy)**

```plaintext
nano file.txt
```

* Easy to use
    
* Shortcuts shown at bottom
    
* Save: `CTRL + O`
    
* Exit: `CTRL + X`
    

#### **Vim (Advanced)**

```plaintext
vim file.txt
```

Modes:

* **Normal mode** (default)
    
* **Insert mode** → `i`
    
* **Command mode** → `:`
    

Common commands:

```plaintext
i        # insert mode
:w       # save
:q       # quit
:wq      # save and quit
:q!      # quit without saving
```

---

### **Practice Tasks**

* Create files
    
* Edit files using nano & vim
    
* Copy and move files
    
* Rename files
    
* Change hostname
    
* Navigate directories
    

---

## ✅ Summary

You learned:

* RHCSA basics and importance
    
* Linux installation using VMware
    
* Linux directory structure
    
* Basic Linux commands
    
* Boot process (BIOS → GRUB → Kernel → OS)
    
* BIOS vs UEFI
    
* File operations
    
* Nano & Vim editors
    

# **RHCSA – Class Notes (Day 5 & 6)**

---

## **Day 5: File and Directory Management**

### **Copying Directories**

```plaintext
cp -r source_directory destination_directory
```

* `-r` → recursive (copy directory and all its contents)
    
* Example:
    

```plaintext
cp -r /home/hassan/docs /home/hassan/backup_docs
```

---

### **Deleting Files**

```plaintext
rm filename
```

* Removes a file
    

```plaintext
rm -i filename
```

* Asks **confirmation** before deletion
    

---

### **Deleting Directories**

```plaintext
rmdir directory_name
```

* Removes **empty directories only**
    

```plaintext
rm -r directory_name
```

* Removes **directory and all contents recursively**
    

```plaintext
rm -rf directory_name
```

* Removes **directory and contents without warning**
    
* ⚠️ **Use carefully**! Can delete important data
    

---

### **Wildcard** `*`

* `*` is used to represent **all files or directories**
    
* Example:
    

```plaintext
rm *.txt
```

* Deletes all `.txt` files in current directory
    

---

### **Command Structure**

```plaintext
command [options] [arguments]
```

* **Command** → what to do (`ls`, `cp`, `rm`)
    
* **Options** → modify behavior (`-l`, `-r`, `-f`)
    
* **Arguments** → files or directories to operate on
    

**Example:**

```plaintext
ls -l /home/hassan
```

---

### **Hidden Files**

* Files starting with `.` are hidden
    
* Create a hidden file:
    

```plaintext
touch .hiddenfile
```

---

### **Clear Terminal**

```plaintext
clear
```

* Clears the screen
    

---

### **Creating Directories**

```plaintext
mkdir folder_name
```

#### **Nested Directories**

```plaintext
mkdir -p parent_folder/child_folder
```

* `-p` → create parent directories if they don’t exist
    

#### **Creating Multiple Folders**

```plaintext
mkdir folder{1..10}
```

* Creates `folder1`, `folder2`, … `folder10`
    

#### **Creating Multiple Files**

```plaintext
touch file{1..10}.txt
```

* Creates `file1.txt` → `file10.txt`
    

---

### **Viewing Directory Tree**

```plaintext
tree directory_name
```

---

## **Day 6: Reading File Content & Searching**

### **View File Content**

#### **cat**

```plaintext
cat /etc/services
```

* Displays **entire file content**
    

#### **more**

```plaintext
more /etc/fstab
```

* Shows file **page by page** (use space to scroll)
    

#### **less**

* Better alternative to `more`
    
* Scroll forward/backward
    

```plaintext
less /etc/fstab
```

#### **head**

```plaintext
head -n 10 /etc/services
```

* Shows first **10 lines** of file
    

#### **tail**

```plaintext
tail -n 10 /etc/services
```

* Shows last **10 lines** of file
    

#### **nl**

```plaintext
nl /etc/services
```

* Shows file content with **line numbers**
    

---

### **Search Inside Files –** `grep`

```plaintext
grep "pattern" filename
```

* Search for **specific text** in a file
    
* Example:
    

```plaintext
grep "ftp" /etc/services
```

#### **With options**

* `-i` → ignore case
    
* `-c` → show **count** of matching lines
    
* `-v` → show **non-matching lines**
    
* `-n` → show **line numbers**
    

Example:

```plaintext
grep -i "ftp" /etc/services
grep -c "ssh" /etc/services
```

---

### **Word Count –** `wc`

```plaintext
wc filename
```

* Shows lines, words, characters
    

Options:

* `-l` → number of lines
    
* `-w` → number of words
    
* `-c` → number of bytes
    
* `-m` → number of characters
    

Example:

```plaintext
wc -l /etc/services
wc -w /etc/services
```

---

### **Redirection & Operators**

* **Redirect output to a file**
    

```plaintext
ls > file.txt
```

* Overwrites `file.txt` with output of `ls`
    
* **Append output to a file**
    

```plaintext
ls >> file.txt
```

* Adds output to the **end** of `file.txt`
    
* **Pipes** (send output of one command to another)
    

```plaintext
cat /etc/services | grep ftp
```

✅ **Correction:**

* `>` → overwrite
    
* `>>` → append
    
* `|` → pipe (send output to another command)
    

---

### **Summary – Day 5 & 6**

You learned:

* Copying, moving, deleting files and directories
    
* Wildcards `*` for multiple files
    
* Command structure (command → options → arguments)
    
* Hidden files and creating them
    
* Creating folders/files in bulk
    
* Reading files (`cat`, `more`, `less`, `head`, `tail`, `nl`)
    
* Searching in files (`grep` with options)
    
* Word count (`wc`)
    
* Redirection (`>`, `>>`) and pipes (`|`)
    

## **Day 7: Operators in Linux**

Linux allows combining commands and controlling execution flow using **operators**.

---

### **1️⃣ Semicolon** `;`

* **Purpose:** Run multiple commands **sequentially**, **regardless of whether previous commands succeed or fail**
    
* **Syntax:**
    

```plaintext
command1; command2; command3
```

* **Example:**
    

```plaintext
echo "Hello"; ls; pwd
```

* Output:
    
    1. Prints “Hello”
        
    2. Lists files
        
    3. Shows current directory
        

✅ **Note:** Commands run **one by one** even if one fails.

---

### **2️⃣ Single Pipe** `|`

* **Purpose:** Sends output of first command as input to second command
    
* **Syntax:**
    

```plaintext
command1 | command2
```

* **Example:**
    

```plaintext
cat /etc/services | grep ftp
```

* `cat` prints file → `grep` filters only lines containing “ftp”
    

---

### **3️⃣ Double AND** `&&`

* **Purpose:** Run **second command only if the first command succeeds**
    
* **Syntax:**
    

```plaintext
command1 && command2
```

* **Example:**
    

```plaintext
mkdir test && cd test
```

* Only enters `test` folder if folder creation **succeeds**
    

---

### **4️⃣ Single AND** `&`

* **Purpose:** Run command in **background**
    
* **Syntax:**
    

```plaintext
command &
```

* **Example:**
    

```plaintext
gedit file.txt &
```

* Opens `gedit` in background, so terminal is **free to use**
    

---

### **5️⃣ Double Pipe** `||`

* **Purpose:** Run **second command only if the first command fails**
    
* **Syntax:**
    

```plaintext
command1 || command2
```

* **Example:**
    

```plaintext
cd nonexistfolder || echo "Folder does not exist"
```

* If `cd` fails, prints warning
    

---

### **Summary of Operators**

| Operator | Purpose |
| --- | --- |
| `;` | Run commands sequentially, ignore errors |
| `&&` | Run next command only if previous succeeds |
| \` |  |
| `&` | Run command in background |
| \` | \` |

---

## **User and Group Management**

Linux manages **users and groups** for **access control** and **permissions**.

---

### **Types of Users**

| User Type | Description | UID |
| --- | --- | --- |
| **Root user** | Super admin, full privileges | `0` |
| **System user** | Used by OS services, limited login | `1–999` |
| **Regular user** | Normal human user, limited privileges | `1000+` |

---

### **Types of Groups**

| Group Type | Description |
| --- | --- |
| **Root group** | Associated with root user, admin group |
| **System group** | For OS processes and services |
| **Regular group** | For normal users, sharing resources |

---

### **Commands (Basics)**

* **View current user**
    

```plaintext
whoami
```

* **View groups of a user**
    

```plaintext
groups username
```

* **View all users**
    

```plaintext
cat /etc/passwd
```

* **View all groups**
    

```plaintext
cat /etc/group
```

---

✅ **Corrections / Clarifications**

1. UID ranges for system vs regular users:
    
    * System: 1–999
        
    * Regular: 1000+
        
2. Background operator: single `&` runs **command in background**, not a chain.
    
3. Pipes and logical operators (`&&`, `||`) are different:
    
    * `|` → sends **output to input**
        
    * `&&` / `||` → controls **execution flow**
        

---

### **Examples**

```plaintext
# Sequential execution
echo "Start"; ls; echo "End"

# Logical AND
mkdir demo && cd demo

# Logical OR
cd nofolder || echo "Folder not found"

# Background process
gedit file.txt &

# Pipe
cat /etc/services | grep ftp
```

---

This covers **Day 7 operators + intro to user & group management**.

# **RHCSA Day 8 – User and Group Management**

User and group management is a **core topic in RHCSA** and very important for real-world Linux administration. On Day 8, we focused on creating users, managing passwords, understanding user IDs (UIDs), group IDs (GIDs), and how Linux stores user and group information internally.

---

## 1\. Adding a New User

To create a new user in Linux, we use the `useradd` command.

```bash
useradd username
```

Example:

```bash
useradd ali
```

This command:

* Creates the user
    
* Assigns a UID automatically
    
* Creates a home directory `/home/ali`
    
* Assigns a default shell
    

> ⚠️ By default, the user does **not** have a password yet.

---

## 2\. Setting or Changing User Password

To set or change a password, use:

```bash
passwd username
```

Example:

```bash
passwd ali
```

You will be prompted to enter and confirm the password.

---

## 3\. Checking User ID and Group Information

### Check UID and GID

```bash
id username
```

Example:

```bash
id ali
```

Output shows:

* UID (User ID)
    
* GID (Primary Group ID)
    
* Secondary groups
    

### Check Current Logged-in User

```bash
whoami
```

---

## 4\. Types of Users in Linux

Linux has **three main types of users**:

| User Type | Description | UID Range |
| --- | --- | --- |
| Root User | Superuser with full access | 0 |
| System User | Used by services and processes | 1–999 |
| Regular User | Normal human users | 1000+ |

---

## 5\. Modifying a User (User Management)

The `usermod` command is used to modify user properties.

### Example: Set Account Expiry Date

```bash
usermod -e 2026-12-31 ali
```

### Lock a User Account

```bash
usermod -L ali
```

### Unlock a User Account

```bash
usermod -U ali
```

---

## 6\. Password Aging and Expiry

We can control password policies using `chage`.

```bash
chage username
```

Example:

```bash
chage ali
```

To view password aging info:

```bash
chage -l ali
```

You can:

* Set password expiry
    
* Force password change
    
* Set warning days
    

---

## 7\. Users vs Groups

### What is a User?

* An individual account
    
* Has its own UID
    
* Can log in
    

### What is a Group?

* Collection of users
    
* Used to manage permissions easily
    
* Identified by GID
    

> Groups make permission management easier instead of assigning permissions user by user.

---

## 8\. Adding Groups

```bash
groupadd groupname
```

Example:

```bash
groupadd developers
```

---

## 9\. Primary and Secondary Groups

### Primary Group

* Each user has **one primary group**
    
* Assigned at user creation
    
* Used by default when creating files
    

### Secondary Groups

* Additional groups a user belongs to
    
* Used for extra permissions
    

### Add User to a Secondary Group

```bash
usermod -aG groupname username
```

Example:

```bash
usermod -aG developers ali
```

> ⚠️ `-a` is very important. Without it, existing groups will be removed.

---

## 10\. Checking User and Group Files

Linux stores user and group information in `/etc` directory.

### `/etc/passwd`

```bash
cat /etc/passwd
```

Contains:

* Username
    
* UID
    
* GID
    
* Home directory
    
* Shell
    

> Passwords are **not stored here**.

---

### `/etc/shadow`

```bash
cat /etc/shadow
```

Contains:

* Encrypted passwords
    
* Password expiry info
    

> Only readable by **root user**.

---

### `/etc/group`

```bash
cat /etc/group
```

Contains:

* Group name
    
* GID
    
* Group members
    

---

## 11\. Summary (Day 8)

On Day 8, we learned:

* How to add users and set passwords
    
* How to check UID, GID, and group membership
    
* Difference between users and groups
    
* Primary vs secondary groups
    
* How to add users to groups
    
* User modification and password expiry
    
* Internal Linux files: `/etc/passwd`, `/etc/shadow`, `/etc/group`
    

This topic is **very important for RHCSA exam and real Linux administration**.
