Note: A "single UNIX command" means exactly that, one command.
A "single command string" means you can have more than one command connected with pipes. If you have any semicolons then that is more than one command string.

1. Create a find command that will locate any file called "hosts" and once found, grep each one of the "hosts" files that you found for the number of lines that the string appears in within the file.
Begin your find search with the /etc directory.
When you grep for the number of lines containing in the file, the grep command MUST be part of the find command string. Do NOT use a pipe in the command string.
A. What command string did you use?
B. On how many lines did the string appear?

2. cd to the directory ~smcgowan/Cyber/Unix/Final
While viewing the file called passwd2 you notice that all of the references to the user's shells, the C shell, were entered in upper-case letters. This is not correct.
Create a sed command string that will convert ONLY the references to the user's shell CSH to csh within the file called passwd2 and write the results to a new file called newpasswd.
Be Careful.
What command string did you use?

3. cd to the directory ~smcgowan/Cyber/Unix/Final
A copy of the group file was created using the ! as the field separator. This file is called group2. The fields should be separated using a : not a !.
Create a single command string that will modify the file called group2 and change all occurrences of the ! to a :. The command string must also sort the file numerically on the GID field and then save the output to a file called newgroup.
What command string did you use?

4. In ~smcgowan/Cyber/Unix/Final, there is a directory called Secret
Inside the Secret directory there is a file called list.
Why is it that you can cat the file called list but, you cannot execute a long listing on the directory called Secret ? Be specific.

5. cd to ~smcgowan/Cyber/Unix/Final
When you more the file called blink, you get the error message:
blink: Too many levels of symbolic links
What is it that is causing this error?

6. You have an ascii file that contains a list of UNIX usernames.
You would like to mail this list to everyone on the list. You want the subject of the message to be "mailing list". Without making an alias in your .mailrc file, what is the unix command (using mailx) that will get this done?

7. You need to locate the PID of a process in the process table so that the process can be killed. On the UML system, construct a SINGLE command string that will locate ONLY the PID of the process called 'lpsched'.
The final output should contain ONLY one number (and nothing else) - the PID of this process.
What command string will do this?
(Note: you should not use anything other than the name of the command "lpsched". I know that you know that the owner of this process is "root", but I am just using this process as an example, and the point of the quesiton is that you can find any process, whoever owns it, given just the name)

8. Use awk to output a list of all the "in real life" names of the users on the UML system (ce) that have csh as their login shell. You must use only awk to generate the list (ie no grep or any other filter). You can pipe the output to some other command to get the count.
A. What awk command will do this?
B. How many users are in this list? (show the command you used)
Use a slightly different awk command to count the number of users that use tcsh (note: the awk command doesn't have to do the counting, just the finding of the users)
C. What awk command will do this?
D. How many users use /usr/bin/tcsh? (show the command you used)

9. cd to ~smcgowan/Cyber/Unix/Final
When you use the more command on the file entry called grades.dat, you get the error message:
grades.dat: No such file or directory
What is it that is causing this error?

10. You have a file that contains thousands of names and phone numbers in the following format:
McGowan,Sean 978-934-4000
Kilcoyne,Kathleen 603-555-1212
Club603,The 617-505-1332
Boyle,William 301-444-1221

Write a command string that will output only the lines where the area code (first 3 numbers) is 603. Have the command output these lines with the area code removed, and sorted according to last name. Assume there are many more lines, the lines given are just examples for the format.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

A. What command string did you use?
$find /etc -name 'hosts' -exec grep -c '' {} \;
Observation. The only files where it couldn’t read from I got “permission denied”
The complete output of the command is given below:

find: cannot read dir /etc/inet/secret: Permission denied
find: cannot read dir /etc/mail/spamassassin/sa-update-keys: Permission denied...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Linux Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats