2. Module 1
Introduction Unix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix specification.
General features of Unix commands/ command structure. Command
arguments and options. Understanding of some basic commands such as
echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of
a command and locating it. The man command knowing more about Unix
commands and using Unix online manual pages. The man with keyword
option and whatis. The more command and using it with other
commands. Knowing the user terminal, displaying its characteristics and
setting characteristics. Managing the non uniform behaviour of terminals
and keyboards. The root login. Becoming the super user: su command.
The /etc/passwd and /etc/shadow files. Commands to add, modify and
delete users.
4. Introduction
• Computer system
• Hardware
• Input Device
• Processing Unit
• Storage devices
• Software
• System software
• Application software
• Operating System (OS)
• Hardware / Software ?
• Why OS
• OS load
5. Module 1
IntroductionUnix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix specification.
General features of Unix commands/ command structure. Command
arguments and options. Understanding of some basic commands such as
echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of
a command and locating it. The man command knowing more about Unix
commands and using Unix online manual pages. The man with keyword
option and whatis. The more command and using it with other
commands. Knowing the user terminal, displaying its characteristics and
setting characteristics. Managing the non uniform behaviour of terminals
and keyboards. The root login. Becoming the super user: su command.
The /etc/passwd and /etc/shadow files. Commands to add, modify and
delete users.
6. The UNIX Architecture
• BSD (originally: Berkeley Software Distribution)
refers to the particular version of the UNIX
operating System that was developed at and
distributed from the University of California at
Berkeley
• Berkeley Software Distribution (BSD) is a Unix
operating system derivative developed and
distributed by the Computer Systems Research
Group (CSRG) of the University of California,
Berkeley, from 1977 to 1995.
7. The UNIX Architecture
1. Division of labor
• Kernel : communicates directly with hardware
• Shell : command interpreter, translates
commands in to action
–Sh : Bourne Shell
–Csh: C shell
–Ksh : Korn shell
2.The file and Process
• File
• Process
8. The UNIX Architecture
3. System calls
• Kernel, shell, apllications --- C
• All UNIX flavors use the same system calls ---
• POSIX (Portable Operating System
Interface)
• Examples : Open, write
10. The Architecture of Unix Operating System
Unix has a graphical user interface similar to the Windows operating
system that makes it easy for navigation and a good supportive
environment. The internal design view of this operating system can
be known from its architecture.
The he architecture of this operating system is four layered. It consists of
Hardware, Kernel, System Call interface(shell) and application
libraries/tools, utilities, etc…The kernel controls the hardware of the
computer and resides at the core of the architecture. System calls acts as
the interface between the kernel and other libraries. These libraries
include general functions and built on top of the system calls. Shell is a
special application that provides an interface to the other applications of
the architecture.
11. Kernel
For this operating system, Kernel is the central core that interacts directly with the
hardware of the system. The main functions of Kernal are-
● Computer hardware such as memory, disc, printers, etc.. are controlled by the
kernel.
● The kernel schedules the processes, control and executes various user-
defined tasks.
● Manages the data storage and control the computer accesses by several
users.
● The kernel is composed of several sub-components such as configurations
including boot code, device drivers to control hardware, header files.
12. Shell
It is the interface between the user and the kernel. Users can
interact with the shell using shell commands. Shell has two
main responsibilities which include interpreting the commands
given by the users and execute them using the kernel,
providing programming ability to the users to write shell
commands for a shell script to perform specific tasks.
13. Commands
Some of the major categories of commands used by the
Unix operating system are – ‘sh’ – shell commands
providing a primary user interface, ‘utilities’ forming the
core toolkit of Unix commands includes sub-categories
such as system utilities supporting administrative tools
and User utilities for environment management tools.
14. Properties
From the time of its development, Unix has been adopted by many
companies. It still plays a big role in many data centers and research labs.
Some of the properties of Unix that make it so preferable over other
systems are-
● Multiuser accessing – Multiple users can work on the system
simultaneously by connecting through a point known as terminal.
● Multi-tasking-It provides the facility to run multiple programs or processes
by multiple users on one system.
15. ● Portability – It provides the flexibility to be used on multiple hardware
architectures. As it uses a high-level language, it is easy to comprehend and
modify the Unix code according to the hardware architecture of the computer.
Thus to work on new hardware architecture, the user has to simply modify the
Unix code and run on the system.
● Processes– Files are the collection of data created by the user. It includes
documents, programming instructions, etc…Processes are the executions of
the programs or files. Unix follows the hierarchical file structure that starts with
a root directory followed by the subdirectories ending with the file name.
● Communication – Requests and commands given by the user are carried out
by the kernel and shell together. The user communicates with the system using
Shell. It also provides inter-system communication through UUCP. This
operating system also obeys the TCP/IP protocol.
16. ● It also provides easy maintenance of the files
● This operating system provides Pipes and Filters to the user to design complex
programs from simple programs.
● It provides a wide variety of tools for software development and software
maintenance.
● It is very popularly used on Desktop computers, laptops, mainframes, and
other computing hardware.
17. Types of Unix Operating Systems
Unix gives the user the flexibility to modify the Unix code according to their
requirements. Thus it is easy to port the Unix code on different types of
hardware. The freely available source code of this operating system and its
portability feature lead to various Unix like operating systems. Some of the
popular Unix like operating systems are Solaris, Darwin, AIX, HP-UX,
FreeBSD, NetBSD, Xenix, IRIX, Tru64, macOS, etc…
18. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. General features of Unix commands/ command structure.
Command arguments and options. Understanding of some basic
commands such as echo, printf, ls, who, date, passwd, cal, Combining
commands. Meaning of Internal and external commands. The type
command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
19. Features of UNIX
1. UNIX: A Multiuser system
2. UNIX: A Multitasking system
3. The Building Block Approach
4. The UNIX toolkit
5. Pattern Matching
6. Programming Facility
7. Documentation
20. The UNIX toolkit
The Unix operating system introduced the idea of a toolkit. That is,
rather than having a few generalized and complex utilities
programs, the system contains a toolkit of small and simple
programs which the user combines to perform sophisticated tasks
and to create custom programs.
Because Unix treats files, commands, and devices all pretty much
as files, and since most of these tools will take their input either from
files or from other commands (or standard input if no file name is
given), this juxtaposition of tools is general and powerful.
21. Grep Command in Unix with Simple Examples
Grep command in Unix/Linux is the short form of ‘global search for
the regular expression’.
• The grep command is a filter that is used to search for lines
matching a specified pattern and print the matching lines to
standard output.
example
grep [options] [pattern] [file]
The pattern is specified as a regular expression. A regular expression is a
string of characters that is used to specify a pattern matching rule. Special
characters are used to define the matching rules and positions.
23. UNIX o/s provides shell. Shell works like a
programming language. It provides commands
and keywords.
24. Module 1
Introduction Unix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix specification
General features of Unix commands/ command structure. Command
arguments and options. Understanding of some basic commands such as
echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of
a command and locating it. The man command knowing more about Unix
commands and using Unix online manual pages. The man with keyword
option and whatis. The more command and using it with other
commands. Knowing the user terminal, displaying its characteristics and
setting characteristics. Managing the non uniform behaviour of terminals
and keyboards. The root login. Becoming the super user: su command.
The /etc/passwd and /etc/shadow files. Commands to add, modify and
delete users.
25. The UNIX Environment
• Stand alone personal environment
• Time sharing systems
• Client server system
26. Module 1
Introduction. Unix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix specification.
General features of Unix commands/ command structure. Command
arguments and options. Understanding of some basic commands such as
echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of
a command and locating it. The man command knowing more about Unix
commands and using Unix online manual pages. The man with keyword
option and whatis. The more command and using it with other
commands. Knowing the user terminal, displaying its characteristics and
setting characteristics. Managing the non uniform behaviour of terminals
and keyboards. The root login. Becoming the super user: su command.
The /etc/passwd and /etc/shadow files. Commands to add, modify and
delete users.
27. UNIX structure
• The kernel: Process control, Resource
management
• The shell: interpreter, programming capability
• Utilities: Text editors, search programs, sort ,
• Application
28. Module 1
Introduction. Unix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix specification.
General features of Unix commands/ command structure. Command
arguments and options. Understanding of some basic commands such as
echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of
a command and locating it. The man command knowing more about Unix
commands and using Unix online manual pages. The man with keyword
option and whatis. The more command and using it with other
commands. Knowing the user terminal, displaying its characteristics and
setting characteristics. Managing the non uniform behaviour of terminals
and keyboards. The root login. Becoming the super user: su command.
The /etc/passwd and /etc/shadow files. Commands to add, modify and
delete users.
29. POSIX and the single UNIX specification
Portable Operating System Interface for Computer
Environment.
IEEE
• POSIX.1: C application programming interface,
system calls.
• POSIX.1a:
• POSIX.1b
• POSIX.2: Shell and utilities
• X/Open & IEEE: Single Unix Specification Version 3
(SUSV3).
30. Module 1
Introduction. Unix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix specification.
General features of Unix commands/ command structure. Command
arguments and options. Understanding of some basic commands such as
echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of
a command and locating it. The man command knowing more about Unix
commands and using Unix online manual pages. The man with keyword
option and whatis. The more command and using it with other
commands. Knowing the user terminal, displaying its characteristics and
setting characteristics. Managing the non uniform behaviour of terminals
and keyboards. The root login. Becoming the super user: su command.
The /etc/passwd and /etc/shadow files. Commands to add, modify and
delete users.
31. Command structure
• Since the introduction of UNIX System V, Release
3, any new commands must obey a particular
syntax governed by the following rules:
• Command names must be between 2 and
9 characters in length.
• Command names must be comprised of
lowercase characters and digits.
• Option names must be one character in length.
32. • command [options] [arguments]
• where an argument indicates on what the command is to perform
its action, usually a file or series of files. ...
• Commands are case sensitive. ...
• Options are generally preceded by a hyphen (-), and for
most commands, more than one option can be strung together, in
the form: ls -alR
will perform a long list on all files in the current directory and
recursively perform the list through all sub-directories.
• For most commands you can separate the options, preceding each
with a hyphen, e.g.:
• command -option1 -option2 -option3 as in:
ls -a -l -R
33. • Whitespace
• Cat README
• Options
ls -l
ls -l filename
ls –l –a –t
ls –lat
34.
35. Command structure
2. Filename Arguments
ls –lat chap01 chap02 chap03
cp chap01 chap02
rm chap01 chap02
3. Exceptions
who
ls
pwd etc….
36. Module 1
Introduction Unix Components/Architecture. Features of Unix. The UNIX
Environment and UNIX Structure, Posix and Single Unix
specification.eneral features of Unix commands/ command structure.
Command arguments and options. Understanding of some basic
commands such as echo, printf, ls, who, date, passwd, cal, Combining
commands. Meaning of Internal and external commands. The type
command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
37. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
39. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
41. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
43. ls options
ls -x output in multiple columns
ls –F Identifying directories and executable
ls -a list all files including hidden file starting
with .
ls –x dir
_name
Listing directory contents
ls –xR Recursive listing
44. ls
• ls –d current directory
• ls –l list with long format - show
permissions
• ls –la list long format including hidden file
• ls –s list file size
• ls –S sort by file size
• ls –t sort by time & date
45. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
47. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
49. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
51. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
53. Commands
• Examples:
1.ps (process status):In UNIX, everything you do,
every command you type, is considered a
"process". This command will list all the jobs you
have running in your account, which includes the
login shell.
2.Cat filename
3.Wc filename
54. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
55. Flexibility of command usage
1. Combining commands
wc chap01 ; ls –l chap01
( wc chap01; ls –l chap01)>newlist
56. Flexibility of command usage
2. A command line can overflow or be split into
multiple lines
echo “5th sem 2 section
is a very good class.
I love this class”
57. Flexibility of command usage
3. Entering a command before previous command
has finished
4. man: Browsing the manual pages on line
man argument
5. Navigation and search
f or spacebar
b
58. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
59. Meaning of Internal and external
commands
Internal commands are commands that are already
loaded in the system. They can be executed any time
and are independent.Example: cd, source,XCOPY,
CHKDSK, LABEL, TREE etc
External commands are loaded when the user requests
for them.Example:ls, cat etc
60. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
61. Locating commands
The type command is used to describe how its argument would be
translated if used as commands. It is also used to find out whether it
is built-in or external binary file.
• type cd
• type -a
This option is used to find out whether it is an alias, keyword or a
function and it also displays the path of an executable, if available.
-t : This option will display a single word as an output.
• alias – if command is a shell alias
• keyword – if command is a shell reserved word
• builtin – if command is a shell builtin
• function – if command is a shell function
• file – if command is a disk file
62. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
64. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
66. Understanding the man documentation
1. Understanding a man page
Name, Synopsis and description
[]
…
pipeline
67. Understanding the man documentation
2. Using man to understand man
man man
more chap01
68. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
70. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
71. Knowing your terminal
• The who command will give us the information we are
looking for.
• The one-letter command w requires less typing and
provides more information.
USER: The user name.
TTY: The type of terminal they are logged in at. This will usually be a pts (a pseudo-teletype). :0
means the physical keyboard and screen connected to this computer.
FROM: The name of the remote host if this is a remote connection.
LOGIN@: The time at which the user logged in.
IDLE: Idle time. This shows ?xdm? in the screenshot because we’re running under an X-
windows Display Manager, which does not provide that information.
72. JCPU: Joint CPU time, this is the CPU time used by all processes that
have been attached to this tty. In other words, the total CPU time of this
user in this logged in session.
PCPU: Process CPU time, this is the CPU time used by the current
process. The current process is named in the WHAT column.
WHAT: The command line of this user’s current process.
• The whoami command provides a very pithy
answer
• teletype
The tty command of terminal basically prints the file name of the terminal connected to
standard input. tty is short of teletype, but popularly known as a terminal it allows you to
interact with the system by passing on the data (you input) to the system, and displaying
the output produced by the system
73. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
74. Displaying its characteristics and setting
characteristics
$stty –a
• On Unix operating systems, the stty command changes and prints
terminal line settings.
stty -echo
stty echo
stty -a
75. Displaying its characteristics and setting
characteristics
• Backspace should erase characters
$stty –echoe
• Enter password through a shell script
$stty –echo
• Changing the interrupt key
$stty intr ^c
• Changing the end of file
$stty eof ^a
• When everything else fails
$stty sane
76. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
77. Managing the non uniform behavior of
terminals and keyboards
Keystroke Function
[Ctrl-h] Erase text
[Ctrl-c] or [delete] Interrupts a command
[Ctrl-d] Terminates login session or a
program that expects its input
from the key board
[Ctrl-s] Stops scrolling of screen output
and locks keyboard
[Ctrl-q] Resumes scrolling of screen
output and unlocks keyboard
[Ctrl-u] Kills command line without
executing it
78. Managing the non uniform behavior of
terminals and keyboards
Keystroke Function
[Ctrl-] Kills running command but
creates a core file containing
the memory image of the
program
[Ctrl-z] Suspends process and returns
shell prompt
[Ctrl-j] Alternative to [enter]
[Ctrl-m] As above
Stty sane Restores terminal to normal
status
79. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
81. • A critical means for preventing users from directly damaging
Unix-like systems or increasing the vulnerability of such
systems to damage by others is the avoidance of using the root
account except when absolutely necessary
• rather than routinely logging into the system as root,
administrators should log in with their admin account and then
use the su command. This will provide you with root privileges
only as needed and without requiring a new login.
82. Example: To list the contents of a directory owned by root you would type:
su root ls /root
You will be prompted for your root password. The account of the admin user
can be returned to by typing exit.
83. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
84. Becoming a super user
su
password: ****
sudo su
On UNIX this special user is known as superuser or root (not to be
confused with the root directory). Superuser can override file
security and do almost anything she wants on the system (she
cannot see your password, since it is encrypted, but she can
change it). In fact, any user with a userid of 0 is a superuser.
Naturally, such users should always have a password.
85. Becoming a super user
• creating user environment
su –henry
[ctrl-d]/ exit
• The administrator's privileges
– Change the content or attribute of any file like its
permission and ownership. He can delete any file
even if the directory is write protected.
– Initiate or kill any process
86. • The administrator's privileges
– Change any user’s password without knowing the
existing one
– Set the system clock with date
– Address all users concurrently with wall
– Limit the maximum size of files that users are
permitted to create with ulimit
– Control users access to the scheduling services like at
and cron
– Control users access to many networking services like
FTP, SSH etc.
Becoming a super user
87. • date: setting the system date
date MMDDhhm
• wall: Communicating with users
wall
• ulimit: Setting limits on file size
ulimit 20971510
Becoming a super user
89. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
90. /etc/passwd is the key file in any Linux Unix system.
• The password file is a human-readable file that contains
information about users on the system including their encrypted
passwords
• Some systems don’t have encrypted passwords in this file if
/etc/shadow file is generated.
• cat /etc/passwd
91. • Username:Its user name being used by the user to login
• Password:Its password in an encrypted format.you see x instead of encrypted
password since /etc/shadow file is generated on the system. The encrypted
password is found in /etc/shadow file in such case.
• UID:Its user id. Its unique number assigned to every account on the system.
• GID:Its group id. Its unique number of groups of which account is member of.
• Comment:This field is introduced to have some descriptions against the account.
This is purely for humans to identify/understand what related account is or to
whom it belongs to
• Home directory:Its a directory where normally user lands into when he/she login.
• Login shell:This is a shell that will be spawn when the user successfully logs in.
root:x:0:0:root:/root:/bin/bash
root:$6$h./k6HFM$EmRq6TQl80Lq7BF5k0v9A8MvCZx5P
ddhczyUViwtfj.FWkl6xsE0TtYJ91V30FZw6nd5maIQXSkbN
RpPG6o8v.:18527:0:99999:7:::
/etc/passwd and /etc/shadow
92. Module 1
Introduction, Brief history. Unix Components/Architecture. Features of Unix.
The UNIX Environment and UNIX Structure, Posix and Single Unix
specification. The login prompt. General features of Unix commands/
command structure. Command arguments and options. Understanding of
some basic commands such as echo, printf, ls, who, date, passwd, cal,
Combining commands. Meaning of Internal and external commands. The
type command: knowing the type of a command and locating it. The man
command knowing more about Unix commands and using Unix online
manual pages. The man with keyword option and whatis. The more
command and using it with other commands. Knowing the user terminal,
displaying its characteristics and setting characteristics. Managing the non
uniform behaviour of terminals and keyboards. The root login. Becoming
the super user: su command. The /etc/passwd and /etc/shadow files.
Commands to add, modify and delete users.
93. • adduser username : add user
• Command to add a new user to the system. This command can be as short
as just one argument of userid. When running with just userid as an
argument then it takes all default values for creating that user as defined
in /etc/default/useradd file. Or else a number of options can be specified
which defines parameters of this new user while creation.
for more command usage refer:
• https://kerneltalks.com/linux/linux-user-management-useradd-userdel-
usermod/
# cat /etc/default/useradd
# useradd defaults file
GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
add, modify and delete users
94. • Command: userdel
As the name suggests its a command to delete users. It has only two
options –
● -r Remove user’s home_dir & mail spool
● -f Removes user even if he/she logged in. Removes home_dir, mail
spool & group of the same name even these are being shared by
another user. Dangerous!
95. Command: usermod
This command used to modify user parameters which we saw in
useradd command. All parameter options with useradd command
compatible with this command. Apart from those options, it supports
below ones –
● -l <new_login> Change login name to different. You have to
manually rename home_dir
● -L Lock account. Basically it puts ! in front of encrypted password in
passwd or shadow file.
● -U Unlock account. It removes!
● -m <new_home> Moves home_dir to new_dir. -d is mandatory to use with it.
96. Module 1
Unix files. Naming files. Basic file types/categories. Organization of files.
Hidden files. Standard directories. Parent child relationship. The home
directory and the HOME variable. Reaching required files- the PATH
variable, manipulating the PATH, Relative and absolute pathnames.
Directory commands – pwd, cd, mkdir, rmdir commands. The dot (.) and
double dots (..) notations to represent present and parent directories and
their usage in relative path names. File related commands – cat, mv, rm,
cp, wc and od commands. File attributes and permissions and knowing
them. The ls command with options. Changing file permissions: the
relative and absolute permissions changing methods. Recursively
changing file permissions. Directory permissions.
97. Unix files
• Unix uses a hierarchical file system structure,
much like an upside-down tree, with root (/)
at the base of the file system and all other
directories spreading from there.
98. Unix files
• It has a root directory (/) that contains other files
and directories.
• Each file or directory is uniquely identified by its
name, the directory in which it resides, and a
unique identifier, typically called an inode.
• File inode numbers can be seen by specifying the -
i option to ls command.
• It is self-contained. There are no dependencies
between one file system and another.
99. Naming files
• Alphabetic characters and numerical
• The period (.), hyphen (-) and underscore (_).
• . Last_time
• list.
• ^V^B^D-++bcd
• -{}[]
• @#$%*abcd
• A.b.c.d.e
• Abcd.txt abcd.txt ABCD.txt aBCD.txt
101. 1. Ordinary files – An ordinary file is a file on the system that contains data, text, or
program instructions.
● Used to store your information, such as some text you have written or an image you
have drawn. This is the type of file that you usually work with.
● Always located within/under a directory file.
● Do not contain other files.
● In long-format output of ls -l, this type of file is specified by the “-” symbol.
2. Directories – Directories store both special and ordinary files. For users familiar with
Windows or Mac OS, UNIX directories are equivalent to folders. A directory file contains
an entry for every file and subdirectory that it houses. If you have 10 files in a directory,
there will be 10 entries in the directory. Each entry has two components.
(1) The Filename
(2) A unique identification number for the file or directory (called the inode number)
102. Special Files – Used to represent a real physical device such as a printer,
tape drive or terminal, used for Input/Output (I/O) operations. Device or
special files are used for device Input/Output(I/O) on UNIX and Linux
systems. They appear in a file system just like an ordinary file or a
directory.
Pipes – UNIX allows you to link commands together using a pipe. The pipe
acts a temporary file which only exists to hold data from one command
until it is read by another.A Unix pipe provides a one-way flow of data.The
output or result of the first command sequence is used as the input to the
second command sequence. To make a pipe, put a vertical bar (|) on the
command line between two commands.For example: who | wc -l
103. Sockets – A Unix socket (or Inter-process communication socket) is a special file
which allows for advanced inter-process communication. A Unix Socket is used in a
client-server application framework. In essence, it is a stream of data, very similar to
network stream (and network sockets), but all the transactions are local to the
filesystem.
In long-format output of ls -l, Unix sockets are marked by “s” symbol.
Symbolic Link – Symbolic link is used for referencing some other file of the file
system.Symbolic link is also known as Soft link. It contains a text form of the path to
the file it references. To an end user, symbolic link will appear to have its own
name, but when you try reading or writing data to this file, it will instead reference
these operations to the file it points to. If we delete the soft link itself , the data file
would still be there.If we delete the source file or move it to a different location,
symbolic file will not function properly.
105. ● / : The slash / character alone denotes the root of the filesystem tree.
● /bin : Stands for “binaries” and contains certain fundamental utilities, such
as ls or cp, which are generally needed by all users.
● /boot : Contains all the files that are required for successful booting
process.
● /dev : Stands for “devices”. Contains file representations of peripheral
devices and pseudo-devices.
● /etc : Contains system-wide configuration files and system databases.
Originally also contained “dangerous maintenance utilities” such as init,but
these have typically been moved to /sbin or elsewhere.
106. ● /home : Contains the home directories for the users.
● /lib : Contains system libraries, and some critical files such as kernel
modules or device drivers.
● /media : Default mount point for removable devices, such as USB
sticks, media players, etc.
● /mnt : Stands for “mount”. Contains filesystem mount points. These
are used, for example, if the system uses multiple hard disks or hard
disk partitions. It is also often used for remote (network) filesystems,
CD-ROM/DVD drives, and so on.
● /proc : procfs virtual filesystem showing information about processes
as files.
● /
107. ● root : The home directory for the superuser “root” – that is, the system administrator. This
account’s home directory is usually on the initial filesystem, and hence not in /home
(which may be a mount point for another filesystem) in case specific maintenance needs
to be performed, during which other filesystems are not available. Such a case could
occur, for example, if a hard disk drive suffers physical failures and cannot be properly
mounted.
● /tmp : A place for temporary files. Many systems clear this directory upon startup; it might
have tmpfs mounted atop it, in which case its contents do not survive a reboot, or it might
be explicitly cleared by a startup script at boot time.
● /usr : Originally the directory holding user home directories,its use has changed. It now
holds executables, libraries, and shared resources that are not system critical, like the X
Window System, KDE, Perl, etc. However, on some Unix systems, some user accounts
may still have a home directory that is a direct subdirectory of /usr, such as the default as
in Minix. (on modern systems, these user accounts are often related to server or system
use, and not directly used by a person).
108. ● /usr/bin : This directory stores all binary programs distributed with the operating system
not residing in /bin, /sbin or (rarely) /etc.
● /usr/include : Stores the development headers used throughout the system. Header files
are mostly used by the #include directive in C/C++ programming language.
● /usr/lib : Stores the required libraries and data files for programs stored within /usr or
elsewhere.
● /var : A short for “variable.” A place for files that may change often – especially in size, for
example e-mail sent to users on the system, or process-ID lock files.
● /var/log : Contains system log files.
● /var/mail : The place where all the incoming mails are stored. Users (other than root) can
access their own mail only. Often, this directory is a symbolic link to /var/spool/mail.
● /var/spool : Spool directory. Contains print jobs, mail spools and other queued tasks.
● /var/tmp : A place for temporary files which should be preserved between system
reboots.
110. Standard directories
/
This is the root directory which should
contain only the directories needed at the
top level of the file structure
/lib
Contains shared library files and
sometimes other kernel-related files
/bin
This is where the executable files are
located. These files are available to all
users
/boot
Contains files for booting the system
/dev
These are device drivers
/home
Contains the home directory for users and
other accounts
/etc
Supervisor directory commands, configuration
files, disk configuration files, valid user lists,
groups, Ethernet, hosts, where to send critical
messages
/mnt
Used to mount other temporary file
systems, such as cdrom and floppy for
the CD-ROM drive and floppy diskette
drive, respectively
111. Standard directories
/proc
Contains all processes marked as a file
by process number or other information that
is dynamic to the system
/sbin
Contains binary (executable) files,
usually for system administration. For
example, fdisk and ifconfigutlities
/tmp
Holds temporary files used between system
boots
/kernel
Contains kernel files
/usr
Used for miscellaneous purposes, and can be
used by many users. Includes administrative
commands, shared files, library files, and
others
/var
Typically contains variable-length files
such as log and print files and any other
type of file that may contain a variable
amount of data
114. When you log in to the system, the shell undergoes a phase called initialization to set
up the environment. This is usually a two-step process that involves the shell reading the
following files −
● /etc/profile
● profile
The process is as follows −
● The shell checks to see whether the file /etc/profile exists.
● If it exists, the shell reads it. Otherwise, this file is skipped. No error message is
displayed.
● The shell checks to see whether the file .profile exists in your home directory. Your
home directory is the directory that you start out in after you log in.
● If it exists, the shell reads it; otherwise, the shell skips it. No error message is
displayed.
● As soon as both of these files have been read, the shell displays a prompt
115. The PATH variable, manipulating the PATH
• echo $PATH
• $PATH=“set your own path”
• echo $PATH
116. When you type any command on the command prompt, the shell has
to locate the command before it can be executed.
The PATH variable specifies the locations in which the shell should look
for commands. Usually the Path variable is set as follows −
$PATH=/bin:/usr/bin
Here, each of the individual entries separated by the colon character (:)
are directories. If you request the shell to execute a command and it
cannot find it in any of the directories given in the PATH variable, a
message similar to the following appears
$hello
hello: not found
117. DISPLAY: Contains the identifier for the display that X11 programs should use by
default.
HOME:Indicates the home directory of the current user: the default argument for the
cd built-in command.
IFS:Indicates the Internal Field Separator that is used by the parser for word
splitting after expansion.
LANG:LANG expands to the default system locale; LC_ALL can be used to
override this. For example, if its value is pt_BR, then the language is set to
(Brazilian) Portuguese and the locale to Brazil.
LD_LIBRARY_PATH:A Unix system with a dynamic linker, contains a
colonseparated list of directories that the dynamic linker should search for shared
objects when building a process image after exec, before searching in any other
directories.
PATH:Indicates the search path for commands. It is a colon-separated list of
directories in which the shell looks for commands.
118. PWD:Indicates the current working directory as set by the cd command.
RANDOM:Generates a random integer between 0 and 32,767 each time it is
referenced.
SHLVL:Increments by one each time an instance of bash is started. This variable is
useful for determining whether the built-in exit command ends the current session.
TERM:Refers to the display type.
TZ:Refers to Time zone. It can take values like GMT, AST, etc
UID:Expands to the numeric user ID of the current user, initialized at the shell
startup.
119. Relative and absolute pathnames
• Absolute pathnames
$cat /home/ankitha/login.txt
• Relative pathname
cd progs
cat login.txt
cd progs/scripts
cd ../..
cp ../vasu/ex.txt .
cd ./pis
130. od
octal form
1. od file //ASCII octal form
2. od –b file //octal value of each printable character
3. od –c file // print the character
4. od –bc file //displays character and corresponding
octal value