0.Linux
- Linux is a free and open-source operating system, meaning its code is publicly available for anyone to modify and expand. This has resulted in a wide variety of Linux distributions available today.
- It is similar in function to Unix, an operating system developed in the late 1960s.
- Linux is known for its stability, rarely experiencing system freezes that require restarts.
- It can be used both as a desktop operating system and a server operating system due to its flexibility and stability.
- Multiple users can use the same computer simultaneously, and it supports running multiple applications at the same time.
- Linux has built-in networking capabilities and offers a range of system tools and utilities for enhanced usability.
Linux Distributions
- A Linux distribution is a packaged version of Linux that bundles the core operating system (the kernel) with additional tools and software applications. These are developed by individuals or companies.
- Distributions are usually downloaded and can be installed in various formats like CDs, USB drives, or ISO images.
- Examples of popular Linux distributions:
- Amazon Linux 2
- Red Hat Enterprise Linux (RHEL)
- Debian
- Ubuntu
- CentOS
- Amazon Linux 2 is specifically designed for use on AWS virtual machines and is optimised for performance and security within the AWS cloud.
- CentOS was widely used but has been replaced by CentOS Stream since December 2020.
Components of a Linux System
- Kernel: The heart of the OS, the kernel controls everything in the system. This includes managing CPU time, memory allocation for the operating system and applications, and access to hardware components like the sound card, hard drive, and network card.
- Daemons: These are background processes that run independently of user interaction and provide essential system services. Examples include:
- syslogd: This daemon logs system and application messages for troubleshooting.
- sshd: Manages secure shell (SSH) connections to the computer, enabling remote access.
- Applications: These are the programs that users interact with to perform tasks, like:
- Word processors
- Web browsers
- Email clients
- Media players
- Data Files: These contain the information created and used by both users and applications. They come in various formats like text files, music files, image files, and more. These files are usually organised into directories.
- Configuration Files: These files hold settings that control the behaviour of system programs and services. They are often plain text files and use extensions like .cnf, .conf, .cfg, .cf, and .ini. For example, the
/etc/groupfile manages user permissions on the system.
Linux User Interfaces
- Linux offers two primary ways to interact with the system:
- Graphical User Interface (GUI): A visually intuitive interface similar to Windows or macOS, commonly used on desktop systems.
- Command Line Interface (CLI): A text-based interface where users type commands to interact with the system. This is favoured for its flexibility, power, and efficiency, especially in server environments.
The Shell and Commands
- The shell acts as an interpreter between the user and the kernel when using the CLI. It takes commands typed by the user and executes them by calling the appropriate kernel functions.
- Bash Shell is the default shell in most Linux distributions.
- Each shell has its own syntax for writing commands.
- The
mancommand provides access to the manual pages, which offer detailed documentation for each command, including its purpose, syntax, options, and usage examples.
Lab work theory explanation [Important]
Connecting to a Remote Linux Server: SSH & PuTTY
SSH (Secure Shell) Explained
SSH (Secure Shell) is a network protocol used for secure remote access to a computer. It allows users to:
- Log in to a remote machine.
- Execute commands on the remote machine.
- Transfer files between the local and remote machines.
SSH achieves its security by encrypting the communication between the client (your computer) and the server (the remote machine). This encryption prevents eavesdropping and ensures that only authorized users can access the server.
How is SSH Used with AWS Linux AMIs?
When you launch an Amazon Linux 2 instance in AWS, you are provided with a private key file (usually in the .pem format) for authentication. This key is essential for establishing a secure SSH connection to your instance. Here's how it works:
- Launch Instance: You launch an Amazon Linux 2 instance (or any Linux-based AMI) in AWS.
- Key Pair: A key pair (consisting of a public and private key) is either created during instance launch or you can use an existing key pair. The public key is stored on the instance, and you download the private key to your local machine.
- SSH Client: You use an SSH client on your local machine (like the built-in terminal in macOS and Linux or PuTTY on Windows) to connect to the instance using its public IP address.
- Authentication: The SSH client uses your private key to authenticate with the instance's public key. This establishes a secure encrypted connection.
- Access: Once authenticated, you can interact with your Linux instance as if you were physically present at the console.
PuTTY: Connecting from Windows
PuTTY is a free and open-source SSH client for Windows. Since Windows doesn't come with a built-in SSH client, PuTTY provides a graphical interface for connecting to remote servers.
Key Points about PuTTY:
- Conversion: PuTTY uses the
.ppk(PuTTY Private Key) format. You'll need to convert your.pemkey to.ppkusing PuTTYgen, a tool included with PuTTY. - Configuration: PuTTY allows you to specify the instance's IP address, the username (e.g.,
ec2-user), and the path to your.ppkkey file. - Connection: Once configured, PuTTY establishes the secure SSH connection to your Amazon Linux 2 instance, enabling you to manage it remotely.
Importance of SSH and PuTTY for AWS
- Security: SSH provides a secure way to manage your Linux instances, preventing unauthorized access.
- Remote Management: You can manage your AWS instances from anywhere, without needing physical access to a server.
- Automation: SSH allows you to automate tasks like software installation, configuration management, and system updates using scripts.