COMPLETE SOLUTIONS
Course
CNIT
1. What is UNIX, and what are its two major divisions?
Answer: UNIX is a multiuser, multitasking operating system originally developed at AT&T Bell
Labs. It has two major divisions:
BSD (Berkeley Software Distribution): Developed at the University of California,
Berkeley, introducing networking and performance enhancements.
SVR4 (System V Release 4): Developed by AT&T, incorporating features from BSD,
SunOS, and other UNIX variants to create a standardized system.
2. Describe the typical structure of a UNIX command.
Answer: A UNIX command consists of three components:
Command: The program or utility to execute.
Options (Flags): Modifiers that change command behavior (e.g., -l for detailed output).
Arguments: Targets or inputs for the command (e.g., filenames or directories).
Example: ls -l /home/user
ls (command)
-l (flag for long listing format)
/home/user (directory argument)
3. What is the purpose of the 'root' account in UNIX systems?
Answer: The root account is the superuser with unrestricted access to all commands and files. It
is used for:
System configuration
Software installation
Managing users and permissions
Due to its extensive privileges, it should be used cautiously to prevent accidental system
modifications or security risks.
,4. Explain the role of the UNIX shell.
Answer: The UNIX shell is a command-line interpreter that enables users to interact with the
system. It allows:
Executing commands
Managing processes and files
Running scripts
Common shells include Bash, Zsh, and Csh.
5. What are the standard input, output, and error streams in UNIX?
Answer:
Standard Input (stdin, file descriptor 0): Default input source (usually the keyboard).
Standard Output (stdout, file descriptor 1): Default output destination (usually the
terminal).
Standard Error (stderr, file descriptor 2): Default error message output (typically the
terminal).
Redirection:
command > file (redirects stdout to a file)
command < file (takes input from a file)
command 2> error.log (redirects stderr to a file)
6. How does the UNIX file system hierarchy organize directories?
Answer: UNIX follows a hierarchical file structure, starting from the root directory (/). Key
directories include:
/bin → Essential command binaries
/etc → Configuration files
/home → User directories
/var → Logs and variable data
, /usr → System utilities and libraries
Each directory serves a specific role in system organization.
7. What is the function of the chmod command?
Answer: The chmod (change mode) command modifies file and directory permissions.
Permission types:
Read (r = 4) → View contents
Write (w = 2) → Modify contents
Execute (x = 1) → Run as a program
Syntax:
chmod u+x file → Grants execute permission to the owner
chmod 755 file → Sets permissions using octal notation (rwxr-xr-x)
8. How can you view the contents of a text file in UNIX?
Answer:
cat filename → Displays the entire file
less filename → View file page by page
more filename → Similar to less, but with fewer features
head filename → Shows the first 10 lines
tail filename → Shows the last 10 lines
Each command offers different functionalities for file viewing.
9. What is the purpose of the grep command?
Answer: The grep (Global Regular Expression Print) command searches for patterns within
files.
Example:
grep "error" logfile.txt → Finds occurrences of "error" in logfile.txt