Question

1. Write the command to set the following permissions on a script file with the following...

1. Write the command to set the following permissions on a script file with the following name; myscript.sh

Owner: full access; read, write and execute
Group: read and execute
Other: no access

2. Create a new file with the name "myfirstscript.sh". Write a new script that performs the following tasks in sequence;

  1. Display the usernames of currently logged in users; sorted from a-z
    1. HINT: You will need to filter the output of the whocommand
  2. Display a list of usernames who are logged into the system more than once
    1. HINT: usernames that are logged in more than once = not 'unique'
  3. Display a list of usernames that have been logged in since yesterday

Also, provide the commands to;

  1. Set read and execute permission for the user and member of the user’s group; read-only permission for others; and write permission for the user only
  2. Run your script from it’s stored directory

Note: The output of your script must be self-explanatory. For example, the output for the users who are currently logged into the system must be preceded by a header like this: “List of users who are currently logged in to the system in alphabetical order”

3. Write a script that performs the following actions;

Define the following two variables with the provided values;
variable lab with value lab?
variable labs with value lab*
Display the value of lab and labs
Define a variable named price with a value of 84.5
Define a variable named sentence and use the price variable to set its value to "The price of the book is $84.5"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

echo "Usernames currently logged in sorted from a-z"

who -u | sort

echo "Usernames logged into the system more than once"

users | wc -w

echo "Usernames logged into the system since yesterday"

last –s ‘-1 day’ | sort

touch input.txt

echo "set permission”

chmod 754 myfirstscript.sh

Add a comment
Know the answer?
Add Answer to:
1. Write the command to set the following permissions on a script file with the following...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a shell script to solve the following business problem. Create a file called whoislogin.out...

    Write a shell script to solve the following business problem. Create a file called whoislogin.out that contains the output of the who command, then append to the whois.out file, the output of the date and finger commands. Your script should prompt to pick any users from the list of users currently logged onto the system. Use the variable concept to search for the specific user from those displayed on the screen coming from the who is.out file created. Show a...

  • In UNIX Write a script that checks each minute and reports on who logs in and...

    In UNIX Write a script that checks each minute and reports on who logs in and who logs out. You can follow the steps below (not the only way): Using the commands who and cut, extract the list of usernames currently logged in the system To check after a minute, the sleep command can be used: sleep 60 Get the new list of users logged in after a minute For each user in the list; check if he is in...

  • Examine the following script, n-on: who | sort | awk '{print $1}' | uniq | wc...

    Examine the following script, n-on: who | sort | awk '{print $1}' | uniq | wc -l What will be the output of n-on? (A) The number of processes running for each user that is currently logged on to the system. (B) The number of users logged on to the system at the time the script is run. (C) The date and time of your last login to the system. (D) A list of all the users currently logged on...

  • I need this done ASAP. Please write a bash shell script that does the following: Prints...

    I need this done ASAP. Please write a bash shell script that does the following: Prints out how many users are logged on. This can be accomplished using who and wc. Prints out a list of currently logged on users. This can be accomplished using who, grep, regular expressions, and echo. Prints out how many processes you have running from past days, and a list of those jobs. Use `whoami` to get your username. Run ps -ef and see how...

  • Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a...

    Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a time. Prepend each line with a line number followed by a colon and then a space. Example output: 1: root:x:0:0:root:/root:/bin/bash 2: daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 3: bin:x:2:2:bin:/bin:/usr/sbin/nologin 4: sys:x:3:3:sys:/dev:/usr/sbin/nologin Exercise 2: Write a shell script that asks the user for the number of lines they would like to display from the /etc/passwd file and display those lines. Example output: How many lines of /etc/passwd would you like...

  • Open vi or pico and create a script called Information.   Add the contents from the following table to the script: (Hin...

    Open vi or pico and create a script called Information.   Add the contents from the following table to the script: (Hint: use echo to add blank lines to your output and to write out the headings). Headings: Utilities (command to execute) Today’s date is: date The current users logged on to the system are: who My current startup directory is: pwd Today’s identification information is: id The processes running on my system are: ps Add a header to your Information...

  • 9. The command "chmod 711 menu script" allows the owner read, write and execute permissions, and ...

    9. The command "chmod 711 menu script" allows the owner read, write and execute permissions, and only permission for group and other o. Explain why you would use a "Here Document "in your shell script over using the echo commands? 11. What will the following statements provide "from the main body" when the awk script is executed? Field 1 Example: one line of input "widget: 1.59 : 83 Note! the: is the delimiter. Example: Unit-widget, price per/unit -$1.59, quantity number...

  • SHELL SCRIPT: Provide the following questions with the codes and command line Problem 5: Take 5...

    SHELL SCRIPT: Provide the following questions with the codes and command line Problem 5: Take 5 input arguments in a for loop, but only add the even i values to sum and display the result. Problem 6: Write a shell script that accepts path of the directory and returns a count of all the files within the specified directory. (Hint: use alias to perform cd operation) Problem 7: Write a shell script that takes an ‘count’ value as an input...

  • Need Linux Commands and instructions for the following: 6. Write a script to display numbers from...

    Need Linux Commands and instructions for the following: 6. Write a script to display numbers from 1 to n, where n is an integer provided by users (if not, default to 10). Hint: use "read" command to accept user input. a) Display the source code in an editor (#4-9) b) Execute your script in the terminal, and display the command and the result (#4-10)

  • Objective: Practice common UNIX commands. Procedure: The following list of Unix commands are given for self-learning....

    Objective: Practice common UNIX commands. Procedure: The following list of Unix commands are given for self-learning. Use 'whatis' or 'man' command to find out about each command. Your document should include the description or screen shots of the output from each of the command. Commands: df du gzip file history wget Changing access rights: chmod u+x Dir1.0            adds execute permission for the owner chmod go-w file1              removes write permission for the group and others chmod ugo=rw testfile     sets...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT