Shell Scripting
Shell scripting in Linux allows users to automate tasks using shell commands and scripting constructs. Here are some basic commands and concepts:
- Shebang:
#!/bin/bash
at the beginning of a script specifies the shell interpreter. - Variables:
VAR=value
assigns a value to a variable. - Conditional Statements:
if
,else
,elif
for decision-making. - Loops:
for
,while
for iterating over lists or executing commands repeatedly. - Functions:
function_name() { ... }
for defining reusable code blocks.
Package Management
Package management involves installing, updating, and removing software packages. Basic commands include:
- Installing Packages:
apt-get install <package>
(Debian-based),yum install <package>
(Red Hat-based). - Updating Packages:
apt-get update
,yum update
. - Removing Packages:
apt-get remove <package>
,yum remove <package>
.
Virtualization
Virtualization allows running multiple operating systems or environments on a single physical machine. Basic concepts include:
- Hypervisor: Software that enables virtualization (e.g., VirtualBox, KVM).
- Virtual Machine (VM): Guest OS running on a host machine.
- Commands:
virsh
for managing KVM-based VMs,VBoxManage
for VirtualBox.
File Storage
Managing file storage involves handling disks, partitions, and file systems. Basic commands include:
- Disk Partitioning:
fdisk
,parted
for creating and managing partitions. - File Systems:
mkfs
for creating file systems (e.g.,mkfs.ext4
for Ext4). - Mounting:
mount
to attach a file system to the directory tree. - Unmounting:
umount
to detach a file system.
User and Group Management
Linux allows creating, modifying, and deleting users and groups. Basic commands include:
- User Management:
useradd
,usermod
,userdel
. - Group Management:
groupadd
,groupmod
,groupdel
. - Permissions:
chmod
for changing file permissions,chown
for changing file ownership.
Process Management
Monitoring and controlling processes is essential for system administration. Basic commands include:
- Listing Processes:
ps
to list processes,top
for real-time process monitoring. - Killing Processes:
kill
to terminate a process by ID or name. - Monitoring:
htop
for interactive process viewer.