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

For each of the following problems, use your unix system to answer each of these

ID: 3563977 • Letter: F

Question

For each of the following problems, use your unix system to answer each of these questions. If it asks for output, then copy the output into the answer space. Be sure to answer ALL questions given.

11. Unix has some special directory names. What are these names and what are they used for?

12. Suppose you want to search the contents of all files in the subdirectory "project" in your home directory. You want to look for the "printf" statement in all files. What command will you use?

13. How do you log into remote server? Show the command for this from your computer. (If you use an application like Putty, then describe setting up the "session" for logging onto the server.) How do you exit your login?

14. Most Linux implementations use the 'sudo' command to protect the administrator login. How is 'sudo' used to execute a privileged command? Where is the configuration file for 'sudo'? What is the line in the configuration file that gives you the right to use administrator privileges? Explain this line.

15. What are the modes of VI? Give the commands to move between these modes. What mode is used to move around in a text file? Give ALL the VI commands to move in a file.

16. How is a command repeated in VI?

17. In VI, how do you delete 5 lines to a buffer and then insert them at a different location from the buffer?

18. In VI, how do you jump to line number 100? to the beginning of the file? to the end of the file? Also, give the movement commands for character left, character right, line up, line down, line begin, line end, page down, and page up.

19. In VI, how can you search for the keyword 'printf'?

20. In VI, how do you load a file and save a file? What if you make changes to a file and want to exit without saving, how do you do this?

Explanation / Answer

11. /bin - Stands for "binaries" and contains certain fundamental utilities, such as ls or cp, that are needed to mount /usr, when that's a separate filesystem, or to run in single-user (administrative) mode when /usr cannot be mounted. In System V.4, this is a symlink to /usr/bin.

/etc - Contains system-wide configuration files and system databases; the name stands for "et cetera".[11] Originally also contained "dangerous maintenance utilities" such as init,[12] but these have typically been moved to /sbin or elsewhere.

/usr - The "user file system": originally the directory holding user home directories, but already by the Third Edition of Research Unix, ca. 1973, reused to split the operating system's programs over two disks (one of them a 256K fixed-head drive) so that basic commands would either appear in /bin or /usr/bin. It now holds executables, libraries, and shared resources that are not system critical, like the X Window System, KDE, Perl, etc. In older Unix systems, user home directories might still appear in /usr alongside directories containing programs, although by 1984 this depended on "local customs"

12 . grep -r "printf" projects/*

13. type

ssh root@host "command"

ie: ssh root@192.168.1.1 "cat /etc/fstab"

14. root user has all the sudo priviliges. The file will be available in /etc/sudoers. It look as:

Modify here to get root access.

15.

Write Mode

When you first enter the editor, you are in the command mode. To enter the write mode, type the letter a for append. This is one of the four possible commands for entering the write mode. vi is Case Sensitive. Lower case commands are different from upper case commands.

Command Mode

You are in command mode whenever you hit esc to leave the write mode. In command mode, you can move the cursor anywhere in the file.

The x key deletes individual characters, while dd deletes an entire line. To enter the insert mode type the i key. When you're done inserting, hit the "esc" key to return to the command mode.

Command-Line Mode

Command-line mode is used for such things as writing changes and exiting the editor. To enter command-line mode, type : while in command mode. The : will now appear at the bottom of the screen and the command which you type will appear on that line.

16. . symbol is used to repeat commands in vi

17.

p

P

For example, to copy 12 consecutive lines from one part of a file to another, follow these steps:

18. :100 will jump to line 100

begining of file - press G twice

end of file - Shift + G

0 move cursor to the first column on the current line

^ move cursor to first nonblank column on the current line

w move to the beginning of the next word or punctuation mark

W move past the next space b move to the beginning of the previous word or punctuation mark

B move to the beginning of the previous word, ignores punctuation e end of next word or punctuation mark

E end of next word, ignoring punctuation

H move cursor to the top of the screen

M move cursor to the middle of the screen

L move cursor to the bottom of the screen

19 /printf

20 loading and saving the file :wq!

quitting the file without saving :q!

ssh root@host "command"

ie: ssh root@192.168.1.1 "cat /etc/fstab"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote