Linux File Management Essentials
Linux File Management Essentials
ENSIA
May 11, 2025
Contents
2 Creating Partitions 20
2.1 Exploring block storage devices . . . . . . . . . . . . . . . . . . . . . . . 20
2.2 Create a (fake) block device (Loop Device) . . . . . . . . . . . . . . . . . 21
2.3 Create partitions on the pseudo-block device . . . . . . . . . . . . . . . . 22
4 Mounting 24
4.1 Creating mount point folders . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 ‘mount‘ command for attaching filesystems . . . . . . . . . . . . . . . . . 24
4.3 Displaying mounted VFAT filesystems . . . . . . . . . . . . . . . . . . . 25
4.4 ‘df‘ command for disk space usage . . . . . . . . . . . . . . . . . . . . . . 25
4.5 ‘mount –bind‘ option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.6 Making file system mounts persistent (‘/etc/fstab‘) . . . . . . . . . . . . 26
6 Quotas 27
6.1 Commands for Quota Management . . . . . . . . . . . . . . . . . . . . . 28
6.2 Setup and Configuration Steps for Quotas . . . . . . . . . . . . . . . . . 29
Syntax
Relevant Options
• -a: Change only the access time.
• -c, –no-create: Do not create any files. If a specified file does not exist,
touch will do nothing.
• -d, –date=STRING: Parse STRING and use it instead of current time (e.g.,
"2 days ago", "2023-01-15 [Link]").
• -m: Change only the modification time.
• -r, –reference=RFILE: Use RFILE’s times instead of current time.
• -t STAMP: Use [[CC]YY]MMDDhhmm[.ss] format instead of current time.
Underlying Concepts
• Timestamps: Files in Linux have three main timestamps:
3
– atime (Access Time): Last time the file was read.
– mtime (Modification Time): Last time the file’s content was changed.
– ctime (Change Time): Last time the file’s metadata (like permissions
or ownership) was changed. touch primarily affects atime and mtime.
Troubleshooting Tips
• "Permission denied": You lack write permission in the directory where
you’re trying to create the file. Check directory permissions with ls -ld .
• Timestamp not changing: Ensure you are not using options like -c if
you intend to create the file. Also, some filesystems might be mounted with
options (noatime, nodiratime) that prevent atime updates for performance
reasons.
Syntax
Modes of Operation
• Symbolic Mode: Uses letters to represent users and permissions.
– Who (Users): u (owner/user), g (group), o (others), a (all: u, g, and
o).
– Operator: + (add), - (remove), = (set exact permissions, overwriting
existing ones for the specified class).
– Permissions: r (read), w (write), x (execute/search), X (execute/search
if it’s a directory or already has execute permission for some user), s
(setuid/setgid), t (sticky bit).
• Octal (Numeric) Mode: Uses numbers (0-7) for each of owner, group, and
others. Each number is a sum of: 4 (read), 2 (write), 1 (execute).
– Example: rwx = 4+2+1 = 7; r-x = 4+0+1 = 5; rw- = 4+2+0 = 6. A
full permission set is three octal digits (e.g., 755).
Relevant Options
• -R, –recursive: Change files and directories recursively.
• -v, –verbose: Output a diagnostic for every file processed.
• -c, –changes: Like verbose but report only when a change is made.
• –reference=RFILE: Use RFILE’s mode instead of MODE values.
4
• -h, –no-dereference (less common, behavior varies): Affect symbolic links
themselves instead of what they point to. Typically, chmod follows symbolic
links.
Underlying Concepts
• Permission Bits: Standard Unix permissions involve 9 bits for read, write,
execute for user, group, other.
• Special Permissions:
– setuid (Set User ID - s in user execute field): If set on an executable,
the program runs with the owner’s privileges, not the user who ran it.
– setgid (Set Group ID - s in group execute field): If set on an exe-
cutable, it runs with the file’s group privileges. If set on a directory,
new files/directories created inside inherit the directory’s group.
– sticky bit (t in other execute field): On directories, it means only the
file owner, directory owner, or root can delete/rename files within that
directory, even if others have write permission to the directory (e.g.,
/tmp).
• Effect on Symbolic Links:
5
– By default, chmod operates on the target of a symbolic link, not the link
itself. The permissions of a symlink are generally lrwxrwxrwx and don’t
control access to the target.
– To attempt to change the link’s permissions (usually not useful
or possible for access control), some systems might have a -h or
–no-dereference option, but this is not universally standard or effec-
tive for access control.
• Effect on Hard Links: Changing permissions on one hard link changes it
for all hard links to the same inode (and the original file name), as they all
point to the same metadata.
Troubleshooting Tips
• "Operation not permitted": You are not the owner of the file and not
root.
• Octal confusion: Ensure correct octal sums. 777 is full access for all; 000
is no access.
• Recursive changes are powerful: Double-check the path when using -R
to avoid unintended widespread changes.
Syntax
6
• 1st char (Type): - (regular file), d (directory), l (symlink), c (char
device), b (block device), s (socket), p (pipe).
• Next 9 chars (Permissions): 3 sets of rwx (read, write, execute) for
Owner, Group, Others.
2. Number of Hard Links: (e.g., 1)
3. Owner: (e.g., user)
4. Group: (e.g., group)
5. Size: (e.g., 4096 bytes)
6. Last Modification Timestamp: (e.g., May 10 15:30)
7. File/Directory Name: (e.g., filename)
1 ls
2 ls -l
3 ls - la / etc /
4 ls - ld / usr / games / # Shows permissions of the / usr / games
directory itself
5 ls -l / tmp / file1 # Shows permissions of file1 in / tmp
6
Related Commands
• stat FILE: Displays very detailed file or file system status, including all
timestamps and permissions in octal.
Syntax
Relevant Options
• -p, –parents: Create parent directories as needed if they don’t exist. No
error if existing.
• -v, –verbose: Print a message for each created directory.
• -m MODE, –mode=MODE: Set file mode (as in chmod), not a=rwx - umask.
1 mkdir new_project
2 mkdir -p path / to / deep / directory
3
7
Advanced Usage Example (setting permissions at creation)
Underlying Concepts
• Directory Permissions:
– r (read): Allows listing directory contents (e.g., with ls).
– w (write): Allows creating, deleting, and renaming files within the direc-
tory (also requires x).
– x (execute/search): Allows entering (cd) the directory and accessing
files/subdirectories within it by name.
Troubleshooting Tips
• "Permission denied": You don’t have write permission in the parent direc-
tory where you are trying to create the new directory.
• "File exists": A file or directory with that name already exists. Using -p
can suppress this error if the directory already exists as part of the path.
Syntax
Relevant Options
• -s, –symbolic: Make symbolic links instead of hard links.
• -f, –force: Remove existing destination files/links before creating the new
one.
• -v, –verbose: Print name of each linked file.
• -T: Treat LINK_NAME as a normal file always (useful if LINK_NAME could be a
directory).
8
Types of Links & Key Differences
• Hard Link (default):
– Acts as a direct reference (another name) to the file’s data (inode).
– All hard links to a file are indistinguishable from the "original" filename.
– Deleting one hard link does not delete the file’s data until all hard links
to that inode are removed.
– Cannot span across different filesystems.
– Cannot be created for directories (by normal users; . and .. are
system-managed hard links).
• Symbolic Link (Soft Link or Symlink):
– A special file whose content is the path to another file or directory (the
target).
– Like a shortcut in other OSes.
– Can span across different filesystems.
– Can link to directories.
– Can point to non-existent targets (becoming a "broken" or "dangling"
link).
– Has its own inode. Deleting the symlink does not affect the target.
Deleting the target breaks the symlink.
– Permissions of the symlink itself are usually lrwxrwxrwx and don’t di-
rectly control access; access is determined by the target’s permissions
and the path to the target.
9
7 ln -s / tmp ~/ sy ml in k_ to_ tm p_ di r # Should
work
8
Underlying Concepts
• Inodes: Data structures that store metadata about files (permissions, owner,
size, data block locations) but not the filename. Filenames are in directory
entries mapping names to inode numbers. ls -i shows inodes.
• Hard links share the same inode. Symbolic links have their own distinct
inode.
Troubleshooting Tips
• ln: failed to create hard link ’...’: Invalid cross-device
link: Tried to hard link across filesystems.
• ln: ...: hard link not allowed for directory: Tried to hard link
to a directory.
• Broken symlink: Target moved/deleted. ls -l often highlights them.
Check the path stored in the symlink.
Syntax
1 umask [ - S ] [ mask ]
2
10
Relevant Options
• No options: Display current umask in octal.
• -S: Display umask in symbolic form (e.g., u=rwx,g=rx,o=rx).
• [mask]: An octal number to set the umask to.
Underlying Concepts
• Default Permissions: umask controls the initial permissions. They can be
changed later with chmod.
• Shell Setting: umask is usually set in shell startup files (e.g., /etc/profile,
~/.bashrc) to apply to user sessions. Changes via the umask command are
typically for the current shell session and its children.
Troubleshooting Tips
• Permissions not as expected: Double-check octal math and remember it
removes permissions. Common values are 0022, 0002.
• System-wide vs. User: /etc/[Link] might define default umask for
new users, but shell profiles can override it.
Part II
11
1 Descriptions of Common File System Management Applications
Syntax
sfdisk [options] device [parameters]
Relevant Options
• -l, –list [device]: List partitions.
• -d, –dump device: Dump partition table in a script-friendly format.
• device < MBR_backup_file: Restore partition table from file (use with ex-
treme caution).
• –delete device [partition_number]: Delete a partition.
• -N partition_number: Create a new partition.
• –label type: Specify disk label type (e.g., dos, gpt).
• -A, –activate device [partition_number]: Activate bootable flag
(MBR).
Underlying Concepts
Partition tables (MBR/GPT), sectors. sfdisk is less interactive than fdisk or
parted.
12
1 Descriptions of Common File System Management Applications
‘badblocks‘
Purpose
Scans a device (like a partition) for bad blocks or physical defects.
Syntax
badblocks [options] device [last-block] [start-block]
Relevant Options
• -v: Verbose mode.
• -s: Show progress.
• -w: Write-mode test (destructive: writes patterns, then reads back.
ERASES DATA).
• -n: Non-destructive read-write test.
• -o file: Write list of bad blocks to file.
• -b block-size: Specify block size in bytes.
• -p num_passes: Number of passes for checking.
Underlying Concepts
Physical disk sectors can fail. Output can be used by tools like mke2fs or e2fsck
(with -l option) to avoid using these blocks.
Syntax
dosfsck [options] device or [Link] [options] device
Relevant Options
• -a: Automatically repair.
• -r: Interactively repair.
13
1 Descriptions of Common File System Management Applications
Underlying Concepts
File Allocation Table (FAT), clusters, directory entries, file system consistency for
FAT.
Syntax
mkdosfs [options] device [blocks] or [Link] [options] device
[blocks]
Relevant Options
• -F fat-size: Specify FAT size (12, 16, or 32).
• -n volume-name: Set volume name/label.
• -I: Create filesystem on a whole disk (dangerous for system disks).
• -s sectors-per-cluster: Specify sectors per cluster.
• -c: Check for bad blocks before creating.
• -v: Verbose output.
Underlying Concepts
Formatting, FAT structure, boot sector, volume label.
14
1 Descriptions of Common File System Management Applications
‘fdisk‘
Purpose
Interactive, menu-driven utility for creating and manipulating MBR and GPT par-
tition tables.
Syntax
fdisk [options] device
Underlying Concepts
MBR (Master Boot Record), GPT (GUID Partition Table), primary/extended/-
logical partitions (MBR), partition types/IDs, CHS vs LBA addressing.
15
1 Descriptions of Common File System Management Applications
Syntax
fsck [options] [-t fstype] device | mountpoint
Relevant Options
• -A: Check all filesystems in /etc/fstab.
• -t fstype: Specify filesystem type (e.g., ext4, xfs).
• -a or -p: Automatically repair without prompting (safe changes for -p).
• -y: Assume "yes" to all questions.
• -r: Interactively repair (often default for specific fsck tools).
• -N: Don’t execute, just show what would be done.
• -C [fd]: Display completion/progress bar.
Underlying Concepts
Filesystem consistency, superblocks, inodes, data blocks, journaling. fsck tries to
bring a corrupted filesystem back to a consistent state.
Syntax
mkfs [-t fstype] [fs-options] device [size]
Relevant Options
• -t fstype: Specify filesystem type (e.g., ext4, xfs, vfat).
• [fs-options]: Options specific to the filesystem type.
16
1 Descriptions of Common File System Management Applications
Underlying Concepts
Formatting, creating metadata structures (superblocks, inode tables, etc.). This
process erases all data on the target partition.
‘parted‘
Purpose
Powerful program for creating, deleting, resizing, checking, and copying partitions
and file systems. Supports MBR and GPT. Interactive or script mode.
Syntax
parted [options] [device [command [args]...]]
17
1 Descriptions of Common File System Management Applications
Scripted Example
Underlying Concepts
More modern than fdisk for some tasks, especially GPT and resizing. Often needs
mkfs after making a partition.
‘mount‘
Purpose
Attaches a file system to a specific directory (mount point) in the main file system
hierarchy.
Syntax
(simplified) mount [options] device directory or mount -t type [options]
device directory
Relevant Options
• No arguments: List all currently mounted filesystems.
• -a, –all: Mount all filesystems specified in /etc/fstab.
• -t vfstype: Specify filesystem type (e.g., ext4, xfs, vfat).
• -o options: Comma-separated mount options:
– ro (read-only), rw (read-write).
– defaults (rw,suid,dev,exec,auto,nouser,async).
– noexec, nouser, user, auto, noauto.
– remount: Remount an already mounted filesystem.
– bind: Perform a bind mount.
18
1 Descriptions of Common File System Management Applications
Underlying Concepts
Mount points (empty directories), VFS (Virtual Filesystem Switch), /etc/fstab.
‘umount‘ (Unmount)
Purpose
Detaches a mounted file system. Crucial before removing a device or running fsck.
Syntax
umount [options] device|mountpoint
Relevant Options
• -a: Unmount all filesystems in /etc/fstab.
• -f, –force: Force unmount (dangerous).
• -l, –lazy: Lazy unmount (detach now, cleanup when no longer busy; risky).
• -t type: Unmount only filesystems of this type.
• -r: If unmounting fails, try to remount read-only.
Troubleshooting Tips
• "target is busy" or "device is busy": Processes are using the filesystem,
or a shell’s current directory is on it.
19
2 Creating Partitions
2 Creating Partitions
2.1 Exploring block storage devices
‘lsblk‘ (List Block Devices)
Purpose
Lists information about block devices in a tree-like format.
Syntax
lsblk [options]
Relevant Options
• -f, –fs: Display filesystem information (type, label, UUID).
• -l, –list: Use list format instead of tree.
• -p, –paths: Print full device paths.
• -o columns: Specify output columns (e.g.,
NAME,FSTYPE,MOUNTPOINT,SIZE,UUID).
1 lsblk
2 lsblk -f
3 lsblk - fp
4 lsblk -o NAME , SIZE , FSTYPE , MOUNTPOINT / dev / sda
5
Output Description
Shows device names, partitions, sizes, types, and mount points. -f adds FS type,
label, UUID.
Syntax
df [options] [file...]
20
2 Creating Partitions 2.2 Create a (fake) block device (Loop Device)
Relevant Options
• -h, –human-readable: Print sizes in human-readable format (1K, 234M, 2G).
• -T, –print-type: Print filesystem type.
• -i: Display inode information.
• –total: Produce a grand total.
1 df
2 df -h
3 df - hT
4 df -h / home # Show usage for the filesystem / home is on
5
Output Description
Columns: Filesystem, Size, Used, Avail, Use%, Mounted on.
‘truncate‘
Purpose
Shrink or extend the size of a file to a specified size.
Syntax
truncate -s desired_size filename
Relevant Options
• -s, –size=SIZE: Set file to SIZE bytes. Suffixes: K, M, G, T.
• -c, –no-create: Do not create if file does not exist.
21
2 Creating Partitions 2.3 Create partitions on the pseudo-block device
Syntax
losetup [options] [loop_device] [file]
Relevant Options
• No options: List all active loop devices.
• -f, –find: Find the first unused loop device.
• -d loop_device: Detach the file from the loop device.
• –show: If attaching, print the name of the loop device used.
• -P, –partscan: Force kernel to scan for partitions on the loop device.
• –nooverlap: Avoid reusing an existing loop device.
After creating partitions, the kernel might need a re-read if –partscan wasn’t used
or triggered: sudo partprobe /dev/loop0. Then lsblk /dev/loop0 should show
22
3 Creating file systems
Formatting Partitions
VFAT ([Link])
EXT4 (mkfs.ext4)
XFS ([Link])
23
4 Mounting
4 Mounting
4.1 Creating mount point folders
‘mkdir‘ for Mount Points
Mount points are just empty directories.
1 sudo mkdir / mnt / my_vfat_part
2 sudo mkdir / mnt / my_ext4_part
3 sudo mkdir / mnt / my_xfs_part
4 sudo mkdir / mnt / my_bind_target
5
24
4 Mounting 4.3 Displaying mounted VFAT filesystems
Syntax
sudo mount –bind old_directory new_directory or sudo mount -o bind
old_directory new_directory
Example
25
4 Mounting 4.6 Making file system mounts persistent (‘/etc/fstab‘)
1 # < file system > < mount point > < type > < options
> < dump > < pass >
2 UUID = YOUR _ VFAT _ UUID _ HERE / mnt / my _ vfat _ part vfat
defaults , utf 8 , nofail 0 2
3 UUID = YOUR _ EXT 4_ UUID _ HERE / mnt / my _ ext 4_ part ext 4
defaults , nofail 0 2
4 UUID = YOUR _ XFS _ UUID _ HERE / mnt / my _ xfs _ part xfs
defaults , nofail 0 2
5
26
6 Quotas
Important: After editing, test with sudo mount -a. For loop devices, losetup
itself is not persistent; /etc/fstab entries for them rely on the loop device being
active.
Installation of gparted
General Process
1. BACKUP DATA!
2. Identify free space or partition to shrink.
3. Unmount partitions to be modified (use Live CD/USB for system partitions).
4. Use tools to shrink/create partitions.
5. Format new partition (sudo mkfs.ext4 /dev/sdaX).
6. Create mount point (sudo mkdir /mnt/new_real_partition).
7. Mount it (sudo mount /dev/sdaX /mnt/new_real_partition).
8. Optionally add to /etc/fstab.
6 Quotas
Disk Quota Concepts
Disk quotas limit disk space or number of files a user/group can use.
• Hard Limit: Absolute maximum. Operations exceeding it fail.
• Soft Limit: Warning threshold. Can be exceeded temporarily for a grace
period. Acts as hard limit after grace period expires if still over.
• Grace Period: Time a user can stay above soft limit before enforcement.
27
6 Quotas 6.1 Commands for Quota Management
Syntax
quotacheck [options] filesystem or quotacheck -a [options]
Relevant Options
-a (all fstab), -c (create), -u (user), -g (group), -v (verbose), -m (no remount ro),
-f (force).
Example
sudo quotacheck -avcug (check All, Verbose, Create, User, Group)
‘edquota‘
Purpose
Edits user or group quotas via an editor.
Syntax
edquota [options] -u username or edquota [options] -g groupname or
edquota -t
Relevant Options
-u username, -g groupname, -t (grace periods), -p protoname (duplicate quo-
tas).
Example
Editor shows blocks (space in KB) and inodes (files) with soft/hard limits and
current usage.
‘repquota‘
Purpose
Prints a summary of disk usage and quotas.
28
6 Quotas 6.2 Setup and Configuration Steps for Quotas
Syntax
repquota [options] filesystem or repquota -a [options]
Relevant Options
-a (all fstab), -u (user), -g (group), -v (verbose), -s (human-readable).
Example
sudo repquota -avus
‘quotaon‘
Purpose
Turns disk quotas on for filesystem(s).
Syntax
quotaon [options] filesystem or quotaon -a [options]
Relevant Options
-a, -u, -g, -v.
Example
sudo quotaon -avug
‘quotaoff‘
Purpose
Turns disk quotas off.
Syntax
quotaoff [options] filesystem or quotaoff -a [options]
Relevant Options
(Similar to quotaon: -a, -u, -g, -v).
Example
sudo quotaoff -avug
29
7 The first system process (PID 1)
2. Edit /etc/fstab: Add usrquota,grpquota to mount options for the target filesys-
tem. Example: UUID=YOUR_DEVICE_UUID /mnt/data ext4 defaults,usrquota,grpquota
0 2 (Backup first: sudo cp /etc/fstab /etc/[Link])
3. Inform systemd (modern systems) & Remount:
1 sudo systemctl daemon - reload
2 sudo mount -o remount / mnt / data (or umount/mount)
3
Part III
System and Process Monitoring
7 The first system process (PID 1)
PID 1: The Init Process
• Process ID (PID): Unique number for each running process. PID 1 is
special.
• It’s the first process started by the kernel at boot.
• Ancestor of all other user-space processes; adopts orphaned processes.
• Responsible for starting/managing system services and system shutdown.
• Historically init, now commonly systemd.
• If PID 1 dies, the system will panic.
30
8 Detailed process information using command ‘ps‘7.2 Using ‘ps‘ command for PID 1
1 cat / proc /1/ comm # Shows command name ( e . g . , " systemd ")
2 cat / proc /1/ status | grep Name
3
1 ps -p 1 -o comm =
2
1 ps -p 1 -o cmd =
2 ps -p 1 -o args =
3 ps -p 1 -o comm , args
4 ps - fp 1 # Full format listing for PID 1
5
Syntax Forms
• BSD style (no hyphens): ps aux
31
9 Foreground and background processes
1 ps auxf
2 ps - efH
3 ps axjf
4 ps -e -- forest
5 ps - eo pid , ppid , user , cmd -- forest
6
Information Displayed (common columns): USER, PID, %CPU, %MEM, VSZ, RSS,
TTY, STAT (R, S, Z, T, D), START, TIME, COMMAND/CMD, PPID.
1 ps -u root
2 ps -f -u root
3 ps aux | grep ’^ root ’
4 pgrep -u root -l
5
32
10 Managing processes with command ‘kill‘
Ctrl+Z (Suspend)
Sends SIGTSTP (Terminal Stop) to foreground process. Process pauses (state T).
jobs
Lists active jobs (background or suspended). Syntax: jobs [-lrs]. Output: Job
number, status, command.
bg [%job_id]
Resumes a suspended job in the background. No %job_id acts on current job.
fg [%job_id]
Brings a background/suspended job to foreground. No %job_id acts on current
job.
Example Workflow
1. Start: sleep 600
2. Suspend: Ctrl+Z (Shell: [1]+ Stopped sleep 600)
3. List: jobs (Shows "Stopped")
4. Foreground: fg %1 (Resumes in foreground)
5. Suspend: Ctrl+Z
6. Background: bg %1 (Shell: [1]+ sleep 600 &)
7. List: jobs (Shows "Running")
33
10 Managing processes with command ‘kill‘
Syntax
kill [options] [-signal] PID...
‘killall‘
Purpose
Kills processes by name.
Syntax
killall [options] [-signal] name...
Relevant Options
-u user, -i (interactive), -v (verbose), -e (exact name), -w (wait). Signal options
same as kill.
Example
34
11 Monitoring System Resources with command ‘top‘
Troubleshooting
• "Operation not permitted": Trying to kill process of another user (and
not root).
• Zombie processes (Z state): Already dead. Parent must wait(), or
init/systemd will clean up.
Syntax
top [options]
35
12 Changing Process Priority with ‘nice‘ and ‘renice‘
Usage
1 top
2 Inside top: P (CPU), M (Mem), 1 (cores), u (user), q (quit)
3
‘nice‘ command
Purpose
Runs a command with a modified niceness value.
Syntax
nice [OPTION] [COMMAND [ARG]...]
Relevant Options
-n adjustment or –adjustment=adjustment: Add adjustment to niceness.
Basic Usage
36
13 Creating processes from a C/C++ program
‘renice‘ command
Purpose
Alters niceness of *already running* processes.
Syntax
renice [-n] priority [[-p] pid...] [[-g] pgrp...] [[-u] user...]
Relevant Options
priority: New absolute niceness value (-20 to 19). -p pid, -g pgrp, -u user.
Basic Usage
Behavior: Lower niceness = larger CPU share under load. Does not directly affect
I/O priority (see ionice).
37
13 Creating processes from a C/C++ program
38
13 Creating processes from a C/C++ program
39
13 Creating processes from a C/C++ program
21 } else {
22 // Parent process
23 printf ( " Parent ( PID % d ) : Waiting for child ( PID % d ) to
complete .\ n " , getpid () , pid ) ;
24 int status ;
25 waitpid ( pid , & status , 0) ; // Wait for the specific child
26
27 if ( WIFEXITED ( status ) ) {
28 printf ( " Parent : Child ( PID % d ) exited with status % d .\ n " ,
pid , WEXITSTATUS ( status ) ) ;
29 } else if ( WIFSIGNALED ( status ) ) {
30 printf ( " Parent : Child ( PID % d ) killed by signal % d .\ n " ,
pid , WTERMSIG ( status ) ) ;
31 }
32 printf ( " Parent : Child has terminated . Parent exiting .\ n " ) ;
33 }
34 return EXIT_SUCCESS ;
35 }
40