Toggle navigation
Home
Blog
Carnivorous Plants
Critter Camera
Publications
Projects
Project Supervision
Courses
Sonoma State University
Department of Computer Science
CS-210: Introduction to Unix
Exercise 7
Objective:
Testing one's knowledge of Unix commands in preparation for the midterm exam.
Question 1:
Presume the following three text files exist in your home directory on Blue:
alpha.txt
bravo.txt
charlie.txt
Using standard output and redirection, what is the syntactically-correct Unix command to merge the contents of
alpha.txt
,
bravo.txt
, and
charlie.txt
into a single file called
merged.txt
in your home directory. You may NOT safely assume you are currently in your home directory (i.e. you are in some random directory on the Unix system).
Question 2:
What is the syntactically-correct Unix command to create an alias "uu" which changes to the parent directory of the parent directory from your current working directory when you type "uu" on the command line? Specifically, I want to be able to go up two directory levels (parent directory of parent directory) with one command.
Question 3:
Inside your home directory is the directory
My Documents
. This directory contains a mixture of directories and files. The files could be one of three possible formats: simple text, Microsoft Word, or Adobe Acrobat. Each file contains an appropriate extension for its file type:
Text files have a ".txt" extension (e.g. "simple.txt");
Microsoft Word format files contain a ".docx" extension (example: "resume.docx");
Adobe Acrobat's portable document format files contain a ".pdf" extension (example: "resume.pdf").
What is the syntactically-correct Unix command to locate all text files inside
My Documents
and all its sub-directories?
Question 4:
What is the syntactically-correct Unix command to redirect standard input to a file name
myfile.txt
in your home directory? You may safely assume
myfile.txt
does not exist in your home directory.
Question 5:
Inside your home directory is a file named
secret
. What command would you type to change the permissions of the file
secret
as follows:
User permissions: read access, write access, no execute.
Group permissions: no read access, no write access, no execute.
World permissions: no read access, no write access, no execute.
Question 6:
Presume the following five text files exist in your home directory on Blue:
recipe1.txt
recipe2.txt
recipe3.txt
recipe4.txt
recipe5.txt
Using brace expansion and standard output, what is the syntactically-correct Unix command to concatenate these files together into a file called
ALL_RECIPES.txt
in the following order:
recipe5.txt
is the first file to be appended to
ALL_RECIPES.txt
recipe4.txt
is the second file to be appended to
ALL_RECIPES.txt
recipe3.txt
is the third file to be appended to
ALL_RECIPES.txt
recipe2.txt
is the fourth file to be appended to
ALL_RECIPES.txt
recipe1.txt
is the fifth file to be appended to
ALL_RECIPES.txt
Question 7:
A file named
mystery
is located in your home directory on Blue. What is the syntactically-correct Unix command to determine what type of file
mystery
is (i.e. image file, text file, sound file, video file, etc.)?
Question 8:
What is the syntactically-correct Unix command to search for filenames containing the case-sensitive text,
$how me the money!
anywhere in the filename in your home directory (and all sub-directories in your home directory on Blue)?
Question 9:
A directory named
My Documents
is located inside your home directory on Blue. Inside
My Documents
, you need to create the following twelve directories:
2026-01
2026-02
2026-03
2026-04
2026-05
2026-06
2026-07
2026-08
2026-09
2026-10
2026-11
2026-12
Using brace expansion, what is the syntactically-correct Unix command to create the directories above inside
My Documents
?
Question 10:
What is the syntactically-correct Unix command to display my user identification number (uid) and group identification number (gid)?
Submission Instructions:
Please submit your answers to Canvas for the questions above.