Linux is a widely used open-source operating system based on Unix. It is known for its stability, security, and flexibility. The core of Linux is the *Linux Kernel*, which manages hardware resources, system operations, and communication between software and hardware.
1. Linux Architecture
Linux has a layered architecture, which consists of:
- Kernel: The core of the Linux operating system, managing hardware resources, memory, processes, and system calls. It acts as an intermediary between hardware and software.
- Shell: An interface that allows users to interact with the kernel via commands (e.g., Bash, Zsh).
- System Libraries: Provide functions and services to programs, including system calls.
- System Utilities: Programs that perform system maintenance tasks (e.g., file manipulation, network management).
2. Linux Distributions
Linux distributions (distros) are variations of Linux that bundle the kernel with different software and package management tools. Popular distros include:
- Ubuntu: User-friendly, popular for desktops and servers.
- CentOS: Derived from Red Hat Enterprise Linux, commonly used in servers.
- Debian: Known for stability and the basis of many other distros, including Ubuntu.
- Arch Linux: A rolling-release distro focused on simplicity and contro
- Red Hat Enterprise Linux (RHEL): A commercial distribution with enterprise support.
3. Basic Linux Commands
Linux comes in various distributions (distros) tailored for specific use cases. Examples include:
1. ls: Lists files and directories.
2. cd: Changes the current directory.
3. pwd: Prints the current directory path.
4. cp: Copies files and directories.
5. mv: Moves or renames files and directories.
6. rm: Removes files and directories.
8. chmod: Changes file permissions.
9. man: Displaysthe manual for commands.
4. File Permission Management
Linux uses a permission model for file access that includes:
Permissions are represented as r (read), w (write), and x (execute).
- Owner: The user who owns the file.
- Group: Users who belong to the file's group.
- Others: Everyone else.
Use the chmod command to change file permissions. For example, chmod 755 filename gives full permissions to the owner and read/execute permissions to others.
5.User Creation
To create a new user in Linux, the useradd command is used. For example, sudo useradd username creates a new user. After that, passwd username sets the user’s password. To delete a user, use userdel username.
Linux also supports managing users with groups, where multiple users can share permissions to certain files by belonging to a specific group.
6. Shell Scripts
Shell scripts are files containing a series of Linux commands that can automate tasks. A shell script typically starts with #!/bin/bash to define the shell type. Example:
#!/bin/bash
echo "Hello, World!"
Save the file with .sh extension and make it executable with chmod +x script.sh. Run the script with ./script.sh.
7. SSH (Secure Shell)
SSH is a protocol used to securely connect to remote systems. It encrypts the data transmitted between the client and the server. To use SSH, the following command is used:
ssh username@hostname_or_IP
SSH is essential for remote server management and is widely used in system administration.
In summary, Linux offers a robust and flexible platform for both development and system administration, with a wide range of tools for managing systems, users, and automating tasks.
