unit 4 linux BCA OS
unit 4 linux BCA OS
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.
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.
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.
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.
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.
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.
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:
$ 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.
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
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
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
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]
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.
cd: Changes the current directory to a specified path, allowing users to navigate
the file system.
uname: Displays information about the operating system kernel, including the
kernel version and machine architecture.