0% found this document useful (0 votes)
6 views

Linux Basics

The document provides an overview of the Linux operating system, including its architecture, components, and popular distributions. It also lists 50 essential Linux commands for file management, user management, system information, networking, package management, and firewall configuration. Additionally, it introduces Bash scripting, highlighting its benefits and key components.

Uploaded by

tanish.sce21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Linux Basics

The document provides an overview of the Linux operating system, including its architecture, components, and popular distributions. It also lists 50 essential Linux commands for file management, user management, system information, networking, package management, and firewall configuration. Additionally, it introduces Bash scripting, highlighting its benefits and key components.

Uploaded by

tanish.sce21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

OS Information

Linux is an open-source, Unix-like operating system kernel initially created by Linus Torvalds in
1991. It is widely used for servers, desktops, mobile devices, and embedded systems due to its
flexibility, stability, and security. Linux distributions (distros) include a Linux kernel combined
with supporting software and package management systems.

Popular Linux Distributions:

• Ubuntu
• CentOS/Red Hat Enterprise Linux (RHEL)
• Debian
• Fedora
• Arch Linux
• Kali Linux

2. OS Architecture

Linux follows a modular architecture with several layers:

• Kernel: Core of the OS that interacts with hardware, manages system resources, and
provides essential services.
o Process management
o Memory management
o Device drivers
• System Libraries: Provide standard functions and interfaces for applications (e.g., libc).
• System Utilities: Essential tools for managing the system, such as shell commands and
configuration utilities.
• User Space: Applications and user interfaces that interact with the system.

3. OS Components

1. Kernel: The core part of Linux managing hardware resources and system calls.
2. Shell: Command-line interface (CLI) that interprets user commands (e.g., Bash, Zsh).
3. File System: Organizes and stores data (e.g., ext4, NTFS, XFS).
4. System Services: Background processes, also called daemons, such as cron and sshd.
5. Package Manager: Tool for managing software packages (e.g., apt, yum, dnf).
6. Networking Components: Manage communication (e.g., TCP/IP stack).
7. User Interfaces: GUI systems like GNOME, KDE, or CLI-based tools.

4. Basic 50 Linux Commands

File and Directory Management

1. ls - List directory contents.


2. pwd - Print current working directory.
3. cd - Change directory.
4. mkdir - Create a new directory.
5. rmdir - Remove an empty directory.
6. touch - Create an empty file.
7. cp - Copy files and directories.
8. mv - Move or rename files and directories.
9. rm - Remove files or directories.
10. find - Search for files and directories.

File Content Management

11. cat - View file content.


12. less - View file content with pagination.
13. head - Display the first lines of a file.
14. tail - Display the last lines of a file.
15. nano - Edit files with the Nano text editor.
16. vi or vim - Edit files with the Vi/Vim editor.
17. wc - Word, line, character count of a file.
18. sort - Sort file content.
19. uniq - Filter duplicate lines.
20. grep - Search for patterns in a file

User and Permission Management

21. whoami - Display current user.


22. id - Display user ID and group ID.
23. chmod - Change file permissions.
24. chown - Change file ownership.
25. passwd - Change user password.
26. adduser/useradd - Add a new user.
27. deluser/userdel - Delete a user.
28. groups - Show user groups.

System Information

29. uname - Display system information.


30. hostname - Display or set system hostname.
31. df - Show disk space usage.
32. du - Show directory size.
33. free - Display memory usage.
34. top - Show active processes.
35. ps - Display process information.
36. uptime - Show system uptime.
37. who - Show logged-in users.
38. dmesg - Show kernel messages.

Networking Commands

39. ping - Test network connectivity.


40. ifconfig or ip - Configure network interfaces.
41. netstat - Display network connections.
42. curl - Fetch data from a URL.
43. wget - Download files from the web.
44. scp - Copy files between systems.
45. ssh - Connect to a remote server.

Package Management

46. apt (Debian/Ubuntu) - Install, update, or remove packages.


47. yum/dnf (RHEL/CentOS) - Install, update, or remove packages.
48. snap - Manage snap packages.

Archiving and Compression

49. tar - Archive files.


50. zip/unzip - Compress or decompress files.
5. Firewalld, Iptables, and SELinux

Firewalld

• Description: A dynamic firewall management tool with support for network zones and
firewall policies.
• Key Features:
o Provides a higher-level abstraction for managing firewall rules.
o Supports runtime and permanent configurations.
o Zone-based configuration to simplify rule management.
• Common Commands:
o firewall-cmd --state - Check if firewalld is running.
o firewall-cmd --list-all - List all active rules.
o firewall-cmd --add-service=ssh - Allow SSH traffic.
o firewall-cmd --reload - Reload rules without restarting the service.

Iptables

• Description: A legacy command-line tool for configuring firewall rules at a lower level.
• Key Features:
o Operates on chains and tables (e.g., INPUT, FORWARD, OUTPUT).
o Provides fine-grained control over packet filtering.
o Rules are applied immediately but do not persist after a reboot without saving
them.
• Common Commands:
o iptables -L - List all current rules.
o iptables -A INPUT -p tcp --dport 22 -j ACCEPT - Allow SSH traffic.
o iptables -D INPUT 1 - Delete the first rule in the INPUT chain.
o iptables-save > /etc/iptables/rules.v4 - Save rules for persistence.

SELinux

• Description: Security-Enhanced Linux (SELinux) is a security module providing


mandatory access control (MAC) policies.
• Key Features:
o Adds an extra layer of security to control access to system resources.
o Policies define how applications and users can interact with files, processes, and
networks.
o Modes: enforcing (active), permissive (log-only), disabled (off).
• Common Commands:
o sestatus - Check the status of SELinux.
o getenforce - Display the current SELinux mode.
o setenforce 0 - Temporarily set SELinux to permissive mode.
o chcon -t httpd_sys_content_t /var/www/html - Change SELinux context for web
files.

Basic Details of Bash Scripting

Bash scripting is a powerful tool for automating tasks in Unix/Linux environments. It uses Bash
(Bourne Again Shell) to execute commands in sequence.

Why Bash Scripting?

1. Automates repetitive tasks.


2. Integrates with system utilities.
3. Enables batch processing.
4. Used in server administration and DevOps.

Key Components of Bash Scripts

1. Shebang (#!): Specifies the interpreter.


#!/bin/bash

2. Variables: Stores data.


name="Intern"
echo "Hello, $name"

3. Conditions: Decision-making.
if [ "$name" == "Intern" ]; then
echo "Welcome!"
fi

4. Loops: Repeats tasks.


for i in {1..5}; do
echo "Iteration $i"
done
5. Functions: Reusable blocks.
greet() {
echo "Hello, $1!"
}
greet "World"

6. Command Substitution: Captures command output.


current_date=$(date)
echo "Today is $current_date"

You might also like