Started Study on June 8, 2026
←
Section 3: System Access and Filesystems
Linux Root Directories
- / - The root directory
- /boot - Boot loader files, contains grub.cfg
- /dev - System device files
- /bin - Everyday user commands
- /sbin - System/filesystem commands
- /etc - System configuration files
- /home - User home directories
- /lib - Essential shared libraries and kernel modules
- /media - Mount points for removable media
- /mnt - Temporarily mounted filesystems
- /opt - Optional application software packages
- /proc - Virtual filesystem providing process and system information
- /root - Home directory for the root user
- /run - Runtime data for running processes
- /srv - Service data
-
/sys - Virtual filesystem providing an interface to kernel data structures
- /tmp - Temporary files
- /usr - User binaries, libraries, and documentation
- /var - Variable data such as logs and spool files
Important Filesystem Commands
- cd - Change directory
- ls - List directory contents
- pwd - Print working directory
File Management
- touch - Create an empty file
- cp - Copy files and directories
- mv - Move or rename files and directories
- vi - Edit files
- mkdir - Create a directory
- rmdir - Remove an directory
- chgrp - Change group ownership
- chmod - Change file permissions
Find Files and Diectories
File Types
- - - Regular file
- d - Directory
- l - Symbolic link
- c - Special file or device file
- s - Socket file
- p - Named pipe (FIFO)
- b - Block device file
Soft and Hard Links
-
inode: A number that uniquely identifies a file or directory in the
filesystem
-
Soft link (symbolic link): A file that points to another file or directory
by its path
- Hard link: A directory entry that points to an inode
Section 4:
Filters / Text Procesors Commands
- cut - Extract columns from a file
- cut -d "," -f1 merged.txt > items.txt
- -d: Delimiter
- -f1: Extract from the first field
-
awk - Designed for data extraction, mostly used to extract fields from
output
- cat seinfeld-characters | awk '{$2="Osborne" ; print $0}'
- awk 'length($0) > 15' seinfeld-characters
- ls -l | awk '{if($9 == "seinfeld") print $0;}'
- ls -l | awk '{print NF}'
- grep - Search for keyword in files/output
- grep Seinfeld seinfeld-characters
- grep -c Seinfeld seinfeld-characters (count entries)
- grep -n Seinfeld seinfeld-characters (show line numbers)
- grep -i Seinfeld seinfeld-characters (ignore case)
- grep -v Seinfeld seinfeld-characters (show those without a match)
- grep -v Seinfeld seinfeld-characters | awk '{print $1}' | cut -c1-3
- egrep - Search for multiple keywords
- egrep -i "Seinfeld|Kramer" seinfeld-characters
- sort - Sort lines of text files
- uniq - Report or filter out duplicate lines
- wc - Word count
Text Processing Commands
- sort - Sort lines of text files
- sort seinfeld-characters
- sort -r file (reversed)
- sort -k2 file (sorts by second column value)
- ls -l | sort -k9
- uniq - Hides duplicate sequential entries
- Always use with sort first!
- sort seinfeld-characters | uniq
- sort file | uniq -c (Shows count of each unique)
- sort file | uniq -d (Only show duplicates)
- ls -l | sort | uniq
- wc - Word count
- wc file - Shows line count, words, and bytes
- wc -l file - Shows line count
- wc -w file - Shows word count
- wc -c file - Shows byte count
Compare Files
- diff - Compare files line by line
- diff file1 file2
- cmp - Compare files byte by byte
- cmp file1 file2
sed Command
- Replace a string in a file
- sed 's/old_string/new_string/g' file
- sed -i : Actually changes the file
- new_string can be blank to remove content
- Find and delete a line
- sed '/Seinfeld/d' seinfeld-characters
- Remove empty lines
- sed '/^$/d' file
- Remove first or n lines in a file
- sed '1d' file (removes first line)
- sed '1,3d' file (removes first 3 lines)
- Replace tabs with spaces
- sed 's/\t/ /g' file
- Show defined lines from a file
- sed -n 12,18p file (shows lines 12-18)
- sed 12,18d file (removes lines 12-18)
- sed G file (inserts blank line after each line)
- sed '8!s/Seinfeld/S/g' file (replaces all but line 8)
- :%s/Seinfeld/Peter/ (replace all in vim)
User Account Mgmt
- useradd {}
- groupadd {}
- userdel {}
- groupdel {}
- usermod -G superheroes spiderman
- chgrp -R superheroes spiderman
-
useradd -g superheroes -s /bin/bash -c "Ironman Character" -m -d
/home/ironman ironman
systemtctl
- systemctl start|stop|status servicename.service
- systemctl enable|disable servicename.service
- systemctl restart|reload servicename.service
- systemctl list-units --all
-
To add service: Create unit file in /etc/systemd/system/servicename.service
- systemctl poweroff|halt|reboot
Kill Process Signals
- kill -{} PID
- SIGTERM - Graceful termination
- SIGKILL - Forceful termination
- SIGSTOP - Pause process
- SIGCONT - Resume process
- SIGSEGV - Segmentation fault, invalid memory location
Kill Real-Time Signals
- Send extra information
- SIGRTMIN - Marks beginning of signal range
- SIGRTMAX - Marks end of signal range
System Health Lab Task 1:
- Check system usage and resources
- Manage and monitor processes
- Check disk usage: df -h
- Check memory usage: free -h
- Check running processes: top
- Review system log files
- List Log directory: ls /var/log
- Check the contents of a log file
- head -n 10 /var/log/auth.log
- tail -n 10 /var/log/auth.log
- less /var/log/auth.log
- Manage and monitor processes
- Start a process in the background: sleep 100 &
- View background jobs: jobs
- Move job to background: bg %1
- Move job to foreground: fg %1
- Check user processes: ps -u labsuser
- Run process with modified priority: nice -n 5 sleep 200 &
- Summarize system health information
- View active sessions and activity: w
- Check logged-in users: who
- Check login history: last | head -n 10
System Maintenance Commands
- shutdown
- init
- reboot
- halt - Forces a shutdown as if holding the power button
Changing the Hostname
- hostnamectl set-hostname newhostname
- Must reboot for changes to take effect
Finding System Information
- General Info: uname -a
- lsb_release -a
- cat /etc/os-release
- dmidecode
Terminal Control Keys
- CTRL-u: Erase everything you've typed on current line
- CTRL-c: Stop/kill a command
- CTRL-z: Suspend a command
- CTRL-d: Exit from interactive program