Question

In: Computer Science

unix operating system create the scripts in your Fedora Server Virtual Machine 1- Open the file...

unix operating system

create the scripts in your Fedora Server Virtual Machine

1- Open the file lab1 located in the labs directory and create a script that prompts the user to enter name, address and phone #. All entered details are directed to file "info.txt" in the same directory

When display info.txt, it should look like this example:

Name: John Smith

Address: 31-10 Thomson Ave.

Phone: 718-482-0000

2- Open the file lab2 located in the labs directory and create a script to display the logged in user name and user UID

When you execute lab2, the output should look like this example:

Username: root

User ID: 0

Solutions

Expert Solution

I created the scripts in Kali Linux since I don't have Fedora Server Virtual Machine. But you need not worry as the steps provided will work in any Linux Operating System.

At first, I created the directory 'labs' with the command: mkdir labs in the root directory or the home directory.

We create the lab1 file , we use the command touch lab1 . Now we create the script.

The first line of a bash script should always sstart with a #!/bin/bash which denotes that the script will use the interpreter as the bash shell. THis is very much important in create an linux script.

Now, we take the user input with the following command read -p "Enter your name:" name which takes the takes and put it in the variable 'name'

The same is done for inputs address and number
Now we echo the values of $name, $address and $number to the info.txt file which is created along.


We are done with the script now, it gets created with the inputs given by us.
lab1.sh file:

#!/bin/bash

read -p "Enter your name: " name

read -p "Enter your address: " address

read -p "Enter your phone number: " number

echo "$name" >> info.txt

echo "$address" >> info.txt

echo "$number" >> info.txt


Here is the screenshot to the script and the output:

chmod -x make this script executable
chmod 777 makes the file/script read, write, and execute permission for all the users.

2) We use echo $USER print the logged in user and id -u to print numberic id.

Make sure to use #!/bin/bash at the start of the program.

With the help of echo command, we print the result.

lab1.sh file

#!/bin/bash
echo "Username:$(echo $USER)"
echo "User ID:$(echo $(id -u))"

Screenshot to the file:

Screenshot to the output and execution:

Always remember to give permissions to files and foldes with the chmod commnad in linux.

If you have any doubts, leave a comment below before rating. I'll happy to assist you further. Do upvote this if it helped you. Thank you


Related Solutions

In Project 13-1, you configured the DHCP daemon (dhcpd) on your Fedora Linux virtual machine. On...
In Project 13-1, you configured the DHCP daemon (dhcpd) on your Fedora Linux virtual machine. On your Ubuntu Server Linux virtual machine, install and configure udhcpd to provide the same functionality described in Project 13-1, and test your settings by configuring your Fedora Linux virtual machine as a DHCP client that obtains IPv4 configuration from udhcpd. Finally, restore your original configuration.
Demonstrate your grasp of the Unix file system by constructing a directory structure as follows: In...
Demonstrate your grasp of the Unix file system by constructing a directory structure as follows: In your home ( ~ ) directory, create a directory named “UnixCourse”. This directory will be used in the remaining assignments of this course, as well as this one. Several of the commands that you will issue in this course will examine files in this directory and, in some cases, send me a listing of those files or even copies of those files for grading...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of mv command The mv command is more than just a wrapper around the rename system call. Write a version of mv that accepts two argument. The first argument must be the name of a file, and the second argument may be the name of a file or the name of a directory. If the destination is the name of a directory, then mv moves...
Using node.js, create the following tasks. 1. Set up a server and HTML file server as...
Using node.js, create the following tasks. 1. Set up a server and HTML file server as shown in the videos. Once you have it successfully running, make the following adjustments A. When a 404 error (file not found) occurs, display a funny message about the file missing and/or did you forget how to type? B. If the user enters a request for the home page (index.html) then: Display an index.html page you have created which includes your name, course number,...
Create an example (make up your own numbers) for a virtual open economy with import as...
Create an example (make up your own numbers) for a virtual open economy with import as a function of total income. Find the equilibrium output level and the open economy multiplier.
Create an example (make up your own numbers) for a virtual open economy with import as...
Create an example (make up your own numbers) for a virtual open economy with import as a function of total income. Find the equilibrium output level and the open economy multiplier. ı sent this question before but I couldn't read most of the answer.
Create shell scripts, .sh file. Please include a shebang line at the top of the script...
Create shell scripts, .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that plays a simple “guess the number” game with the user. It should select a random integer in the range [0 - 10], ask the user to guess the value, and provide feedback of the form “too high”, “too low”, or “congratulations” as appropriate. After the correct value is guessed, the script should terminate.
Create by using Linux server • Create a file name it foo.txt • Remove all permissions...
Create by using Linux server • Create a file name it foo.txt • Remove all permissions from foo.txt • What happen if you try to read the file? • Change foo.txt permission to read and write only for owner • Change foo.txt permission to read for group • Change foo.txt permission to read and write everyone
Pertaining to the Linux operating system, which is a variant of Unix, DISCUSS Topics that will...
Pertaining to the Linux operating system, which is a variant of Unix, DISCUSS Topics that will include things such as history, Linux kernel, and design principles.
Create shell scripts, each in its own .sh file. Please include a shebang line at the...
Create shell scripts, each in its own .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that reads sunspot data from data-shell/data/sunspot.txt and uses awk to print a list of the total number of sunspots for each year on record as well as the twelve monthly averages across the record. Note: "awk allows you to index arrays using strings, so as you traverse the data file,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT