Solve the following questions. A portion of your mark for the assignment will be for correctly following the directions. The reference system for these questions istuxworld.
- Theexpand(1)command expands tabs to sequences of space characters. Suppose you have a file namedmyfile.txtin your current working directory. List five different commands you could use to expand tab characters in the filemyfile.txtusing theexpandcommand. The five commands must exemplify five different types or forms of commands.
For the purposes of this question, the “form or type of command” is determined by:
- whether one (child) process is created to perform the command (this is one possibility) or two processes (children) are created to perform the command (the other possibility);
- the presence (one possibility) or lack (the other possibility) of pipes in the command;
- whether or notexpand(1)gets its input from a file (one possibility) or from itsstdin(the other possibility);
- whether or notexpand(1)is given any “[FILE]” arguments (one possibility) or not (the other possibility) when it is started within the child process.
If the set of choices to the above are different for one command than they are for another command, then those two commands are “of a different type”. However, the options given to
expand(1)are not used to determine the “type of command” in this question.
Also for the purposes of this question,
- whenexpand(1)executes according to your command, its standard output must be (bound to) your virtual terminal (in which you are executing the command);
- your commands cannot use command substitution, process substitution, subshells, or (the built-in command)exec, if you happen to already know what any of those are;
- there can be only one instance ofexpandin the pipeline;
- whether or not the commands execute in the foreground or background is irrelevant to this question;
- the settings of any environment variables used byexpand(1)are irrelevant to this question.
Remember to consult the
expand(1)ontuxworldor pages 814 – 815 of the Sobell text (4th edition) to find out more information about the command.
Submit a fileq1_solution.txtcontaining your five commands. If you cannot determine five different types of commands, submit as many as you can.
Hint: what does an argument (to
expand) of “-” mean?
- A LINUX/UNIX user would like to get the short description lines (whatis(1)descriptions) from all themanpages whose description lines contain both the string “regular” and the string “expression”, but which are not in Section 3 of themanpages, nor in any of Section 3’s subsections. If a “3” should occur within the description line but not as (part of) the section number then thiswhatis(1)line should benotbe filtered out (removed) on this basis. Finally the user would like the set of description lines saved in a file calledq2_re.txtas well as presented on her screen (e.g. in a virtual terminal window) in a manageable manner, one window-full at a time. Write a single pipeline which will do all of this. Sections such as “(3pm)” are subsections of section 3.
Restriction: if you use
aproposin your pipeline, you cannot use the-s,–sections, or–sectionoption. Similarly, if you use “man -k, you cannot use any of the above-mentioned options (to
apropros), or the-Soption, or theMANSECTenvironment variable.
Submit your pipeline in a file namedq2_solution.txt, a log of the output it produces in a file namedq2_log.txt, and the fileq2_re.txt.
Hint: yourq2_re.txtfile should contain the lines
lzegrep (1) – search compressed files for a regular expression
lzfgrep (1) – search compressed files for a regular expression
among many others.
Remember that the reference system for this assignment is LINUX as found ontuxworld. Output on a different LINUX/UNIX system may vary from that ontuxworld.
The Sobell text has a lot of information useful for answering this question, including pages 33 – 38, 853 – 857, 898 – 901, and Appendix A.
- There are three parts to this question.
- Suppose a process has (effective) user-id (UID) 1000 and (effective) group-id (GID) 2000. Further suppose that an ordinary fileexampleis owned by user 4101 and has a group-id of 2000. Assume thatexamplecontains a binary executable program. For each possible mode of file access (read, write, and execute) state whether a kernel call requesting that type of access would succeed whenexamplehas each of the following permissions.