347 lines
6.2 KiB
Markdown
347 lines
6.2 KiB
Markdown
# OS-9: Linux Client Tools
|
|
|
|
Status: not started
|
|
|
|
Domain:
|
|
- 1.0 Operating Systems
|
|
|
|
Objective alignment:
|
|
- 1.9 Linux client tools
|
|
|
|
## What You Need To Know
|
|
|
|
Linux questions on Core 2 usually test:
|
|
- Basic file navigation
|
|
- Permissions and ownership
|
|
- Important configuration files
|
|
- Package managers
|
|
- Network commands
|
|
- Process and disk usage commands
|
|
- The difference between normal user and root/admin actions
|
|
|
|
## Memory Tricks
|
|
|
|
Command buckets:
|
|
- **Files**: `ls`, `pwd`, `mv`, `cp`, `rm`, `find`, `cat`
|
|
- **Permissions**: `chmod`, `chown`, `sudo`, `su`
|
|
- **Network**: `ip`, `ping`, `curl`, `dig`, `traceroute`
|
|
- **System**: `top`, `ps`, `df`, `du`, `mount`, `fsck`
|
|
- **Help**: `man`
|
|
|
|
Key files:
|
|
- `/etc/passwd`: user account list
|
|
- `/etc/shadow`: password hashes
|
|
- `/etc/hosts`: local name-to-IP mappings
|
|
- `/etc/resolv.conf`: DNS resolver settings
|
|
- `/etc/fstab`: file systems mounted at boot
|
|
|
|
Memory hook:
|
|
- **PASS users, SHADOW passwords, HOSTS names, RESOLV DNS, FSTAB mounts.**
|
|
|
|
## Linux Concepts
|
|
|
|
Root:
|
|
- The all-powerful administrative account.
|
|
- User ID `0`.
|
|
|
|
`sudo`:
|
|
- Runs one command with elevated privileges.
|
|
- Safer than staying logged in as root.
|
|
|
|
`su`:
|
|
- Switches to another user, often root.
|
|
- You remain that user until you exit.
|
|
|
|
Kernel:
|
|
- Core of the operating system.
|
|
- Manages hardware, memory, and processes.
|
|
|
|
Bootloader:
|
|
- Starts the operating system during boot.
|
|
|
|
systemd:
|
|
- System and service manager.
|
|
- Starts and manages services, login sessions, logging, and other system processes.
|
|
|
|
## Commands To Enter
|
|
|
|
Safe commands:
|
|
|
|
```bash
|
|
pwd
|
|
```
|
|
|
|
What it does:
|
|
- Prints the current working directory.
|
|
|
|
```bash
|
|
ls
|
|
```
|
|
|
|
What it does:
|
|
- Lists files and directories.
|
|
|
|
```bash
|
|
ls -l
|
|
```
|
|
|
|
What it does:
|
|
- Lists files with permissions, owner, group, size, and date.
|
|
|
|
```bash
|
|
cat /etc/os-release
|
|
```
|
|
|
|
What it does:
|
|
- Shows Linux distribution details.
|
|
|
|
```bash
|
|
cat /etc/passwd
|
|
```
|
|
|
|
What it does:
|
|
- Shows local user account entries.
|
|
- Each line includes username, UID, GID, home directory, and shell.
|
|
|
|
```bash
|
|
cat /etc/hosts
|
|
```
|
|
|
|
What it does:
|
|
- Shows local hostname-to-IP mappings.
|
|
|
|
```bash
|
|
cat /etc/resolv.conf
|
|
```
|
|
|
|
What it does:
|
|
- Shows DNS resolver settings.
|
|
|
|
```bash
|
|
cat /etc/fstab
|
|
```
|
|
|
|
What it does:
|
|
- Shows file systems configured to mount at startup.
|
|
|
|
```bash
|
|
grep root /etc/passwd
|
|
```
|
|
|
|
What it does:
|
|
- Searches `/etc/passwd` for lines containing `root`.
|
|
|
|
```bash
|
|
find . -name "*.txt"
|
|
```
|
|
|
|
What it does:
|
|
- Finds `.txt` files under the current directory.
|
|
|
|
```bash
|
|
ip addr
|
|
```
|
|
|
|
What it does:
|
|
- Shows network interfaces and IP addresses.
|
|
|
|
```bash
|
|
ip route
|
|
```
|
|
|
|
What it does:
|
|
- Shows routes, including the default gateway.
|
|
|
|
```bash
|
|
ping -c 4 127.0.0.1
|
|
```
|
|
|
|
What it does:
|
|
- Sends four pings to the local loopback address.
|
|
|
|
```bash
|
|
curl https://example.com
|
|
```
|
|
|
|
What it does:
|
|
- Retrieves data from a URL.
|
|
|
|
```bash
|
|
dig example.com
|
|
```
|
|
|
|
What it does:
|
|
- Queries DNS for detailed domain information.
|
|
- If `dig` is not installed, try `nslookup example.com`.
|
|
|
|
```bash
|
|
traceroute example.com
|
|
```
|
|
|
|
What it does:
|
|
- Shows the route packets take to a destination.
|
|
- If not installed, use `tracepath example.com` if available.
|
|
|
|
```bash
|
|
top
|
|
```
|
|
|
|
What it does:
|
|
- Shows live process and resource usage.
|
|
- Press `q` to quit.
|
|
|
|
```bash
|
|
ps aux
|
|
```
|
|
|
|
What it does:
|
|
- Shows running processes.
|
|
|
|
```bash
|
|
df -h
|
|
```
|
|
|
|
What it does:
|
|
- Shows mounted file systems and free space in human-readable units.
|
|
|
|
```bash
|
|
du -h
|
|
```
|
|
|
|
What it does:
|
|
- Shows disk usage for files/directories.
|
|
|
|
```bash
|
|
man grep
|
|
```
|
|
|
|
What it does:
|
|
- Opens the manual page for `grep`.
|
|
- Press `q` to quit.
|
|
|
|
## Practice File Commands
|
|
|
|
Use these in a temporary folder:
|
|
|
|
```bash
|
|
mkdir linux-practice
|
|
cd linux-practice
|
|
echo "Core 2 Linux practice" > notes.txt
|
|
cp notes.txt copy.txt
|
|
mv copy.txt renamed.txt
|
|
ls -l
|
|
grep Linux notes.txt
|
|
chmod u+x renamed.txt
|
|
ls -l
|
|
cd ..
|
|
rm -r linux-practice
|
|
```
|
|
|
|
What they do:
|
|
- `mkdir` creates a directory.
|
|
- `cd` changes directory.
|
|
- `echo ... > file` writes text to a file.
|
|
- `cp` copies a file.
|
|
- `mv` moves or renames a file.
|
|
- `grep` searches inside a file.
|
|
- `chmod u+x` adds execute permission for the owner.
|
|
- `rm -r` removes a directory and its contents.
|
|
|
|
## Admin Commands To Know
|
|
|
|
Do not run these casually on important systems:
|
|
|
|
```bash
|
|
sudo chown user:group file
|
|
```
|
|
|
|
What it does:
|
|
- Changes file owner/group.
|
|
|
|
```bash
|
|
sudo apt update
|
|
sudo apt install package-name
|
|
```
|
|
|
|
What it does:
|
|
- Updates package lists and installs software on Debian/Ubuntu-based systems.
|
|
|
|
```bash
|
|
sudo dnf install package-name
|
|
```
|
|
|
|
What it does:
|
|
- Installs software on Fedora/Red Hat-based systems.
|
|
|
|
```bash
|
|
sudo fsck /dev/device
|
|
```
|
|
|
|
What it does:
|
|
- Checks and repairs a file system.
|
|
- Usually run on unmounted or read-only volumes.
|
|
|
|
```bash
|
|
sudo mount /dev/device /mnt
|
|
```
|
|
|
|
What it does:
|
|
- Mounts a storage device to a directory.
|
|
|
|
## Windows Comparisons
|
|
|
|
- `ls` is like `dir`.
|
|
- `pwd` is like checking your current path in Command Prompt/PowerShell.
|
|
- `top` and `ps` are like Task Manager process views.
|
|
- `df -h` is like checking drive free space.
|
|
- `fsck` is like `chkdsk`.
|
|
- `traceroute` is like Windows `tracert`.
|
|
- `dig` is like `nslookup`, but usually more detailed.
|
|
|
|
## Mini Lab
|
|
|
|
Goal:
|
|
- Practice common Linux commands safely.
|
|
|
|
Linux:
|
|
1. Run `cat /etc/os-release`.
|
|
2. Run `pwd`.
|
|
3. Run `ls -l`.
|
|
4. Run `cat /etc/passwd`.
|
|
5. Run `cat /etc/hosts`.
|
|
6. Run `cat /etc/resolv.conf`.
|
|
7. Run `ip addr`.
|
|
8. Run `ip route`.
|
|
9. Run `df -h`.
|
|
10. Run `ps aux`.
|
|
11. Run `top`, then press `q`.
|
|
12. Create and remove the `linux-practice` folder from the practice command section.
|
|
|
|
Record:
|
|
- Distribution:
|
|
- Current directory:
|
|
- Current user:
|
|
- DNS server:
|
|
- Default gateway:
|
|
- Root filesystem free space:
|
|
- One running process:
|
|
- What permission changed after `chmod u+x`:
|
|
|
|
Windows comparison:
|
|
1. Run `dir`.
|
|
2. Run `taskmgr`.
|
|
3. Run `tracert example.com`.
|
|
4. Run `nslookup example.com`.
|
|
5. Record which Linux commands match those Windows tools.
|
|
|
|
## Quick Check Before Quiz
|
|
|
|
You are ready for the OS-9 quiz when you can answer these without looking:
|
|
- Which file lists user accounts?
|
|
- Which file stores password hashes?
|
|
- Which command changes file permissions?
|
|
- Which command shows live process/resource usage?
|
|
- Which command shows disk free space?
|
|
- Which package manager is common on Ubuntu/Debian?
|
|
- Which command gives help/manual pages?
|
|
|