Network and System Administration
Network and System Administration
Challenges
Scalability: As organizations grow, systems and networks need to scale efficiently without
degradation in performance.
Security: Protecting the system from both internal and external threats through firewalls,
encryption, and continuous monitoring.
Downtime Management: Minimizing downtime through redundancy, backups, and
disaster recovery plans.
Automation: Handling repetitive tasks through scripting or automation tools to improve
efficiency and reduce human error.
Resource Optimization: Ensuring that servers, storage, and network bandwidth are used
efficiently to avoid bottlenecks.
Common Practices
Backup and Recovery: Regularly backing up data and creating disaster recovery plans.
Monitoring and Logging: Using monitoring tools (e.g., Nagios, Zabbix) and maintaining
logs for troubleshooting and security.
Documentation: Keeping up-to-date documentation of systems, configurations, and
procedures.
User Management: Managing user accounts, permissions, and authentication methods.
Patch Management: Keeping systems and software updated with the latest security
patches and updates.
Windows Systems
Philosophy:
o Designed to be user-friendly with a strong focus on graphical user interfaces (GUI).
Strengths:
o GUI-oriented: Makes it easier for non-technical users to interact with the system.
o Broad Application Support: Extensive support for enterprise applications (e.g., Microsoft
Office, Exchange Server, etc.).
o Active Directory (AD): Offers a robust directory service for centralized management of
resources.
o Integration with Microsoft Ecosystem: Seamless integration with other Microsoft
products and services.
Common Uses:
o Enterprise environments, desktop computing, user account management, etc.
Challenges:
o Licensing costs can be high.
o Windows may be more susceptible to malware compared to Unix-like systems.
Additional Considerations:
Hybrid Environments: Many organizations utilize both Unix-like and Windows systems in
hybrid environments to leverage the strengths of each.
Cloud Platforms: Both Unix-like and Windows systems are widely available on cloud
platforms, providing flexibility and scalability options.
Personal Preferences: The choice between Unix-like and Windows systems often depends
on personal preferences, familiarity, and specific use case requirements.
Linux Distributions
Definition: A Linux distribution is a specific version of Linux bundled with various tools,
applications, and system management utilities.
Popular Distributions
1. Ubuntu:
o Popular for beginners due to its ease of use and strong GNOME GUI.
o Widely used for both desktop and server environments.
2. CentOS/Red Hat Enterprise Linux (RHEL):
o Enterprise-grade distribution with a focus on security and stability.
o Preferred for corporate and high-availability server environments.
3. Debian:
o Known for its stability and versatility.
o Often used as the basis for other distributions (e.g., Ubuntu).
4. Arch Linux:
o Highly customizable and aimed at experienced users.
o Minimal out-of-the-box, encouraging users to build from the ground up.
5. Fedora:
o A cutting-edge distro, often used for testing the latest technologies.
o Serves as the upstream project for RHEL.
The File System Hierarchy Standard (FHS) defines the directory structure and directory
contents in Linux and Unix-like systems. It outlines how directories should be organized,
ensuring consistency across different Linux distributions.
Key Directories in FHS
/(Root Directory): The top-level directory, from which all other directories branch off.
/bin: Contains essential user commands (e.g., ls, cp, mv), required for the system to
operate in single-user mode.
/boot: Holds files needed for the bootloader, including the Linux kernel.
/dev: Contains device files representing hardware devices (e.g., hard drives, keyboards).
/etc: Holds system configuration files (e.g., passwd, hosts, fstab).
/home: Directory containing user-specific data and configuration (each user has a sub-
directory within /home).
/lib: Contains essential shared libraries and kernel modules required for booting.
/mnt and /media: Used for mounting external devices (e.g., USB, CD-ROMs).
/opt: For installing optional software that is not part of the standard Linux distribution.
/proc: Virtual filesystem providing information about system processes and hardware.
/root: The home directory for the superuser (root).
/sbin: Contains essential system administration commands (e.g., ifconfig, fdisk).
/tmp: Temporary files are stored here; usually cleaned up automatically.
/usr: Secondary hierarchy containing user programs and libraries that are not essential for
system booting.
/var: Contains variable data such as logs, spool files, and temporary storage for system
services (e.g., log, mail).
The FHS helps ensure that system files and user data are properly organized and
accessible, making it easier for administrators to navigate and manage Linux systems.
Single-rooted Hierarchy
In Linux and Unix-like systems, the file system is single-rooted, meaning there is a single
top-level directory called the root directory (/).
All files, directories, devices, and partitions are part of this single hierarchy and branch out
from the root directory.
Unlike Windows, where there may be separate file systems for each drive (C:, D:, etc.),
Linux unifies everything under a single root. For instance, external drives and partitions
are mounted under existing directories within the root hierarchy.
Seamless Integration
In a single-rooted hierarchy, different file systems (e.g., external devices, network drives, or
partitions) are mounted to directories within the root structure, creating a seamless and
unified interface.
Example: You might mount a USB drive to /mnt/usb, making it appear as part of the file
system tree, even though it's physically a separate device.
Administrators can manage multiple file systems (e.g., ext4, NTFS, FAT32) within the same
file hierarchy, making it easier to access and work with various storage media.
Extensibility refers to the system's ability to grow and scale without major
reconfigurations. Linux file systems can be expanded easily, either by adding new storage
devices or by resizing partitions.
The Logical Volume Manager (LVM) allows dynamic resizing of file systems, making it
easier to extend disk storage without interrupting system operations.
Ext4 (Fourth Extended File System): The most widely used Linux file system, known for
its reliability, performance, and scalability.
XFS: High-performance journaling file system, commonly used in large-scale environments.
Btrfs (B-tree File System): A modern file system with advanced features like snapshots,
compression, and dynamic resizing.
ZFS: Offers high storage capacities, advanced data protection, and file system integrity
checks.
Flexibility: Linux file systems support a wide range of devices and partition types (local
and remote).
Stability: Systems are rarely affected by file system crashes due to journaling and other
safeguards.
Security: Linux's file system permissions and access controls (read, write, execute) provide
robust security.
Additional Considerations
File System Type: Specify the file system type using the -t option if necessary (e.g., -t ext4,
-t ntfs).
Mount Options: Use mount options to control behavior (e.g., -o rw for read/write access, -
o ro for read-only access).
Automatic Mounting: Configure /etc/fstab to automatically mount file systems at boot.
Network File Systems (NFS): Mount network drives using NFS by specifying the server
and share name.
Virtual File Systems (VFS): Linux supports various virtual file systems (e.g., procfs, sysfs)
for accessing system information.
By mastering the process of mounting file systems, administrators can easily access
and manage external storage devices, network drives, and other file systems within
their Linux environments.
You can configure file systems to be mounted automatically at boot by adding an entry to
the /etc/fstab file. This file defines which devices are mounted where and with what
options.
Mounting Network File Systems
Linux also supports mounting network file systems like NFS (Network File System) and
SMB/CIFS (for accessing Windows shares). These allow accessing remote file systems as
if they were local.
Example of mounting an NFS share:
Bash
Additional Considerations
fstab Entries: The /etc/fstab file uses a specific format for entries. Refer to the
documentation for more details.
NFS Configuration: Ensure that NFS is enabled and configured correctly on both the
server and client machines.
SMB/CIFS Configuration: Install the necessary packages (e.g., cifs-utils) and configure
SMB/CIFS on both Windows and Linux systems.
Security: Implement appropriate security measures (e.g., authentication, encryption)
when mounting network file systems.
By mastering these techniques, administrators can effectively manage and access file
systems from various sources within their Linux environments.
1.5.1.3 File System Object-Oriented Design and File System Standards
An object-oriented design in file systems refers to viewing each entity within the system
(files, directories, devices, etc.) as an object that can be interacted with in a uniform way.
1. Uniformity: Files, directories, and devices are treated similarly as objects, making the
system modular and extensible.
2. Encapsulation: Each file or directory object manages its own data and metadata (e.g.,
ownership, permissions, timestamps).
3. Inheritance: File system objects can inherit properties (e.g., permissions) from their
parent objects.
4. Polymorphism: Objects in the file system can respond to the same commands (e.g., read,
write) differently based on their type (e.g., file, directory, device).
FHS (File System Hierarchy Standard): As previously discussed, this standard defines the
structure and organization of file systems in Linux.
POSIX (Portable Operating System Interface): A set of standards for maintaining
compatibility between Unix-like operating systems, including how file systems and
permissions are handled.
Other notable file system standards include EXT (Extended File System standards),
which govern the EXT family (EXT2, EXT3, EXT4), commonly used in Linux.
1.5.1.4 Unix File and Directory Permissions
Unix-like systems, including Linux, implement a permissions model to control who can
access, modify, or execute files and directories.
Permission Types
Read (r): Allows viewing the contents of a file or listing the contents of a directory.
Write (w): Allows modifying or deleting the contents of a file or directory.
Execute (x): Allows executing a file as a program or entering a directory.
User Classes
Permission Format
Symbolic Mode:
Bash
Changing Ownership
1. SetUID (Set User ID): When applied to an executable file, the process will run with the file
owner's permissions rather than the user who executed it.
o Symbolic representation: s in the owner's execute position.
o Octal representation: 4 (e.g., chmod 4755 filename).
2. SetGID (Set Group ID): When applied to a directory, files created within it inherit the
group ownership of the directory.
o Symbolic representation: s in the group's execute position.
o Octal representation: 2 (e.g., chmod 2755 dirname).
3. Sticky Bit: When applied to a directory, only the file owner can delete or modify files
within it.
o Symbolic representation: t in the others' execute position.
o Octal representation: 1 (e.g., chmod 1755 dirname).
Example of Special Permissions
Consider a shared directory where multiple users can write files, but no one can delete files
except their owner. In this case, you would set the sticky bit:
Bash
chmod +t /shared_directory
1. ls (List Files):
o Displays the contents of a directory.
o Example:
Bash
ls -l
2. cp (Copy Files):
o Copies files or directories.
o Example:
Bash
cp file1 file2
3. mv (Move/Rename Files):
o Moves or renames files or directories.
o Example:
Bash
mv file1 /home/user/destination/
4. rm (Remove Files):
o Deletes files or directories.
o Example:
Bash
rm file1
5. touch (Create Empty Files):
o Creates an empty file or updates the timestamp of an existing file.
o Example:
Bash
touch newfile.txt
6. cat (Concatenate and Display Files):
o Displays the content of a file.
o Example:
Bash
cat file1
7. nano or vi (Text Editors):
o Simple text editors used to modify files within the shell.
o Example:
Bash
nano file1
vi file1
cd (Change Directory):
o Navigates to a different directory.
o Example:
Bash
cd /home/user
pwd (Print Working Directory):
o Displays the current working directory.
o Example:
Bash
pwd
mkdir (Make Directory):
o Creates a new directory.
o Example:
Bash
mkdir newdirectory
rmdir (Remove Directory):
o Deletes an empty directory.
o Example:
Bash
rmdir emptydir
find (Search for Files/Directories):
o Searches for files or directories based on specified criteria.
o Example:
Bash
du -h
ps aux
top (System Monitor):
o Displays a list of running processes, their CPU usage, memory consumption, and other
statistics.
o Example:
Bash
top
kill (Terminate Processes):
o Terminates a running process.
o Example:
Bash
kill 1234
jobs (List Background Jobs):
o Lists background jobs that are running or suspended.
o Example:
Bash
jobs
fg (Foreground Job):
o Brings a background job to the foreground.
o Example:
Bash
fg %1
1.5.2.2 Advanced File Manipulation Commands (Init, Processes, and Threads)
ps (Process Status):
o Displays information about active processes.
o Example:
Bash
ps aux
top (Real-time Process Monitoring):
o Shows a real-time view of running processes and their resource usage.
o Example:
Bash
top
htop (Improved top with an Interactive Interface):
o An advanced process manager with a better user interface and functionality.
kill and killall (Terminate Processes):
o Terminates a process using its process ID (PID).
o Example:
Bash
kill 1234
killall firefox
nice and renice (Process Priority Management):
o Adjusts the priority of a process. A lower "nice" value increases priority.
o Example:
Bash
nice -n 10 processname
renice -n 5 1234
jobs, fg, bg:
o jobs: Displays background jobs.
o fg: Brings a background job to the foreground.
o bg: Sends a job to run in the background.
init and systemd (System Initialization):
o init: Legacy system and service manager. Used to initialize processes during booting.
o systemd: A more modern and commonly used system and service manager that starts up
and maintains processes.
o Example:
Bash
df -h
Combining Commands
Pipelines (|): Connect the output of one command to the input of another.
o Example:
Bash
Redirecting Output
Output Redirection (>): Redirect the output of a command to a file, overwriting existing
content.
o Example:
Bash
Command Substitution
firefox &
bg and fg: Manage background jobs, bringing them to the foreground or resuming them.
Environment Variables
Environment variables store information used by programs and the shell itself.
o Example:
Bash
echo $PATH
Displays the directories where the shell looks for executable files.
Setting Variables:
o Example:
Bash
export MYVAR="Hello"
echo $MYVAR
Shell Scripting
Shell scripts are programs written in the shell language (e.g., Bash) to automate tasks.
o A basic script example:
Bash
#!/bin/bash
echo "This is a basic shell script."
ls -l
Save the script as script.sh.
Make it executable with chmod +x script.sh.
Run it with ./script.sh.
Aliases
ls *.txt
o ? (Question mark): Matches a single character.
o [] (Square brackets): Matches characters within the brackets.
By understanding these advanced features, you can significantly enhance your efficiency
and automation capabilities when working with the shell.
2.1.1 What are User and Group Concepts, and User Private Group Scheme?
User Concepts
A user in a Linux or Unix-like system is any individual who interacts with the system. Each
user is associated with an account, which grants access to system resources based on their
permissions. Users are assigned unique identifiers and can belong to one or more groups
that define their roles and privileges.
1. Username: A unique identifier chosen by the user or system administrator (e.g., john,
admin).
2. User ID (UID): A unique numerical identifier assigned to each user (e.g., 1000, 1001). The
system uses this number internally to identify the user.
3. Home Directory: A private directory assigned to each user to store personal files
(/home/username).
4. Shell: The command-line interpreter associated with the user (e.g., /bin/bash).
5. Password: A secret key used to authenticate the user when logging in.
6. UID 0 (Root User): The root user (UID 0) is the superuser with unrestricted access to all
system files and commands.
Adding a User: System administrators use commands like useradd to create a new user
account. - Example: bash sudo useradd -m john sudo passwd john
Deleting a User: To remove a user account, the userdel command is used. - Example:
bash sudo userdel -r john
Modifying a User: The usermod command modifies user attributes such as home
directories, groups, or shell settings. - Example: bash sudo usermod -s /bin/zsh john
Group Concepts
Group: A collection of users who share common access permissions.
Components of a Group:
o Group Name
o Group ID (GID)
o Group Members
Types of Groups:
o Primary Group: Automatically assigned to each user.
o Secondary Groups: Additional groups a user belongs to.
groups john
Removing a User from a Group:
Bash
UPG in Action
1. A user creates a file, and it is automatically assigned the permissions -rw-r--r-- (644).
2. The user can share the file with others by adding them to the same group.
User Administration
Adding a User:
Bash
groups john
Password Aging
Password aging is a security measure used to enforce password expiration and renewal
policies.
Key settings:
o Maximum Password Age
o Minimum Password Age
o Warning Period
Using chage command:
o View password aging information:
Bash
Conclusion:
User and group administration** is essential for controlling access to system resources, while
**password aging** policies help enhance security by enforcing password renewal. Default
user files, managed through the `/etc/skel` directory, provide a standard configuration
environment for all new users, ensuring consistency and allowing customization by
administrators. Together, these concepts ensure effective management and security of user
accounts in any Linux or Unix-based system.
Examples
This section builds upon your understanding of file ownership and dives into managing file
permissions for secure access control.
sudo quotaon -v /
Additional Considerations:
Quota Reporting: Use repquota to view quota usage.
Adjusting Quotas: Modify quota limits using edquota as needed.
Quota Enforcement: Ensure quotas are enforced consistently.
By effectively managing disk quotas, administrators can prevent excessive disk
usage and ensure fair resource allocation among users.
You've provided a comprehensive overview of disk quota management in Linux. Here's a
summary of the key points:
Disk Quotas
Purpose: Limit disk space and inode usage for users and groups.
Types:
o Soft Quota: A limit that can be exceeded temporarily.
o Hard Quota: A strict limit that cannot be exceeded.
Setup:
1. Enable quotas in /etc/fstab.
2. Initialize quota files using quotacheck.
3. Assign quotas using edquota.
4. Configure grace periods using edquota -t.
5. Enable quota enforcement using quotaon.
Best Practices
Use soft quotas for warnings.
Monitor disk usage regularly.
Apply quotas to groups for efficient management.
Educate users about disk quotas.
By effectively managing disk quotas, administrators can ensure fair resource
allocation and prevent excessive disk usage.
Conclusion:
Controlling access to files** using permissions, ACLs, and advanced features like sticky bits
and setuid is essential for maintaining security and organization on a system. **Disk quotas**
are vital for managing resources, preventing individual users or groups from consuming
excessive disk space, which could impact system performance. Properly managing file access
and quotas is key to a stable, secure, and efficient multi-user environment.
CHAPTER 3: FILE SYSTEMS AND MANAGEMENT OF DATA STORAGES (4HR)