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

Linux Fundamentals & Shell Programmin

The document discusses Linux operating system, its components, advantages and disadvantages. It provides details about Linux kernel, distributions, architecture including kernel, system library, shell, hardware layer and system utilities. It also compares Linux with other operating systems and describes cron command in Linux.

Uploaded by

FUN FACTZ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Linux Fundamentals & Shell Programmin

The document discusses Linux operating system, its components, advantages and disadvantages. It provides details about Linux kernel, distributions, architecture including kernel, system library, shell, hardware layer and system utilities. It also compares Linux with other operating systems and describes cron command in Linux.

Uploaded by

FUN FACTZ
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Linux Fundamentals & Shell Programming

Question 1. What is Linux Operating System ?


The Linux Operating System is a type of operating system that is similar to Unix, and it is built upon
the Linux Kernel. The Linux Kernel is like the brain of the operating system because it manages how
the computer interacts with its hardware and resources. It makes sure everything works smoothly
and efficiently. But the Linux Kernel alone is not enough to make a complete operating system. To
create a full and functional system, the Linux Kernel is combined with a collection of software
packages and utilities, which are together called Linux distributions. These distributions make the
Linux Operating System ready for users to run their applications and perform tasks on their
computers securely and effectively. Linux distributions come in different flavors, each tailored to suit
the specific needs and preferences of users.

What is Linux

Linux is a powerful and flexible family of operating systems that are free to use and share. It was
created by a person named Linus Torvalds in 1991. What’s cool is that anyone can see how the
system works because its source code is open for everyone to explore and modify. This openness
encourages people from all over the world to work together and make Linux better and better. Since
its beginning, Linux has grown into a stable and safe system used in many different things, like
computers, smartphones, and big supercomputers. It’s known for being efficient, meaning it can do
a lot of tasks quickly, and it’s also cost-effective, which means it doesn’t cost a lot to use. Lots of
people love Linux, and they’re part of a big community where they share ideas and help each other
out. As technology keeps moving forward, Linux will keep evolving and staying important in the
world of computers.

Linux Distribution

Linux distribution is an operating system that is made up of a collection of software based on Linux
kernel or you can say distribution contains the Linux kernel and supporting libraries and software.
And you can get Linux based operating system by downloading one of the Linux distributions and
these distributions are available for different types of devices like embedded devices, personal
computers, etc. Around 600 + Linux Distributions are available and some of the popular Linux
distributions are:

MX Linux

Manjaro

Linux Mint

elementary

Ubuntu

Debian

Solus

Fedora
openSUSE

Deepin

Architecture of Linux

Linux architecture has the following components:

Kernel: Kernel is the core of the Linux based operating system. It virtualizes the common hardware
resources of the computer to provide each process with its virtual resources. This makes the process
seem as if it is the sole process running on the machine. The kernel is also responsible for preventing
and mitigating conflicts between different processes. Different types of the kernel are:

Monolithic Kernel

Hybrid kernels

Exo kernels
Micro kernels

System Library:Linux uses system libraries, also known as shared libraries, to implement various
functionalities of the operating system. These libraries contain pre-written code that applications
can use to perform specific tasks. By using these libraries, developers can save time and effort, as
they don’t need to write the same code repeatedly. System libraries act as an interface between
applications and the kernel, providing a standardized and efficient way for applications to interact
with the underlying system.

Shell:The shell is the user interface of the Linux Operating System. It allows users to interact with the
system by entering commands, which the shell interprets and executes. The shell serves as a bridge
between the user and the kernel, forwarding the user’s requests to the kernel for processing. It
provides a convenient way for users to perform various tasks, such as running programs, managing
files, and configuring the system.

Hardware Layer: The hardware layer encompasses all the physical components of the computer,
such as RAM (Random Access Memory), HDD (Hard Disk Drive), CPU (Central Processing Unit), and
input/output devices. This layer is responsible for interacting with the Linux Operating System and
providing the necessary resources for the system and applications to function properly. The Linux
kernel and system libraries enable communication and control over these hardware components,
ensuring that they work harmoniously together.

System Utility: System utilities are essential tools and programs provided by the Linux Operating
System to manage and configure various aspects of the system. These utilities perform tasks such as
installing software, configuring network settings, monitoring system performance, managing users
and permissions, and much more. System utilities simplify system administration tasks, making it
easier for users to maintain their Linux systems efficiently.

Advantages of Linux

The main advantage of Linux is it is an open-source operating system. This means the source code is
easily available for everyone and you are allowed to contribute, modify and distribute the code to
anyone without any permissions.

In terms of security, Linux is more secure than any other operating system. It does not mean that
Linux is 100 percent secure, it has some malware for it but is less vulnerable than any other
operating system. So, it does not require any anti-virus software.

The software updates in Linux are easy and frequent.

Various Linux distributions are available so that you can use them according to your requirements or
according to your taste.

Linux is freely available to use on the internet.

It has large community support.

It provides high stability. It rarely slows down or freezes and there is no need to reboot it after a
short time.

It maintains the privacy of the user.

The performance of the Linux system is much higher than other operating systems. It allows a large
number of people to work at the same time and it handles them efficiently.
It is network friendly.

The flexibility of Linux is high. There is no need to install a complete Linux suite; you are allowed to
install only the required components.

Linux is compatible with a large number of file formats.

It is fast and easy to install from the web. It can also install it on any hardware even on your old
computer system.

It performs all tasks properly even if it has limited space on the hard disk.

Disadvantages of Linux

It is not very user-friendly. So, it may be confusing for beginners.

It has small peripheral hardware drivers as compared to windows.

What is Linux Operating System?

Linux is an open-source operating system developed by Linus Torvalds in 1991. It provides a


customizable and secure alternative to proprietary systems. With its stable performance, Linux is
widely used across devices, from personal computers to servers and smartphones. The collaborative
efforts of its developer community continue to drive innovation, making Linux a dominant force in
the world of computing.

Question (2) Why is Linux better than other operating systems?


The question of whether Linux is "better" than other operating systems is subjective and depends on
various factors such as user preferences, specific use cases, and technical requirements. However,
Linux does have several characteristics that make it attractive to many users and organizations:

Open Source: Linux is open-source, meaning its source code is freely available for anyone to view,
modify, and distribute. This fosters a collaborative environment and encourages innovation.

Customization: Linux offers a high degree of customization, allowing users to tailor the operating
system to their specific needs. There are numerous distributions (distros) of Linux, each with its own
set of features and configurations.

Stability and Reliability: Linux is known for its stability and reliability, particularly in server
environments. It is often chosen for critical infrastructure due to its robustness and ability to handle
heavy workloads.

Security: Linux is inherently more secure than some other operating systems due to its design
principles and the open-source nature that allows for quick identification and patching of security
vulnerabilities.

Performance: Linux tends to perform well even on older or less powerful hardware, making it
suitable for a wide range of devices, from servers to embedded systems.

Community Support: The Linux community is vast and active, providing extensive documentation,
forums, and support channels for users to seek help and share knowledge.
Cost: Linux is free to use and distribute, which can result in significant cost savings, especially for
organizations deploying it on a large scale.

However, it's essential to note that Linux may not be the best choice for every scenario. Some users
may prefer the familiarity and software compatibility of other operating systems like Windows or
macOS, depending on their specific needs and workflows. Ultimately, the "better" operating system
is subjective and depends on individual requirements and preferences.

Question 3. Describe cron command in Linux ?


In Linux, the cron command is used to schedule tasks to run periodically at specific intervals. These
tasks can range from running scripts, executing commands, or performing system maintenance
tasks. cron operates on a time-based scheduling system and is commonly used for automating
repetitive tasks.

Here's a breakdown of how the cron command works:

Cron Table: The cron command uses a configuration file called the "cron table" or "crontab." Each
user on a Linux system can have their own cron table, which contains entries specifying the
commands or scripts to run and when to run them.

Syntax: The syntax for a cron job entry in the cron table follows a specific format:

markdown

Copy code

* * * * * command_to_run

Each asterisk represents a time parameter:

Minute (0-59)

Hour (0-23)

Day of the month (1-31)

Month (1-12)

Day of the week (0-6, where 0 is Sunday)

The command_to_run is the actual command or script to execute.

Special Characters: In addition to numeric values, special characters can be used in cron job entries:

* - Represents all possible values for that time parameter.

, - Allows specifying multiple values within the same parameter (e.g., 1,15,30 for minutes means the
job will run at minute 1, 15, and 30).
- - Specifies a range of values (e.g., 10-15 for hours means the job will run from hour 10 to hour 15,
inclusive).

/ - Allows specifying intervals (e.g., */5 for minutes means the job will run every 5 minutes).

Examples:

0 3 * * * /path/to/script.sh - Runs the script /path/to/script.sh every day at 3:00 AM.

*/15 * * * * /path/to/command - Runs the command /path/to/command every 15 minutes.

30 2 * * 1-5 /path/to/backup.sh - Runs the script /path/to/backup.sh at 2:30 AM every weekday


(Monday to Friday).

Managing Cron Jobs:

To edit the cron table, you can use the crontab -e command, which opens the user's cron table in the
default text editor.

crontab -l lists the current cron jobs for the user.

crontab -r removes all cron jobs for the user.

cron is a powerful tool for automating tasks in Linux, providing users with the ability to schedule
routine operations without manual intervention.

Question 4. Explain batch command in Kill, sleep & who in Linux ?

n Linux, the batch command is used in conjunction with the kill, sleep, and who commands to
manage processes, delay execution, and display information about users currently logged into the
system. Here's an explanation of each command:

batch Command:

The batch command is used to execute commands when system load levels permit. It is typically
used to schedule commands or scripts to run when the system load average drops below a certain
threshold. This helps prevent unnecessary strain on the system during periods of high activity.

Syntax: batch [options] [filename]

Options:

-p: Displays a prompt when the command finishes.

Example: batch script.sh would schedule the execution of the script script.sh when system load
levels are low.

kill Command:
The kill command is used to terminate or send signals to processes in Linux. It allows users to stop
processes that are running or alter their behavior.

Syntax: kill [options] <pid>

Options:

-9 or SIGKILL: Forces termination of the process by sending the SIGKILL signal, which cannot be
ignored or caught by the process.

Example: kill -9 1234 would forcefully terminate the process with PID 1234.

sleep Command:

The sleep command is used to delay the execution of commands or scripts for a specified amount of
time. It is often used in shell scripts to introduce delays between commands.

Syntax: sleep [options] <duration>

Example: sleep 5 would pause execution for 5 seconds before proceeding to the next command.

who Command:

The who command is used to display information about users who are currently logged into the
system. It shows details such as username, terminal, login time, and remote host (if applicable).

Syntax: who [options]

Options:

-q or --count: Displays only the count of logged-in users.

-H or --heading: Prints a header line before the output.

Example: who would display a list of users currently logged into the system.

By using these commands together, users can manage processes, delay execution, and monitor user
activity on a Linux system effectively.

Linux Commands
Linux, often associated with being a complex operating system primarily used by developers, may
not necessarily fit that description entirely. While it can initially appear challenging for beginners,
once you immerse yourself in the Linux world, you may find it difficult to return to your previous
Windows systems. The power of Linux commands in controlling your PC, coupled with their clean
user interface, can make it hard to switch back to older operating systems. If you’re a developer, you
can likely relate to the advantages and appeal of Linux.

To support developers and beginners alike, we have created a comprehensive Linux/Unix command
line cheat sheet. This cheat sheet covers all the basic and advanced commands, including file and
directory commands, file permission commands, file compression and archiving, process
management, system information, networking, and more with proper examples and descriptions. In
addition to that we provide all the most used Linux Shortcut which includes Bash shortcuts, Nano
shortcuts, VI & Vim Shortcuts Commands. It provides a solid foundation on Linux OS commands, as
well as insights into practical applications.
By the end of this cheat sheet, you will have a basic understanding of Linux/Unix Commands and
how it makes development easy for developers.

Basic Linux Commands with Examples

In this Linux cheat sheet, we will cover all the most important Linux commands, from the basics to
the advanced. We will also provide some tips on how to practice and learn Linux commands. This
cheat sheet is useful for Beginners and Experience professionals.

1. File and Directory Operations Commands

File and directory operations are fundamental in working with the Linux operating system. Here are
some commonly used File and Directory Operations commands:

Command Description Options Examples

ls -l
displays files and directories with
-l: Long format
detailed information.
listing.
ls -a
List files and -a: Include hidden
shows all files and directories,
directories. files hidden ones
including
-h: Human-readable
ls -lh
file sizes.
displays file sizes in a human-
ls readable format.

cd /path/to/directory
Change directory. changes the current directory to
cd the specified path.

pwd
Print current working
displays the current working
directory.
pwd directory.

mkdir my_directory
Create a new
creates a new directory named
directory.
mkdir “my_directory”.

-r: Remove
Remove files and rm file.txt
directories
directories. deletes the file named “file.txt”.
rm recursively.
Command Description Options Examples

-f: Force removal rm -r my_directory


without deletes the directory
confirmation. “my_directory” and its contents.

rm -f file.txt
forcefully deletes the file “file.txt”
without confirmation.

cp -r directory destination
copies the directory “directory”
and its contents to the specified
Copy files and -r: Copy directories destination.
directories. recursively.
cp file.txt destination
copies the file “file.txt” to the
cp specified destination.

mv file.txt new_name.txt
renames the file “file.txt” to
Move/rename files and “new_name.txt”.
directories. mv file.txt directory
moves the file “file.txt” to the
mv specified directory.

Create an empty file or touch file.txt


update file creates an empty file named
touch timestamps. “file.txt”.

cat file.txt
View the contents of a
displays the contents of the file
file.
cat “file.txt”.

head file.txt
shows the first 10 lines of the file
-n: Specify the “file.txt”.
Display the first few
number of lines to
lines of a file. head -n 5 file.txt
display.
displays the first 5 lines of the file
head “file.txt”.
Command Description Options Examples

tail file.txt
shows the last 10 lines of the file
-n: Specify the “file.txt”.
Display the last few
number of lines to
lines of a file. tail -n 5 file.txt
display.
displays the last 5 lines of the file
tail “file.txt”.

ln -s source_file link_name
Create links between -s: Create symbolic creates a symbolic link named
files. (soft) links. “link_name” pointing to
ln “source_file”.

-name: Search by find /path/to/search -name


filename. “*.txt”
Search for files and
searches for all files with the
directories. -type: Search by file extension “.txt” in the specified
find type. directory.

You might also like