Question

In: Computer Science

QUESTION 5 1.    Switch to insert mode, and then create a script that performs the following: •       Sets...

QUESTION 5

  1. 1.    Switch to insert mode, and then create a script that performs the following:

    •       Sets the environment for the script to bash

    •       Have at least two comment lines that state the purpose of the script

    •       Clear the screen

    •       Sends messages back to the screen informing the user of what he or she is seeing displayed on the screen

    •       Have the script perform the following:

    o   Show your home directory

    o   Show your current working directory

    o   Create a directory called demo, and send any errors to a null file so the user does not see them on the screen.

    o   Switch to this new directory

    o   Show you are in the demo directory

    o   Place a empty file named file1 in the demo directory, then

    o   Display a long list of the contents of this (demo) directory

    o   Change back to your home directory

    o   Display a long list of all the files in your home directory

    2.   What construct did you use to send command errors to a null file in your script?

    Answer:__________________________

4 points   

QUESTION 6

  1. Save your changes and exit the vim editor.

    Command(s) to save your file and exit the vim editor?

    Answer:___________________________________

    2.   Display the permissions for your script.

    What command did you use?:__________________________

    Answer:________________________

    3.   Does the owner have execute permission?

    Answer:____________________________________________

    4.   Give the user (owner) execute permission to run the script.

    What command did you use to change the permissions on the script?

    Answer:__________________________________________

    What notation did you use to change permissions: symbolic or numeric (octal)?

    Answer:____________________________________________

    5.   Run the script.

    What command did you use to run the script?

    Answer:____________________________________________

Solutions

Expert Solution

Please find the below answers. Please provide your feedback

Thanks and Happy learning!

QUESTION 5

1. Please see the script below in the code section

2. The construct used is : 2>/dev/null, Here the 2 indicates the standard error. So basically we are just redirecting the errors printed to standard error to /dev/null file.

QUESTION 6

1. Command to sane the file and exit the wim console is : wq

Here 'w' means write and 'q' means quit. So to exit from vim editor press 'esc' key then type colon(:) and type 'w' and then type 'q'. Then press enter key to exit the vim console.

2. Use the command ls -l to display the long listing of the file. This long listing included the permission of the file.

3. Yes the owner has the execute permission. The permissions for a file can be read(4), write(2) or execute(1) or the combination of the three. So if a file has the permission 755 then that means the owner has read+write+execute (4+2+1 = 7) permission asn others has only read+execute(4 + 1= 5) permission.

4. command to change the permission is 'chmod'.

So to give the owner the permission to execute us the command 'chmod u+x script.sh' [assuming that the shell script file name is script.sh, here 'u' means the user/owner]

One can use symbolic (ie r,w,x) or numeric (ie 4, 2, 1) notatiosn to add/remove the permissions. In the above command we user the symbolic notation.

5. The script can be run using the command ./script.sh

QUESTION 5

1.

#!/bin/bash
#Above line sets the environment for the script to bash

#Purpose of this script is to practice the
#basic unix/Linux commands

#Clear the screen
clear

#Display message in the screen
echo "Users home directory is : $HOME"

echo "Users current directory is :`pwd`"

echo "Creating directory with name demo."
mkdir demo 2>/dev/null

echo "Switching to the demo directory."
cd demo

echo "Users current directory is :`pwd`"

echo "Creating an empty file named file1 in the demo directory."
touch file1

echo "Long listing of the demo directory is:"
ls -l .

echo "Switching back to home directory"
cd $HOME

echo "Users current directory is :`pwd`"

echo "Long listing of all the files in the home directory is:"
ls -l $HOME

Related Solutions

Calculate the mean, median, and mode for the following sets of scores: (a) 5, 8, 12,...
Calculate the mean, median, and mode for the following sets of scores: (a) 5, 8, 12, 10, 5 (b) 1, 5, 4, 2, 3 (c) 10, 20, 50, 20, 30
Open the terminal and using vi/vim create a new script and name it lab6 Insert at...
Open the terminal and using vi/vim create a new script and name it lab6 Insert at the top of your file a comment with your name, class and section number (e.g. #John Doe, EMT 2390L - OL123). In this lab you are going to display a multiplication table of a number entered by the user between 2 and 10 using a for loop and without using multiplication. The table will display the values that are less than or equal to...
Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.
Assignment 3 – Incorporating a Table into a Document.Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.Tell me about your college expenses you have by filling this table with subjects and data. Then write two paragraphs telling me about the information you provided in the table. Bold and color table heading.  Example of table:College ExpensesTuitionBooksComputer/InternetOther suppliesScience ClassMath classC.I.S. ClassEnglish ClassGive the page a proper title....
Write a script in C that will do the following : 1. Create the directory ZHW3....
Write a script in C that will do the following : 1. Create the directory ZHW3. 2. Verify that the directory is created by display all information related to the directory and not just the name of the directory. 3. Assume that the input from the command is used to validate password strength. Here are a few assumptions for the password string. • Length – minimum of 8 characters. • Contain alphabets , numbers , and @ # $ %...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform a ls -al on the files within the user's home directory and save it to a file called ls.dat within your ~ directory 2.   Save the tree information for the /home directory in a file called tree.dat within your ~directory 3.   Create a new directory in your home directory called "backups" 4.   Move the files you just created to the new directory 5.   Rename...
java script coding to create a math test program with 5 questions.
java script coding to create a math test program with 5 questions.
Consider 5 sequentially connected switches labeled switch 1, 2, 3, 4 and 5, and each switch...
Consider 5 sequentially connected switches labeled switch 1, 2, 3, 4 and 5, and each switch has 4 hosts connected to it (total of 20 hosts). If a host on switch #1 made a virtual circuit connection to every other host on the network, how many rows would be in each switch's virtual circuit table?
Question: Consider the following variation of insertion sort: For 1 ≤ i < n, to insert...
Question: Consider the following variation of insertion sort: For 1 ≤ i < n, to insert the element A[i] among A[0] ≤ A[1] ≤ … ≤ A[i-1], do a binary search to find the correct position for A[i]. a. How many key comparisons would be done in the worst case? b. How many times are elements moved in the worst case? c. What is the asymptotic order of the worst case running time?
Create a shell script called (Main.sh). The script must call the following scripts (FileS.sh), (Work.sh), (Ether.sh),...
Create a shell script called (Main.sh). The script must call the following scripts (FileS.sh), (Work.sh), (Ether.sh), (Arch.sh) and (Buzz.sh). The first script Main.sh must have two subroutines. The First Subroutine will display the following messages on the screen: 1-Display User login name, date and time. 2-Display System boot time. 3-Working path and Shell type 4-Display Home directory and number of files and directories in your Home. 5-Message describing briefly the requited tasks.
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT