🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

OPS Midterms
319 Questions
6 Views

OPS Midterms

Created by
@VibrantSwamp

Podcast Beta

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is one of the strengths of Command Line Interfaces (CLIs)?

  • Well-suited for automation, such as mass-conversion of thousands of images (correct)
  • Well-suited for editing images and documents
  • Well-suited for occasional tasks
  • Requires far more data than Graphical User Interfaces (GUIs)
  • GUIs are well-suited for automation tasks.

    False

    What type of interface was dominant on personal computers before Microsoft Windows and the Apple Macintosh existed?

    Text User Interfaces

    A typical CLI display contains about ______ kilobytes of data.

    <p>2</p> Signup and view all the answers

    Why are CLIs often used over remote connections?

    <p>Because they require far less data than GUIs</p> Signup and view all the answers

    Graphical User Interfaces (GUIs) are well-suited for occasional tasks.

    <p>False</p> Signup and view all the answers

    Match the following interfaces with their characteristics:

    <p>Command Line Interfaces (CLIs) = Well-suited for automation tasks Graphical User Interfaces (GUIs) = Well-suited for graphical tasks Text User Interfaces (TUIs) = Dominant on personal computers before GUIs</p> Signup and view all the answers

    What was the state of computing in the very early days?

    <p>Impossible to standardize</p> Signup and view all the answers

    What type of user interface enables the user to interact with multiple application windows?

    <p>Graphical User Interface (GUI)</p> Signup and view all the answers

    Operating systems provide at least three types of user interfaces.

    <p>False</p> Signup and view all the answers

    What is the primary purpose of the user interface?

    <p>to enable the user to interact with the system</p> Signup and view all the answers

    Most operating systems provide a set of basic starter applications, such as a _______________, clock, a few games, and sometimes a web browser.

    <p>text editor</p> Signup and view all the answers

    Match the following user interfaces with their descriptions:

    <p>CLI = enables the user to enter commands and view output GUI = enables the user to interact with multiple application windows TUI = full-screen text interfaces such as file editors and file managers</p> Signup and view all the answers

    Utilities in an operating system can use either the GUI or CLI.

    <p>True</p> Signup and view all the answers

    What is another term for Text-Based User Interface?

    <p>Text User Interface (TUI)</p> Signup and view all the answers

    What type of tasks do utilities in an operating system perform?

    <p>setup, configuration, and maintenance</p> Signup and view all the answers

    What is the primary function of the kernel?

    <p>To manage resources and security settings</p> Signup and view all the answers

    System libraries are provided by third-party vendors.

    <p>False</p> Signup and view all the answers

    What are system libraries?

    <p>A common set of software routines that programs access to perform common operations.</p> Signup and view all the answers

    The kernel operates in a special ______________________ mode, which enables it to manage resources and security settings.

    <p>Privileged</p> Signup and view all the answers

    Match the following components of an Operating System:

    <p>Kernel = Manages resources and security settings System Libraries = Provides common software routines Services = Runs continuously in the background User Interface = Provides interaction with the user</p> Signup and view all the answers

    The kernel is loaded by the computer's firmware.

    <p>True</p> Signup and view all the answers

    What are services in an Operating System?

    <p>Programs that run continuously in the background, providing services such as WiFi authentication, print management, and file sharing.</p> Signup and view all the answers

    What is NOT a component of an Operating System?

    <p>Compiler</p> Signup and view all the answers

    What was a key difference between Unix and DOS?

    <p>DOS did not have a hierarchical filesystem while Unix did</p> Signup and view all the answers

    DOS used the forward-slash character in filenames.

    <p>False</p> Signup and view all the answers

    What was the version of DOS that introduced Unix-like features?

    <p>2.0</p> Signup and view all the answers

    Microsoft introduced features from ______________ into DOS.

    <p>Xenix</p> Signup and view all the answers

    What was the reason DOS used the backward-slash character in filenames?

    <p>Because it was already being used for another purpose</p> Signup and view all the answers

    DOS was a multi-tasking system.

    <p>False</p> Signup and view all the answers

    Match the following operating systems with their characteristics:

    <p>DOS = Single-tasking system Unix = Multi-tasking system with hierarchical filesystem CP/M = Single-tasking system with flat filesystem</p> Signup and view all the answers

    What was the original heritage of DOS?

    <p>CP/M-like</p> Signup and view all the answers

    What is the primary purpose of hardware abstraction in an Operating System?

    <p>To hide hardware details from application software</p> Signup and view all the answers

    One customer of a cloud server can access another customer's data.

    <p>False</p> Signup and view all the answers

    What is the primary benefit of maintaining the programming model in an Operating System?

    <p>It allows programmers to create software using a single conceptual framework</p> Signup and view all the answers

    An application can send data to the network in the same way regardless of whether the connection uses _______________, WiFi, or 5G.

    <p>wired ethernet</p> Signup and view all the answers

    Match the following benefits of Operating System abstraction with their descriptions:

    <p>Hardware Abstraction = Hides hardware details from application software Programming Model = Provides a single conceptual framework for programmers Multi-Tenancy = Allows multiple customers to access a single resource</p> Signup and view all the answers

    What is an example of an Operating System abstraction?

    <p>A program requesting input from the keyboard</p> Signup and view all the answers

    Multiple programs can be written to work in the same region of memory without conflict.

    <p>True</p> Signup and view all the answers

    What is the primary benefit of multi-tenancy in a cloud server?

    <p>It allows multiple customers to access a single resource, while keeping their data isolated from each other</p> Signup and view all the answers

    What is the current significance of the Unix trademark?

    <p>Not as significant as it once was</p> Signup and view all the answers

    Linux is an officially recognized Unix system.

    <p>False</p> Signup and view all the answers

    What are the two operating systems focused on in this course?

    <p>Windows (version 10) and Linux</p> Signup and view all the answers

    A CLI is provided by two components: a terminal program which accepts user input from a _______________ and displays text output.

    <p>keyboard</p> Signup and view all the answers

    Match the following operating systems with their characteristics:

    <p>Mac OS and iOS = Unix-like Linux = Unix-like FreeBSD and OpenBSD and NetBSD = Unix-like Windows = Proprietary</p> Signup and view all the answers

    What is the primary interface available on the lab computers?

    <p>Both GUI and CLI</p> Signup and view all the answers

    Graphical User Interfaces (GUIs) are well-suited for automation tasks.

    <p>False</p> Signup and view all the answers

    What is the name of the large server system that provides a Linux CLI by remote connection?

    <p>Matrix</p> Signup and view all the answers

    What was added to PC-DOS/MS-DOS 2.0?

    <p>Hierarchical filesystems</p> Signup and view all the answers

    All modern versions of Windows are derived from MS-DOS.

    <p>False</p> Signup and view all the answers

    When was the X Window System introduced?

    <p>1984</p> Signup and view all the answers

    Unix was originally a proprietary product of ________________.

    <p>Bell Labs / AT&amp;T</p> Signup and view all the answers

    Match the following operating systems with their characteristics:

    <p>Unix = Original proprietary product of Bell Labs / AT&amp;T MS-DOS = Added hierarchical filesystems in version 2.0 Windows NT = Combined features from DOS/Windows and OS/2 OS/2 = Jointly-developed by Microsoft-IBM</p> Signup and view all the answers

    What was the primary purpose of the X Window System?

    <p>To add GUIs to Unix systems</p> Signup and view all the answers

    Unix became a family of related operating systems customized by various vendors.

    <p>True</p> Signup and view all the answers

    What was the new 32-bit operating system released in 1993?

    <p>Windows NT 3.1</p> Signup and view all the answers

    What is the primary purpose of the kernel?

    <p>To manage resources and security settings</p> Signup and view all the answers

    System libraries are provided by third-party vendors.

    <p>False</p> Signup and view all the answers

    What are the two broad categories of software licenses in use?

    <p>Proprietary licenses and Open Source Licenses</p> Signup and view all the answers

    What type of argument is 'ls -l' in the command 'ls -l'?

    <p>Option</p> Signup and view all the answers

    The copyright holder can license the software to another party under a _______________________ license.

    <p>Open Source</p> Signup and view all the answers

    Open Source Software is generally protected by patent.

    <p>False</p> Signup and view all the answers

    What type of user interface enables the user to interact with multiple application windows?

    <p>Graphical User Interface (GUI)</p> Signup and view all the answers

    What is the primary purpose of the option '-l' in the command 'ls -l'?

    <p>To select 'long' output</p> Signup and view all the answers

    Match the following types of Open Source Licenses with their characteristics:

    <p>Free Software Licenses = require anyone redistributing the software to do so under the same terms as the software was received. Permissive Licenses = allow the open source software to be redistributed without the same permissions as the software was received under.</p> Signup and view all the answers

    The 'dir' command is used to list files in _______________ systems.

    <p>Windows</p> Signup and view all the answers

    Match the following types of arguments with their descriptions:

    <p>Option = Alters the operation of the command Option with a Value = Consists of an option immediately followed by a value Positional Argument = All other arguments, and their position may be significant</p> Signup and view all the answers

    DOS used the forward-slash character in filenames.

    <p>False</p> Signup and view all the answers

    What are the two operating systems focused on in this course?

    <p>Unix-like systems and other Operating Systems</p> Signup and view all the answers

    The 'cp' command is used to copy files in Windows systems.

    <p>False</p> Signup and view all the answers

    What is the purpose of the option '-h' in the command 'ls -l -h'?

    <p>To show human-readable sizes</p> Signup and view all the answers

    What type of argument is 'new' in the command 'cp old new'?

    <p>Positional Argument</p> Signup and view all the answers

    What is a shell?

    <p>A program that interprets commands and displays their output</p> Signup and view all the answers

    All commands are built into the shell.

    <p>False</p> Signup and view all the answers

    What is the name of the shell widely used on Linux systems?

    <p>Bash</p> Signup and view all the answers

    Commands may also be called ______________, utilities, applications, or executables.

    <p>programs</p> Signup and view all the answers

    Match the following shells with their primary usage:

    <p>Bash = Linux systems PowerShell = Windows systems CMD = Windows systems</p> Signup and view all the answers

    What is the primary purpose of a command?

    <p>To perform a specific task or function</p> Signup and view all the answers

    The terms 'programs', 'utilities', 'applications', and 'executables' are interchangeable only in the context of shell scripting.

    <p>False</p> Signup and view all the answers

    What is the structure of most commands?

    <p>command_name arguments</p> Signup and view all the answers

    What is the name of the course being discussed in the lecture?

    <p>OPS102</p> Signup and view all the answers

    Labs account for 30% of the total mark in OPS102.

    <p>False</p> Signup and view all the answers

    What is the name of the Linux distribution that provides a command-line interface by remote connection?

    <p>Matrix</p> Signup and view all the answers

    The course OPS102 focuses on two operating systems: _______ and Windows.

    <p>Linux</p> Signup and view all the answers

    Why did the instructor swap weeks 1 and 2 in OPS102?

    <p>Because week 2 topics will help students in their other courses.</p> Signup and view all the answers

    All modern versions of Windows are derived from MS-DOS.

    <p>True</p> Signup and view all the answers

    Match the following course components with their weightage:

    <p>Labs = 20% Quizzes = 25% Mid-Term Test = 25% Final Test = 30%</p> Signup and view all the answers

    What is the course code that was replaced by OPS102 for SDDS students?

    <p>ULI101</p> Signup and view all the answers

    What is required to access Matrix?

    <p>Being on-campus or connected to SenecaNet or VPN</p> Signup and view all the answers

    You can connect to Matrix from any location using SSH.

    <p>False</p> Signup and view all the answers

    What protocol is used to securely connect to Matrix?

    <p>SSH (Secure Shell)</p> Signup and view all the answers

    You can connect to Matrix from any Seneca lab workstation, or from your personal computer using ___________________.

    <p>SSH (Secure Shell)</p> Signup and view all the answers

    Why is SSH used to connect to Matrix?

    <p>For security reasons</p> Signup and view all the answers

    Web access is allowed to Matrix from off-campus.

    <p>True</p> Signup and view all the answers

    Match the following access methods with their descriptions:

    <p>On-campus = Physically present at Seneca campus Off-campus with VPN = Connected to Seneca VPN from outside Off-campus without VPN = No access to Matrix</p> Signup and view all the answers

    What is the name of the server system that provides a Linux CLI by remote connection?

    <p>Matrix</p> Signup and view all the answers

    What might be the reason you can't connect to matrix.senecapolytechnic.ca?

    <p>All of the above</p> Signup and view all the answers

    PuTTY is a terminal emulator for MacOS only.

    <p>False</p> Signup and view all the answers

    What is the port number used when connecting to matrix.senecapolytechnic.ca using PuTTY?

    <p>22</p> Signup and view all the answers

    To connect to matrix from MacOS, you would use the command ssh [email protected]

    <p>senecausername</p> Signup and view all the answers

    What is the default connection type used in PuTTY?

    <p>SSH</p> Signup and view all the answers

    You should not log out of matrix.senecapolytechnic.ca when you're finished.

    <p>False</p> Signup and view all the answers

    Match the following platforms with their corresponding terminal emulators:

    <p>Windows = PuTTY MacOS = Terminal Linux = Terminal</p> Signup and view all the answers

    What is the hostname used when connecting to the Linux server?

    <p>matrix.senecapolytechnic.ca</p> Signup and view all the answers

    What is the name of the server cluster that provides a Linux CLI by remote connection?

    <p>Matrix</p> Signup and view all the answers

    All modern versions of Windows are derived from MS-DOS.

    <p>True</p> Signup and view all the answers

    What type of OS is CentOS?

    <p>a version of Linux</p> Signup and view all the answers

    Matrix has been configured to allow users to only interact with the Linux OS using a _______________ interface.

    <p>command line</p> Signup and view all the answers

    Match the following storage systems with their descriptions:

    <p>NFS = a file system that allows access to files on a remote computer HyperV = a virtual machine</p> Signup and view all the answers

    Linux is a multi-tasking system.

    <p>True</p> Signup and view all the answers

    What is the primary benefit of maintaining the programming model in an Operating System?

    <p>it allows multiple programs to work in the same region of memory without conflict</p> Signup and view all the answers

    How do Seneca students access the Linux OS on matrix?

    <p>using SSH</p> Signup and view all the answers

    What is the purpose of the /dev directory in a Linux file system?

    <p>To store device driver files</p> Signup and view all the answers

    A relative pathname always starts with a slash.

    <p>False</p> Signup and view all the answers

    What is the symbol used to represent the user's home directory in Linux?

    <p>tilde (~)</p> Signup and view all the answers

    In Linux, the path separator is a _______________.

    <p>forward slash (/)</p> Signup and view all the answers

    Match the following directory paths with their descriptions:

    <p>/home/cory = User's home directory /var = Dynamic files /tmp = Temporary files for programs /opt = Additional installed application programs</p> Signup and view all the answers

    The kernel operates in a user mode.

    <p>False</p> Signup and view all the answers

    What is the purpose of the /tmp directory in a Linux file system?

    <p>Temporary files for programs</p> Signup and view all the answers

    A full pathname that starts from the root of the hierarchy is called a _______________ pathname.

    <p>absolute</p> Signup and view all the answers

    What is the command to create a directory in Linux?

    <p>mkdir</p> Signup and view all the answers

    The 'rmdir' command can remove non-empty directories.

    <p>False</p> Signup and view all the answers

    What is the purpose of the 'touch' command?

    <p>Create an empty file or update the time of an existing file</p> Signup and view all the answers

    The 'rm' command is used to _______ files or directories.

    <p>remove</p> Signup and view all the answers

    Match the following commands with their functions:

    <p>mkdir = Create a directory mv = Move or rename files/directories cp = Create a copy of files/directories rm = Remove files or directories</p> Signup and view all the answers

    What is the command to move or rename files/directories in Linux?

    <p>mv</p> Signup and view all the answers

    The 'pushd' and 'popd' commands are used to change directories.

    <p>True</p> Signup and view all the answers

    What is the purpose of the 'cp' command?

    <p>Create a copy of files or directories</p> Signup and view all the answers

    What is a primary purpose of the "man" command in Linux/Unix systems?

    <p>To provide access to documentation</p> Signup and view all the answers

    In Linux/Unix, text files are commonly used for data, presentations, configuration, logs, and more.

    <p>True</p> Signup and view all the answers

    What is the primary function of file management skills in Linux/Unix systems?

    <p>To create files and directories, read the contents of files, copy files for backup purposes, move or rename incorrectly spelled filenames, and view text file contents without the danger of editing or corrupting those files.</p> Signup and view all the answers

    In Linux/Unix, the system and shell provide "easy" ways to deal with ______.

    <p>files</p> Signup and view all the answers

    What is a common use of file management skills in Linux/Unix systems?

    <p>All of the above</p> Signup and view all the answers

    Match the following file operations with their descriptions:

    <p>Creating files = To create new files Moving files = To rename or relocate files Copying files = To create duplicate files Deleting files = To remove files</p> Signup and view all the answers

    The "man" command is divided into sections, and you can see these sections by running "man man".

    <p>True</p> Signup and view all the answers

    What is the primary purpose of the "dir /?" command in Windows?

    <p>To provide help on the &quot;dir&quot; command.</p> Signup and view all the answers

    What is the purpose of file globbing in Linux?

    <p>To expand wildcards into a list of matching files</p> Signup and view all the answers

    File globbing is a feature provided by the kernel.

    <p>False</p> Signup and view all the answers

    What happens when you press the enter key after typing a command with wildcards?

    <p>The shell expands the wildcards into a list of matching files before executing the command.</p> Signup and view all the answers

    When you type a command with wildcards and press the enter key, the shell performs _______________________ on any wildcards on the command line before executing the command.

    <p>file name expansion</p> Signup and view all the answers

    Which of the following commands is used to find specific lines in a file?

    <p>grep</p> Signup and view all the answers

    The find command is used to sort the lines of a file.

    <p>False</p> Signup and view all the answers

    Match the following file operations with their descriptions:

    <p>sort = Sort the lines of a file uniq = Display identical consecutive lines only once cut = Remove undesired columns from your data in a file grep = Find specific lines in a file</p> Signup and view all the answers

    Bash shell automatically expands wildcards into the names of all the files and directories in the current working directory before executing the command.

    <p>True</p> Signup and view all the answers

    What is the purpose of the "touch" command in Linux/Unix systems?

    <p>To create an empty file or change the file's timestamp</p> Signup and view all the answers

    In Linux/Unix systems, the "cp" command can only copy files to a new directory.

    <p>False</p> Signup and view all the answers

    What is the purpose of the "rm" command with the "-r" option?

    <p>To remove directories recursively</p> Signup and view all the answers

    The "cat" command is used to ______ the contents of a file.

    <p>display</p> Signup and view all the answers

    Match the following Linux/Unix commands with their functions:

    <p>cp = Copy a file mv = Rename a file rm = Remove a file touch = Create an empty file or change the file's timestamp</p> Signup and view all the answers

    What is the purpose of the "head" command in Linux/Unix systems?

    <p>To display the beginning of a file</p> Signup and view all the answers

    In Windows, you can use the "cat" command to display the contents of a file without any additional software.

    <p>False</p> Signup and view all the answers

    What is the difference between the "mv" and "cp" commands in Linux/Unix systems?

    <p>The &quot;mv&quot; command renames a file, while the &quot;cp&quot; command copies a file.</p> Signup and view all the answers

    What is the purpose of the question mark (?) in globbing?

    <p>To match any exactly one character</p> Signup and view all the answers

    The character class [0-2] will match any character that is not 0, 1, or 2.

    <p>False</p> Signup and view all the answers

    What is the effect of using an exclamation mark (!) as the first character in a character class in globbing?

    <p>It inverts the class, making it match any character that is not listed in the class</p> Signup and view all the answers

    The command rm img?.jpg will delete all files with names starting with "img", followed by _______________, and ending with ".jpg".

    <p>any one character</p> Signup and view all the answers

    What is the interpretation of the pattern ls File?.pdf?

    <p>Lists all files with names starting with &quot;File&quot;, followed by any exactly one character, and ending with &quot;.pdf&quot;.</p> Signup and view all the answers

    Match the following patterns with their interpretations:

    <p>ls File?.pdf = Lists all files with names starting with &quot;File&quot;, followed by any exactly one character, and ending with &quot;.pdf&quot;. rm img?.jpg = Delete all files with names starting with &quot;img&quot;, followed by any one character, and ending with &quot;.jpg&quot;. ls File[0-2].pdf = Lists all files with names starting with &quot;File&quot;, followed by either 0, 1, or 2, and ending with &quot;.pdf&quot;.</p> Signup and view all the answers

    The command ls File[0-2].pdf will list all files with names starting with "File", followed by any zero or more characters, and ending with ".pdf".

    <p>False</p> Signup and view all the answers

    What is the purpose of globbing in the bash shell?

    <p>Globbing is used to expand filenames and directories based on wildcard characters and patterns</p> Signup and view all the answers

    What is the main purpose of a text editor?

    <p>To create, modify and save editing changes of text files</p> Signup and view all the answers

    Graphical User Interfaces (GUIs) are well-suited for automation tasks.

    <p>False</p> Signup and view all the answers

    What is the end-of-line indicator in UNIX/Linux?

    <p>new line (line feed or ^J or )</p> Signup and view all the answers

    In Windows, the end-of-line indicator is a _______________ followed by a line feed.

    <p>carriage return (^M or )</p> Signup and view all the answers

    Match the following text files with their uses:

    <p>System configuration files = Editing text files is an everyday activity for both programmers as well as administrators Scripts and programs = Edit System configuration files Documentation = Write/edit documentation Web pages = Develop web pages</p> Signup and view all the answers

    Why are text files important in Linux/Unix?

    <p>For data, presentations, configuration, logs, and more</p> Signup and view all the answers

    CLIs are well-suited for automation tasks.

    <p>True</p> Signup and view all the answers

    What is the name of the commands that can help when transferring text files between systems?

    <p>dos2unix(1) and unix2dos(1)</p> Signup and view all the answers

    Manual typewriters and teletype machines worked similar to how _______________ files work.

    <p>text files</p> Signup and view all the answers

    Match the following with their descriptions:

    <p>Text editors = Allows users to create, modify and save editing changes of text files Unix/Linux = System and shell provide “easy” ways to deal with files Line endings = End-of-line indicators in text files</p> Signup and view all the answers

    What was the original editor used on Unix systems?

    <p>ed</p> Signup and view all the answers

    Which of the following text editors is the default on many Linux distributions?

    <p>Nano</p> Signup and view all the answers

    The vi editor was developed by Bill Joy at UCBerkeley.

    <p>True</p> Signup and view all the answers

    The notation ^G in nano editor means pressing and holding the __________ key and then the G key.

    <p>control</p> Signup and view all the answers

    Which of the following text editors is known for its visual mode?

    <p>vi</p> Signup and view all the answers

    What is the purpose of the grep command?

    <p>to echo the ed syntax of: g/regexp/p</p> Signup and view all the answers

    Match the following text editors with their characteristics:

    <p>Nano = Easy to use and default on many Linux distributions VIM = Highly customizable and powerful Gedit = A popular text editor on Linux systems Notepad = A basic text editor on Windows systems</p> Signup and view all the answers

    All modern versions of Windows are derived from MS-DOS.

    <p>False</p> Signup and view all the answers

    The ed editor was replaced by __________ on Unix systems.

    <p>ex</p> Signup and view all the answers

    What is a benefit of using the nano editor?

    <p>It provides a menu at the bottom of the screen.</p> Signup and view all the answers

    The vim editor is an older version of the vi editor.

    <p>False</p> Signup and view all the answers

    What is the purpose of the ^G command in nano?

    <p>To get help at any time</p> Signup and view all the answers

    The _______ command is used to open a file in nano.

    <p>^R</p> Signup and view all the answers

    Why is it recommended to become familiar with vi/vim?

    <p>For anything beyond the absolute basics.</p> Signup and view all the answers

    Nano is a more advanced text editor than vi/vim.

    <p>False</p> Signup and view all the answers

    Match the nano command with its function:

    <p>^O = Save a file ^W = Find ^R = Open a file</p> Signup and view all the answers

    What is the purpose of the vimtutor(1) command?

    <p>To get started with learning vi/vim</p> Signup and view all the answers

    The nano editor is suitable for ________________ use.

    <p>casual, occasional</p> Signup and view all the answers

    Vi/vim is only used by programmers.

    <p>False</p> Signup and view all the answers

    What is the purpose of the "chmod" command in Linux?

    <p>To change permissions of a file</p> Signup and view all the answers

    In the "ls -l" output, the first character represents the file type.

    <p>True</p> Signup and view all the answers

    What are the three types of permissions that can be set for a file in Linux?

    <p>read, write, and execute</p> Signup and view all the answers

    The "chmod" command uses ______ methods to set permissions: symbolic and octal.

    <p>two</p> Signup and view all the answers

    Match the following permissions with their corresponding abbreviations:

    <p>Read = r Write = w Execute = x User = u Group = g Others = o</p> Signup and view all the answers

    What is the purpose of the "chmod" command with the "g+rw" option?

    <p>To add read and write permissions for the group</p> Signup and view all the answers

    In the octal method of setting permissions, permissions can be set explicitly by "chmod" with an octal number.

    <p>True</p> Signup and view all the answers

    What is the purpose of the "chmod" command with the "a-w" option?

    <p>To remove write permissions for all users</p> Signup and view all the answers

    What is the primary purpose of setting permissions in a multi-user operating system?

    <p>To control who has access to files and folders</p> Signup and view all the answers

    In Linux, directory permissions have the same meaning as file permissions.

    <p>False</p> Signup and view all the answers

    What are the three permission indicators in Linux?

    <p>Read, Write, and Execute</p> Signup and view all the answers

    In Linux, the ______________ permission allows the execution of a file as a command.

    <p>Execute</p> Signup and view all the answers

    What is the purpose of Access Control Lists (ACLs) in Linux?

    <p>To provide an advanced permission mechanism</p> Signup and view all the answers

    Match the following permissions with their descriptions:

    <p>Read = Read access to the file's contents Write = Permission to modify the file's contents Execute = Allows the execution of a file as a command</p> Signup and view all the answers

    In Linux, the kernel operates in user mode.

    <p>False</p> Signup and view all the answers

    Why is it necessary to have read permission to execute a script in Linux?

    <p>Because scripts need to be read before they can be executed</p> Signup and view all the answers

    What is the purpose of the setuid bit in a file's mode?

    <p>To run the file with the owner's permissions</p> Signup and view all the answers

    The chmod command with 3 octal digits sets the permissions for user, group, and others.

    <p>True</p> Signup and view all the answers

    What is the octal representation of the permissions rwxr-x---?

    <p>750</p> Signup and view all the answers

    The chmod command with the octal number 754 sets the permissions to ______________.

    <p>rwx r-x r--</p> Signup and view all the answers

    Match the following special permission bits with their descriptions:

    <p>a) setuid = 2. Runs the file with the owner's permissions. b) setgid = 3. Runs the file with the group's permissions. c) sticky bit = 1. Ensures that only the owner of a file or the root user can delete or modify it.</p> Signup and view all the answers

    What is the purpose of the sticky bit in a file's mode?

    <p>To ensure that only the owner of a file or the root user can delete or modify it</p> Signup and view all the answers

    What is the binary representation of the octal number 7 in permissions?

    <p>111</p> Signup and view all the answers

    The command chmod 755 file1.txt sets the permissions to ______________.

    <p>rwxr-xr-x</p> Signup and view all the answers

    What is the purpose of the setuid bit in Linux?

    <p>To allow normal users to execute a command with root privileges</p> Signup and view all the answers

    The sticky bit is used to ensure the privacy and security of files in shared directories.

    <p>True</p> Signup and view all the answers

    What is the purpose of the umask in Linux?

    <p>to 'mask off' (disable) permission bits for files or directories created by a process</p> Signup and view all the answers

    The 'passwd' command allows users to change their own password without requiring ________________ access.

    <p>sudo</p> Signup and view all the answers

    What is the effect of the sticky bit on a directory?

    <p>Only the owner of a file can delete or rename it</p> Signup and view all the answers

    The umask is set on a per-user basis.

    <p>False</p> Signup and view all the answers

    Match the following Linux security features with their descriptions:

    <p>setuid = Allows normal users to execute a command with root privileges sticky bit = Ensures the privacy and security of files in shared directories umask = Masks off permission bits for files or directories created by a process</p> Signup and view all the answers

    What is the purpose of the 'passwd' command in Linux?

    <p>to allow users to change their own password</p> Signup and view all the answers

    What is the purpose of the 'x' permission in a Linux directory?

    <p>Grant 'pass-through' permission to access and through the directory</p> Signup and view all the answers

    The 'ls -l' command shows permissions and details of a file.

    <p>True</p> Signup and view all the answers

    What option is used with the 'ls' command to show permissions and details of a directory?

    <p>-ld</p> Signup and view all the answers

    The 'r' permission grants permission to _______________________ the contents of a directory.

    <p>read</p> Signup and view all the answers

    What is the purpose of the 'w' permission in a Linux directory?

    <p>Grant permission to write/edit directory content</p> Signup and view all the answers

    Match the following Linux permissions with their descriptions:

    <p>r = Grant permission to read the contents of a directory w = Grant permission to write/edit directory content x = Grant 'pass-through' permission to access and through the directory</p> Signup and view all the answers

    Write permission on a directory allows removing files in that directory.

    <p>True</p> Signup and view all the answers

    The 'ls -ld' command shows permissions and details of the _______________________ directory.

    <p>current</p> Signup and view all the answers

    What is the standard input file descriptor?

    <p>0</p> Signup and view all the answers

    The greater than symbol (>) is used to read input from a file.

    <p>False</p> Signup and view all the answers

    What does the '2>&1' syntax do in the command './myprog >myoutput.txt 2>&1'?

    <p>It sends standard error output to the same place as standard output.</p> Signup and view all the answers

    The shell uses special characters and syntax on command lines to implement I/O _______________________.

    <p>redirection</p> Signup and view all the answers

    Match the file descriptors with their standard streams:

    <p>0 = Standard Input 1 = Standard Output 2 = Standard Error</p> Signup and view all the answers

    What is the purpose of the '>>' symbol in the command 'tr '[A-Z]' '[a-z]' lowercase.txt >> output.txt'?

    <p>To append to the output file</p> Signup and view all the answers

    The 'less than' symbol (<) is used to write output to a file.

    <p>False</p> Signup and view all the answers

    What is the purpose of the '2>' syntax in the command 'gcc -o myprog myprog.c 2>gccerrors.txt'?

    <p>To redirect standard error output to a file.</p> Signup and view all the answers

    The shell provides convenient ways to attach the file descriptors to _______________________, devices, or other commands.

    <p>files</p> Signup and view all the answers

    What is the purpose of the '>' symbol in the command 'tr '[A-Z]' '[a-z]' lowercase.txt > output.txt'?

    <p>To write output to the file</p> Signup and view all the answers

    What is a key aspect of the Unix philosophy?

    <p>Write programs to work together</p> Signup and view all the answers

    In Unix, commands can only read input from files.

    <p>False</p> Signup and view all the answers

    What is the universal interface in Unix?

    <p>text streams</p> Signup and view all the answers

    Commands can send their output to files or other commands instead of displaying it on the _______________.

    <p>terminal</p> Signup and view all the answers

    Match the following concepts with their descriptions:

    <p>Input/Output Redirection = Sending output to files or commands instead of the terminal Pipes = Connecting commands to work together Filters = Commands that read input, process or modify it, and send it along as output</p> Signup and view all the answers

    What is a characteristic of Unix/Linux commands?

    <p>They can work together as filters</p> Signup and view all the answers

    Error messages are typically printed on the terminal.

    <p>True</p> Signup and view all the answers

    What is the term for redirecting output or error messages to files or commands?

    <p>Input/Output Redirection</p> Signup and view all the answers

    In Unix, commands can get their input from _______________ or the terminal.

    <p>other commands</p> Signup and view all the answers

    What is a key concept in Unix philosophy?

    <p>Write programs to work together</p> Signup and view all the answers

    What is the purpose of "/dev/null" in Linux?

    <p>To ignore any output or errors</p> Signup and view all the answers

    Commands can send their standard output directly to the standard input of another command. (True or False)

    <p>True</p> Signup and view all the answers

    What is the magic of pipes in Linux?

    <p>The ability to connect the output of one command to the input of another command without creating intermediate files.</p> Signup and view all the answers

    The shell uses the ______ system call to connect the necessary file descriptors before running commands.

    <p>pipe(2)</p> Signup and view all the answers

    Match the following Linux filter commands with their descriptions:

    <p>sort = sorts lines of text cut = extracts columns from a file more = displays a file one page at a time less = displays a file one page at a time</p> Signup and view all the answers

    What is the purpose of the "|" pipe operator in Linux?

    <p>To connect two commands together</p> Signup and view all the answers

    Commands must be chained in a specific order when using pipes in Linux. (True or False)

    <p>True</p> Signup and view all the answers

    What is the standard output of a command in Linux?

    <p>The output of a command that is sent to the screen or to another command.</p> Signup and view all the answers

    The "2>" symbol in the command "grep Linux * 2>/dev/null" redirects ______ to /dev/null.

    <p>error messages</p> Signup and view all the answers

    What is the benefit of using pipes in Linux?

    <p>To make commands more powerful</p> Signup and view all the answers

    What is the primary function of the OS in process management?

    <p>To manage system resources</p> Signup and view all the answers

    The 'ps' command in Linux shows all running processes by default.

    <p>False</p> Signup and view all the answers

    What is the purpose of the 'pstree' command in Linux?

    <p>To offer a tree view of process, branching from parent process to child process</p> Signup and view all the answers

    The OS keeps track of the ______________ and of the system resources.

    <p>processes</p> Signup and view all the answers

    Match the following Linux commands with their functions:

    <p>ps = Offers a snapshot of processes pstree = Offers a dynamic real-time view of processes top = Offers a tree view of process, branching from parent process to child process</p> Signup and view all the answers

    What is an important concept in all operating systems?

    <p>Process Management</p> Signup and view all the answers

    The 'top' command in Linux offers a snapshot of processes.

    <p>False</p> Signup and view all the answers

    Why is it crucial for system administrators to monitor processes?

    <p>To know which processes are running, their current state, resources they use, and which user started them</p> Signup and view all the answers

    During the lifetime of a process, it uses many system resources like ______________ and memory.

    <p>CPU</p> Signup and view all the answers

    What is the primary benefit of process management in operating systems?

    <p>To manage system resources fairly</p> Signup and view all the answers

    What is the command to display all processes of the current user?

    <p>ps x</p> Signup and view all the answers

    The 'ps' command only displays processes that are currently using the CPU.

    <p>False</p> Signup and view all the answers

    What is the state of a process that is waiting for its parent process to retrieve its exit code?

    <p>Zombie</p> Signup and view all the answers

    The 'pstree' command shows a tree view of all current _______________.

    <p>processes</p> Signup and view all the answers

    What is the purpose of the 'top' command?

    <p>To provide a dynamic view of what's going on</p> Signup and view all the answers

    Foreground processes are initiated by the system and run in the background.

    <p>False</p> Signup and view all the answers

    What is the command to display process information of a specific user?

    <p>ps -u username</p> Signup and view all the answers

    Match the following process states with their descriptions:

    <p>Running = currently using the CPU Sleeping = waiting in queue to use the CPU Stopped = stopped (but not terminated), either by user or other process Zombie = terminated but is waiting for its parent process to retrieve its exit code</p> Signup and view all the answers

    The 'ps' command displays information about processes, including _______________, TTY, Time, and CMD.

    <p>PID</p> Signup and view all the answers

    All processes in Linux are initiated by the 'systemd' process.

    <p>True</p> Signup and view all the answers

    What type of processes usually run in the background?

    <p>System-related processes</p> Signup and view all the answers

    Foreground processes do not take away the command line until the process is finished.

    <p>False</p> Signup and view all the answers

    How can you start a process in the background?

    <p>By appending '&amp;' at the end of the command line.</p> Signup and view all the answers

    To send a process to the background while also stopping it, you can press ______ and then the 'bg' command.

    <p>Ctrl+Z</p> Signup and view all the answers

    Match the following process types with their characteristics:

    <p>Foreground processes = Take away the command line until the process is finished Background processes = Run non-interactively and do not expect user input System-related processes = Usually run in the background and are called daemons User-initiated processes = Run in the foreground by default</p> Signup and view all the answers

    What is the purpose of the 'kill' command?

    <p>To send signals to processes</p> Signup and view all the answers

    The 'kill' command can kill multiple processes at once.

    <p>False</p> Signup and view all the answers

    What is the syntax for the 'kill' command?

    <p>kill PID (PID or %job)</p> Signup and view all the answers

    To start a process in the foreground, you can simply run the command ______.

    <p>normally</p> Signup and view all the answers

    What happens when you press Ctrl+Z and then the 'bg' command?

    <p>The process is sent to the background and stopped</p> Signup and view all the answers

    What happens when you press Ctrl+Z in the terminal?

    <p>The current process is stopped and returned to the shell prompt</p> Signup and view all the answers

    The kill command can only send the TERM signal to a process.

    <p>False</p> Signup and view all the answers

    What is the purpose of the jobs command?

    <p>To show stopped and background processes.</p> Signup and view all the answers

    The bg command is used to move a job to the _______________________.

    <p>background</p> Signup and view all the answers

    Match the following commands with their functions:

    <p>bg = Move a job to the background fg = Move a job to the foreground jobs = Show stopped and background processes kill = Send a signal to a process</p> Signup and view all the answers

    What is the purpose of the kill -9 command?

    <p>To send a signal to a process to terminate it instantly</p> Signup and view all the answers

    Process management is not an important component of an operating system.

    <p>False</p> Signup and view all the answers

    What is the purpose of the fg command?

    <p>To move a job to the foreground</p> Signup and view all the answers

    The _______________________ signal is sent to a process by default when using the kill command.

    <p>TERM</p> Signup and view all the answers

    You can only send two types of signals to a process using the kill command.

    <p>False</p> Signup and view all the answers

    What is monitored in the Details tab of Task Manager?

    <p>Process states</p> Signup and view all the answers

    Windows PowerShell provides commands for managing processes.

    <p>True</p> Signup and view all the answers

    What is the purpose of the Get-Process command in PowerShell?

    <p>Get a list of running Windows processes</p> Signup and view all the answers

    The Set Affinity option is used to set the ______________________ priority of a process.

    <p>CPU</p> Signup and view all the answers

    Match the following PowerShell commands with their functions:

    <p>Get-Process = Get a list of running Windows processes Start-Process = Start a process/program Stop-Process = Forcibly stop (kill) a process Debug-Process = Debug a process</p> Signup and view all the answers

    What can be done to a specific process by right-clicking on the process name?

    <p>All of the above</p> Signup and view all the answers

    Process management is not an important component of every operating system.

    <p>False</p> Signup and view all the answers

    Why should users monitor the processes?

    <p>For better system performance</p> Signup and view all the answers

    Monitor resource usage includes monitoring ______________________ usage.

    <p>CPU, Memory, Disk, Network, GPU</p> Signup and view all the answers

    What can be used to monitor a specific process?

    <p>All of the above</p> Signup and view all the answers

    What is the term used in Windows for a process?

    <p>Task</p> Signup and view all the answers

    In Windows, the Task Manager is used to monitor threads.

    <p>False</p> Signup and view all the answers

    What is the function of the CreateProcess() function in Windows?

    <p>To create a new process</p> Signup and view all the answers

    In Windows, the ___________________ function is used to wait for a process to finish.

    <p>WaitForSingleObject()</p> Signup and view all the answers

    Match the following Windows functions with their descriptions:

    <p>CreateProcess() = Create a new process WaitForSingleObject() = Wait for a process to finish CloseHandle() = Close a process handle</p> Signup and view all the answers

    What is the hierarchical structure of processes in Windows?

    <p>Parent-child</p> Signup and view all the answers

    In Windows, all processes run as the same user.

    <p>False</p> Signup and view all the answers

    What is the primary interface for monitoring processes in Windows?

    <p>Task Manager</p> Signup and view all the answers

    In Windows, the ___________________ function is used to close a process handle.

    <p>CloseHandle()</p> Signup and view all the answers

    What is the Microsoft documentation resource for process management in Windows?

    <p><a href="https://learn.microsoft.com/en-us/windows/win32/procthread/processes-and-threads">https://learn.microsoft.com/en-us/windows/win32/procthread/processes-and-threads</a></p> Signup and view all the answers

    Study Notes

    User Interfaces

    • Command Line Interfaces (CLI) are used in Windows, Linux, and Android
    • Graphical User Interfaces (GUI) are used in Windows and Linux
    • GUIs are well-suited for graphical tasks, but may require excessive repetitive actions
    • CLIs are well-suited for automation, but not for occasional tasks
    • GUIs require more data than CLIs (e.g., 6 megabytes vs. 2 kilobytes)

    GUI vs CLI

    • GUIs are suitable for graphical tasks, such as editing images and documents
    • CLIs are suitable for automation, such as mass-conversion of thousands of images
    • GUIs require more data than CLIs, making CLIs suitable for remote connections

    Text User Interfaces

    • A Text User Interface (TUI) employs the same display technology as a CLI, but presents a full-screen interface
    • TUIs were dominant in personal computers before Microsoft Windows and Apple Macintosh
    • TUIs are still common in traditional business applications, such as banking

    A Bit of History

    • In the early days of computing, standardization was impossible due to unique computers
    • One customer of a cloud server should not be able to access another customer's data
    • Multiple smartphone apps may be permitted to access a single photo album

    Hardware Abstraction

    • The OS hides hardware details so that application software can deal with hardware consistently
    • Examples: a program can request input from a keyboard without knowing the connection, and an application can send data to the network regardless of the connection type

    Maintaining the Programming Model

    • The OS controls the hardware to maintain the illusion of the programmer's model
    • Example: multiple programs can operate simultaneously without conflict, using the hardware virtual memory system to load programs into different regions of physical memory

    The User Interface(s)

    • The user interface is the software that enables the user to interact with the system
    • Most operating systems provide at least two types of user interfaces: text-based (CLI) and graphical (GUI)

    Components of an Operating System

    • The four key components of an operating system are:
      • The Kernel
      • System Libraries
      • Services
      • User Interface(s)
      • Utilities and Applications

    The Kernel

    • The kernel is the heart of the operating system, operating in a special privileged mode
    • The kernel manages resources and security settings for all other software
    • The kernel is loaded by the computer's firmware and initializes the hardware and resources

    System Libraries

    • System libraries provide a common set of software routines for programs to access
    • These libraries eliminate the need for duplicate code in programs for common operations
    • Examples: drawing on the screen, accessing the network, and playing sound

    Services

    • Services are programs that run continuously in the background, providing services such as WiFi authentication, print management, and file sharing

    Unix and Unix-like Operating Systems

    • Unix became a trademark, and any operating system that conforms to the Unix standards can use the Unix trademark.
    • Apple's MacOS is officially a Unix system, but Linux is not.
    • Unix-like operating systems include Linux, Mac OS, iOS, FreeBSD, OpenBSD, and NetBSD.

    Operating Systems in this Course

    • The course focuses on two operating systems: Windows 10 (a proprietary operating system) and Linux (representing Unix-like operating systems).
    • Windows 10 is installed on the lab computers, and Linux is available through a remote connection to a server called Matrix.

    Command Line and Commands

    • A Command Line Interface (CLI) is provided by two components: a terminal program and a shell.
    • The shell interprets commands, starts and stops programs, and displays output.
    • Common shells include Bash, PowerShell, and CMD.

    What is a Command?

    • A command is a small program that performs a specific task.
    • Commands can be built into the shell or be separate programs.
    • Examples of commands include the Chrome web browser, git version control tool, and LibreOffice Writer word processor.

    Command Structure

    • Most commands have a similar structure: command_name arguments.
    • The command_name is the name of the command, and the arguments are options, values, or positional arguments.

    Types of Arguments

    • Option (or switch or control argument): alters the operation of the command.
    • Option with a value: consists of an option followed by a value.
    • Positional arguments: all other arguments, where the position may be significant.

    Options – Examples

    • ls command: lists files, with options like -l for long output.
    • dir command: lists files, with options like /b for bare output.

    Options – Long and Short Versions (Linux)

    • ls -l -h : shows human-readable sizes.
    • ls -l --human-readable : same as above.
    • ls -lh : same as above.

    Option with a Value

    • ls -l -sort=size : sorts files by size (Linux).
    • ls -l -sort time : sorts files by time (Linux).

    Positional Arguments

    • cp old new : copies file "old" to "new" (Linux).
    • copy old new : copies file "old" to "new" (Win10).

    Open Source and Proprietary Software

    • Software is protected by copyright, and the copyright holder controls how it is used.
    • There are two broad categories of software licenses: proprietary licenses and open source licenses.

    Open Source Licenses

    • Open source licenses conform to the Open Source Definition (https://opensource.org/osd/).
    • There are two types of open source licenses: free software licenses and permissive licenses.

    Types of Open Source Licenses

    • Free software licenses: require redistributing software under the same terms as received.
    • Permissive licenses: allow redistributing software without the same permissions as received.

    Course Introduction and Overview

    • OPS102 is a course about Operating Systems for Programmers, covering both Linux and Windows.
    • The course is designed for software developers and replaced ULI101 for SDDS students.
    • The course breakdown includes labs (20%), quizzes (25%), mid-term test (25%), and final test (30%).

    Matrix and Connecting to Matrix

    • Matrix is a server cluster with multiple computers running CentOS (a version of Linux).
    • All registered students in OPS102 have access to an account on Matrix.
    • To connect to Matrix, you must be on campus or connected to SenecaNet, or off campus with Seneca VPN.
    • You can connect to Matrix from any Seneca lab workstation or personal computer using SSH (secure shell).
    • SSH is a protocol for secure remote login/connection from one computer to another.

    Simple Commands to Start With

    • Simple commands to practice on Matrix include basic Linux commands.

    Hierarchical File Systems

    • A file system location is found by following the directory tree hierarchy.
    • There are multiple ways of specifying pathnames: absolute, relative, and relative to home.
    • Absolute pathnames start from the root of the hierarchy, while relative pathnames do not start with a slash.
    • Relative to home pathnames use a tilde (~) as a shorthand for the user's home directory.

    Practicing Linux Commands and File Systems

    • You will practice Linux commands and perform lab exercises on Matrix.
    • You will reference your Matrix account during quizzes and tests.

    Troubleshooting Connection Issues

    • Common connection issues include mis-spelled username, password, or hostname.
    • Ensure that your username is in lowercase and CAPS LOCK is off.

    Connecting to Matrix Using PuTTY (Windows) or Terminal (MacOS/Linux)

    • Download and install PuTTY on Windows, or use the Terminal app on MacOS/Linux.
    • Set up PuTTY with the host name "matrix.senecapolytechnic.ca", port 22, and connection type SSH.
    • On MacOS/Linux, use the SSH command to connect to Matrix.

    Files in Linux/Unix

    • Data is saved in files, and Linux/Unix systems prefer text files.
    • Files are used for data, presentations, configuration, logs, and more.
    • The system and shell provide easy ways to deal with files.

    Learning About Commands

    • Extensive documentation is available on Linux/Unix systems using the "man" command.
    • The "man" command provides access to most documentation, which is divided into sections.
    • Man pages can be accessed using the command "man man".

    File and Directory Operations

    • Important file management skills include creating and deleting files and directories, reading file contents, copying files, moving or renaming files, and viewing file contents without editing.
    • These operations can be performed using various commands:
      • Creating directories: mkdir (Linux/Unix) and mkdir (Windows)
      • Moving files and directories: mv (Linux/Unix) and move (Windows)
      • Copying files and directories: cp (Linux/Unix) and copy (Windows)
      • Deleting files and directories: rm (Linux/Unix) and del (Windows)
      • Removing empty directories: rmdir (Linux/Unix) and rmdir (Windows)
      • Recursive directory removal: rm -r (Linux/Unix) and deltree (Windows)

    Directory Operations

    • The "cd" command is used to change directories.
    • The "pushd" and "popd" commands are also used to manipulate directories.
    • The "mkdir" command creates one or more directories, and the "-p" option ensures the path/parents exist.
    • The "rmdir" command removes one or more empty directories.

    File Operations

    • Files can be created using a text editor or output from program output redirection.
    • The "touch" command creates an empty file or updates the file's timestamp.
    • The "cp" and "mv" commands copy and move files, respectively.
    • The "rm" command removes files, and the "-r" option removes directories recursively.

    Working with Text Files

    • Linux/Unix systems have many tools for working with text files, including:
      • cat and copy file con: (Windows) to display the contents of a file.
      • more and less to display the contents of a file one screen at a time.
      • head and tail to display the beginning or end of a file.
      • file to determine the type of file.
    • Windows typically requires add-on programs for most of these operations, or the use of WSL (Windows Subsystem for Linux).

    Working with Text Files (cont'd)

    • Additional tools for working with text files include:
      • sort to sort the lines of a file.
      • uniq to display identical consecutive lines only once.
      • cut to remove undesired columns from data in a file.
      • tr to translate/replace the occurrences of characters.
      • grep to find specific lines in a file.
      • find to find files matching specific criteria in the filesystem.
      • diff to show the differences between two files.

    File Globbing

    • File globbing is a feature provided by the shell, allowing the use of special characters called wildcards to write a generic name that the shell will expand into specific matching names.
    • Wildcards include:
      • * to match any characters.
      • ? to match any one character.
      • [ ] to match any one of the characters contained in the class.
      • ! to invert the character class and match any character not listed.

    File Globbing Examples

    • * can be used to expand into a list of files and directories, such as img001.jpg, imgface.jpg, and img500.jpg.
    • ? can be used to match files with a specific pattern, such as File?.pdf to match files starting with File, followed by any one character, and ending with .pdf.
    • [ ] can be used to match files with a specific pattern, such as ls File[123].pdf to match files starting with File, followed by any one of the characters 1, 2, or 3, and ending with .pdf.

    What is a Text File?

    • A text file is a file that contains data in a human-readable format.
    • In Linux/Unix, text files are widely used for data, presentations, configuration, logs, and more.
    • The system and shell provide "easy" ways to deal with files.

    Line Endings in Text Files

    • Each line in a text file has an end-of-line indicator.
    • In UNIX/Linux, the end-of-line indicator is a "new line" (line feed or ^J or \n).
    • In Windows, the end-of-line indicator is a "carriage return" (^M or \r) followed by a "line feed".
    • In MacOS, the end-of-line indicator is a "carriage return" (^M or \r).
    • When text files are transferred between systems, there could be problems.

    Text Editors

    • A text editor is a software that allows users to create, modify, and save editing changes to text files.
    • Text editors are essential for programmers and administrators in Unix and Linux systems.
    • Text editors are used for editing system configuration files, writing scripts and programs, writing/editing documentation, and developing web pages.

    Text Editors – History

    • Before video terminals, "line editors" were used, such as qed, ed, and edlin (DOS).
    • The ed(1) editor was replaced by ex(1) on Unix, which later evolved into vi(1).
    • The vi(1) editor originated from Bill Joy at UCBerkeley and first appeared in BSD.

    Text Editors – Many Choices Today

    • There are many text editors available in Linux and Windows, such as VIM, Nano, Gedit, Notepad, Notepad++, and Sublime.

    Nano Text Editor Introduction

    • The Nano text editor is an easy-to-use text editor installed on many Linux systems.
    • Nano editing commands typically use control characters.
    • The menu is always displayed at the bottom of the nano screen.

    More About Nano

    • Basic Nano commands include:
      • ^G – to get help at any time
      • ^R – open a file
      • ^O – save a file
      • ^W – find
      • ^\ – replace
      • ^X – exit

    Nano vs Vi

    • The vi(1) command is often actually vim(1), which adds modern features to classic vi.
    • For casual, occasional use, the nano editor is fine.
    • For anything beyond the basics, it's recommended to become familiar with vi (or vim).

    File System Security: Permissions

    • In multi-user operating systems, controlling access to files and folders is crucial, and this is achieved by setting permissions.

    How Does setuid/setgid Work?

    • setuid allows a program to run with the permissions of the file owner, enabling it to perform actions that would typically require the owner's privileges.
    • An example of setuid in action is the "passwd" command, which allows users to change their own passwords without requiring "sudo" access for root user permissions.

    The Sticky Bit

    • The sticky bit is a special permission that can be set on directories, ensuring that only the owner of a file or the root user can delete or rename the file.
    • The main purpose of the sticky bit is to ensure the privacy and security of files in shared directories.

    Default Permissions and Umask

    • umask is an attribute of a process that is inherited by child processes, and is normally set at shell start-up.
    • umask "masks off" (disables) permission bits for any files or directories created by the process.

    File Permissions in Linux

    • Every file and folder in the file system has its own set of permissions, which determine who may access a file, and in what way(s).
    • There are three permission indicators: user (u), group (g), and others (o).
    • Permissions include:
      • Read (r): allows reading the file's contents.
      • Write (w): allows modifying the file's contents.
      • Execute (x): allows executing the file as a command, and scripts also need read permission to execute.

    Directory Permissions in Linux

    • Directory permissions are similar to file permissions, but have slightly different meanings.
    • Permissions include:
      • Read (r): grants permission to read the contents of the directory, and list contents using the "ls" command.
      • Write (w): grants permission to change or edit the directory content, and create or delete subdirectories and files.
      • Execute (x): allows access to and through the directory, but does not in itself allow reading or writing.

    Viewing Permissions

    • The "-l" (long) option to "ls" shows permissions and other details about files and directories.
    • The "ls -d" command on a directory shows the directory, not its contents.

    Setting Permissions

    • The "chmod" (change mode) command is used to change or grant permissions to different users or groups.
    • There are two methods to set permissions with "chmod": the symbolic method and the octal method.

    Symbolic Method for "chmod"

    • Permissions are set for user (u), group (g), others (o), or all (a).
    • Permissions are set by adding (+), removing (-), or setting (=) read (r), write (w), and/or execute (x) permissions.

    Octal Method for "chmod"

    • Permissions can be set explicitly by "chmod" with an octal number.
    • Octal numbers represent the permission bits, with read = 4, write = 2, and execute = 1.
    • Combine the octal representation of user, group, and other permissions to form a 3-digit octal number.

    Standard Input, Output, and Error

    • Every program or command has three open file descriptors: 0 (standard input), 1 (standard output), and 2 (standard error output).
    • These file descriptors can be attached to files, devices, or other commands.

    Input/Output Redirection and the Shell

    • The shell uses special characters and syntax to implement I/O redirection.
    • &lt; is used to read input from a file.
    • &gt; is used to write output to a file, overwriting the file if it exists.
    • &gt;&gt; is used to append output to a file.
    • I/O redirection can be used with any command, but it may not be useful with some commands (e.g., "date").

    Redirecting Error Output

    • The standard error output can be redirected using 2&gt; or 2&gt;&gt;.
    • 2&gt;&amp;1 sends the standard error output to the same place as the standard output.

    Input/Output and "/dev/null"

    • /dev/null is a special file that can be written to or read from, but the data is discarded.
    • /dev/null is useful for ignoring output or error messages.

    Connecting Commands with Pipes

    • Pipes connect the output of one command to the input of another command.
    • The | operator is used to create a pipe between commands.
    • Commands can be chained together in a specific order to achieve a specific task.

    The Unix Philosophy

    • The Unix Philosophy states that programs should:
      • Do one thing and do it well.
      • Work together.
      • Handle text streams, which is a universal interface.
    • Many Linux/Unix commands act as filters, reading input, processing or modifying it, and sending it as output.

    Process Management

    • Process management is crucial in operating systems, where programs executing are referred to as processes
    • The OS keeps track of processes and system resources to manage them fairly

    Monitoring Processes

    • System administrators need to monitor:
      • Which processes are running in the system
      • The current state of the processes
      • Resources these processes are taking
      • Which user started which process
    • Tools for monitoring processes:
      • "ps" command: offers a snapshot of processes
      • "pstree" command: offers a tree view of process, branching from parent process to child process
      • "top" command: offers a dynamic real-time view of processes

    The "ps" Command

    • Displays all processes of the current user by default
    • Options:
      • "-e" displays all processes currently running
      • "aux" displays user-oriented variant, all processes
      • "-u username" displays process of a user named username
    • Columns description:
      • PID: Process ID
      • TTY: The terminal that controls the process
      • Time: the number of hours, minutes, and seconds the process has been running
      • CMD: the command line, the process was called with

    Process States

    • Processes in Linux can exist in four different states:
      • (R)unning: currently using the CPU
      • (S)leeping: waiting in queue to use the CPU
      • s(T)opped: stopped (but not terminated), either by user or other process
      • (Z)ombie: terminated but waiting for its parent process to retrieve its exit code

    The "pstree" Command

    • Shows a tree view of all current processes
    • Processes are always instantiated by other processes
    • Your system starts with the "systemd" process
    • Parent processes start child processes

    The "top" Command

    • Provides a dynamic view of what’s going on
    • Shows process listed according to CPU usage
    • Shows memory usage and status

    Process Control

    • Two types of processes in Linux:
      • Foreground: interactive, initiated by a user and controlled through terminal session
      • Background: non-interactive, not connected to a terminal

    Starting a Process

    • Once you run a command or program, it will start a process in the system
    • You can start a process in the background by appending "&" at the end of the command line
    • System-related processes usually run in the background and are called daemons

    Terminating (Signalling) a Process

    • The "kill" command is used to send signals to processes
    • Syntax: "kill PID" (PID or %job)
    • The kill command sends signals to processes, including the terminate signal
    • Many different signals are available
      • Ctrl+Z sends the TSTP (terminal stop) signal

    Jobs – Foreground, Stopped, Background

    • The shell starts processes and allows you to stop/re-start and foreground/background processes (jobs)
    • Ctrl+Z stops the currently active foreground job and returns you to the shell prompt
    • The jobs command shows stopped and background processes
    • bg moves a job to the background, fg moves to foreground
    • Add a job number to affect a particular job e.g. bg %2

    Process Management in Windows

    • Monitor resource usage: CPU, Memory, Disk, Network, and GPU.
    • The Details tab of Task Manager shows the process states.

    Process Control in Windows

    • When an application is started, a process is created, which can be viewed in the Task Manager.
    • Right-clicking on the process name shows actions that can be taken on the specific process, including:
      • End task
      • Set Priority
      • Set Affinity

    Managing Processes Using PowerShell

    • Windows PowerShell provides the following commands for managing processes:
      • Get-Process: Get a list of running Windows processes
      • Start-Process: Start a process/program
      • Stop-Process: Forcibly stop (kill) a process
      • Debug-Process: Debug a process
      • Wait-Process: Wait until a process ends
    • Monitoring processes using Get-Process, and monitoring a specific process using Get-Process.

    Process Management Recap

    • Everything that runs on a computer is a process.
    • Processes in Linux are hierarchical - every process has a parent.
    • Tools like "ps", "pstree", and "top" are used to manage processes.
    • The shell allows foreground, stopped, and background processes.
    • Signals can be sent to processes with the "kill" command.

    Processes in Windows

    • Windows generally says "task" rather than "process".
    • A hierarchy of parent and child processes exists, and tasks can run as different users.
    • In code, CreateProcess(), WaitForSingleObject(), and CloseHandle() are used.
    • Microsoft documentation provides more information on processes and threads.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    ops102_2_1.pdf
    ops102_1_1.pdf
    ops102_1_2.pdf
    ops102_3_1.pdf
    ops102_3_2.pdf
    ops102_4_1.pdf
    ops102_4_2.pdf
    ops102_5_1.pdf
    ops102_5_2.pdf

    More Quizzes Like This

    Use Quizgecko on...
    Browser
    Browser