Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Linux Exercises Filter 1: 1. Using the tar command archive the content of your home directory into a file named myhome.tar in the /tmp directory.

Linux Exercises

image text in transcribed

image text in transcribed

image text in transcribed

Filter 1: 1. Using the tar command archive the content of your home directory into a file named myhome.tar in the /tmp directory. Display the size of that file using the Is command. 2. Using the gzip command compress that file into myhome.tar.gz then display the size of that file using the Is command. 3. Using cat, tar and gunzip commands and connect them in a pipe to list the content of myhome.tar.gz. That means all three commands are issued in one command line. 4. Using the tar command alone with appropriate options to achieve the same thing, i.e. list the content of myhome.tar.gz Filter 2: 1. Use the cat command to create a file named fruits.list that contains these words: banana, apple, orange, strawberry, blueberry and pear in separate lines, i.e. each line contains one word only. (Hint: use I/O redirection and Cti-D.). 2. Display the content of that file. 3. Use the cat and grep commands to display only lines that contains 'berry' in that file. 4. Add blackberry, avocado, and pineapple to fruits.list, display the contents of fruits.list 5. Use cat, grep and we commands find out how many fruits in the list that has the character 'p' in its name. Only the number needs to be displayed. Filter 3 1. Make sure that your working directory is your home directory 2. Create directories privi, priv2, pub1 and pub2 3. Create empty files sec1, sec2, chi, ch2, ch3 and ch4 (hint: touch command) 4. Change the permission of sec1, sec2, privi and priv2 to allow only you to read&write and explore these directory and files, but everyone can have full access to pub1, pub2; and read&write access to chi, ch2, ch3 and ch4. If a file or directory has the desired permission when created then their permission does not need to be changed. 5. Using the Is command to display only these directories and files in the long format, showing their permission to verify. (Hint: use 'Id' option). 6. Display only the permission string of these files and directories in a sorted list. (Hint: cut, sort command) 7. Display only the permission string of these files and directories in a sorted list, but each permission type is listed only once. (Hint: uniq command). 8. Display the number of permission types of these directories and files. Only the number needs to be displayed. (Hint: wc command). Process 1 1. Using the ps -ef and grep command list all processes started by you (i.e. owned by your userid). (Hint: 'Auserid' with match with a line that start with userid.) 2. Run command group (echo "Snoozing..."; date; sleep 50; echo "Awake.";date ) > sleep.out & Note: Do not omit the parenthesis!!! 3. Repeat 1, identify process number of the process sleep 4. Display the content of file sleep.out 5. Kill the sleep process 6. Repeat 1. and verify that the process sleep no longer exist 7. Display the content of file sleep.out 8. Remove file sleep.out Process 2 1. Run command (date; sleep 45; echo "Done."; date) > date out in the foreground (i.e. without &) 2. Suspend it with Ctrl-Z. Pay attention to the number in the [], it will become handy later. This number is the job number of the command that has been suspended. 3. Run command top to display only processes started by you (ie, associated with your userid). Write down the process ID of the sleep 45 process. Quit command top by entering 4. 4. Run command sleep 60 &, repeat step 3 and write down the process ID of the sleep 60 process. Note that top will display both sleep processes so you need to identify the one that is started later. 5. Run command sleep 100&, repeat step 3 and write down the process ID of the sleep 100 process. 6. Run echo "Process ID of sleep 45 is X and process ID of sleep 60 is Y, and that of sleep 100 is Z", where X, Y and Z are process ID of the three sleep processes started earlier 7. Put the previously suspended command into the background with command bg. 8. Run command jobs 9. Bring the command in step 1 back into the foreground with command fg. wait until it finishes. 10.Kill the sleep 60 process with the kill command 11.Kill the sleep 100 process with the kill command 12.Run command jobs 13.Using ps-ef and grep to list all processes started by you and verify that there is no sleep process remain 14.Display the content of file date.out using the cat command Filter 1: 1. Using the tar command archive the content of your home directory into a file named myhome.tar in the /tmp directory. Display the size of that file using the Is command. 2. Using the gzip command compress that file into myhome.tar.gz then display the size of that file using the Is command. 3. Using cat, tar and gunzip commands and connect them in a pipe to list the content of myhome.tar.gz. That means all three commands are issued in one command line. 4. Using the tar command alone with appropriate options to achieve the same thing, i.e. list the content of myhome.tar.gz Filter 2: 1. Use the cat command to create a file named fruits.list that contains these words: banana, apple, orange, strawberry, blueberry and pear in separate lines, i.e. each line contains one word only. (Hint: use I/O redirection and Cti-D.). 2. Display the content of that file. 3. Use the cat and grep commands to display only lines that contains 'berry' in that file. 4. Add blackberry, avocado, and pineapple to fruits.list, display the contents of fruits.list 5. Use cat, grep and we commands find out how many fruits in the list that has the character 'p' in its name. Only the number needs to be displayed. Filter 3 1. Make sure that your working directory is your home directory 2. Create directories privi, priv2, pub1 and pub2 3. Create empty files sec1, sec2, chi, ch2, ch3 and ch4 (hint: touch command) 4. Change the permission of sec1, sec2, privi and priv2 to allow only you to read&write and explore these directory and files, but everyone can have full access to pub1, pub2; and read&write access to chi, ch2, ch3 and ch4. If a file or directory has the desired permission when created then their permission does not need to be changed. 5. Using the Is command to display only these directories and files in the long format, showing their permission to verify. (Hint: use 'Id' option). 6. Display only the permission string of these files and directories in a sorted list. (Hint: cut, sort command) 7. Display only the permission string of these files and directories in a sorted list, but each permission type is listed only once. (Hint: uniq command). 8. Display the number of permission types of these directories and files. Only the number needs to be displayed. (Hint: wc command). Process 1 1. Using the ps -ef and grep command list all processes started by you (i.e. owned by your userid). (Hint: 'Auserid' with match with a line that start with userid.) 2. Run command group (echo "Snoozing..."; date; sleep 50; echo "Awake.";date ) > sleep.out & Note: Do not omit the parenthesis!!! 3. Repeat 1, identify process number of the process sleep 4. Display the content of file sleep.out 5. Kill the sleep process 6. Repeat 1. and verify that the process sleep no longer exist 7. Display the content of file sleep.out 8. Remove file sleep.out Process 2 1. Run command (date; sleep 45; echo "Done."; date) > date out in the foreground (i.e. without &) 2. Suspend it with Ctrl-Z. Pay attention to the number in the [], it will become handy later. This number is the job number of the command that has been suspended. 3. Run command top to display only processes started by you (ie, associated with your userid). Write down the process ID of the sleep 45 process. Quit command top by entering 4. 4. Run command sleep 60 &, repeat step 3 and write down the process ID of the sleep 60 process. Note that top will display both sleep processes so you need to identify the one that is started later. 5. Run command sleep 100&, repeat step 3 and write down the process ID of the sleep 100 process. 6. Run echo "Process ID of sleep 45 is X and process ID of sleep 60 is Y, and that of sleep 100 is Z", where X, Y and Z are process ID of the three sleep processes started earlier 7. Put the previously suspended command into the background with command bg. 8. Run command jobs 9. Bring the command in step 1 back into the foreground with command fg. wait until it finishes. 10.Kill the sleep 60 process with the kill command 11.Kill the sleep 100 process with the kill command 12.Run command jobs 13.Using ps-ef and grep to list all processes started by you and verify that there is no sleep process remain 14.Display the content of file date.out using the cat command

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions