Operating system: The operating system is an organized group pf ... - DOC
Shared by: HC120911203524
-
Stats
- views:
- 0
- posted:
- 9/11/2012
- language:
- Latin
- pages:
- 3
Document Sample


COS 231: Introduction to UNIX – Spring 2002 Midterm Exam - preparation Mar 05,2002
Midterm Exam – preparation 05 March 2002
1. Write command lines to:
a. Display the long listing of all files including
the subdirectories in /usr/home/ $ ...................................
b. You have two files: f001 and f002 in your home
directory. Write the command which will modify the
content of file f002. The content of f002 should be:
<content of f002> <content of f001> <content of f002>: $ ..............................
c. Make a symbolic link (named locbin) in your home
directory to locbin directory, which is two levels up from
your home: $ .............................
d. What command will tell you your User Id (uid) and
name and your Group ID (gid) and name? $ ……………………
e. What command allows you to change your password? $ …………………….
f. Give the command that prints the name of the current
directory file $ ………………………
2. If the following command lines are legal?
Write True or False.
a. $ cat f001 /usr/vak/cos231/f002 > /usr
b. $ ls –l | sort | cat > f002
c. $ mkdir ./test1; cp f001 f002 ./test1
d. $ rm –i f*[1-5,r-z]
e. $ mv ?*[abcd]? ~
3. Who can (owner, group, other, and all) :
(a) execute the following files ?:
-rwx------ 2 vak cos_231 17568 Sep 21 10:56 fil_001 . . . . . .
---x--xrw- 2 vak cos_231 17568 Sep 21 10:56 fil_001 . . . . . .
(b) read the following files?:
--wx-wx-wx 2 vak cos_231 17568 Sep 21 10:56 fil_001 . . . . . .
-rwxr---w- 2 vak cos_231 17568 Sep 21 10:56 fil_001 . . . . . .
(c) write the following files?:
dr-xr-xr-x 2 vak cos_231 17568 Sep 21 10:56 fil_001 . . . . . .
-rwxrw---x 2 vak cos_231 17568 Sep 21 10:56 fil_001 . . . . . .
V. Karagiozov 1/3
COS 231: Introduction to UNIX – Spring 2002 Midterm Exam - preparation Mar 05,2002
4. Give group file name (wild card), if it is possible:
a. all files that have a "p" as a second and "d" or
"F" as a last char.
b. all files that start with a "p", have "d"
somewhere inside and the last is "u".
c. all files that start with a digit or char "p" and
end with a two digits.
d. all files that start with an uppercase letter and
are only three char long.
e. all files that have an uppercase letter
somewhere inside their names
.
6. Given the following file:
In fact, information on file ownership, permissions, and so forth is
provided only by filesystem types that are meant to be used for
storing Linux files. For filesystem types that don't store this
information, the kernel drivers used to access these filesystems
"fake" the information.
Perform the following sequience of vi commands
j dd k dd j dd “2p Esc :s/file/pile/g H dd dd 6Wd$
What will be the final content of the file?
7. You are user syyy. Write the command(s) to execute the script filescript
-rw-r--r-- 1 syyy group 1234 Oct 8 8:23 filescript
8. Is the following a relative or absolute filename reference: ./330/assn1
9. What will output this script if executed?
set `w|grep USER`
echo $*
echo $2, $1, $8
The sample of the output from w command:
10:01pm up 24 days, 7:35, 4 users, load average: 0.13, 0.05, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
volin pts/2 193.68.137.186 8:43pm 0.00s 0.15s 0.02s w
tsvetk pts/4 193.68.141.13 9:58pm 2:19 0.04s 0.01s -bash
paulp pts/3 193.68.141.158 12:31pm 4:28m 0.10s 0.10s -bash
10. Give the command that lists only background processes running
on the current terminal.
11. You have 3 jobs in the background. Give the command and argument to bring the job
whose job_id is 2 to the foreground.
12. Job 1 is suspended. Restart it in the background
V. Karagiozov 2/3
COS 231: Introduction to UNIX – Spring 2002 Midterm Exam - preparation Mar 05,2002
13. Given the following information: cmd=”echo oops” What will the following print
a. echo '$cmd' # single quotes
b. echo "$cmd" # double quotes
c. echo `$cmd` # agraves
14. If the variable cmd set up as follows: cmd="ls – l"
What command can run the commands stored in the variable cmd?
Suppose the file testreg contains 7 lines, three of them are empty lines:
Line1 aaa
Line2
Line3 dcdc
Line4
Line5 cccc
Line6
Line7 fffff
15. What these commands will output?
grep '.*' testreg |wc –l
grep 'a?*' testreg |wc –l
grep '..*' testreg |wc –l
grep 'v*g*' testreg |wc –l
grep '[a|c]' testreg |wc –l
16. What this pattern matches: \<the
17. What this pattern matches: the\>
18. What will be printed by this command? ( is a space)
$ echo Hey! What's next? Mike's #1 friend has $$.
19. What this pattern matches: ^bag$
20. Are these two commands equivalent?
$ cat food 2>&1 >file
$ cat food >file 2>&1
V. Karagiozov 3/3
Get documents about "