UNIX
UNIX
1. Hardware Layer:
It contains the hardware-related information required for the functioning of
the UNIX environment.
2. Kernel Layer:
The core (commonly known as the heart) of the operating system. It is a software
application that acts as the interface between the hardware and the user.
The kernel is responsible for handling the major functionality of the Unix Operating
System including process, memory, file, network, etc.
Functions of the Kernel Layer:
o Ensures that all the system and user tasks are executed concurrently.
o Acts as a device manager helping processes gain access to peripheral
devices connected to the computer with the help of device drivers .
o Manages memory using techniques like paging, swapping, and virtual storage.
3. Shell Layer:
The interface between the user and kernel. It is a program
that interprets/translates commands typed into the terminal into a series of
commands that can be sent to the shell. This script containing commands is called
a shell script. The shell is what keeps a history of commands typed in by the user. To
repeat a command previously typed, you can simply click the scroll-up key and you
will get access to the older commands.
UNIX uses multiple shells including Bourne Shell (sh), C shell (csh), Korn shell (ksh), etc. The
initial shell that the user logs into is defined by the system administrator. The user can
change the default shell by using the 'chsh' command.
4. Application Programs Layer:
The outermost layer that includes programs that are accessed by command on the
command line. It executes external applications like word processors and graphic
programs . Although the earlier Command line was the only way to access them,
now GUI can also be used.
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.
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.
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.
ADVERTISEMENT
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.
Posix -
POSIX (Portable Operating System Interface) is a family of standards specified by the IEEE for
maintaining compatibility between operating systems. POSIX defines the application
programming interface (API), along with command line shells and utility interfaces, for
software compatibility with variants of Unix and other operating systems.
Key Points about POSIX:
1. Standardization: POSIX is designed to ensure that software developed for one POSIX-
compliant operating system can be compiled and run on another POSIX-compliant
system with minimal modifications.
2. API Specification: POSIX provides a set of standardized APIs that applications can use
to interact with the operating system. These APIs include system calls for file
operations, process control, and inter-process communication.
3. Shell and Utilities: POSIX defines a standard command-line interface and utility
programs. This includes standard utilities like ls, grep, awk, and a standard shell
(usually the Bourne shell or a compatible shell).
4. Portability: The primary goal of POSIX is to facilitate the portability of applications
across different UNIX-like operating systems. This is crucial for developers who aim to
write software that can run on various platforms without needing to be rewritten for
each one.
5. Versions and Compliance: POSIX standards are published in various versions.
Compliance with POSIX can vary, with some operating systems being fully compliant
and others only partially so. Some notable POSIX-compliant operating systems include
Linux, macOS, and many versions of UNIX.
6. Modular Approach: The POSIX standards are modular, allowing different parts of the
specification to be implemented independently. This modularity enables operating
systems to support only the necessary parts of the standard relevant to their use
case.
Single-User Mode -
1. Purpose:
• Single-user mode is used primarily for system maintenance tasks, such as
repairing file systems, resetting passwords, or performing backup and restore
operations. It provides an environment where the system administrator has
direct access to the system without interference from other users or services.
2. Characteristics:
• Minimal Environment: The system boots into a minimal environment with only
essential services running. Typically, it mounts the root filesystem in read-only
mode to ensure system stability.
• No Networking: Network services are usually disabled, reducing the risk of
remote access during sensitive operations.
• Single User: Only the root user has access to the system in this mode. Other
user logins are disabled.
• Direct Access: The root user has direct access to the command line interface
(CLI), allowing for administrative tasks without the normal multi-user
environment overhead.
3. Booting into Single-User Mode:
• Manual Intervention: Typically, entering single-user mode requires manual
intervention during the boot process. This can be done by modifying the boot
parameters at the bootloader stage (e.g., GRUB) to specify the runlevel for
single-user mode.
• Runlevel: Traditionally, Unix-like systems use runlevels to define modes of
operation. Single-user mode corresponds to runlevel 1 in many Unix System V-
based systems. Modern systems using systemd refer to this as "rescue.target"
or "emergency.target."
Internal Commands : Commands which are built into the shell. For all the shell built-in
commands, execution of the same is fast in the sense that the shell doesn’t have to search
the given path for them in the PATH variable, and also no process needs to be spawned
for executing it.
Examples: source, cd, fg, etc.
External Commands : Commands which aren’t built into the shell. When an external
command has to be executed, the shell looks for its path given in the PATH variable, and
also a new process has to be spawned and the command gets executed. They are usually
located in /bin or /usr/bin. For example, when you execute the “cat” command, which
usually is at /usr/bin, the executable /usr/bin/cat gets executed.
Examples: ls, cat etc.
Basic Commands -
Calendar (cal) - The cal command is used to display a calendar in the terminal. By default,
it shows the current month's calendar.
Example:
To display the current month's calendar:
cal
To display a specific year's calendar:
cal 2024
To display a specific month's calendar of a specific year:
cal 5 2024
Display system date (date) - The date command is used to display or set the system
date and time.
Example:
To display the current date and time:
date
Message display (echo) - The echo command is used to display a line of text or a
variable value.
Example:
To display a simple message:
echo "Hello, World!"
Password changing (passwd) - The passwd command is used to change the user's
password.
Example:
To change your own password:
passwd
You will be prompted to enter your current password and then the new password.
Knowing who are logged in (who) - The who command displays a list of users who are
currently logged into the system.
Example:
To see who is logged in:
who
System information using uname - The uname command prints system information,
such as the operating system name, kernel version, and more.
Example:
To display the system's kernel name:
uname
To display detailed system information:
uname -a
File name of terminal connected to the standard input (tty) - The tty command
displays the file name of the terminal connected to the standard input.
Example:
To find out the terminal file name:
Tty
File System - A file system is a method and data structure that the operating system uses
to manage files on a disk or partition. It determines how data is stored and retrieved.
Without a file system, data placed in a storage medium would be one large body of data
with no way to tell where one piece of information stops and the next begins.
Types of Files
Types of Unix Files
The UNIX files system contains several different types of files
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.
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)
• Branching points in the hierarchical tree.
• Used to organize groups of files.
• May contain ordinary files, special files or other directories.
• Never contain “real” information which you would work with (such as text). Basically,
just used for organizing files.
• All files are descendants of the root directory, ( named / ) located at the top of the
tree.
In long-format output of ls –l , this type of file is specified by the “d” symbol.
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. On UNIX systems there are two flavors of special files for
each device, character special files and block special files :
• When a character special file is used for device Input/Output(I/O), data is transferred
one character at a time. This type of access is called raw device access.
• When a block special file is used for device Input/Output(I/O), data is transferred in
large fixed-size blocks. This type of access is called block device access.
For terminal devices, it’s one character at a time. For disk devices though, raw access
means reading or writing in whole chunks of data – blocks, which are native to your
disk.
• In long-format output of ls -l, character special files are marked by the “c” symbol.
• In long-format output of ls -l, block special files are marked by the “b” symbol.
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 In long-format output of ls –l , named pipes are marked by the “p” symbol.
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. In long-format output of ls –l , Symbolic link are marked by the “l” symbol
(that’s a lower case L).
File Naming Convention - File naming conventions vary between different operating
systems, but there are common guidelines:
• Length: Most modern systems allow long filenames, but historically they were limited
to 8.3 format (eight characters, a period, and a three-character extension).
• Case Sensitivity: Some systems (e.g., UNIX, Linux) are case-sensitive, meaning file.txt
and File.txt are different files. Others (e.g., Windows) are not.
• Allowed Characters: Avoid special characters like \, /, :, *, ?, ", <, >, | to maintain
compatibility across systems.
• Extensions: Used to indicate the file type (e.g., .txt for text files, .jpg for image files).
Parent-Child Relationship - In a hierarchical file system, directories can contain files and
other directories. The directory that contains another directory is called the parent
directory, and the contained directory is called the child directory. This relationship creates
a tree structure, where the root directory is the topmost parent.
Displaying Pathname of the Current Directory (pwd) - The pwd command stands
for "print working directory." It displays the full pathname of the current directory.
Example:
$ pwd /home/user
Changing the Current Directory (cd) - The cd command is used to change the current
directory.
Examples:
$ cd /home/user/Documents $ cd .. $ cd ~ # Changes to the home directory
Listing Contents of Directory (ls) - The ls command lists the contents of a directory.
Examples:
$ ls
file1.txt file2.txt directory
$ ls -l # Detailed listing
total 4
-rw-r--r-- 1 user user 0 May 31 12:00 file1.txt
-rw-r--r-- 1 user user 0 May 31 12:00 file2.txt
drwxr-xr-x 2 user user 4096 May 31 12:00 directory
Line, Word, and Character Counting (wc) - Counts lines, words, and characters in a
file.
Example:
wc file.txt wc -l file.txt # counts lines
wc -w file.txt # counts words
wc -c file.txt # counts characters
Displaying File Differences (diff) - Displays the differences between two files line by
line.
Example:
diff file1.txt file2.txt
Creating Archive File (tar) - Archives multiple files into a single file.
Example:
tar -cvf archive.tar file1.txt file2.txt
File Attributes
File and Directory Attributes Listing - To list file and directory attributes in Linux, you
typically use the ls command with various options. The most commonly used options are:
• ls -l: Lists files and directories with detailed attributes including permissions, number
of links, owner, group, size, and modification date.
• ls -a: Lists all files, including hidden files.
• ls -lh: Lists files with human-readable file sizes.
Example :
ls -l
-rw-r--r-- 1 user group 4096 May 1 12:34 example.txt
Brief Idea About the Attributes
1. File Type and Permissions: The first column shows file type and permissions.
❖ -rw-r--r--: A regular file with read and write permissions for the owner, read
permissions for the group, and read permissions for others.
2. Number of Links: The second column shows the number of hard links to the file.
3. File Ownership: The third and fourth columns show the owner and group of the file.
4. File Size: The fifth column shows the size of the file in bytes.
5. Modification Date: The sixth column shows the last modification date and time of the
file.
6. File Name: The last column shows the name of the file.
File Ownership - Each file in Linux has an owner and an associated group. The
ownership is set when the file is created. The owner is usually the user who created the file,
and the group is typically the primary group of that user.
File Permissions - File permissions in Linux are divided into three categories:
1. Owner Permissions: Permissions for the user who owns the file.
2. Group Permissions: Permissions for the group that owns the file.
3. Other Permissions: Permissions for all other users.
Absolute Permissions - Absolute permissions use octal notation to set permissions. Each
permission category (owner, group, others) is represented by a digit from 0 to 7.
• chmod 755 file: Sets permissions to rwxr-xr-x (read, write, execute for owner; read,
execute for group and others).
• chmod 644 file: Sets permissions to rw-r--r-- (read, write for owner; read for group
and others).
Changing File Ownership - The chown command is used to change the ownership of a
file.
• chown user file: Changes the owner of the file to user.
• chown user:group file: Changes the owner and group of the file to user and group.
Changing Group Ownership
The chgrp command is used to change the group ownership of a file.
• chgrp group file: Changes the group of the file to group.
Examples :
1. Listing file attributes:
ls -l
2. Changing file permissions (relative):
chmod u+x file.txt chmod g-w file.txt
3. Changing file permissions (absolute):
chmod 755 file.txt chmod 644 file.txt
4. Changing file ownership:
chown newuser file.txt chown newuser:newgroup file.txt
5. Changing group ownership:
chgrp newgroup file.txt
Significance of File Attribute for Directory - Directories have special attributes that
control access:
• r (read): Allows listing the contents of the directory.
• w (write): Allows creating, deleting, or renaming files in the directory.
• x (execute): Allows accessing the directory and its content (needed for cd).
File Locating (find) - The find command searches for files in a directory hierarchy based
on criteria such as name, type, size, and modification time.
Examples:
❖ Find by name: find /path -name filename
❖ Find by type: find /path -type d (directories), find /path -type f (files)
❖ Find by size: find /path -size +100M (files larger than 100MB)
❖ Find by modification time: find /path -mtime -7 (files modified within the last 7 days)
Types of Shell
There are several types of shells in UNIX, each with its own features and syntax:
• Bourne Shell (sh): The original UNIX shell.
• C Shell (csh): Introduces a syntax similar to the C programming language.
• Korn Shell (ksh): Combines features of both the Bourne and C shells.
• Bash (Bourne Again Shell): An improved version of the Bourne shell, widely used in
Linux.
Pattern Matching - Pattern matching in UNIX is used to find files or text that match a
certain pattern. Wildcards like * (matches any number of characters) and ? (matches a
single character) are commonly used.
ls *.txt
Escaping - Escaping is used to give special characters their literal meaning. This is done
using the backslash (\).
echo "This is a dollar sign: \$"
Quoting - Quoting prevents the shell from interpreting special characters. Single quotes (')
preserve the literal value of each character within the quotes. Double quotes (") allow
variable and command substitution but prevent wildcard expansion.
echo 'This is a quoted string with $dollar signs' echo "This is a quoted string with a
variable: $HOME"
Redirection - Redirection allows you to change the input and output sources for
commands. The symbols > and >> are used to redirect output to a file, and < is used to
redirect input from a file.
echo "Hello, World!" > output.txt cat < input.txt
Standard Input, Output, and Error - UNIX programs use three standard streams:
• Standard Input (stdin): File descriptor 0.
• Standard Output (stdout): File descriptor 1.
• Standard Error (stderr): File descriptor 2.
command > output.txt 2> error.txt
/dev/null and /dev/tty
• /dev/null: A special file that discards all data written to it.
• /dev/tty: Represents the terminal for the current process.
command > /dev/null 2>&1 echo "Enter input:" > /dev/tty
Pipe - Pipes (|) are used to pass the output of one command as input to another.
ls -l | grep "Jan"
Tee - tee reads from standard input and writes to both standard output and one or more
files.
ls -l | tee filelist.txt
Shell Variables - Shell variables store data that can be used by the shell and other
programs.
MY_VAR="Hello, World!" echo $MY_VAR
Processes
Basic Idea about UNIX Process - A process in UNIX is an instance of a running program.
Each process has a unique process ID (PID).
Display Process Attributes (ps) - The ps command displays information about active
processes.
ps -ef
Display System Processes - The top command displays real-time system processes.
top
Process Creation Cycle - Processes are created using the fork system call, which creates
a child process. The exec family of functions is then used to replace the child's memory
space with a new program.
Shell Creation Steps
The shell is started in the following steps:
1. init: The first process started by the kernel.
2. getty: Prepares for login.
3. login: Authenticates the user.
4. shell: Starts the user’s shell.
Process State and Zombie State - Processes can be in various states, such as running,
sleeping, stopped, or zombie. A zombie process is one that has completed execution but still
has an entry in the process table.
Reduce Priority (nice) - The nice command runs a command with a modified scheduling
priority.
nice -n 10 command
Using Signals to Kill Process - The kill command sends a signal to a process, usually to
terminate it.
kill -9 PID
Background and Foreground Jobs - bg sends a job to the background, and fg brings it
to the foreground.
bg %1 fg %1
Listing Jobs - The jobs command lists all jobs in the current session.
jobs
Suspend Job
Press Ctrl+Z to suspend a job.
Customization
Environment Variables - Environment variables are dynamic values that can affect the
behavior of running processes on a computer. They are part of the environment in which a
process runs and can be used to pass configuration settings to applications and scripts.
Filters
Prepare File for Printing (pr) - The pr command is used to format a file for printing. It
adds headers, footers, and paginates the text.
Example:
pr myfile.txt
This command formats myfile.txt with headers, footers, and page numbers.
Vertical Division of File (cut) - The cut command is used to extract sections from each
line of a file.
Example:
cut -d ',' -f 1,3 myfile.csv
This command extracts the 1st and 3rd fields from myfile.csv, assuming fields are separated
by commas.
Paste Files (paste) - The paste command merges lines of files side-by-side.
Example:
paste file1.txt file2.txt
This command merges lines of file1.txt and file2.txt horizontally.
Sort File (sort) - The sort command sorts the lines of a file.
Example:
sort myfile.txt
This command sorts the lines in myfile.txt in alphabetical order.
Finding Repetition and Non-repetition (uniq) - The uniq command reports or filters
out repeated lines in a file. It requires sorted input.
Example:
sort myfile.txt | uniq
This command sorts myfile.txt and then removes duplicate lines.
Manipulating Characters Using (tr) - The tr command translates or deletes characters.
Example:
tr 'a-z' 'A-Z' < myfile.txt
This command translates all lowercase letters to uppercase in myfile.txt.
Searching Pattern Using grep - The grep command searches for patterns in files using
basic regular expressions.
Example:
grep "pattern" myfile.txt
This command searches for "pattern" in myfile.txt.
Basic Regular Expression (BRE) - BRE uses simple regex patterns for searching.
Example:
grep "^[a-z]" myfile.txt
This command searches for lines starting with a lowercase letter in myfile.txt.
Extended Regular Expression (ERE) and egrep - ERE supports more complex patterns
and can be used with grep -E or egrep.
Examples:
grep -E "a{2,3}" myfile.txt
This command searches for occurrences of 'a' repeated 2 or 3 times in myfile.txt.
egrep "a{2,3}" myfile.txt
This command does the same using egrep.
Shell Script
Simple Shell Scripts - A simple shell script is a sequence of commands written in a file.
Example:
#!/bin/bash
echo "Hello, World!"
Save the above script in a file named hello.sh and make it executable using chmod +x
hello.sh. Run it with ./hello.sh.
Condition Checking (if, case) - You can use if and case for condition checking.
Example:
#!/bin/bash
if [ $1 -gt 10 ]; then
echo "The first argument is greater than 10"
else
echo "The first argument is 10 or less"
fi
case $2 in
start)
echo "Starting..."
;;
stop)
echo "Stopping..."
;;
*)
echo "Unknown command"
;;
esac
Save it as condition.sh, make it executable, and run with ./condition.sh 15 start.
Expression Evaluation (test, []) - The test command or [] is used for evaluating
expressions.
Example:
#!/bin/bash
if [ -e /etc/passwd ];
then
echo "File exists"
else
echo "File does not exist"
fi
Save it as test.sh, make it executable, and run with ./test.sh.
Computation (expr) - The expr command is used for arithmetic computations.
Example:
#!/bin/bash
result=$(expr 5 + 3)
echo "5 + 3 = $result"
Save it as computation.sh, make it executable, and run with ./computation.sh.
Using expr for Strings - The expr command can also manipulate strings.
Example:
#!/bin/bash
length=$(expr length "hello")
substring=$(expr substr "hello world" 1 5)
echo "Length of 'hello' is $length"
echo "Substring of 'hello world' is $substring"
Save it as strings.sh, make it executable, and run with ./strings.sh.
Use of Positional Parameters - Positional parameters are used to handle command line
arguments.
Example:
#!/bin/bash
echo "Script name: $0"
echo "First argument: $1"
echo "Second argument: $2"
echo "All arguments: $@"
Save it as positional.sh, make it executable, and run with ./positional.sh arg1 arg2.
System Administration
Essential Duties of a UNIX System Administrator - A UNIX System Administrator is
responsible for maintaining the operation and security of UNIX systems.
Their duties include:
1. System Installation and Configuration: Install and configure UNIX operating systems
and software.
2. User Account Management: Create, manage, and delete user accounts.
3. System Monitoring: Monitor system performance and resource usage.
4. Backup and Recovery: Plan and execute regular backups and restore systems when
necessary.
5. Security Management: Implement security policies, manage access controls, and
apply patches and updates.
6. Troubleshooting: Diagnose and resolve hardware, software, and network issues.
7. Scripting and Automation: Develop and maintain scripts for automating
administrative tasks.
8. Documentation: Maintain documentation related to system configurations,
procedures, and policies.
9. Support: Provide technical support to users and address their issues.
Starting and Shutdown of UNIX Systems
1. Starting (Booting) a UNIX System:
• Power On: Turn on the physical or virtual machine.
• BIOS/UEFI Initialization: The BIOS/UEFI firmware initializes hardware
components.
• Bootloader Execution: The bootloader (GRUB, LILO) is loaded from the boot
sector and allows the selection of the operating system or kernel version to
load.
• Kernel Loading: The selected kernel is loaded into memory and initializes
system components.
• init/Systemd Initialization: The init or systemd process (the first process with
PID 1) is started, which sets up user-space services and mounts file systems.
• Runlevel/Target Execution: Services corresponding to the specified runlevel
(SysV init) or target (systemd) are started.
2. Shutting Down a UNIX System:
• Command Execution: Use commands like shutdown, poweroff, halt, or reboot
to initiate shutdown.
• Example: shutdown -h now (halts the system immediately)
• Service Termination: The system terminates running services and processes.
• File System Unmounting: Filesystems are synced and unmounted to prevent
data corruption.
• Kernel Shutdown: The kernel halts the system or reboots, depending on the
command issued.
Example Commands
• Adding a User: useradd john
• Setting a Password: passwd john
• Deleting a User: userdel john
• Modifying a User: usermod -d /new/home/john john (changes home directory)
• Checking Disk Quota: quota -u john
Configuration Files
1. /etc/passwd: Contains user account information.
• Format: username:password:UID:GID:GECOS:home_directory:shell
2. /etc/shadow: Contains encrypted passwords and password expiration information.
• Format:
username:encrypted_password:last_changed:min:max:warn:inactive:expire
3. /etc/group: Contains group information.
• Format: group_name:password:GID:user_list