practice
.pdf
keyboard_arrow_up
School
Simon Fraser University *
*We aren’t endorsed by this school
Course
5375
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
3
Uploaded by BailiffRaven3669
CS 3375 001
Practice Exam Questions
1.
General knowledge (15)
a. Name two unix servers (Sun solaris) you can log into at UTD.
b. The file
test_file
has been created and you have permission to read and execute it.
Provide four different unix commands (Sun solaris) to view the contents of the file (not
edit the file).
b. Provide the commands to delete a line of text in the Pico, Vi, and emacs editors.
c. The cs 3375 subdirectory under Dr. Cooper’s account has the following directory in it:
drwxr-xr-x
2 kcooper
cs
512 Nov
2 14:23 shell
Provide a sequence of one or more commands to make a copy of this directory and its
contents into your own 3375 directory.
d. Describe the 9 file permission bits in terms of their purpose and organization.
e. Given the following file permissions, can someone other than the owner who is outside
the group
cs
change directories to the
shell
directory? Explain why or why not.
drwx---r-x
2 kcooper
cs
512 Nov
2 14:23 shell
2. Shell environment and scripting (15)
a. “sha-bang”
- What is the purpose of the “sha-bang” syntax used at the beginning of a script?
- Provide the syntax for a BASH script.
- Is it possible to execute a script file that does not have the “sha-bang” line in it?
b. What is the difference between job control and process control? Give an example of
two commands for each.
c. Circle all the statements that are true:
- BASH is the only shell available for unix (Sun Solaris)
- The presence or absence of whitespace in a BASH script never makes a difference in
the interpretation of a script
- PATH and XTERM are environment variables
- Single quotes, double quotes, and backquotes all behave exactly the same way in BASH
- the * meta-character means zero or more matches
- the ? meta-character means exactly 2 matches
d. The contents of a directory contains the following files that you have read and execute
access to:
chap
chap01
chap03
chap15
chap17
chapy
chap.txt
chap02
chap04
chap16
chapx
chapz
.txt
Give a command to:
-
list all the files
- list the files that have the characters chap, followed by either a 0 or a 1, followed by any
number of arbitrary characters
What is the result of the following command?
ls chap[a-z]*.*
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
create a Python script. Your script should:
Ask the user for the name of a file (if the file exists it will be in the current directory). If the file does not exist, your script should inform the user of the error and let them try again.
Allow the user to exit the program gracefully without actually processing a file - you may choose how to do this, just make sure the user knows!
The program should only display the first five (5) lines of the file's content. If the file contains less than five (5) lines, it should display the file's entire content.
Be sure your script can handle at least the following conditions:
*The file does not exist
*There are no lines in the file
*There are more than five lines in the file
*There are exactly five lines in the file
arrow_forward
Description (for python please)
This is a command line program, dl_cu.py that accepts two parameters:
a root directory
a best before date in the form YYYY-MM-DD
Based on these inputs dl_cu.py generates a report lists all of the files thathaven't been modified since the best before date. The output includes:
The full path of each file
The modification date of the file
The file file size in MB
After presenting the user with this list it will ask them if they would like todelete all of of the listed files and any empty directories stored in the root directory.
arrow_forward
A - Z
B = Y
C = X
D = W
E - V
F = U
G = T
H = S
I = R
J = Q
K = P
L = 0
M = N
N - M
O = L
P = K
Q = J
O 3D
R - I
S = H
T = G
U = F
V - E
W - D
X = C
Y = B
Z - A
SLD NZMB KILTIZNNVIH WLVH RG GZPV GL XSZMTV Z ORTSG YFOY?
MLMV, GSZG'H Z SZIWDZIV KILYOVN
OUTPUT
It should generate a file named out.txt
Contents of out.txt:
Message Num: 1
Coded Message
SLD NZMB KILTIZNNVIH WLVH RG GZPV GL XSZMTV Z ORTSG YFOY?
Decoded Message
HOW MANY PROGRAMMERS DOES IT TAKE TO CHANGE A LIGHT BULB?
Message Num: 2
Coded Message
MLMV, GSZG'H Z SZIWDZIV KILYOVN
Decoded Message
NONE, THAT'S A HARDWARE PROBLEM
Please note in your output file print a newline (outToFile<
arrow_forward
Second script (awk)
Write a short awk script (in a file named num.awk) that accepts as argument a single file and prints to the terminal the file with the lines numbered
arrow_forward
Linux Help please - DON'T COPY FROM CHEGG, I WILL REPORT
arrow_forward
Using only Unix system calls(like open, seek(), tell, etc.), write a C program to reverse the order of the lines in a
text file.
The first line becomes last, the second line becomes the one before the last one and so on.
Note: your program should have two arguments, the input file name and the output file name.
Call model: reverseFile
arrow_forward
C programmnig
arrow_forward
None
arrow_forward
In a UNIX-like file system, a directory typically contains:
A.
filenames and i-nodes
B.
permission information, pointers to direct blocks
C.
filenames and ownership information
D.
filenames, i-nodes, major device numbers and minor device numbers
arrow_forward
PLeae write in python
The populated contacts.txt file with at least 5 contacts
1 screenshot of executed code in command line/terminal window for the print address book option (either paste into Word document or as an image)
1 screenshot of executed code in command line/terminal window for the search contact option (either paste into Word document or as an image)
arrow_forward
System Administration
Shell Scripts: exercises sheet 2
Exercise 1:
Write a shell script that displays the contents of the directories existing in a directory given as
argument (use the for loop)
Exercice 2:
Write a shell script that displays the contents of subdirectories of the directories that are given as
arguments. The script should be called with any number of parameters.
Exercice 3:
Write a shell script that displays the nth line of a file(you can use head and tail). The integer n and
the input file name are given by the user in response to the request of the script (use the command
read). Try to do all possible tests (file exists or not etc...)
Exercise 4:
Write a shell script that give a variable x the following content "School man women fish dog cat
sheep" and then print each word in a separate line on the screen (use the for loop).
Exercise 5:
Propose a shell script that displays the number of files in the present working directory.
arrow_forward
With in 10 min please
arrow_forward
Answer all questions else downvote
question 1.
Create a script where you prompt the user for input, and the value provided will be a user. Loop through each file in that user's home directory (ignore the sub directories) and count the number of times a file contains the word ERROR (hint use 'wc' command to help with counting) and output the total number of errors at the end of the script.
Once completed, take a screenshot of the source code of the script, and of the script executing, to execute the script you will need to create your own sample input, please include the sample input as part of your execution screenshot.
question 2.
What would be your current working directory if you changed directories to /log/././././../media/log/ssh/test/../users/
question 3.
What would be your current working directory if you changed directories to /opt/test/usr/www/sbin/boot/pdfs/./spool/share/etc/./bin/.././httpd/
arrow_forward
plase jelp me
arrow_forward
COMP-1034: Files and CSV Practice Problems1. Write a Python script to read a text file and display its content.2. Write a Python script to write a text file with some content.3. Write a Python script to append text to an existing text file.4. Write a Python script to copy the contents of one file into another file.5. Write a Python script to count the number of lines in a text file.6. Write a Python script to read a text file and find the longest word.7. Write a Python script to read a text file and find the shortest word.8. Write a Python script to read a text file and replace a specific word with another word.9. Write a Python script to read a CSV file and display the data.10. Write a Python script to write a CSV file with some data.11. Write a Python script to append data to an existing CSV file.12. Write a Python script to count the number of rows in a CSV file.13. Write a Python script to count the number of data rows in a CSV file. This means to excludethe header row.14. Write a…
arrow_forward
Write a Python program to copy the content of
one file to the another file which is placed in same
directory.
Remeber:- Your code must be short & crisp
arrow_forward
write c program? plz single c file
write a program that will copy all files under the given folder to another one. In order to be able to complete this assignment, you have to research how to obtain the list of files in a directory in Linux. You must copy each file in a separate process. The folder name should be obtained from the arguments. You must perform all error checks?
arrow_forward
* Question Completion Status:
QUESTION 11
Wite a program (mymv infile outfile) to rename a infile as outfile using file system calls, link(), and unlink()
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac).
BIUS
Paragraph
Arial
10pt
P.
QUESTION 12
Write a program that takes the file name as the command line argument and outputs the size of the file in byte
the file)
!!
!!!
arrow_forward
Please comment all code
Using a python editor, write a python script that imports os and does the following: it changes the directory to net created previously, it displays the current directory, it checks if the path to one of the subdirectories of net exists, it checks if the name of one of the files created previously is a directory, it returns the sizes of both files, uses for a loop to print the content of net as a list of strings, uses a for loop to retrieve all files with the extension .xlsx, uses a for loop to join a few files to the net
arrow_forward
79.
The type of allocation in which blocks of file are allocated to consecutive blocks of disks is classified as
a.
indexed allocation
b.
header allocation
c.
contiguous allocation
d.
linked allocation
arrow_forward
Is -lah shows a file with the following permissions:
1 sally org 1.7K Jun 2 22:01 demo
The user sally needs to read and write, member of org need to read and execute, and
others on the system cannot use the file.
Write a command or commands to change the permissions as specified.
arrow_forward
Computer Science
Hello I have a Powershell question but my answer doesn't seem to work. The answer columns are where the blank contents are supposed to be filled
Before you begin, create a new text file located in C:\MyTextFile.txt, add ten lines of text to it, and save the file.
Complete the PowerShell script below by filling-in the missing information so that the script will satisfy the following requirements:
Read the contents of the text file you created earlier.
Using a while loop, display each line of text one line at a time in the console window.
Solution Clear-Host Answer = Answer Answer = Answer Content -Path 'C:\MyTextFile.txt' Answer ( $lineNumber Answer le $fileContents.length ) { Answer line = $fileContents[ Answer ] Write-Host "Line $lineNumber Contents: Answer " $ Answer + }
This is what I have so far for my answer
Clear-Host
$lineNumber = 0
$fileText = Get-Content -Path
'C:\MyTextFile.txt'
while ( $lineNumber -le
$fileContents.length)
{…
arrow_forward
122.
Which is a duplicate copy of a file program that is stored on a different storage media than the original location:
a.
Concurrency
b.
Deadlock
c.
Backup
d.
Recovery
arrow_forward
UNIX ASSIGNMENT - IXQuestion 8 : Rename all the files within a folder with suffix “CS_” i.e. suppose a folder has two files file_a.txt and file_b.pdf than they both should be renamed from a single command to CS_a.txt and CS_b.pdf
arrow_forward
Bash shell/Linux
arrow_forward
Question 5
Full explain this question
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- create a Python script. Your script should: Ask the user for the name of a file (if the file exists it will be in the current directory). If the file does not exist, your script should inform the user of the error and let them try again. Allow the user to exit the program gracefully without actually processing a file - you may choose how to do this, just make sure the user knows! The program should only display the first five (5) lines of the file's content. If the file contains less than five (5) lines, it should display the file's entire content. Be sure your script can handle at least the following conditions: *The file does not exist *There are no lines in the file *There are more than five lines in the file *There are exactly five lines in the filearrow_forwardDescription (for python please) This is a command line program, dl_cu.py that accepts two parameters: a root directory a best before date in the form YYYY-MM-DD Based on these inputs dl_cu.py generates a report lists all of the files thathaven't been modified since the best before date. The output includes: The full path of each file The modification date of the file The file file size in MB After presenting the user with this list it will ask them if they would like todelete all of of the listed files and any empty directories stored in the root directory.arrow_forwardA - Z B = Y C = X D = W E - V F = U G = T H = S I = R J = Q K = P L = 0 M = N N - M O = L P = K Q = J O 3D R - I S = H T = G U = F V - E W - D X = C Y = B Z - A SLD NZMB KILTIZNNVIH WLVH RG GZPV GL XSZMTV Z ORTSG YFOY? MLMV, GSZG'H Z SZIWDZIV KILYOVN OUTPUT It should generate a file named out.txt Contents of out.txt: Message Num: 1 Coded Message SLD NZMB KILTIZNNVIH WLVH RG GZPV GL XSZMTV Z ORTSG YFOY? Decoded Message HOW MANY PROGRAMMERS DOES IT TAKE TO CHANGE A LIGHT BULB? Message Num: 2 Coded Message MLMV, GSZG'H Z SZIWDZIV KILYOVN Decoded Message NONE, THAT'S A HARDWARE PROBLEM Please note in your output file print a newline (outToFile<arrow_forwardSecond script (awk) Write a short awk script (in a file named num.awk) that accepts as argument a single file and prints to the terminal the file with the lines numberedarrow_forwardLinux Help please - DON'T COPY FROM CHEGG, I WILL REPORTarrow_forwardUsing only Unix system calls(like open, seek(), tell, etc.), write a C program to reverse the order of the lines in a text file. The first line becomes last, the second line becomes the one before the last one and so on. Note: your program should have two arguments, the input file name and the output file name. Call model: reverseFilearrow_forwardC programmnigarrow_forwardNonearrow_forwardIn a UNIX-like file system, a directory typically contains: A. filenames and i-nodes B. permission information, pointers to direct blocks C. filenames and ownership information D. filenames, i-nodes, major device numbers and minor device numbersarrow_forwardPLeae write in python The populated contacts.txt file with at least 5 contacts 1 screenshot of executed code in command line/terminal window for the print address book option (either paste into Word document or as an image) 1 screenshot of executed code in command line/terminal window for the search contact option (either paste into Word document or as an image)arrow_forwardSystem Administration Shell Scripts: exercises sheet 2 Exercise 1: Write a shell script that displays the contents of the directories existing in a directory given as argument (use the for loop) Exercice 2: Write a shell script that displays the contents of subdirectories of the directories that are given as arguments. The script should be called with any number of parameters. Exercice 3: Write a shell script that displays the nth line of a file(you can use head and tail). The integer n and the input file name are given by the user in response to the request of the script (use the command read). Try to do all possible tests (file exists or not etc...) Exercise 4: Write a shell script that give a variable x the following content "School man women fish dog cat sheep" and then print each word in a separate line on the screen (use the for loop). Exercise 5: Propose a shell script that displays the number of files in the present working directory.arrow_forwardWith in 10 min pleasearrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education