Starting from:

$25

CSC3320 - System Level Programming  - Lab Assignment 3 - Post-Lab - Solved

Learn how to set permissions for the files and directories. Practices on editing a file via the vi editor. 

 
Part 1: VI Editing - Small file 

 

Open your terminal and connect to snowball server. Change your directory to your home directory (cd ~ ), and then create a new directory named as “Lab3” (mkdir Lab3). After that, go to directory Lab3 (cd Lab3) and please download the file

"Try.c" (content shown in table below) by the following command (internet access required):              

 cp                                      /home/frondel1/Public/Try.c                              Try.c 

Be sure it succeeds using “ls” to see the file name “Try.c” listed. 

 

 

 

 

Try the following steps by issuing some commands in your vi  editor 1) Open "Try.c" with vi editor 

$vi Try.c 

 



 

2)          Move cursor to the beginning of “Error!” 

use UP DOWN LEFT RIGHT arrow to control cursor 

 

3)          Insert  “xxx”. 



type “xxx” (hit x three times) 

 

4)          Append a blank line after the current line. 

 Hit Esc to command mode o (lowercase o) 

 

5)          Delete “xxx”. 

Hit Esc to command mode. 

Move cursor to the beginning of "xxx", press x three times or press 3s to delete "xxx" 

 

6)          Copy the first 2 lines, move cursor to the beginning of file, and then paste it after current line 

:1,2y 

 :0 p 

 

7)          Delete the first 2 lines 

:1,2d 

 

8)          Save it 

:w 

 

9)          Replace all "fptr" with "FPTR" 

:1,$s/fptr/FPTR/g 

 

10)      Save and exit. 

:wq 

Part 2: VI Editing - Large file 

 

1)      Go into your Lab3 directory. 

$cd ~/Lab3 

 

2)      Copy "RealEstate.csv" from instructor's public directory to your Lab3 directory

         again. 

$cp /home/frondel1/Public/RealEstate.csv . 

 

Please write the commands you will issue to complete the following tasks and answering corresponding questions step by step in your report. 

 

3)      Use vi to open “RealEstate.csv”.

 

4)      Move the cursor to the last line (without knowing the number of last line).

 

5)      Display line number.

 

6)      Search for the transaction for the estate located at "111 EAST"

 

Which line is this string located? (Please just write down the line number)

Delete this line.

7)      Move the cursor to the line 50.

 

8)      Substitute all comma "," with colon ":" from line 50 to line 54.

 

9)      Copy line 50 to line 54 to the end of file.

 

10)  Remove line 50 to line 54.

 

11)  Describe how to enter the text mode and insert a new line "Recorded in year

2008" between line 1 and line 2.

 

12)  Switch back to command mode.

 

13)  Save the file and quit vi.

 

 

 



Part 3: Permissions for files      

Follow the instructions step by step and finish the questions as required. 

1) Go into your Lab3 directory. 

$cd ~/Lab3 

 

2)   Check the file permissions for file "Try.c" in your own Lab3 directory. 
$ls -l Try.c 

 

3) You may see similar output as below, in which rw-rw-r-- of the first field is the file permission string for "Try.c".

 

                                      

More products