0% found this document useful (0 votes)
7 views19 pages

unit 4 linux BCA OS

Linux is an open-source operating system developed by Linus Torvalds in 1991, based on Unix, and is known for its stability, security, and flexibility. It allows users to customize and modify the system, making it popular for servers and various applications. The document also outlines Linux's architecture, command formats, and essential commands for file and directory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views19 pages

unit 4 linux BCA OS

Linux is an open-source operating system developed by Linus Torvalds in 1991, based on Unix, and is known for its stability, security, and flexibility. It allows users to customize and modify the system, making it popular for servers and various applications. The document also outlines Linux's architecture, command formats, and essential commands for file and directory management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

https://www.naukri.

com/code360/library/linux-utilities
https://www.hostinger.in/tutorials/linux-
commands

Introduction
Linux is an open-source and free operating system derived from Unix. Linus
Torvalds, who studied computer science at the University of Helsinki in 1991,
developed it as a side project. The Linux operating system is different because no
company or person owns it. Instead, it is developed co-operatively by a group of
developers and users worldwide working together.

History of Linux
The Linux operating system is based on Unix. So before we learn the history of
Linux, we need to know about Unix. In the 1960s, a group of programmers led by
Ken Thompson and Dennis Ritchie created Unix at Bell Labs. Unix was an operating
system that was initially made for powerful mainframe computers. Later on, it was
modified so smaller computers could also run it.

Evolution of Unix
In the 1980s, several operating systems similar to Unix were made. These systems
tried to copy Unix's features while being affordable and easier to use. These included
Berkeley Software Distribution (BSD), Xenix, and GNU` (GNU's Not Unix). Based
on the Unix kernel, these operating systems were made more modular and flexible
using open-source code.

Expansion of Unix
During the 1970s and 1980s, Unix became more prominent in academic and scientific
circles. The availability of source code allowed customization and the development of
individual flavors.

In the 1980s, businesses like Sun Microsystems, Hewlett-Packard, and IBM made
commercial versions of Unix that were tailored for specific hardware platforms and
had more features. Unix's growth in history was further helped by Linux, a free and
open-source operating system based on Unix.

MacOS, Apple's desktop operating system, is based on Unix and shares many of its
key features. It was another big step forward for Unix. Unix is still one of the most
important developments in the world of computing, and its continued development
and growth will continue to shape the industry for many years to come.

Why was Linux Created?


Linus Torvalds, a Finnish computer science student, invented Linux, an open-source
operating system that became popular in 1991. Torvalds didn't like the limitations in
the operating systems available then, so he set out to develop one that was free and
open source.

The aim behind Linux was to make an operating system that anybody could use and
modify as they wanted. Torvalds released the initial version of Linux under the GNU
General Public License, which let users use, modify, and share the software as long as
they make their modifications available under the same license.

Due to its dependability, versatility, and growth potential, Linux is now a popular
choice for servers, supercomputers, and embedded devices. It has also created a lively
community of developers who keep adding to its growth and development.

Evolution of Linux
The open-source operating system Linux has greatly changed since it was first built.
Early versions of Linux were primarily controlled by the command line and didn't
have the easy-to-use graphical interfaces that other operating systems had. But
because the system was flexible, reliable, and safe, many developers started building
graphical interfaces and a wide range of software applications.

Linux has become more popular as businesses and organizations have started to use it
and as cloud computing has become more widespread. It has become a flexible and
extensively used operating system that can run on everything from small embedded
devices to high-performance supercomputers. It has changed through time because of
the community of developers and users who continue to work on it and help it grow.
Features or Advantages of Linux (What Made it So
Popular?)
The reason why Linux became so popular is because of its inbuilt natural features.
Let's learn all the natural features.

Customizable: Users can modify and customize the system to meet their specific
needs.

Stability: Linux is regarded as stable and reliable, making it a popular choice for
servers and other systems that need to work well all the time.

Security: Viruses and malware are less likely to affect Linux than other operating
systems, making it a safe choice for businesses and individuals.

Flexibility: Linux can be modified to run on various hardware platforms, from small
embedded devices to supercomputers.

Open-source: The source code is available to everyone, which allows for


transparency and encourages the community to help with its development and
expansion.

Cost-effective: Linux is generally free, or it can be called affordable, making it


a good choice for individuals and businesses.

Overall, Linux's qualities have helped it become famous and successful and made it an
excellent alternative to operating systems that are not affordable.
Linux programming is characterized by its open-source nature, allowing for community-driven
development and modification. It offers a flexible and highly customizable environment, suitable for a
wide range of applications from servers and embedded systems to scientific computing. Linux
programming emphasizes security, utilizing a robust permissions model to control file access and protect
data.

characteristics of LINUX :
1. Open-Source and Community-Driven:

Linux is an open-source operating system, meaning its source code is freely available for anyone to view,
modify, and distribute.

This open nature fosters a large and active community of developers who contribute to its development
and maintenance.

This collaborative environment ensures continuous improvement and adaptation to new technologies
and needs.

2. Flexibility and Customization:

Linux offers a high degree of flexibility, allowing users to tailor the system to their specific requirements.

It's suitable for various use cases, including server environments, embedded systems, and scientific
applications.

The modular architecture and open-source nature allow for easy customization and extension.

3. Security:
Linux utilizes a robust permissions model that controls access to files and directories, ensuring security
and data protection.

This model restricts access based on user or group, enforcing security across multi-user environments.

The open-source nature also enables community scrutiny and rapid response to security vulnerabilities,
according to Naukri.com.

4. Multiuser and Multitasking:


Linux is designed to support multiple users simultaneously, allowing for concurrent access to the system.

It also supports multitasking, enabling users to run multiple applications concurrently.

This feature is crucial for server environments and other applications requiring resource sharing and
efficient utilization, according to Naukri.com.

5. Portability:

Linux is highly portable, meaning it can run on a wide variety of hardware platforms, from embedded
devices to supercomputers.

This portability allows for its use in diverse environments and applications.
6. Stability:

Linux is known for its stability and robustness, making it a reliable choice for servers and critical
applications.

Its well-structured code and robust kernel architecture contribute to its reliability and resilience.

7. Command-Line Interface (CLI) and Graphical User Interface (GUI):

Linux provides a powerful command-line interface (CLI) for interacting with the system, offering fine-
grained control.

It also supports graphical user interfaces (GUI) like GNOME and KDE, providing a more user-friendly
experience.

LINUX SYSTEM ARCHITECTURE :

What is Linux Kernel?


The Linux kernel is the central component of a Linux operating system, operating as
the core interface between a computer's hardware and its processes. It forms the
fundamental basis of the entire Linux operating system, with all applications and
servers interacting with it. Every Linux distribution builds on the Linux kernel,
utilizing its characteristics to provide multiple software capabilities. The kernel in
Linux effectively manages system resources, providing enough memory allocation for
applications, optimizing processor utilization, and preventing system deadlocks
resulting from conflicting demands of different applications.

Fundamental Architecture of Linux The fundamental architecture of Linux is divided


into main two parts:

 User Space
 Kernel Space
1. User Space:
The User Space is the domain where user applications and processes operate.
It is the area where most user-level programs, such as software applications
and utilities, execute. User Space does not have direct access to memory or
hardware. It connects to the hardware via kernel space. User-space processes
or programs can only access some parts of memory via system calls. Crashes in
user mode are recoverable due to complete protection. The GNU C library in
the user space provides the mechanism for switching user space applications
to the kernel space.

2. Kernel Space:
The Kernel Space, also referred to as the System Space, is a privileged domain
dedicated to the execution of kernel programs. It includes all the memory and
facilitates interaction with hardware components such as RAM and hard disks.
Within the Kernel Space, different blocks and modules handle various
operations essential to the operating system, including file management,
memory management, and process management. The Kernel Space includes
components such as the system call interface, the kernel itself (the core
component of Linux), and device modules.

Architecture of Kernel
The architecture of a kernel follows a modular approach. It consists of several
components that work together to manage system resources and facilitate
communication between different parts of the operating system. The following are the
core Subsystems of the Linux Kernel:

 The Process Scheduler


 The Memory Management Unit (MMU)
 The Virtual File System (VFS)
 The Networking Unit
 Inter-Process Communication Unit

Basic command format in LINUX:


In Linux, commands generally follow the format: command [options] [arguments].
The command itself is the executable program (e.g., ls, cd), options modify the
command's behavior (e.g., -l in ls -l), and arguments are input data the command
needs (e.g., the file name in cat filename.txt).
Elaboration:
Command:
This is the name of the program you want to execute, like ls to list directory
contents or cd to change directories.
Options:
These are flags or switches that modify how the command behaves. They often
start with a hyphen (-) and can specify things like output format, verbosity, or
actions. For example, in ls -l, -l is an option that specifies a long listing format.
Arguments:
These are the inputs the command needs to do its job. For instance, in cat
filename.txt, filename.txt is the argument, the file the command will display.
Examples:
ls -l /home/user/documents (list directory /home/user/documents in long format)
mkdir new_directory (create a directory named new_directory)
cp source_file destination_file (copy source_file to destination_file)
Internal and External Commands in LINUX:
Internal Command
Internal commands are the commands that are executed directly by
the shell. These commands will not have a separate process. You can’t find
these commands in PATH directories in system because these are built in
shell command. echo is an external command and if you try to find its path
it will show shell built in.

$ type echo
echo is a shell builtin

when you run echo the system will not search in PATH location, it will
execute it from shell builtin commands that are stored in some separate file.

External Command
External commands are the commands that are executed by the kernel.
These commands will have a process id running for it. External Command
existed in any PATH directory like /bin, /usr/bin etc. like ls, sed, mv.
These commands having independent existence in /bin, /usr/bin, or any
other directory. External commands paths can be found using type command

$ type ls

ls is /bin/ls
Directory commands in LINUX:
In Linux, several commands are used to interact with directories. mkdir creates
new directories, rmdir removes empty directories, ls lists the contents of a
directory, cd changes the current directory, pwd displays the current working
directory, and cp copies files and directories. Additionally, mv can be used to
move or rename directories.

mkdir:
Creates a new directory. For example, mkdir my_new_directory creates a
directory named "my\_new\_directory".

rmdir:
Removes an empty directory. For example, rmdir empty_directory removes a
directory named "empty\_directory".
ls: Lists the contents (files and directories) of a specified directory. If no directory
is specified, it lists the contents of the current directory.

cd:
Changes the current directory. For example, cd my_new_directory changes the
current directory to "my\_new\_directory".

pwd:
Prints the full path of the current working directory.

cp:
Copies files and directories. For example, cp file1.txt
/path/to/destination/directory copies "file1.txt" to the specified destination.

mv:
Moves or renames files and directories. For example, mv file1.txt
/path/to/destination/directory moves "file1.txt" to the specified destination.

File Related Commands in LINUX :


ls (List): Lists the contents of a directory, including files and
subdirectories. Options like -l (long format), -a (show hidden files), and -
h (human-readable sizes) can be used with ls for more information.
ls [options] [directory_or_path]

cd (Change Directory): Changes the current working directory. You can


use absolute or relative paths to navigate the file system.
cd [path_or_directory]

The cd command has several shortcuts:


 cd – returns to the current user’s home directory.

 cd .. – moves a directory up.

 cd – – goes back to the previous directory.

mkdir (Make Directory): Creates a new directory.


mkdir [options] directory_name1 directory_name2

To create a folder in another location, specify the full path.


Otherwise, this command will make the new item in your current
working directory.
For example, enter the following to
create new_folder in /path/to/target_folder:
mkdir path/to/target_folder/new_folder

touch: Creates an empty file or updates the timestamp of an existing


file.
touch [options] [path_and_file_name]

If you omit the path, the touch command will create a new file in
your current working directory. Here’s an example:
touch file.txt

cp (Copy): Copies files or directories. It can copy to a new location or


create a duplicate within the same directory, explains Medium.
cp file1 file2 [target_path]

You can also use cp to duplicate the content of one file to another
using this syntax. If the target is in another location, specify the full
path like so:
cp source_file /path/to/target_file
mv (Move/Rename): Moves a file or directory to a
new location or renames it. The mv command can
also be used to move files to a different
directory. mv file_or_directory [target_directory]
For example, we will move file1.txt from another location to
the /new/file/directory path using this command:
mv /original/path/file1.txt the/target/path

You can also use the mv command to rename files in your Linux
system. Here’s an example:
mv old_name.txt new_name.txt

rm (Remove): Deletes files or directories. Be cautious as this command


permanently removes items.
rm [options] file1 file2

You can add the -r option to remove a folder and its contents,
including subdirectories. Use the -i flag to display a confirmation
message before the removal or -f to deactivate it completely.
cat (Concatenate): Displays the contents of a file. It can also be used to
concatenate multiple files into one.
cat file_name

To print the content in reverse order, use tac instead. If you add the
standard output operator symbol (>), the cat command will create a
new file. For example, the following will make file.txt:
cat > file.txt

You can also use cat with the operator to combine the content of
multiple files into a new item. In this
command, file1.txt and file2.txt will merge into target.txt:
cat file1.txt file2.txt > target.txt

file: Determines the type of a file, such as text, image, or archive.


file [file_name]

If you use this command on a symbolic link , it will output the


actual file connected to the shortcut. You can add the -k option to
print more detailed information about the item.

pwd (Print Working Directory): Displays the current working


directory.
pwd [options]

the pwd command has only two options. The -L option


prints environment variable content, like shortcuts, instead of the
actual path of your current location. Meanwhile, -P outputs the
exact location.
For example, /shortcut/folder is a shortcut for /actual/path, and
you are currently in /actual/path/dir. If you use the -L option, the
output will be:
/shortcut/folder/dir

Meanwhile, the -P option will print the exact canonical path:


/actual/path/dir

rmdir (Remove Directory): Removes an empty directory.


rmdir [options] directory_name

The rmdir command won’t work if the directory contains subfolders.


To force the deletion, add the –p option. Note that you must own
the item you want to remove or use sudo instead.

find: Searches for files based on various criteria, including name, type,
and modification time, All Hands on Tech explains.
chmod: Changes the permissions of a file or directory (read,
write, execute).
chown: Changes the owner of a file or directory.
grep: Searches for specific text patterns within files.
grep [options] keyword [file]

You can also filter data from another utility by piping it to


the grep command. For example, the following
searches file.txt from the ls command’s output:
ls | grep "file.txt"

diff: Compares the contents of two files.


diff file_name1 file_name2

By default, the diff command only shows the differences between


the two files. To print all the content and highlight the discrepancies,
enable the context format using the -c option. You can also ignore
case sensitivity by adding -i.
For example, run the following to show only the differences
between 1.txt and 2.txt:
diff -c 1.txt 2.txt
du: Displays disk usage information for files and directories.
du [directory]

The command will check your working directory if you don’t specify
a path or folder. By default, it breaks down each subfolder’s disk
usage, but you can add the -s option to summarize the total usage
in one output.
You can also use the -M option to change the information
from KB to MB.

Disk Related Commands In LINUX:


In Linux, several commands are used for managing and
monitoring disk space and partitions. The most common
include df, du, fdisk, lsblk, and parted. These commands
provide tools to check free space, analyze disk usage, create
and manipulate partitions, and list block devices.
Disk Space Monitoring:
df (disk free): Displays disk space usage of file systems. It
shows the total space, used space, available space, and mount
points.
For example, df -h displays the disk space in a human-readable
format.
du (disk usage): Estimates disk space occupied by files and
directories. It can show usage in human-readable format with
du -h.
For example, du -sh /path/to/directory shows the total disk
usage for a directory in a human-readable format.
ncdu (NCurses Disk Usage): A more interactive disk usage
analyzer with a graphical interface.
Partition Management:
fdisk:
A command-line utility for creating, deleting, and modifying
disk partitions.
parted:
An alternative to fdisk with a more user-friendly interface, also
used for manipulating disk partitions.
lsblk:
Lists block devices, including disks and their partitions, with
information like size and mount points.
Other Useful Commands:
blkid: Displays block device information, like UUID, filesystem
type, and label.
mkfs: Creates a filesystem on a disk or partition.
mount: Mounts a filesystem to a directory.
umount: Unmounts a filesystem.
General Utilities:
General-purpose utilities in Linux are fundamental command-line tools used for a
wide range of tasks, including file management, system administration, and text
processing. These utilities are essential for everyday use and system maintenance.
Examples include ls for listing directory contents, cd for navigating directories, cat
for displaying file content, and grep for searching within files.
Here's a more detailed look at some key general-purpose utilities:

File and Directory Management:


ls: Lists files and directories within the current directory or a specified directory. It
can display detailed information, including permissions, timestamps, and file
sizes.

cd: Changes the current directory to a specified path, allowing users to navigate
the file system.

mkdir: Creates a new directory.


rmdir: Removes an empty directory.
touch: Creates a new file or updates the timestamp of an existing one.
rm: Removes files and directories.
mv: Moves or renames files and directories.
cp: Copies files and directories.
pwd: Prints the current working directory's path.
ln: Creates symbolic links (shortcuts) to files and directories.
Text Processing and Display:
cat: Displays the contents of a file on the terminal. It can also be used to
concatenate files.

echo: Prints a given text or variable to the terminal.


grep: Searches for a pattern within a file or a stream of data.
head: Displays the first few lines of a file.
tail: Displays the last few lines of a file.
less: Displays the contents of a file in a paginated manner, allowing scrolling and
searching.
System Information and Control:
man: Displays the manual pages for a specific command, providing detailed
information about its usage and options.

uname: Displays information about the operating system kernel, including the
kernel version and machine architecture.

whoami: Displays the current user's username.


date: Displays the current date and time.
cal: Displays a calendar for a given month, year, or range of
years.
ps: Displays a list of running processes on the system.
kill: Sends a signal to a process to terminate it.
history: Displays a list of previously executed commands.
Other General-Purpose Utilities:
tar: Archives files and directories into a single archive file.
gzip and gunzip: Compress and decompress files, respectively.
zip and unzip: Compress and decompress files, respectively.
sort: Sorts the lines of a file alphabetically or numerically.
diff: Compares two files and displays their differences.
cmp: Compares two files and reports whether they are
identical.
These general-purpose utilities are just a starting point, and
there are many other useful tools available in Linux for a wide
range of tasks.

You might also like