i
th entry in file 1 corresponds to the
i
th entry in file 2 for all entries. Answer questions
29 and 30.
29. What command could you issue to create a file containing all names and phone num-
bers, properly organized?
30. Assume that the phone.txt file is incomplete so that some entries do not contain
phone numbers. The numbers between the two files still correspond (for instance,
if the 3rd person’s phone number is missing, the phone.txt file skips a line with the
entry 3). Revise your command from question 29 so that missing phone numbers are
indicated with the word UNKNOWN.
31. Explain what the split instruction does.
Navigating the Linux File System
◾
121
32. Imagine that you have a large multimedia (1 GB) file (e.g., a movie stored as an mpg
or avi file). You want to break up the file into smaller 100 MB files. Provide a com-
mand to accomplish this so that the file components are all numbered like 00, 01, 02,
03 after their name.
33. What is the difference between
wc foo1.txt
and
wc –l foo1.txt
?
34. Referring to Figure 3.3, write a command to create a symbolic link of the file in zap-
paf’s directory foo1.txt from foxr’s temp directory. How would your command differ
if you wanted to create a hard link?
35. Assume that file alink is a symbolic link to the file afile located in another directory.
What happens to afile if you delete alink? What happens to alink if you delete afile?
36. Repeat question 35 assuming that alink is a hard link instead of a symbolic link.
37. Write a find command to find and list all files in the current directory accessed within
the last 3 days.
38. Write a find command to find all files in your home directory modified less than
60 min ago and delete them.
39. Write a find command to perform wc -l on all files in your home directory newer than
the file myfile.txt.
40. Write a find command to find all files in the entire file system (starting at /) whose
permissions are 666 and change them to 664.
41. Write a find command to find all files in the current directory whose size is between
1000 and 10,000 bytes.
Assume for questions 42 through 50, we have the following partial long listing of
files and subdirectories in the current directory. Also assume that you are not user
foxr but you are in the group cool. Answer each question independently (i.e., do not
assume that a previous instruction changed the permissions as shown below).
drwxrwxr-- foxr foxr . . . subdir1
drwxr-xr-- foxr cool . . . subdir2
-rw-rw-r-- foxr foxr . . . foo1
-r-xr-xr-- foxr foxr . . . foo2
-rwxr----- foxr cool . . . foo3
-rw-r--r--
foxr foxr . . . foo4
-rw-rw-rw- foxr foxr . . . foo5
42. Provide the 3-digit permissions for each of the items listed here.
43. Write a chmod command to permit execute access both group and world for foo3
using the ugo
=
approach.
122
◾
Linux with Operating System Concepts
44. Write a chmod command to permit execute access both group and world for foo3
using the ugo
+
/- approach.
45. Write a chmod command to permit execute access both group and world for foo3
using the 3-digit approach.
46. Write a chmod command to permit write access to foo4 for group but remove read
access for world using the ugo
+
/- approach.
47. Write a chmod command to remove all group and world access to foo1 using the
ugo
+
/- approach.
48. Write a chmod command to remove all group and world access to foo1 using the
3-digit approach.
49. As a member of cool, do you have the ability to cd into subdir2?
50. Of the items listed here, which have permissions that you think should be altered?
Why?
51. Which of the following permissions you generally do not see in a Linux system? Why
not?
a. 765
b. 646
c. 404
d. 200
e. 111
52. What does the permission 1777 mean? How would the permissions of such a direc-
tory appear when you use
ls –al
?
53. Why might you make a directory world-writable? If you do so, what are the conse-
quences on files stored there?
54. Why would you set a directory’s sticky bit?
55. How does the /proc directory differ from all other top-level directories?
56. Briefly explain the difference between the types of programs you would find in /bin
versus /sbin.
57. Why is /root located under / and not /home?
58. Of the following directories, which would you generally not anticipate changing for
weeks or more at a time? /bin, /boot, /home, /sbin, /var
59. Under which top-level directory will the system administrator probably spend time
editing files?
Navigating the Linux File System
◾
123
60. Explain why a user may wish to invest in a magnetic tape drive and magnetic tape
cartridges.
61. Research the following compression formats and specify whether they are lossy or
lossless: flac, gif, jpeg, mp3, mpeg-1, mpeg-2, mpeg-4, png, tiff, and wma.
62. A file stores the following text. Define a dictionary of words for this file and then sub-
stitute each word with a number as its replacement where the number is the location
of the word, alphabetically, in the dictionary. Periods, spaces, and line breaks should
be retained in the file. Include your dictionary in your replacement file. How much
compression do you achieve with your replacement file?
The blue fox jumped over the red cow.
The red cow ate the green grass.
The green cow ate the blue grass.
The blue fox then jumped over the green cow.
The green cow ate more blue grass.
125
C h a p t e r
4
Managing Processes
T
his chapter’s learning objectives are
• To understand the parent–child relationship between processes in Linux
• To understand the different ways an operating system can manage processes
• To understand the role of the effective UID and GID for processes
• To understand the difference between foreground and background processes and be
able to move Linux processes between the two
• To understand the tools available in Linux to monitor running processes
• To understand niceness and how to adjust process priorities
• To understand the ways that processes can terminate and how to use kill, killall
4.1 INTRODUCTION
A
process
is a running program. Processes can be started from the GUI or the command
line. Processes can also start other processes. Some programs interact with the user and
others run to completion and report their results, either to a window or a disk file. In this
chapter, we look at how to manage processes, primarily from the command line interface.
We will also look at process and resource management GUI programs.
Whenever a process runs, Linux keeps track of it through a process ID (PID). After
booting, the first process is an initialization process called
init
. It is given a PID of 1.
From that point on, each new process gets the next available PID. If your Linux system has
been running for a while, you might find PIDs in the tens of thousands.
A process can only be created by another process. We refer to the creating process as the
Do'stlaringiz bilan baham: |