Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with Command in Linux Operation systems... Please any ideas ? Thanks (

ID: 3853859 • Letter: N

Question

Need help with Command in Linux Operation systems... Please any ideas ? Thanks

(ie. If you were asked which command would allow you to navigate to the /var directory you would display the following: cd /var (NOT just the command cd))

Vi Editor

1. Using the vi editor:

Create a document with four lines, each containing the word “today.

” What command would you use to copy the first four lines using only one command?

What command would you use to save the file, and exit vi? Reopen the document.

What command would you use to change“today”to“yesterday” but only on the first four lines?

2. Using the vi editor:

Create a document called first.file, and enter a few lines of text in it. Save it.

Create a second document called second.file, and enter a few lines of text in it. Save it.

What commands would you use to create a third document called third.file by merging the text from the first two files?

3. Delete all text from third.file that you created using vi. What command would you use to restore the data you just deleted?

4. Using the vi text editor create a file with 12 lines of text and on the fifth line insert your first and last name.

What command would you use to go to the first line of the file?

What command would you use to search the file for your last name?

What command would you use to save the file, but not exit vi?

Without exiting vi, temporarily execute the ls command to confirm that the file is saved.

What command did you use temporarily leave vi (without exiting it) so you could execute t he “ls” command?

What command can you use that will cause line numbers to appear?

Scripting

5. Next, use the command to add your current working directory to the PATH variable.

6. What command will create a variable called iam and assign the results of the whoami command to it?

7. Assign the variable t the value of 20. Next, assign the variable s the value of t+30. Finally, display the contents of t and s to verify you have correctly defined these variables.

8. Create a script called lunch with a for loop that uses the variable sandwiches and then displays a line at a time the following sandwiches: chicken, ham, hummus, tomato.

9. Someone wrote the following script but it doesn’t work and you’ve been asked to troubleshoot it. What is wrong with the following lines of code?

While [ “$value” = “100” ; do ECHO “That’s a large number.”

read value fi

Explanation / Answer

1 ans:

Using vi editor create todayfile first. To insert mode type I and enter a line and press enter. Type line two today and press Enter and type line three today and press Enter. Also type line four today and press Enter. To return o command mode press “Esc” key.

If you want to copy four enterd text lines Type :x and press Enter to save the file and exit the editor. Type vi todayfile and press Enter to re-open the file. Make sure you are in "command" mode and type :1,4s/today/yesterday/g and press Enter. Type :x and press Enter to save and exit the editor.

2 ans: crate a file firtsfile using vi and to insert data type I and enter few lines in it and press Esc.

Type x and press enter to save sand exit. Same way creae second file with vi and insert some data into it by using I and press esc. Also create third file and press enter. In the command mode type r firtfile and press enter key and type r second file and press enter and type x to save and exit.

3nas: to open file in command mode vi thirdfile type this line. And type d and press enter it will repeat upto each line removed from the file.

Finally type x for save and exit.

4ans:

Type vi and 12linefile name and enter insrt mode by using i. and type first and last names. And type x press esc to save and exit.

As the same wxwxute ls command to display the files list. To display the line numbers Type set number and press enter.

5 ans:

To add current working directory to the path use set

Type set=”path of the directory” and press enter.

6 ans: type who am I to know who is currentlu logged into the system in the command mode.

7ans:

$t = 20;

$s = $t+30;

$echo s;

9 anS: