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

1. a Create a named pipe. Open second terminal. Attach a consumer process (for e

ID: 3734353 • Letter: 1

Question

1. a Create a named pipe. Open second terminal. Attach a consumer process (for example less or caf) to that pipe. From the first terminal start piping some text there. What do you see on a less window? b. Do different sequence of reads and write -i,e, read first, or write first. What so you see? c. Using single terminal, and messages with the background job, send more than one messages to the fifo. Run the jobs command. What do you see? After that, attach a read process on the same terminal. After you complete the read, do the jobs command again. What do you see? d Attach more than one consumer and start sending messages from the producer's end. Which one of the consumer gets messages? e. Send some text to the fifo, then do cat "yourpipe some file. Open your file. what do you see? 2. a Send email to the root. Login as a root, read the message and reply to that. Switch back to user's terminal, and check and read the email from the message b. cat the file you created on l e and pipe it to the mail to the root text? . Does the root receive the 3. Open a new file with vi Using the shell command. insert the listing of your directory to the file. Indent all inserted lines to the center of the page with the one command of vi Replace all instances of user name in the file with "nobody Practice several other commands and editing options of your choice that we discussed in this class You can do this here. in the lab, or if you prefer at your home How to submit: Copy your relevant history entries, Add comments of what you did and what was the result (what you saw, how you verified the commands). Save everything in the text file (no word!) and email to my email address as a body of the message not the attachment.

Explanation / Answer

1st your purpose is to send a mail to the root
For this you can use the command "mail" :

mail -s "Hello Root"
Hii Root
How are you
Bye
EOT

-s adds subject to the mail
EOT marks end of text

If we give -a flag, we can add attachment to the mail
Eg: mail -a /opt/myfile.txt -s "Hello Root" </dev/null

To read a mail:

echo p | mail

Echo p will display the mail content

As your mails get stored in /var/spool/mail/root, following command will also work:

cat /var/spool/mail/root

2 b. Whatever file you have created can be sent to the root or any other person as an attachment.
mail -a /opt/myfile.txt -s "Sending Attachment " </dev/null

In this example myfile.txt is the name of file I used

To take message from file:

mail -s "This is Subject" root@add.com < /path/to/file

Specify the root address and also path if the file

3. vi myFile.txt

I created a file with name myFile.txt

Move to insert mode; press the key 'i'
To replace a text :s is used
To automatically indent lines using the vieditor, set the autoindent flag:

If you are currently in insert or append mode, press Esc.
Press : (the colon).

Enter the following command:

set autoindent

When you now insert text, if you press Enter at the end of your text, vi will automatically indent the next new line to match the indent of the previous one.

Replacing a pattern
:s/patten/replace/

Here vi will take pattern as your search text. All occurances of pattern will be replaced with 'replace'

Here you want to replace all instances of your user name with 'nobody'. Let your user name is XYZ (change it to whatever correct is). Command would be

:s/ XYZ/ nobody

Other commands are:

append mode: a

ESC: escape from insert mode

u: undo

dd: delete

3ddd: delete 3 lines

And most importantly to save your work

:wq : save and quit

If you dont use w; you will quit without saving the work


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote