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

Module 5 Unix

Uploaded by

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

Module 5 Unix

Uploaded by

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

UNIX operating system

UNIX is a powerful Operating System initially developed by Ken Thompson,


Dennis Ritchie at AT&T Bell laboratories in 1970. It is prevalent among
scientific, engineering, and academic institutions due to its most appreciative
features like multitasking, flexibility, and many more. In UNIX, the file system
is a hierarchical structure of files and directories where users can store and
retrieve information using the files.

Features of UNIX Operating System:

Let's discuss the features of UNIX OS one by one in detail.


Multitasking: A UNIX operating system is a multitasking operating system that
allows you to initiate more than one task from the same terminal so that one task
is performed as a foreground and the other task as a background process.

Multi-user: UNIX operating system supports more than one user to access
computer resources like main memory, hard disk, tape drives, etc. Multiple users
can log on to the system from different terminals and run different jobs that share
the resources of a command terminal. It deals with the principle of time-sharing.
Time-sharing is done by a scheduler that divides the CPU time into several
segments also called a time slice, and each segment is assigned to each user on a
scheduled basis. This time slice is tiny. When this time is expired, it passes control
to the following user on the system. Each user executes their set of instructions
within their time slice.

Portability: This feature makes the UNIX work on different machines and
platforms with the easy transfer of code to any computer system. Since a
significant portion of UNIX is written in C language, and only a tiny portion is
coded in assembly language for specific hardware.

File Security and Protection: Being a multi-user system, UNIX makes special
consideration for file and system security. UNIX has different levels of security
using assigning username and password to individual users ensuring the
authentication, at the level providing file access permission viz. read, write and
execute and lastly file encryption to change the file into an unreadable format.

Command Structure: UNIX commands are easy to understand and simple to


use. Example: "cp", mv etc. While working in the UNIX environment, the UNIX
commands are case-sensitive and are entered in lower case.

Communication: In UNIX, communication is an excellent feature that enables


the user to communicate worldwide. It supports various communication facilities
provided using the write command, mail command, talk command, etc.

Open Source: UNIX operating system is open source it means it is freely


available to all and is a community-based development project.

Accounting: UNIX keeps an account of jobs created by the user. This feature
enhances the system performance in terms of CPU monitoring and disk space
checking. It allows you to keep an account of disk space used by each user, and
the disk space can be limited by each other. You can assign every user a different
disk quota. The root user can perform these accounting tasks using various
commands such as quota, df, du, etc.

UNIX Tools and Utilities: UNIX system provides various types of tools and
utilities facilities such as UNIX grep, sed and awk, etc. Some of the general-
purpose tools are compilers, interpreters, network applications, etc. It also
includes various server programs which provide remote and administration
services.

The structure of Unix OS Layers are as follows:


While working with UNIX OS, several layers of this system provide interaction
between the pc hardware and the user. Following is the description of each and
every layer structure in UNIX system:

Layer-1: Hardware -

This layer of UNIX consists of all hardware-related information in the UNIX


environment.

Layer-2: Kernel -

The core of the operating system that's liable for maintaining the full functionality
is named the kernel. The kernel of UNIX runs on the particular machine hardware
and interacts with the hardware effectively.
It also works as a device manager and performs valuable functions for the
processes which require access to the peripheral devices connected to the
computer. The kernel controls these devices through device drivers.

The kernel also manages the memory. Processes are executed programs that have
owner's humans or systems who initiate their execution.

The system must provide all processes with access to an adequate amount of
memory, and a few processes require a lot of it. To make effective use of main
memory and to allocate a sufficient amount of memory to every process. It uses
essential techniques like paging, swapping, and virtual storage.

Layer-3: The Shell -

The Shell is an interpreter that interprets the command submitted by the user at
the terminal, and calls the program you simply want.
It also keeps a history of the list of the commands you have typed in. If you need
to repeat a command you typed it, use the cursor keys to scroll up and down the
list or type history for a list of previous commands. There are various commands
like cat, mv, cat, grep, id, wc, and many more.

Types of Shell in UNIX System:

o Bourne Shell: This Shell is simply called the Shell. It was the first Shell
for UNIX OS. It is still the most widely available Shell on a UNIX system.
o C Shell: The C shell is another popular shell commonly available on a
UNIX system. The C shell was developed by the University of California
at Berkeley and removed some of the shortcomings of the Bourne shell.
o Korn Shell: This Shell was created by David Korn to address the Bourne
Shell's user-interaction issues and to deal with the shortcomings of the C
shell's scripting quirks.

Layer-4: Application Programs Layer -


It is the outermost layer that executes the given external applications. UNIX
distributions typically come with several useful applications programs as
standard. For Example: emacs editor, StarOffice, xv image viewer, g++
compiler etc.

This diagram shows three levels: user, kernel, and hardware.

• The system call and library interface represent the border between
user programs and the kernel. System calls look like ordinary function
calls in C programs. Assembly language programs may invoke system
calls directly without a system call library. The libraries are linked
with the programs at compile time.
• The set of system calls into those that interact with the file subsystem
and some system calls interact with the process control subsystem. The
file subsystem manages files, allocating file space, administering free
space, controlling access to files, and retrieving data for users.
• Processes interact with the file subsystem via a specific set of system
calls, such as open (to open a file for reading or writing), close, read,
write, stat (query the attributes of a file), chown (change the record of
who owns the file), and chmod (change the access permissions of a
file).
• The file subsystem accesses file data using a buffering mechanism
that regulates data flow between the kernel and secondary storage
devices. The buffering mechanism interacts with block I/O device
drivers to initiate data transfer to and from the kernel.
• Device drivers are the kernel modules that control the operator of
peripheral devices. The file subsystem also interacts directly with
“raw” I/O device drivers without the intervention of the buffering
mechanism. Finally, the hardware control is responsible for handling
interrupts and for communicating with the machine. Devices such as
disks or terminals may interrupt the CPU while a process is executing.
If so, the kernel may resume execution of the interrupted process after
servicing the interrupt.
• Interrupts are not serviced by special processes but by special
functions in the kernel, called in the context of the currently running
process.
Difference between Unix and Linux
Linux is essentially a clone of Unix. But, basic differences are shown below:
Linux Unix

The source code of Linux is freely The source code of Unix is not freely
available to its users available general public
Linux Unix

It has graphical user interface along


It only has command line interface
with command line interface

Linux OS is portable, flexible, and


can be executed in different hard Unix OS is not portable
drives

Different versions of Linux OS are


Different version of Unix are AIS,
Ubuntu, Linux Mint, RedHat
HP-UX, BSD, Iris, etc.
Enterprise Linux, Solaris, etc.

The file systems supported by Linux


The file systems supported by Unix
are as follows: xfs, ramfs, vfat,
are as follows: zfs, js, hfx, gps, xfs,
cramfsm, ext3, ext4, ext2, ext1, ufs,
vxfs
autofs, devpts, ntfs

Linux is an open-source operating Unix is a proprietary operating


system that was first released in 1991 system that was originally developed
by Linus Torvalds. by AT&T Bell Labs in the mid 1960s.

The Unix kernel is modular, meaning


The Linux kernel is monolithic,
that it is made up of a collection of
meaning that all of its services are
independent modules that can be
provided by a single kernel.
loaded and unloaded dynamically.

Unix was originally designed to run


on large, expensive mainframe
Linux has much broader hardware
computers, while Linux was
support than Unix.
designed to run on commodity
hardware like PCs and servers.

User Interface of Linux is Graphical


User Interface of unix is text-based.
or text-based.

Command Line Interface of Linux is Command Line Interface of unix is


Bash, Zsh, Tcsh. Bourne, Korn, C, Zsh.
Advantages of UNIX:
1. Stability: UNIX is known for its stability and reliability. It can run
for long periods of time without requiring a reboot, which makes it
ideal for critical systems that need to run continuously.
2. Security: UNIX has a robust security model that includes file
permissions, user accounts, and network security features. This makes
it a popular choice for systems that require high levels of security.
3. Scalability: UNIX can be scaled up to handle large workloads and
can be used on a variety of hardware platforms.
4. Flexibility: UNIX is highly customizable and can be configured to
suit a wide range of needs. It can be used for everything from simple
desktop systems to complex server environments.
5. Command-line interface: UNIX’s command-line interface allows for
powerful and efficient interaction with the system.
Disadvantages of UNIX:
1. Complexity: UNIX can be complex and difficult to learn for users
who are used to graphical user interfaces (GUIs).
2. Cost: Some UNIX systems can be expensive, especially when
compared to open-source alternatives like Linux.
3. Lack of standardization: There are many different versions of UNIX,
which can make it difficult to ensure compatibility between different
systems.
4. Limited software availability: Some specialized software may not be
available for UNIX systems.
5. Steep learning curve: UNIX requires a certain level of technical
knowledge and expertise, which can make it challenging for novice
users.

Essential Unix Commands


Unix commands are a set of commands that are used to interact with the Unix
operating system. Unix is a powerful, multi-user, multi-tasking operating
system that was developed in the 1960s by Bell Labs. Unix commands are
entered at the command prompt in a terminal window, and they allow users to
perform a wide variety of tasks, such as managing files and directories, running
processes, managing user accounts, and configuring network settings. Unix is
now one of the most commonly used Operating systems used for various
purposes such as Personal use, Servers, Smartphones, and many more. It was
developed in the 1970’s at AT& T Labs by two famous personalities Dennis M.
Ritchie and Ken Thompson.
• You’ll be surprised to know that the most popular programming
language C came into existence to write the Unix Operating System.
• Linux is Unix-Like operating system.
• The most important part of the Linux is Linux Kernel which was first
released in the early 90s by Linus Torvalds. There are several Linux
distros available (most are open-source and free to download and
use) such as Ubuntu, Debian, Fedora, Kali, Mint, Gentoo, Arch and
much more.
• Now coming to the Basic and most usable commands of Linux/Unix
part. (Please note that all the linux/unix commands are run in the
terminal of a linux system.Terminal is like command prompt as that
of in Windows OS)
• Linux/Unix commands are case-sensitive i.e Hello is different from
hello.
Basic Unix commands:
• File System Navigation Unix Command
Command Description Example

cd Changes the current working directory. cd Documents

Lists files and directories in the current


ls
ls directory.

pwd Prints the current working directory. pwd

mkdir Creates a new directory. mkdir new_folder

rmdir Removes an empty directory. rmdir empty_folder

mv file1.txt
Moves files or directories.
mv Documents/
• File Manipulation Unix Command
Command Description Example

Creates an empty file or updates the


touch new_file.txt
touch access and modification times.

cp Copies files or directories. cp file1.txt file2.txt


Command Description Example

mv file1.txt
Moves files or directories.
mv Documents

rm Remove files or directories. rm old_file.txt

Changes the permissions of a file or


chmod 644 file.txt
chmod directory.

Changes the owner and group of a file or chown user:group


chown directory. file.txt

ln -s target_file
Creates links between files.
ln symlink

Concatenates files and displays their


cat file1.txt file2.txt
cat contents.

head Displays the first few lines of a file. head file.txt

tail Displays the last few lines of a file. tail file.txt

Displays the contents of a file page by


more file.txt
more page.

Displays the contents of a file with


less file.txt
less advanced navigation features.

diff file1.txt
Compares files line by line.
diff file2.txt

patch file.txt <


Applies a diff file to update a target file.
patch changes.diff
• Process Management Unix Command
Command Description Example

Displays information about active processes,


ps aux
ps including their status and IDs.

Displays a dynamic real-time view of system


top
top processes and their resource usage.

Terminates processes using their process IDs


kill <pid>
kill (PIDs).

Sends signals to processes based on name or


pkill -9 firefox
pkill other attributes.

killall -9
Terminates processes by name.
killall firefox

renice -n 10
Changes the priority of running processes.
renice <pid>

Runs a command with modified scheduling nice -n 10


nice priority. command

pstree Displays running processes as a tree. pstree

Searches for processes by name or other


pgrep firefox
pgrep attributes.

Lists active jobs and their status in the current


jobs
jobs shell session.

bg Puts a job in the background. bg <job_id>

fg Brings a background job to the foreground. fg <job_id>

Runs a command immune to hangups, with nohup


nohup output to a specified file. command &
Command Description Example

Removes jobs from the shell’s job table, disown


disown allowing them to run independently. <job_id>
• Text Processing Unix Command
Command Description Example

Searches for patterns in text


grep "error" logfile.txt
grep files.

sed
Processes and transforms text
's/old_string/new_string/g'
streams.
sed file.txt

Processes and analyzes text


files using a pattern scanning awk '{print $1, $3}' data.csv
awk and processing language.
• Network Communication Unix Command
Command Description Example

Tests connectivity with another


ping google.com
ping host using ICMP echo requests.

Traces the route that packets


traceroute google.com
traceroute take to reach a destination.

Queries DNS servers for


domain name resolution and IP nslookup google.com
nslookup address information.

Performs DNS queries,


providing detailed information dig google.com
dig about DNS records.

Performs DNS lookups,


displaying domain name to IP host google.com
host address resolution.
Command Description Example

Retrieves information about


domain registration and whois google.com
whois ownership.

Provides secure remote access


ssh username@hostname
ssh to a system.

Securely copies files between scp file.txt


scp hosts over a network. username@hostname:/path/

Transfers files between hosts


using the File Transfer Protocol ftp hostname
ftp (FTP).

Establishes interactive text-


based communication with a telnet hostname
telnet remote host.

Displays network connections,


routing tables, interface
statistics, masquerade netstat -tuln
connections, and multicast
netstat memberships.

Displays or configures network


ifconfig
ifconfig interfaces and their settings.

Configures wireless network


iwconfig wlan0
iwconfig interfaces.

Displays or modifies the IP


route -n
route routing table.

Displays or modifies the


Address Resolution Protocol arp -a
arp (ARP) cache.
Command Description Example

ss Displays socket statistics. ss -tuln

Displays or sets the system’s


hostname
hostname hostname.

Combines the functionality of


ping and traceroute, providing
mtr google.com
detailed network diagnostic
mtr information.
System Administration Unix Command
Command Description Example

df Displays disk space usage. df -h

Displays disk usage of files and du -sh


du directories. /path/to/directory

Manages cron jobs, which are scheduled


tasks that run at predefined times or crontab -e
crontab -e intervals.
Text Editors in Unix
Text
Editor Description Example

Vi (Vim) is a highly configurable, Open a file with


powerful, and feature-rich text editor Vim: vim filename
based on the original Vi editor. Vim Exit Vim editor:
Vi / offers modes for both command-line Press Esc, then
Vim operations and text editing. type :wq and press Enter

Emacs is a versatile text editor with Open a file with


extensive customization capabilities Emacs: emacs filename
and support for various programming Save and exit Emacs:
Emacs languages. Press Ctrl + X, then Ctrl
Text
Editor Description Example

+ S and Ctrl + X,
then Ctrl + C to exit

Open a file with


Nano is a simple and user-friendly text Nano: nano filename
editor designed for ease of use and Save and exit Nano:
accessibility. Press Ctrl + O, then Ctrl
Nano +X

Ed is a standard Unix text editor that Open a file with Ed: ed


operates in line-oriented mode, making filename
it suitable for batch processing and Exit Ed editor:
Ed automation tasks. Type q and press Enter

Open a file with Jed: jed


Jed is a lightweight yet powerful text
filename
editor that provides an intuitive
Save and exit Jed:
interface and support for various
Press Alt + X, then
programming languages.
Jed type exit and press Enter

You might also like