Task description: Practice using the Shell. Review the exercises described below

Task description:

Practice using the Shell.

  1. Review the exercises described below.
  2. Attempt your solution in a Unix Shell, then record your solutions following the instructions provided.
  3. You need to complete at least 50 points of exercises to pass this assessment and can do so using any combination of the exercises given.
  4. Submit your completed solutions using Gradescope below.
  5. You may submit multiple times until you’ve achieved the 50 points.

Please post your questions to the discussion forums or ask during your workshop.

Academic Integrity Checklist

Do

  • Discuss/compare high level approaches
  • Discuss/compare program output/errors
  • Regularly submit your work as you progress

Be careful

  • Code snippets from reference pages/guides/Stack Overflow must be attributed/referenced.
  • Only use code snippets that do not significantly contribute to the exercise solution.

Do NOT

  • Submit code not solely authored by you.
  • Post/share code in Discussion boards or elsewhere on the Internet etc.
  • Give/show your code to others

    Question 01(2 Points)

    Write a Shell command to display a message foo in the Shell.After you’ve tested and verified your shell command, save the command in a file named question01.sh


    Question 02(2 Points)

    Write a Shell command to display a message Hello World! in the Shell. Be sure to include any spaces.After you’ve tested and verified your shell command, save the command in a file named question02.sh


    Question 03(2 Points)

    Write a Shell command to display the path to the current working directory in the Shell.After you’ve tested and verified your shell command, save the command in a file named question03.sh


    Question 04(2 Points)

    Write a Shell command to list the contents of the current working directory in the Shell.After you’ve tested and verified your shell command, save the command in a file named question04.sh


    Question 05(2 Points)

    Write a Shell command to navigate to the parent directory of the current working directory.After you’ve tested and verified your shell command, save the command in a file named question05.sh


    Question 06(4 Points)

    Write a Shell command to create a directory named dir6 in the current working directory, then another command to navigate the shell to that directory.After you’ve tested and verified your shell command, save the command in a file named question06.sh


    Question 07(4 Points)

    Create a file named flie7 in the current working directory, then write a Shell command to correct our spelling error (rename that file to file7)After you’ve tested and verified your shell command, save the command in a file named question07.sh
    Note: You only need to save the command that renames the file.


    Question 08(4 Points)

    Create a folder named dir8 in the current working directory containing one or more files, then write a Shell command to copy dir8 and its contents to a new folder named dir8_copy in the current working directory.After you’ve tested and verified your shell command, save the command in a file named question08.sh
    Note: You only need to include the copy command in your answer.


    Question 09(4 Points)

    Write shell commands to create the following directory/file structure in the working directory:

    .
    └── dir9
        └── dir9_2
            └── dir9_3
                └── foo
    
    

    After you’ve tested and verified your shell commands, save them in a file named question09.sh with each command on a new line.


    Question 10(4 Points)

    Using the file/directory structure from Question 9, write shell commands to move the directory dir9_3 and its contents to dir9:

    .
    └── dir9
        ├── dir9_2
        └── dir9_3
            └── foo
    
    

    After you’ve tested and verified your shell commands, save them in a file named question10.sh with each command on a new line.
    Note: Do NOT include the commands from Question 9 in your answer.


    Question 11(8 Points)

    Write a single command to create the following directory structure in the working directory:

    .
    └── dir11
        └── dir11_2
            └── dir11_3
                └── dir11_4
    
    

    After you’ve tested and verified your single command, save it in a file named question11.sh
    Note: Do NOT include any other commands or comments in your file.


    Question 12(8 Points)

    Write shell commands to create the following directory/file structure in the working directory:

    .
    └── dir12
        └── dir12_2
            └── dir12_3
                └── foo
    
    

    After you’ve tested and verified your shell commands, save them in a file named question12_i.sh with each command on a new line.Then write Shell commands to copy dir12_3 and ALL of its contents to match the following directory/file structure:

    .
    └── dir12
        ├── dir12_2
        │   └── dir12_3
        │       └── foo
        └── dir12_3_copy
            └── foo
    
    

    After you’ve tested and verified your shell commands, save them in a file named question12_ii.sh with each command on a new line.
    Note: Make sure each file only includes the shell commands for that part.


    Question 13(8 Points)

    Navigate your terminal to the following folders:

    • The directory 2 levels above the current working directory (i.e. the parent directory’s parent directory)
      • Record the command used for this in a file name question13_i.sh
    • The current user’s home directory (should work for any user, not just you)
      • Record the command used for this in a file name question13_ii.sh
    • The root directory
      • Record the command used for this in a file name question13_iii.sh
    • /usr
      • Record the command used for this in a file name question13_iv.sh

    You can verify that each of these commands has worked by printing the current working directory before and after running each command.
    Make sure to test that your commands work from different locations.
    Note: Each of the files containing your commands should only contain the command to navigate to the correct directory.


    Question 14(8 Points)

    Write a single Shell command to list the contents of the current directory.

    • The output must include hidden files (files whose name begins with .)
    • The output must show detailed information about each file (such as size, permissions, etc)
    • The output must be ordered from largest file to smallest file

    Use the relevant help listing/man page to look up the appropriate options for the command.After you’ve tested and verified your single command, save it in a file named question14.sh
    Note: Do NOT include any other commands or comments in your file.


    Question 15(8 Points)

    Consider the following directory/file structure:

    .
    ├── dir15_1
    │   ├── foo
    │   └── bar
    └── dir15_2
        ├── foo
        ├── bar
        └── baz
    
    

    Write a single Shell command to copy the contents of dir15_2 to dir15_1

    • The files from dir15_2 should overwrite the files in dir15_1, but only if they are newer
    • The timestamps and ownership information of the files being copied should be preserved

    Use the relevant help listing/man page to look up the appropriate options for the command.After you’ve tested and verified your single command, save it in a file named question15.sh
    Note: Do NOT include any other commands or comments in your file.


    Question 16(16 Points)

    Write a Bash script question16_i.sh to create the following directory/file structure in the working directory:

    .
    └── dir16_1
        ├── dir16_2
        │   ├── dir16_3
        │   │   └── dir16_4
        │   │       └── file16_3
        │   └── file16_2
        ├── dir16_5
        │   ├── file16_4
        │   └── file16_5
        └── file16_1
    
    

    Then write a second Bash script question16_ii.sh to copy, move, rename, and delete the files and directories to match the following directory/file structure:

    .
    ├── dir16_1
    │   ├── dir16_2
    │   │   ├── dir16_3
    │   │   ├── dir16_4
    │   │   │   └── file16_3
    │   │   └── file16_2_renamed
    │   ├── dir16_5
    │   │   └── file16_5
    │   └── file16_1
    └── dir16_1_copy
        ├── dir16_2
        │   ├── dir16_3
        │   │   └── dir16_4
        │   │       └── file16_3
        │   └── file16_2
        └── file16_1