Beginner's Guide to Linux Basics
Linux Fundamentals
1. Introduction to Linux
What is Linux?
Linux is a Unix-like, open-source operating system kernel created by Linus Torvalds in 1991.
It is widely used in various computing environments, from servers and desktops to embedded systems and supercomputers.
2. Linux Distributions
Common Distributions:
Ubuntu: User-friendly, widely used for desktops and servers.
CentOS/RHEL: Enterprise-focused, stable and secure.
Debian: Known for stability and robustness.
Fedora: Cutting-edge features, community-driven.
Arch Linux: Rolling release model, highly customizable.
3. Linux File System Hierarchy
Structure:
/ (Root): The top-level directory.
/bin: Essential command binaries.
/boot: Boot loader files.
/dev: Device files.
/etc: Configuration files.
/home: User home directories.
/lib: Shared libraries.
/media: Mount points for removable media.
/mnt: Temporary mount points.
/opt: Optional software packages.
/proc: Kernel and process files.
/root: Root user's home directory.
/sbin: System binaries.
/tmp: Temporary files.
/usr: User utilities and applications.
/var: Variable data files.
4. Basic Commands
File and Directory Operations:
ls
: List directory contents.cd
: Change directory.pwd
: Print working directory.mkdir
: Create directories.rmdir
: Remove empty directories.rm
: Remove files or directories.cp
: Copy files or directories.mv
: Move or rename files or directories.
File Viewing and Editing:
cat
: Concatenate and display file contents.less
: View file contents page by page.more
: View file contents page by page.nano
: Simple text editor.vi/vim
: Advanced text editor.
File Permissions and Ownership:
chmod
: Change file modes or Access Control Lists.chown
: Change file owner and group.chgrp
: Change group ownership.
Process Management:
ps
: Report a snapshot of current processes.top
: Display Linux tasks.kill
: Send a signal to a process.killall
: Kill processes by name.bg
: Resume a suspended job in the background.fg
: Bring a background job to the foreground.
5. Package Management
Debian-based Systems (e.g., Ubuntu):
apt-get
: Package handling utility.dpkg
: Debian package manager.
Red Hat-based Systems (e.g., CentOS, RHEL):
yum
: Package manager for RPM-based distributions.rpm
: RPM package manager.
6. User and Group Management
User Commands:
useradd
: Add a new user.usermod
: Modify a user account.userdel
: Delete a user account.passwd
: Change user password.
Group Commands:
groupadd
: Add a new group.groupmod
: Modify a group.groupdel
: Delete a group.
7. Networking Basics
Commands:
ifconfig
: Configure network interfaces.ip
: Show/manipulate routing, devices, policy routing, and tunnels.ping
: Send ICMP ECHO_REQUEST to network hosts.netstat
: Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.ssh
: OpenSSH SSH client (remote login program).
8. Shell Scripting
Basics:
Writing scripts using shell languages like Bash.
Using variables, loops, and conditionals.
Example Script:
#!/bin/bash echo "Hello Kpranit!" for i in {1..5} do echo "Welcome $i times" done
9. System Monitoring and Performance
Commands:
top
: Task manager.htop
: Interactive process viewer.vmstat
: Report virtual memory statistics.iostat
: Report CPU and I/O statistics.free
: Display amount of free and used memory in the system.df
: Report file system disk space usage.du
: Estimate file space usage.
10. Security
Firewall Configuration:
iptables
: Administration tool for IPv4 packet filtering and NAT.ufw
: Uncomplicated Firewall (frontend for iptables).
SSH Configuration:
Secure remote login and file transfer.
Use of public and private keys for authentication.
File Permissions:
Understanding and setting read, write, and execute permissions.
Using
chmod
,chown
, andchgrp
.
Conclusion
Linux fundamentals cover a wide range of topics, from understanding the file system hierarchy and basic command-line operations to more advanced topics like shell scripting and system security. Mastery of these fundamentals provides a solid foundation for using Linux effectively in various environments, whether for personal use, development, or managing servers in a professional setting.
Subscribe to my newsletter
Read articles from Pranit Kolamkar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by