Linux Unveiled: Exploring the Heart of Open-Source Operating Systems


What is Linux? ๐ง
Linux is an open-source operating system (OS) that powers everything from personal computers to servers, smartphones, and even supercomputers! ๐ Itโs known for its stability, security, and flexibility. Unlike proprietary systems like Windows or macOS, Linux is freely available for anyone to use, modify, and distribute.
Imagine having a car you can modify to suit your needs without any restrictions. Thatโs what Linux offers in the world of operating systems.
Difference Between Linux and Unix ๐
While Linux and Unix may seem similar, there are key differences:
Origin: Unix was developed in the 1970s at AT&Tโs Bell Labs, while Linux was created by Linus Torvalds in 1991.
Licensing: Unix is often proprietary, meaning you need to purchase it. Linux, on the other hand, is open-source and free.
Usage: Unix is typically used in large enterprise environments, whereas Linux is used in both enterprise and personal environments.
Compatibility: Unix systems can be quite different from each other, whereas Linux distributions (like Ubuntu, Fedora, etc.) maintain a high level of compatibility.
Imagine Unix as the blueprint for a house and Linux as a house built from that blueprint but freely available to modify and improve by anyone. ๐ก
Linux Architecture ๐๏ธ
The Linux architecture is composed of several layers that work together to manage the computerโs hardware and provide services to the user.
Hardware Layer ๐ฅ๏ธ This is the physical layer that includes all the hardware components like the CPU, memory, disk drives, etc.
Kernel ๐ง The kernel is the core part of Linux. It acts as a bridge between the hardware and the applications. It manages resources, handles system calls, and ensures everything runs smoothly. Think of it as the brain of the operating system.
Shell ๐ The shell is a command-line interface that allows users to interact with the kernel. It takes commands from the user and tells the kernel what to do. Itโs like a translator between you and the system.
System Utilities ๐ง These are essential tools and programs that help manage and maintain the system. They perform a variety of tasks like file manipulation, process management, and more.
Application Layer ๐ฑ This is where all user applications run, like web browsers, office suites, and games.
Linux File System Hierarchy ๐
The Linux file system is structured in a hierarchical directory tree. Here are some key directories youโll encounter:
/: The root directory where everything starts.
/bin: Essential binary executables (like basic commands).
/etc: Configuration files.
/home: User home directories.
/var: Variable files like logs and databases.
/usr: User utilities and applications.
/lib: Essential shared libraries and kernel modules.
Think of the file system hierarchy like an organizational chart for a company, with directories for each department and specific roles within those directories.
Some basic commands
Lists files and directories in the current directory.
ls
Creates a new directory with the specified name.
mkdir <directory_name>
Lists files and directories with detailed information (long format).
ls -l
Prints the current working directory.
pwd
Creates a new empty file or updates the timestamp of an existing file.
touch <file_name>
The
cd
command changes the current directory.cd /
takes you to the root directory, andcd ..
moves you up one level in the directory hierarchy.cd <directory_name> # Change to the specified directory cd / # Change to the root directory cd .. # Move up one directory level
To remove the file and the folder related to that file recursively
rm <file_name> # Deletes the specified file. rm -r <directory_name> #Deletes the specified directory and its contents recursively.
Displays the contents of a file.
cat <file_name>
Outputs the specified text to the terminal.
echo "text"
Writes "hello world" to
newfile.txt
, creating the file if it doesn't exist or overwriting it if it does.echo "hello world" > newfile.txt
Displays the contents of a compressed file (gzip format) without decompressing it.
zcat <compressed_file.gz>
Shows the first 10 lines of a file by default.
head <file_name>
Shows the last 10 lines of a file by default.
tail <file_name> or tail -f <file_name> # -f shows all the last 10 lines even after we update the file
Allows you to view and scroll through a file one screen at a time.
less <file_name>
Displays file contents one screen at a time (older command, similar to
less
).more <file_name>
Copies files or directories from
source
todestination
.cp <source> <destination>
Copies directories recursively, including all files and subdirectories.
cp -r <source_directory> <destination_directory>
Moves or renames files or directories from
source
todestination
.mv <source> <destination>
Displays the number of lines, words, and characters in a file.
wc <file_name> -l: Counts the number of lines. -w: Counts the number of words. -c: Counts the number of characters (or bytes).
Extracts sections from each line of a file based on the specified delimiter and field number. Replace
<delimiter>
with the actual delimiter.cut -d '<delimiter>' -f <field_number> <file_name>
Reads from standard input and writes to both standard output and the specified file.
tee <file_name> eg: echo "hello world" | tee or echo "hello world" | tee <file.txt>
Sorts the lines of a file in alphabetical or numerical order.
sort <file_name>
Compares two files line by line and shows the differences.
diff <file1> <file2>
Opens a file in the
vi
text editor for editing.vi <file_name> or #to exit from the editor first click on esc then type:wq vim <file_name>
To see disk information and disk usage.
df or df -h du
To see all the process.
top or ps
Kill the process.
kill eg. kill -a 'process id'
Shows free disk space.
free or free -h
Subscribe to my newsletter
Read articles from Kiran Ramakrishna Dunka directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by