Podcast
Questions and Answers
Which of the following is an example of an Operating System?
Which of the following is an example of an Operating System?
The main goal of an Operating System is to provide a convenient working environment for programmers only.
The main goal of an Operating System is to provide a convenient working environment for programmers only.
False
What is the purpose of the 'umask' setting in a shell configuration?
What is the purpose of the 'umask' setting in a shell configuration?
It controls the default access permissions for new files.
_________ is a command to clear the terminal screen.
_________ is a command to clear the terminal screen.
Signup and view all the answers
Match the common Operating Systems with their characteristics:
Match the common Operating Systems with their characteristics:
Signup and view all the answers
Which command is used to create a new directory?
Which command is used to create a new directory?
Signup and view all the answers
The relative path of a file starts with a forward slash (/).
The relative path of a file starts with a forward slash (/).
Signup and view all the answers
What notation is used to represent the home directory in file paths?
What notation is used to represent the home directory in file paths?
Signup and view all the answers
To remove a directory, the command used is ______.
To remove a directory, the command used is ______.
Signup and view all the answers
Which of the following is an example of an absolute path?
Which of the following is an example of an absolute path?
Signup and view all the answers
Match the following commands with their functions:
Match the following commands with their functions:
Signup and view all the answers
Hidden files in Linux begin with a period (.) in their filename.
Hidden files in Linux begin with a period (.) in their filename.
Signup and view all the answers
What is the command to display the contents of a file on standard output?
What is the command to display the contents of a file on standard output?
Signup and view all the answers
Which of the following components is considered the core of the Linux operating system?
Which of the following components is considered the core of the Linux operating system?
Signup and view all the answers
Linux is not a multi-user operating system.
Linux is not a multi-user operating system.
Signup and view all the answers
What command would you use to create a directory named 'projects' in Linux?
What command would you use to create a directory named 'projects' in Linux?
Signup and view all the answers
The __________ is the command interpreter that provides the user interface in Linux.
The __________ is the command interpreter that provides the user interface in Linux.
Signup and view all the answers
Match the Linux commands with their functions:
Match the Linux commands with their functions:
Signup and view all the answers
Which distribution of Linux is known for being a free open-source operating system?
Which distribution of Linux is known for being a free open-source operating system?
Signup and view all the answers
Linux file paths are case insensitive.
Linux file paths are case insensitive.
Signup and view all the answers
What protocol was significant in the development of UNIX at Berkeley?
What protocol was significant in the development of UNIX at Berkeley?
Signup and view all the answers
What does ${#color[@]}
return when the color list has five components?
What does ${#color[@]}
return when the color list has five components?
Signup and view all the answers
In Bash, the first command line argument is accessed using $2.
In Bash, the first command line argument is accessed using $2.
Signup and view all the answers
What is the index of the first component in a Bash array?
What is the index of the first component in a Bash array?
Signup and view all the answers
In a Bash script, the command to check a condition using if structure starts with 'if test-______'.
In a Bash script, the command to check a condition using if structure starts with 'if test-______'.
Signup and view all the answers
Match the following positional parameters with their corresponding command line arguments:
Match the following positional parameters with their corresponding command line arguments:
Signup and view all the answers
What command is used to display the top 20 lines of a file?
What command is used to display the top 20 lines of a file?
Signup and view all the answers
The command 'mv file1 file2' can be used to move and rename a file at the same time.
The command 'mv file1 file2' can be used to move and rename a file at the same time.
Signup and view all the answers
What command should you use to remove a directory that is not empty?
What command should you use to remove a directory that is not empty?
Signup and view all the answers
To check the calendar for the year 2001, use the command '____ 2001'.
To check the calendar for the year 2001, use the command '____ 2001'.
Signup and view all the answers
Match the commands with their functions:
Match the commands with their functions:
Signup and view all the answers
Which command will you use to list all entries in a directory, including hidden files?
Which command will you use to list all entries in a directory, including hidden files?
Signup and view all the answers
The 'rm file1 file2' command can delete two files at once.
The 'rm file1 file2' command can delete two files at once.
Signup and view all the answers
What command would you use to view the current working directory?
What command would you use to view the current working directory?
Signup and view all the answers
What is the first command you use to give a script file executable permissions?
What is the first command you use to give a script file executable permissions?
Signup and view all the answers
In a Bash script, all variables are strictly typed.
In a Bash script, all variables are strictly typed.
Signup and view all the answers
What does the acronym GCD stand for?
What does the acronym GCD stand for?
Signup and view all the answers
The shell implements a programming language that includes variables, expressions, assignment, and __________ structures.
The shell implements a programming language that includes variables, expressions, assignment, and __________ structures.
Signup and view all the answers
Match the following Bash expressions with their meanings:
Match the following Bash expressions with their meanings:
Signup and view all the answers
Which operator is used for logical AND in Bash expressions?
Which operator is used for logical AND in Bash expressions?
Signup and view all the answers
The GCD of two integers can be calculated using the Euclidean algorithm as shown in the sample code.
The GCD of two integers can be calculated using the Euclidean algorithm as shown in the sample code.
Signup and view all the answers
What is the command to display the value of a variable named 'x'?
What is the command to display the value of a variable named 'x'?
Signup and view all the answers
When defining a variable, there should be no spaces around the __________ symbol.
When defining a variable, there should be no spaces around the __________ symbol.
Signup and view all the answers
What will be the output of the command 'echo -n "Enter the 1st positive integer: "'?
What will be the output of the command 'echo -n "Enter the 1st positive integer: "'?
Signup and view all the answers
Study Notes
CSC 209 UNIX Tools - Hierarchical Diagram
- A hierarchical diagram displays folders and files created in assignment 1
- The home directory contains the user account jdoel
- The jdoel folder contains multiple subfolders and files
- The csc209 folder contains subfolders asgn01 and asgn02
- The public_html folder is a subfolder under csc209
- The folder csc209 contains the folder esc209
- The root directory (/) is the top-level folder
Login and Bash Initialization
- Sign on as a new user using Net-ID (user ID) and password
- Verify password and establish user identity and group id
- Establish login (home) directory and shell
- Announce the presence of email (traditional)
- Customize terminal settings
- Publish message of the day (motd) (traditional)
- Initiate command interpreter (shell)
- Perform user-specified initialization (code)
- Display prompt and await commands
Password File
- The
/etc/passwd
file historically stores login information - Each line within
/etc/passwd
represents a user - Each line contains seven pieces of user data separated by colons
- Encrypts password in a hash
- Modern systems use
/etc/shadow
or similar mechanisms for security
Shell Initialization Files
- The C Shell is the default login shell at Brockport
- Initialization files
.cshrc
and.login
are executed on startup of the C shell - In Assignment 1, a
.login
file is set up to switch to Bash - Bash initialization executes
/etc/profile
and~/.bash_profile
at login
Sample .bashrc File
- The ~/.bashrc file contains important configurations
- Sources global definitions from
/etc/bashrc
(if applicable) - Contains user-specific aliases (e.g.,
cls
,h
,lo
) - Controls history parameters (e.g.,
HISTSIZE
,HISTFILESIZE
) - Sets default access permissions (using
umask
) - Protects files in redirection
- Defines shell prompt (
PS1
)
What is an Operating System?
- OS is a computer's system software in charge of the entire computer system
- Provides a convenient working environment and organization of files
- Management of computer resources are critical OS functions
- Examples of OS include MS-DOS, Windows 11, macOS 14, UNIX, Linux, Android, and iOS
Brief History of UNIX
- MULTICS project at MIT influenced early UNIX development
- UNIX originated at Bell Labs (AT&T) in 1969 by Ken Thompson and Dennis Ritchie
- UNIX System Laboratory (USL)
- UNIX extensions and communication protocols (TCP/IP) emerged in the 1980s
- Major flavors such as AT&T System 5 Release 4 (SVR4). USL (AT&T) → Novell → Santa Cruz Operations (SCO) BSD 4.4 and some from vendors
UNIX/Linux
- Linux is a multi-user, time-sharing, multi-tasking OS
- Kernel is the core of the operating system
- Shell acts as the user interface and command interpreter
- Features include hierarchical file structure and I/O device support.
Simple Linux Commands
-
date
: Displays date and time -
who
: Lists currently logged-in users -
whoami
: Displays current user ID -
logout
: Logs out of the system -
pwd
: Displays the current working directory -
mkdir
: Creates a new directory -
rmdir
: Removes an empty directory -
cd
: Changes the current working directory -
ls
: Lists directory contents -
chmod
: Changes file permissions
Permissions in Linux
- The ls -l command provides detailed security information of files and directories
- Permissions are specified as three sets of three permissions (read, write, execute)
- Permissions are tied to the owner, group, and others
Ordinary File Permissions
- Displaying files requires read permissions
- Rewriting files requires write permissions
- Executing a file requires execute permissions
Directory File Permissions
- Moving to directories requires execute permissions
- List directories requires read and execute permissions
- Creating new directory entries requires write permission
- Removing directory entries requires write permissions
Default Access Permissions
- Default file permissions are 666 (for files) and 777 (for directories)
- umask (user mask) controls what permissions are removed
- Using ~/.bashrc to set umask to 077 changes default permissions
Superuser (root)
- Superuser (root) is the administrator account
- Can access, create, or delete any files or directories irrespective of permissions
- Superuser bypasses permission restrictions
Format of Linux Commands
- Commands typically follow the format
command_name [options] [argument]
- Options are single characters preceded by a hyphen
- Arguments are often necessary to use the commands effectively
Handling errors while typing commands
-
ctl-h
orBackspace
to delete previous character -
ctl-w
to delete the previous word -
ctl-u
to delete the entire command
On-line help (man command)
- Use
man
to display help for commands - Example
man cat
provides documentation for the cat command
Hierarchical File System
- Organizes files and directories in a tree-like structure
- Root directory (/) is the top-level directory
-
cd
command navigates between directories -
pwd
displays current working directory
Absolute and Relative Path Names
- Absolute paths start with a forward slash (/) or a tilde (~)
- Relative paths are relative to the current working directory
File Manipulation Commands
-
cat
: Concatenates files and prints to the standard output -
od
: Displays content in octal format -
more
: Displays files one screen at a time
Other File Commands
-
head
: Displays the first part of a file -
tail
: Displays the last part of a file -
cmp
: Compares two files; shows the first difference -
diff
: Compares two files; shows all differences -
cal
: Displays a calendar
File System Commands
-
piico
,nano
,emacs
: Editors for file manipulation -
cp
: Copies files -
mv
: Moves or renames files -
rm
: Removes files -
rm -i
: prompts before deleting files
Directory Listing Commands
-
ls
: Lists files and directories in the current working directory -
ls -a
: Includes hidden files in listing -
ls -l
: Displays file information in long format -
ls -ld
: Lists directory information in long format
Directory Manipulation Commands
-
mkdir
: Creates a new directory -
rmdir
: Removes an empty directory -
rm -r
: Recursively removes a directory (be cautious) -
cd
: Changes the current working directory -
pwd
: Shows current working directory
Bash Special Characters
- Special characters define actions such as input/output redirection, variable substitutions, and more
Shell Substitutions and Quoting
- The shell performs input processing of various substitutions
- Three methods are available to quote
- Use
\
(backslash) to quote a character - Use single quotes to disable substitutions entirely
- Use double quotes to allow certain substitutions but restrict wildcard expansion
History Substitution
- Accessing previously entered commands or parts
- Variables like
HISTSIZE
andHISTFILESIZE
influence command history management
Aliases Substitution
- Alias commands to shorten the names for frequently used tasks
- A list of all aliases can be obtained with the
alias
command - An alias is undone using
unalias
Shell Variable Value Substitution
- Accessing the values stored in shell variables using the "$" symbol
- Using
set
displays all current shell variables - Removing particular variables using
unset
Command Output Substitution
- Performing a command, and using the output as a value
- Enclosing the command in backticks
File Name Expansion
- Wildcards and file name expansion
- Example:
ls -l *
will generate a listing of all entries in the current directory - Use
\
or single quotes to disable wildcards
Special Characters and Quoting
- Backslash escapes the effect of special characters inside the quotes
- Single and double quotes both prevent certain interpretations
Redirection and Pipe
- Redirecting input from a file with
input_file <
or redirecting output to a file with>output_file
- Using a pipe to chain commands (e.g.,
command1 | command2
)
Linux Filenames and Shell Substitutions
- Filename length and character restrictions
- Standard usage for creating and deleting files
- Filename wildcards and usage, e.g., "*
and
?`
Linux Directories, Inodes, Links
- Information of file and directories that describe the Linux file system
- Inode number is central to Linux structure to maintain all file attributes
- Hard and soft links
Shell Working and Process Control
- Shell activities and commands (e.g.
ps
,jobs
,fg
)
Process Control Commands
- Using
ps
andkill
to manage running processes
Locating Files in File System
- Using
find
command to locate files - Use criteria for location
Selection Criterion
-
find
command criteria to meet when listing files
Regular Expressions
- Method of describing a set of text strings using meta characters
Stream Editor (sed)
-
sed
is used for repetitive editing tasks - Editing instructions can be in a separate file or given inline
-
sed
performs edits on each line
Bash Scripts
- Shell scripts are programs for the shell
- How to execute code in files
Bash Script Basics
- User-defined variables, use of
$
symbol for accessing variables, arithmetic operations, string handling
Test Expressions
- Logical conditions to check whether a variable is true or false
File Queries
- Examine file types, permissions, sizes with
find
command
Multivalued Variables (Arrays)
- Array variables and how to access them
Command Line Arguments
- Accessing command line arguments passed to a script (e.g., $1, $2, $@ , $#).
Bash Control Structures
- Conditional statements and loops for Bash scripts (like if, elif, else, case, while, and for).
Examples of Bash Scripts
- Practical demonstrations of using the discussed concepts
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on Operating Systems with this quiz that covers key concepts, commands, and characteristics of different systems. From shell configurations to directory management, assess your understanding of both Linux and general Operating System principles.