Linux System Administration Essentials (Part 1): Introduction
The first part of the "Linux System Administration Essentials" series, introducing key concepts like the Linux OS Kernel, file systems, the role of system administrators, and core shell commands.
Linux System Administration Essentials (Part 1): Introduction
Linux system administration is a foundational skill for anyone seeking to manage servers, networks, or cloud infrastructures. Whether you’re working in cybersecurity, DevOps, or IT operations, understanding the core aspects of Linux will help you navigate and troubleshoot efficiently.
In this series, we’ll cover the essentials you need to know to get started with Linux System Administration. Let’s begin with the basics.
Understanding Linux
Linux is an open-source operating system kernel that serves as the foundation for a wide range of operating systems. To understand Linux in detail, it’s helpful to break down its components and context:
What is an Operating System?
An operating system (OS) is software that manages hardware and software resources on a computer. It provides a user interface, manages files, handles input and output operations, and ensures that different applications and users can coexist on the same system without interfering with each other.
The Kernel
The kernel is the core component of an operating system. It acts as a bridge between the hardware of a computer and the applications that run on it. The kernel handles low level tasks such as managing memory, processing tasks and controlling hardware devices.
What is Linux?
Linux specifically refers to the kernel developed by Linus Torvalds in 1991. It is a Unix-like operating system kernel which means it follows principles and design philosophies similar to those of Unix, but it is not Unix itself.
Linux vs Unix
While Linux and Unix share many similarities, Linux is not a direct derivative of Unix. It was created from scratch but adheres to Unix design principles. Unix is a proprietary operating system originally developed in the 1970s while Linux is open-source and freely available.
Distributions
Linux distributions (often called distros) are operating systems built around the Linux kernel. Each distribution includes the kernel along with a variety of softwares and tools to create a complete operating system. Some well-known distributions include:
- Ubuntu: Known for its user-friendliness and widespread use in desktops and servers.
- Fedora: Known for its features and close relationship with Red Hat.
- Debian: Known for its stability and extensive package repositories.
- Arch Linux: Known for its simplicity and customization options.
- CentOS: Known for its stability and used primarily in enterprise environments.
Open Source Philosophy
Linux is released under the GNU General Public License (GPL), which is a type of open-source license. This means that anyone can view, modify and distribute the source code. The open-source nature of Linux has fostered a collaborative development environment and led to a diverse range of applications and tools.
Components of a Linux Distribution
A typical Linux distribution includes:
- The Linux Kernel: The core of the OS.
- GNU Utilities: Essential system utilities and libraries (often from the GNU Project).
- Shell: Command-line interface (e.g., Bash).
- Package Manager: Tool for managing software packages (e.g., APT, YUM).
- Desktop Environment: Graphical user interface (e.g., GNOME, KDE) for user interaction.
- Applications: Pre-installed software for productivity, development, and system management.
Linux architecture from mynotesoracldba
Role of a Linux System Administrator
A Linux System Administrator (SysAdmin) plays a crucial role in managing and maintaining Linux-based systems ensuring they run efficiently, securely and reliably. Some of the tasks involved in this role are as follows:
System Installation and Configuration
It includes
Installing Linux operating systems on servers, workstations or other hardware and setting up partitions, configuring boot loaders and selecting software packages etc.
Setting up the operating system and applications according to the organization’s needs i.e. configuring network interfaces, security settings and system services.
User Management
It includes
Adding and managing user accounts, groups and permissions and setting up user home directories, defining user roles and configuring access rights.
Configuring and managing authentication methods such as password policies, two-factor authentication and integrating with directory services like LDAP or Active Directory.
System Monitoring
It includes
- Monitoring system performance, resource usage and health. Setting up logging and alerting systems to track system activities and detect potential issues.
Security Management
It includes
Applying updates and patches to the operating system and installed applications to address security vulnerabilities and bugs.
Setting up and managing firewall rules to protect the system from unauthorized access.
Configuring and managing user permissions and file access controls to ensure that only authorized users can access sensitive data.
Network Configurations
It includes
Setting up and managing network interfaces, routing and DNS settings. Configuring network services such as DHCP and VPNs.
Diagnosing and resolving network issues.
Backup and Recovery
It includes
Implementing and managing backup strategies to ensure data is regularly backed up and can be restored if needed.
Developing and maintaining disaster recovery plans to ensure system availability and data integrity in case of hardware failures, data corruption or other catastrophic events.
Software Management
It includes
Installing, updating and removing software packages using package managers like apt, yum, or dnf. Resolving dependency issues and ensuring that software is up-to-date.
Compiling and installing software from source when necessary and managing custom-built applications.
User Support and Troubleshooting
It includes
Assisting users with technical issues related to the Linux environment. Troubleshooting application problems, system errors and user account issues.
Investigating and resolving hardware and software issues. Analyzing log files and error messages to diagnose and fix problems.
Responsibilities of Linux System Administrator (from manageengine.com)
Understanding the Linux File System
The Linux file system is structured differently compared to Windows or macOS. It follows a hierarchical layout starting from the root (/
) directory. The Linux filesystem is a critical component of the Linux operating system, organizing and managing how data is stored and accessed. A fundamental design principle of Linux is that “everything is a file”. This means that almost all system resources and devices are represented as files, providing a unified interface for interacting with them. Let’s look at the Linux filesystem in more detail:
Filesystem Hierarchy
The Linux filesystem uses a hierarchical structure that starts from the root directory, denoted by /
. All files and directories are organized under this root directory, forming a tree-like structure.
Standard Directory Layout
Some of the standard directories found in a typical Linux filesystem are as follows:
/bin: Contains essential binary executables needed for basic system operations. Examples include commands like ls, cp, mv and rm.
/boot: Contains files required for booting the system such as the Linux kernel and bootloader configuration files.
/dev: Contains device files that represent hardware devices (like disks, terminals and printers). These files are used to interact with hardware components.
/etc: Contains system configuration files and directories. Examples include network configuration files, user account information (/etc/passwd) and system-wide configuration settings.
/home: The default location for user home directories. Each user has a subdirectory here where personal files are stored (e.g., /home/username).
/lib: Contains shared libraries and kernel modules needed by system programs and applications. Libraries are essential for executing programs and include things like system calls and common functions.
/media: A mount point for removable media like USB drives and CDs. Temporary mount points are created here when devices are attached.
/mnt: Traditionally used for mounting filesystems temporarily. System administrators can create subdirectories here to mount additional filesystems.
/opt: Contains optional software packages that are not part of the default system installation. Software installed here is usually managed independently of the system package manager.
/proc: A virtual filesystem that provides process and kernel information as files. It contains details about system processes and kernel parameters (e.g., /proc/cpuinfo).
/root: The home directory for the root user (superuser). It’s separate from /home to ensure the root user’s files are kept separate from regular user files.
/run: Contains runtime data for the system such as process IDs (PIDs) and temporary files needed during system operation.
/sbin: Contains system binaries which are essential for system maintenance and administration. Commands in this directory are typically used by system administrators (e.g., fsck, ifconfig).
/srv: Contains data for services provided by the system such as web and FTP servers. It provides a location for service-specific data.
/tmp: Holds temporary files created by various applications and system processes. Files in /tmp are usually deleted upon system reboot.
/usr: Contains user-related programs and data. It has subdirectories like /usr/bin for user binaries, /usr/lib for libraries and /usr/share for shared data.
/var: Contains variable data files such as logs, mail spools and database files. It is used for files that are expected to grow or change over time.
Mounting and Filesystem Types
Mounting: Linux uses a mechanism called mounting to access filesystems. Filesystems are attached to directories (mount points) in the existing hierarchy. For example, external drives and partitions are mounted to directories like /mnt or /media.
Filesystem Types: Linux supports various filesystem types, including:
- ext4: The fourth extended filesystem, known for its stability and performance.
- XFS: A high-performance filesystem designed for large files and scalable storage.
- Btrfs: A modern filesystem with features like snapshotting and dynamic inode allocation.
- FAT32 and NTFS: Filesystems used primarily for compatibility with other operating systems, like Windows.
Special Filesystems
/sys: A virtual filesystem that provides information and control over the kernel and hardware devices. It’s used for interacting with device drivers and kernel subsystems.
/dev/shm: A temporary filesystem (tmpfs) used for shared memory. It allows applications to share data quickly using memory rather than disk storage.
Filesystems and Disk Partitions
Partitions: Disk drives are divided into partitions each of which can be formatted with a filesystem. This allows multiple filesystems to coexist on a single physical disk.
Logical Volume Management (LVM): An advanced storage management system that allows for flexible disk partitioning and resizing.
Filesystem Commands
Linux provides several commands to manage and interact with filesystems:
- ls: Lists directory contents.
- df: Shows disk space usage.
- du: Displays disk usage for files and directories.
- mount: Mounts filesystems.
- umount: Unmounts filesystems.
- fsck: Checks and repairs filesystem integrity.
Structure of Linux File System(from The Linux Foundation)
File Permissions and Ownership
Linux filesystems support a robust permission system to control access to files and directories. Each file and directory has associated permissions and ownership attributes:
Permissions: There are three types of permissions for each file or directory:
- Read (r): Allows viewing the file’s contents or listing directory contents.
- Write (w): Allows modifying the file’s contents or adding/removing files in a directory.
- Execute (x): Allows executing the file as a program or script or traversing a directory.
Ownership: Each file and directory has an owner and a group associated with it:
- User (Owner): The individual user who owns the file.
- Group: A group of users that shares access to the file.
- Other: Users who do not own the file or belong to the file’s group.
Linux Permissions
Basic Shell Commands and Navigation
The Linux shell is where system administrators spend a significant amount of time. Understanding basic shell commands and navigation is essential for working efficiently in a Linux or Unix-like environment. The shell is a command-line interface that allows users to interact with the operating system. Here’s a detailed explanation of fundamental shell commands and navigation techniques:
1. Opening the Shell
- Terminal Emulator: On most Linux desktop environments, you can open a terminal emulator (such as GNOME Terminal, Konsole, or xterm) to access the shell.
- Shell Prompt: When you open a terminal, you’ll see a prompt where you can enter commands. The prompt usually displays information such as the username, hostname and current directory.
2. Basic Navigation Commands
pwd
(Print Working Directory): Displays the full path of the current directory.1
pwd
Example Output:
/home/username
ls
(List): Lists the files and directories in the current directory. It has various options to customize its output.- Basic Usage:
ls
- Detailed Listing:
ls -l
(provides detailed information including permissions, ownership and modification date) - Including Hidden Files:
ls -a
(lists all files including hidden ones which start with a dot.
)
- Basic Usage:
cd
(Change Directory): Changes the current working directory.- Change to a Specific Directory:
cd /path/to/directory
- Move Up One Directory:
cd ..
- Return to Home Directory:
cd
orcd ~
- Change to Previous Directory:
cd -
- Change to a Specific Directory:
mkdir
(Make Directory): Creates a new directory.1
mkdir new_directory
rmdir
(Remove Directory): Deletes an empty directory.1
rmdir directory_name
rm
(Remove): Deletes files and directories. Be cautious with this command especially when used with options like-r
and-f
.- Remove a File:
rm file_name
- Remove a Directory and its Contents:
rm -r directory_name
- Force Removal Without Prompt:
rm -f file_name
- Remove a File:
3. File Manipulation Commands
cp
(Copy): Copies files or directories from one location to another.- Copy a File:
cp source_file destination_file
- Copy a Directory Recursively:
cp -r source_directory destination_directory
- Copy a File:
mv
(Move): Moves or renames files and directories.- Move a File:
mv source_file destination_file
- Rename a File:
mv old_name new_name
- Move a Directory:
mv source_directory destination_directory
- Move a File:
touch
: Creates an empty file or updates the timestamp of an existing file.1
touch file_name
cat
(Concatenate): Displays the contents of a file or concatenates multiple files.1
cat file_name
more
andless
: View the contents of a file one page at a time.less
is more advanced and allows both forward and backward navigation.- View a File with
more
:more file_name
- View a File with
less
:less file_name
- View a File with
head
: Displays the first few lines of a file.1
head file_name
- Show the First 10 Lines (default):
head file_name
- Specify Number of Lines:
head -n 20 file_name
- Show the First 10 Lines (default):
tail
: Displays the last few lines of a file.1
tail file_name
- Show the Last 10 Lines (default):
tail file_name
- Specify Number of Lines:
tail -n 20 file_name
- Follow File Changes:
tail -f file_name
(useful for watching log files)
- Show the Last 10 Lines (default):
4. File Permissions and Ownership
chmod
(Change Mode): Changes the permissions of a file or directory.- Set Permissions Using Octal Notation:
chmod 755 file_name
- Set Permissions Using Symbolic Notation:
chmod u+x file_name
(adds execute permission for the owner)
- Set Permissions Using Octal Notation:
chown
(Change Ownership): Changes the owner and/or group of a file or directory.1 2
chown new_owner file_name chown new_owner:new_group file_name
chgrp
(Change Group): Changes the group ownership of a file or directory.1
chgrp new_group file_name
5. Searching and Finding Files
find
: Searches for files and directories in a directory hierarchy.- Find Files by Name:
find /path -name filename
- Find Files by Type:
find /path -type f
(for files) orfind /path -type d
(for directories) - Find Files by Size:
find /path -size +100M
(files larger than 100 MB)
- Find Files by Name:
grep
: Searches for specific patterns within files.- Search for a Pattern in a File:
grep pattern file_name
- Search Recursively in Directories:
grep -r pattern /path
- Search for a Pattern in a File:
6. Viewing and Editing Files
nano
: A simple text editor for the command line.1
nano file_name
vim
: A powerful text editor with a steeper learning curve but more features.1
vim file_name
7. Process Management
ps
: Displays information about currently running processes.- Basic Usage:
ps
- Show All Processes:
ps aux
- Basic Usage:
top
: Provides a dynamic, real-time view of system processes and resource usage.kill
: Sends signals to processes usually to terminate them.1
kill process_id
pkill
: Kills processes by name.1
pkill process_name
Basic Shell Commands
Final Thoughts
In this part of the Linux System Administration Essentials series we covered the basics of Linux, the role of a system administrator, the Linux file system and essential shell commands. This foundation will help you as we dive deeper into more advanced topics in upcoming write-ups.
I hope you found this write-up insightful! If you did, please share it with your friends and colleagues. If you have any doubts feel free to ask. Don’t forget to follow Security Mates for more in-depth explorations of cybersecurity related topics.