Professional Documents
Culture Documents
LongQuiz1and2PrelimAOS Converted Merged
LongQuiz1and2PrelimAOS Converted Merged
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match rm -r aos
• Question 3
"The head and tail commands, allow you to view the first few or last few lines of a file
(15 lines by default)."
Correct Answer: False
• Question 4
How would you write the code that will display the current calendar month
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match cal oct 2020
• Question 5
How to suspend current foreground process in Unix
Correct Answer:
CTRL + Z
• Question 6
Write a command that will create a file called file1.txt
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match touch file1.txt
• Question 7
The usrs directory contains configuration files that the system uses when the
computer starts.
Correct Answer: False
• Question 8
Command that will allow you to move a file in another directory
Correct Answer:
mv
• Question 9
Most shells keep a list of your recently used commands and allow you to recall a
command without retyping it.
Correct Answer: True
• Question 10
"How would you display the current calendar year, were the current day is selected"
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match cal -y
• Question 11
"The less command scrolls only down, whereas more enables you to scroll down and
up."
Correct Answer: False
• Question 12
Write the UNIX comannd that will create a directory called LONGTEST
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match mkdir LONGTEST
• Question 13
It indicates EOF end of file or exit
Correct Answer:
CTRL + D
• Question 14
Command that will allow you to create another name for a file
Correct Answer:
ln
• Question 15
The rm -r command can be used to delete a directory that is not empty.
Correct Answer: True
• Question 16
"Assuming you have newfile1.txt in your home directory home/leo/, how would you
copy newfile1.txt to a directory called backup"
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match cp newfile1.txt ./backup
• Question 17
"How would you list the content of the directory called ""Project"" that will show the permission of files in UNIX"
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match ls -l
• Question 18
Creates empty file and modifies the last modified timestamp
Correct Answer:
touch
• Question 19
You can use the date command to show the system calendar.
Correct Answer: False
• Question 20
Write the command that will display the current date following the sequence day month year
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match date +%d/%m/%y
• Question 21
It specify the entire file hierarchy
Correct Answer:
Absolute Path
• Question 22
UNIX/Linux systems interpret a single dot character to mean the current working
directory.
Correct Answer: True
• Question 23
How would you redirects the output of a command and appends to the file in Unix
Correct Answer:
>>
• Question 24
"How would you list the content of the directory called ""Project"" that will include hidden files in UNIX"
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match ls -a
• Question 25
"You use the ls command to display a directory's contents, including files and other
directories."
Correct Answer: True
• Question 26
It reprresent the current directory position
Correct Answer:
.
• Question 27
Command that will allow you to compare to text files in UNIX
Correct Answer:
diff
• Question 28
Write the UNIX comannd that will delete a directory called project
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match rmdir project
• Question 29
Stops screen output
Correct Answer:
CTRL + S
• Question 30
"Which among the following command line that will create files as series named f1,
f2, f4"
Correct Answer:
Both A and B
• Question 31
How would you redirects the output of a command to a file and overwrites the current
content of the file.
Correct Answer:
>
• Question 32
How would clean or clear the screen in UBUNTU
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match clear
• Question 33
The command cd source uses relative path addressing.
Correct Answer: True
• Question 34
"Assuming you have file1.txt inside project directory, how would you copy file1.txt to
the home directory "
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match cp file1.txt ../
• Question 35
Create a link file of science.txt and name it as science.link
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match ln science.txt science.link
• Question 36
"Assuming you have the following files ""fruits"" and ""prutas"", write a UNIX command
that will compare the the two files"
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match diff fruits prutas
• Question 37
It represents the route through the hierarchy that is traversed to reach the desired file
or directory
Correct Answer:
pathname
• Question 38
It reprresent the directory immediately above your current position
Correct Answer:
..
• Question 39
"In UNIX, what command should you use to rename or move a file to a different
directory"
Correct Answer:
Evaluation Method Correct Answer Case Sensitivity
Exact Match mv
• Question 40
"wc is a command in UNIX used to print newline, word, and byte counts of a file"
Correct Answer: True
False
Hostname
Ifconfig
Ipconfig
Uname
True
Pwd
Del
False
False
A component of a computer’s OS, this is a user interface for access to the operating system’s services.
Command line
Gui
True or false
Tree
Unix
1. An __________________ serves as a liason between the consumers and the resources, often
coordinating the allocation of limited resources among numerous consumers.
▪ operating system
2. Give the equivalent UNIX-LINUX command of the given DOS command: ATTRIB +h or -h
▪ mv file .file
3. _______ shell that was developed at the University of California Berkley by Bill Joy that allows
recalling and editing of previously entered commands and aliasing.
▪ C
4. ________ an operating system components that manages the operation of the computer.
▪ Kernel
5. _________ is a location for other files and subdirectories.
▪ Directory
6. Program Execution _________ the user program in memory and runs it.
▪ Loads
7. Unix Variants and its manufacturer
▪ Linus Torvalds - LINUX
▪ Sun Microsystems -SOLARIS
▪ Open Software Foundation – OSF/1
▪ Microsoft - FENIX
▪ Hewlett-Packard – HP-UX
▪ IBM - AIX
▪ Digital Equipment Compaq (DEC) – ULTRIX
8. __________ shell is similar to Korn shell, it is a command programming language and command
interpreter which supports command history, line editing, filename completion, aliasing, and job
control.
▪ POSIX
9. A __________________ is the operating system feature that manages the different computer
resources such as CPU time, memory space, file storage space, I/O devices, etc. and allocates
them to different application programs and users.
▪ resource allocator
10. ______________ (3 words) handles the way files are organized within the disk or tape. It takes
care of the creation and deletion of files for users.
▪ File system handling
11. _________ shell which is an original shell program that was developed for AT&T, provides a
UNIX system command interpreter and supports a programmable interface to develop shell
programs.
▪ Bourne
12. Common Subdirectories
▪ executables, system admin utilities, and library routines - /usr directory
▪ applications and third-party applications - /opt directory
▪ files which are pointers to device names - /dev directory
▪ system admin files (passwd file) - /etc directory
▪ user home directories Correct - /export/home directory
▪ basic operating system files - /kernel directory
▪ print spooling and mail system error messages - /var directory
25. A Linux command-line command allowing a user to change his/her own password is known
as – passwd
26. What is Terminal? – a program which enables you to access the shell
27. A command line command in Linux used for deleting files and directories is known as - rm
28. Which of the following commands allows for moving one level up in Linux directory tree? –
cd ..
29. Which of the following key combinations allows to terminate the current process in Linux
shell? – Ctrl + C
30. Which of the following commands in Linux is used to display information about files and
directories contained within the current working directory? - ls
What is an Operating System?
Disks
Users
Memory
CPU
Operating System
Programs Network
Printers
Consumers Resources
UNIX Operating System
An operating System can be thought of as
1. Resource Allocator – the operating system manages the
different computer resources such as CPU time,
memory space, file storage space, I/O devices, etc. and
allocates them to different application programs and
users.
2. Control Program – it controls the execution of programs
and the various I/O devices.
Unix Services
An operating system provides the following services for users:
1. Program Execution – loads the user program in memory and
runs it.
2. I/O Operations – responsible for reading and/or writing data
from I/O devices such as disks, tapes, printers, keyboards, etc.
3. File System Handling – handles the way files are organized
within the disk or tape. It takes care of the creation and
deletion of files for users.
4. Error Detection – detect errors within the computer system
(CPU, memory, I/O, or user program) and take the appropriate
action.
History of UNIX
1969 UNIX developed by AT&T Bell Labs
1980 UC Berkeley BSD UNIX 4.2 becomes widely used
Early 1980s Hewlett-Packard introduces HP-UX
Early 1990s POSIX, Portable Operating System Interface
UNIX Variants
•AIX – from IBM
•HP-UX – from Hewlett-Packard
•Ultrix – from DEC
•Xenix – from Microsoft
•OSF/1 – from Open Software Foundation
•Solaris – from Sun Microsystems
•Linux – Linus Torvalds
•Ubuntu
•Suse (Novell Netware)
•Red Hat
•Debian
UNIX Varieties and Benefits
Benefits of UNIX
•based on an open standard
•supported on a wide variety of computers
•TCP/IP tightly integrated
•true 64bit architecture
•Hierarchical File System
•Multi-tasking; Multi-user
File System Directory Hierarchy
File System - group of directories that
can be thought of as a separate tree
structure
similar to logical partitions in the
Windows/DOS world (like C: or D:
drive)
made available (mounted) or
unavailable (unmounted) at the
administrator’s discretion
can either be local (on your computer)
or remote (on another computer)
Directory - location for other files and
subdirectories
like a file drawer in a file cabinet
Subdirectory - Any directory below
another directory
Files - contained in directories and
subdirectories
Common Subdirectories /usr directory - executables,
system admin utilities, and library
routines
/opt (optional) directory -
applications and third party
applications
/dev (devices) directory - files
which are pointers to device names
/etc (etcetera) directory - system
admin files (passwd file)
/export/home directory - user
home directories
/kernel directory - basic operating
system files (main UNIX kernel
genunix)
/var (variable) directory - print
spooling and mail system error
messages
Operating System Components
Shells
Bourne shell ($)
•developed by Stephen Bourne for AT&T
•original shell program
•Provides a UNIX system command interpreter
•Supports a programmable interface to develop shell programs
Korn shell ($)
•developed by David Korn at Bell Labs
•An enhanced Bourne shell
•added features such as aliasing and history
•most widely used shell and is industry standard for users
•this course is based primarily on the Korn shell
Shell cont..
C shell (%)
•developed at the University of California Berkley by Bill Joy
•Short California Shell
•based on the C programming language
•Allows recalling and editing of previously entered commands and
aliasing
POSIX shell
•Similar to Korn shell
•Command programming language and command interpreter
•It supporst command history, line editing, file name completion,
aliasing, and job control
Chapter 2
Logging In and General Orientation
Login ID and Password
Login ID
•user’s “public name”
•must be unique and limited to eight lower case letters and numbers
•stored in the password (/etc/passwd) file which can be viewed by all users
•encrypted passwords are stored in the /etc/shadow file
Passwords
•no less than six and no more than eight characters
•different from the Login ID
•at least two alphabetic characters and one numeric or special character
•case sensitive
•new password must differ by at least three characters
•may contain spaces and special characters
•these password rules do not apply to the root account!
User Accounts
Root or "super user"
•system admin
•set up by default during the installation process
•owns all system files and has access to all files
•used to create new users, manage file systems, install software and
perform other high-level system admin tasks
•Most sysadmins have a regular user account and only login as root when
necessary to perform administrative tasks
Regular User
•created and maintained by the sysadmin when logged on as root
•can run applications programs and customize working environment
•can also create and modify files in their home directory
Changing Password
➢there’
$(
$ if
*press ctrl c if you want to terminate currently running
program
Some Beginning Commands
$who – is used to determine the users currently
logged in the system.
$finger – same as who
$whoami – is used to determine who is currently
logged-in at a particular terminal.
$date - reports the date and time
$passwd - assign a login password
Some Beginning Commands cont.
• $echo - writes arguments to the terminal
• $clear - clears the terminal screen
• $write - sends message to username if logged in
• $talk -
• $mesg [y|n] - allows or denies writes to your terminal
Some Useful Keys to Remember
• Ctrl+C – Use this to abort a running UNIX program
• Ctrl+S – Use this freeze a screen output
• Ctrl+Q – Use this to unfreeze a screen output
• Ctrl+R – Use this to refresh or redraw your screen
• Ctrl+L – Use this if Ctrl+R does not work
• Backspace – Use this to erase mistakes before pressing the Enter key
Logging out
• Ctrl+D
• exit
man pages
Unresponsive Application:
•Determine the process ID number associated with the
application and kill that process (chap 13)
•Logout and log back in again then restart the application .
Chapter 4
Accessing Files and Directories
Path Names
• A path name represents the route through the hierarchy that is
traversed to reach the desired file or directory
Types of Pathnames
Absolute Pathname
•Specifies the entire file hierarchy
•Start at root (/) and list each directory along the path to the
destination
•Slash (/) between each directory name in the path
•Example:
/home/user3/f1
Relative Pathname
•Always starts at your current location in the hierarchy
•If a pathname does not begin with a slash, it is a relative
pathname
•you must know what directory you are currently in since that is
your starting point
Absolute Path
Absolute Path
• Absolute pathname to the user2 directory
• /home/user2
• Absolute pathname to the dir1 directory
• /home/user2/dir1
• Absolute pathname to the coffees directory
• /home/user2/dir1/coffees
Relative Path
Relative Path
• If your current directory is /home:
/home ..
/home/user2 ../user2
/home/user1/f1
../user1/f1
/ ../..
.
./f1
./memo/f1
Examples of dot dot
• If you are currently in the directory /home:
• ..
• ../..
• ../tmp
• ../tmp/f1
• If you are currently in the directory /home/user3:
• ..
• ../..
• ../user2../user1/f1
• ../../tmp/f1
Using Navigation Shortcuts
pwd (print working directory) command -
•no options or arguments
•displays directory using absolute path name
ls –a
list all files in a directory, including hidden (.) files and current (.) and parent (..)
directories
ls –F
displays listing with a symbol to tell what the type the file is:
directory – A forward slash (/) after the name
ASCII Text File - no symbol
Executable – asterisk (*) after the name
Symbolic Link – An at sign (@)
Displaying Long Listing
Recursive Listing
ls -R (recursive) command
- Displays the contents of all directories, subdirectories and their contents for a particular part of
the directory tree
- If done at a high level in the directory structure, the output can be substantial!
Creating & Removing Files & Directories
mkdir - creates directories or folders
must have the appropriate permissions to create a directory
–p (parent) option creates parent directories while creating lower level directories, including all
the directories in a pathname
tail
•displays the last n lines of a file
•last 10 lines are displayed by default if the -n
option is omitted.
•allows you to check the end result of the backup
without looking at the whole file
•-n option allows you to start displaying lines from a
specific point in a file
wc and diff Commands
wc (word count) command
•displays line, word, byte or character counts for a text file
•without options will give a line, word, and byte count of the contents of the file
Option Function
-l Counts lines
-w Counts words
-c Counts bytes
-m Counts characters
diff (difference) command compares two text files and finds differences
Command Format: $ diff [option] file1 file2
–i option ignores the case of the letters
–c option performs a detailed comparison and produces a listing of differences with three lines of
context
Copy Files
• Syntax:
• cp [-i] file1 new_file
• cp [-i] file [file…] dest_dir
• cp –r [-i] dir [dir…] dest_dir
• Examples:
• $ ls –F
• $ cp f1 f1.copy
• $ ls –F
• $ cp note remind memo
Move or Rename Files
• Syntax:
• mv [-i] file1 new_file
• mv [-i] file [file…] dest_dir
• mv [-i] dir [dir…] dest_dir
• Examples:
• ls –F
• mv f1 file1
• ls –F
• mv f2 memo/file2
• ls –F
• ls –F memo
diff Output
Link Files
Syntax:
ln file new_file
ln file [file. . .] dest_dir
Example:
$ ls –l f1
$ ln f1 /home/user2/f1.link
$ ls –l f1
$ ls –l /home/user2
$ ls –i /home/user2/f1.link
Chapter 6
File System Security
Filename Specifications
•Maximum of 14 characters
•Maximum of 255 characters if long
filenames are supported
•May contain alphabetic, numeric, dot,
dash and underscore
Security Policies
•The UNIX system incorporates a 3-tier structure to define who has
access to each file and directory:
User Group Others
•The ls –l command displays the owner and group who has access to
the file
•Default for Files
Read/Write for User and read only for Group and Other
•Default for directories
Read/Write/Execute for User and Read/Execute for Group and Other
File Types
•- regular file
•d directory
•l symbolically linked file
•n network special file
•c character device file
•b block device file (disks)
File System Permissions
- rw-r-- r--
drwxr-xr-x
user - owner / creator of file or directory
group – permissions used by members of the group that owns the file or directory
other – all users other than the file owner, and members of the group that owns
the file or the directory.
Permissions
User & Group ID
$ ls -n
displays the UID and the GID
$ id
displays numeric and alphabetic User ID and Group ID for your Effective User ID (EUID)
$ groups
displays all of the groups you are a member of
Changing Permissions Syntax
$ chmod mode filename
We use the chmod command to change the access mode of a file
Op - Operator
set (=)
remove (-)
give (+)
• Computation:
• 7778 = (111 111 111)2
• 1748 = (001 111 100)2
• NOT(001 111 100)2 = (110 000 011)2
• (111 111 111)2 AND (110 000 011)2 = (110 000 011)2
• 7778 NOT (174)8 (603)8
Other commands
touch - either creates one or more files with zero bytes if
none exists; or updates date/time stamp if file already exists
-a time change access time to time
-m time change modify time to time
-t time use time as your current time
-c if the file does not already exists, do not create it
• Syntax:
• $ chgrp newgroup filename
su - switch user id
• Changes your user id and group id designation
• Syntax:
• $ su [username]
The newgrp command
• Changes the group id.
• Syntax:
• $ newgrp [group_name]
chown
Change file ownership
Syntax: