Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
This guide consolidates the core concepts of the Linux filesystem hierarchy, file manipulation, permission management, and data processing tools that are fundamental to the RHCSA exam and real-world administration.
Think of a filesystem as the library catalog and shelving system for your hard drive. It’s the method the operating system uses to:
Without it, the OS wouldn’t know where files are or how to access them.
Linux uses a single, inverted tree structure that starts from the root directory (/). This is a key difference from Windows (which uses drive letters like C:).
| Directory | Purpose | RHCSA Relevance |
|---|---|---|
/ | The root of the entire filesystem. | The starting point for all absolute paths. |
/etc | Contains system-wide configuration files. | Critical for configuring services like sshd or httpd. |
/home | Contains user home directories (e.g., /home/john). | Essential for user management and data storage. |
/var | Contains variable data like logs, databases, and websites. | Log files in /var/log are crucial for troubleshooting. |
/tmp | Temporary files that are deleted on reboot. | Understanding permissions and cleanup. |
These are the most basic and frequently used commands.
| Command | Purpose | Example |
|---|---|---|
pwd | Print Working Directory – shows where you are. | pwd → /home/john |
ls | List directory contents. | ls -l (detailed list), ls -a (show hidden files) |
cd | Change Directory. | cd /etc, cd .. (up one level), cd or cd ~ (go home) |
tree | Display directory structure as a tree (may require dnf install tree). | tree /etc |
Use wildcards to match multiple files/directories for efficient bulk operations.
| Wildcard | Purpose | Example |
|---|---|---|
* | Matches any number of characters. | ls *.conf (lists all .conf files) |
? | Matches exactly one character. | ls file?.txt (matches file1.txt, but not file10.txt) |
[ ] | Matches one character from a set. | ls file[1-3].txt (matches file1.txt, file2.txt, file3.txt) |
| { } | touch text{1..6}.txt ( created text1.txt to text6.txt) |
Control where command input comes from and where output goes.
| Operator | Purpose | Example |
|---|---|---|
> | Output Redirection (overwrites file). | ls -l /etc > etc_list.txt |
>> | Append Output (adds to end of file). | df -h >> disk_report.txt |
< | Input Redirection (reads from file). | wc -l < /etc/passwd |
| | Pipe (sends output to another command). | cat /var/log/messages | grep error |
| Feature | Hard Link | Soft/Symbolic Link |
|---|---|---|
| Points to: | The inode directly. | The filename/path. |
| Behavior: | An additional name for the exact same file. | A shortcut to the original file. |
| If original is deleted: | File remains (link still points to inode). | Link breaks (“dangling link”). |
| Cross filesystem: | No. | Yes. |
| Command: | ln original link_name | ln -s original link_name |
ls -lOutput: -rwxr-xr--. 1 john root 1234 Jul 10 10:30 myfile
-rwxr-xr--: Permissions string.john: File owner.root: File group.Understanding the Permission String:- rwx r-x r--
-): File type (-=file, d=directory, l=link).rwx): Owner (u) permissions.r-x): Group (g) permissions.r--): Others (o) permissions.chmodchmod [who][operator][permissions] file
who: u (user/owner), g (group), o (others), a (all)operator: + (add), - (remove), = (set exactly)permissions: r (read), w (write), x (execute)chmod g+w myfile (Adds write permission for the group).chown and chgrpchown new_owner file (e.g., chown john myfile)chown owner:group file (e.g., chown john:wheel myfile)chgrp new_group file (e.g., chgrp root myfile)| Command | Purpose | Example |
|---|---|---|
find | Powerful search based on name, size, type, etc. | find /etc -name "httpd.conf"find /home -type f -size +10M |
locate | Very fast search using a pre-built database. | locate sshd_config |
which | Shows the full path of a shell command. | which systemctl |
type | Shows how a command is interpreted (alias, built-in, etc.). | type cd → cd is a shell builtin |
tar Command (Tape Archive)tar -cvf archive_name.tar /path/to/dirtar -xvf archive_name.tartar -tvf archive_name.targzip file.tar → creates file.tar.gzbzip2 file.tar → creates file.tar.bz2xz file.tar → creates file.tar.xztar -czvf backup.tar.gz /etctar -xzvf backup.tar.gz| Command | Purpose | Example |
|---|---|---|
cat | View entire file content. | cat /etc/passwd |
head | View first lines of a file (default: 10). | head -5 /etc/passwd |
tail | View last lines of a file (default: 10). | tail -5 /etc/passwd |
wc | Word count (lines, words, characters). | wc -l /etc/passwd (count users) |
sort | Sort lines of a file. | sort /etc/passwd |
uniq | Report or omit repeated lines (use on sorted data). | sort file.txt | uniq |
diff | Compare two files line-by-line. | diff file1.txt file2.txt |
cmp | Compare two files byte-by-byte. | cmp file1.txt file2.txt |
cut | Extract columns/fields from text. | cut -d: -f1 /etc/passwd (get usernames) |
grep | Search for text patterns. | grep "root" /etc/passwd |
pwd, ls, cd to move around.find or locate to find files.cat, head, tail, less to view contents.grep, cut, sort, wc to process information.chmod and chown to control access.tar to create archives for safe-keeping.Conclusion: Mastery of the filesystem and these core utilitie