You are on page 1of 8

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.

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:


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.

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.

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
Basic Unix Commands
Getting help in Unix

 man – view manual pages for Unix commands


Syntax:
system22@VirtualBox: ~$ man

Unix Shell Commands


 clear – clear screen
Syntax:
system22@VirtualBox: ~$ clear

 history – show history of previous commands


Syntax:
system22@VirtualBox: ~$ history

Time and Date commands

 date – show current date and time


Syntax:

system22@VirtualBox: ~$ time
system22@VirtualBox: ~$ date

 sleep – wait for a given number of seconds


Syntax:
system22@VirtualBox: ~$ sleep

 uptime – find out how long the system has been up


Syntax:
system22@VirtualBox: ~$ uptime

Unix users commands


These commands allow you to get basic information about Unix users in your environment.
 whoami – show your username
Syntax:
system22@VirtualBox: ~$whoami

 id – print user identity


Syntax:
system22@VirtualBox: ~$id
 groups – show which groups user belongs to
Syntax:
system22@VirtualBox: ~$ groups
 passwd – change user password
Syntax:
system22@VirtualBox: ~$ passwd
 who – find out who is logged into the system
Syntax:
system22@VirtualBox: ~$ who
 last – show history of logins into the system
Syntax:
system22@VirtualBox: ~$ last

Unix file operations


Navigating filesystem and managing files and access permissions:

 ls – list files and directories


Syntax:
system22@VirtualBox: ~$ ls
Desktop Downloads Music Public Documents

 cp – copy files (work in progress)


 rm – remove files and directories (work in progress)
 mv – rename or move files and directories to another location
 chmod – change file/directory access permissions
 chown – change file/directory ownership

Text file operations in Unix

Most of important configuration in Unix is in clear text files, these commands will let you
quickly inspect files or view logs:

• cat – concatenate files and show contents to the standard output

Syntax:
system22@VirtualBox: ~$ cat > sample1
This is Sample1
Control +D to exit
Let’s see the file we just created
system22@VirtualBox: ~$ cat sample1

• more –when viewing text files or parsing Unix commands output


• less – an improved tool for viewing text files (better than more command)
• head – show the first 10 lines of text file (you can specify any number of lines)
• tail – show the last 10 lines of text file (any number can be specified)
• grep – search for patterns in text files

Unix directory management commands


Navigating filesystems and managing directories:
 mkdir – make new directory
Syntax:
system22@VirtualBox: ~$ mkdir dir_name
ex : system22@VirtualBox: ~$ mkdir bca

 rmdir – remove directories in Unix


Syntax:
system22@VirtualBox: ~$ rmdir dir_name
ex : system22@VirtualBox: ~$ rmdir bca

 cd – change directory
Syntax:
system22@VirtualBox: ~$ cd dir_name
ex : system22@VirtualBox: ~$ cd bca

 pwd – confirm current directory


Syntax:
system22@VirtualBox: ~$ pwd dir_name

 ln – make links and symlinks to files and directories


Syntax:
system22@VirtualBox: ~$ in dir_name
Unix file operations
Navigating filesystem and managing files and access permissions:
 ls – list files and directories
Syntax:
system22@VirtualBox: ~$ ls
Desktop Downloads Music Public Documents
 cp – copy files (work in progress)
Syntax:
system22@VirtualBox: ~$ cp file1 file2

 rm – remove files and directories (work in progress)


Syntax:
system22@VirtualBox: ~$ rm dir_namr
system22@VirtualBox: ~$ rm file_name
 mv – rename or move files and directories to another location
Syntax:
system22@VirtualBox: ~$ mv dir_namr new dir_name
system22@VirtualBox: ~$ mv file_name new file name

 chmod – change file/directory access permissions


Syntax:
system22@VirtualBox: ~$chmod dir_namr r
system22@VirtualBox: ~$ chmod file_name w

 chown – change file/directory ownership


Syntax:
system22@VirtualBox: ~$ chown dir_namr
system22@VirtualBox: ~$ chown file_name
Text file operations in Unix
Most of important configuration in Unix is in clear text files, these commands
will let you quickly inspect files or view logs:
• cat – concatenate files and show contents to the standard output
Syntax:
system22@VirtualBox: ~$ cat > sample1
This is Sample1
Control +D to exit
Let’s see the file we just created
system22@VirtualBox: ~$ cat sample1
 
• more –when viewing text files or parsing Unix commands output
Syntax:
system22@VirtualBox: ~$ more sample1

• less – an improved tool for viewing text files (better than more command)
Syntax:
system22@VirtualBox: ~$ less sample1

• head – show the first 10 lines of text file (you can specify any number of lines)
Syntax:
system22@VirtualBox: ~$head sample1

• tail – show the last 10 lines of text file (any number can be specified)
Syntax:
system22@VirtualBox: ~$tail sample1

• grep – search for patterns in text files


Syntax:
system22@VirtualBox: ~$grep sample1

WC:
wc stands for word count. As the name implies, it is mainly used for
counting purpose.
 It is used to find out number of lines, word count, byte and
characters count in the files specified in the file arguments.
 By default it displays four-columnar output.
 First column shows number of lines present in a file specified, second
column shows number of words present in the file, third column shows
number of characters present in file and fourth column itself is the file
name which are given as argument.
Syntax:
wc [OPTION]... [FILE]...

$ cat state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh

$ wc state.txt
5 7 58 state.txt

You might also like