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

Lab Questions 1. Type \'echo $TERM. What is your terminal type? 2. What is the f

ID: 3607392 • Letter: L

Question

Lab Questions 1. Type 'echo $TERM. What is your terminal type? 2. What is the full pathname of your terminal device? (You can use the ps or w command to find your current terminal) 3. It is possible to have multiple terminal sessions opern simultaneously. You want to redirect stdout from one 4. Is it possible to redirect output from a terminal device 5. What is the difference between mgetty and getty? 6. Run stty -a. What does (CTRL-?) do? terminal to the other. How would you do this? you own to any other terminal device on the system? What would mgetty be used for? 7. Run '/sbin/ifconfig' from the shell of your Debian and Solaris virtual machines. Note the IPv4 address of the network interface. To determine the address of your CentoS VM, use the command 'ip addr. Try to SSH into the virtual machine from your host operating system. What is your termtype on this session? What is your TTY device name? 8. Recall the termtype and TTY device name of your 9. Run 'ps ax' on both virtual machines (you may have to 10. Look at 'letc/inetd.conf. What services are running original console session. Do they differ from your SSH pseudo-terminal session? pipe it to 'more' or 'less' to see everything). What process has a PID of 1? Is inetd running? under the 'super daemon'?Not all the VMs will be running inetd, and the one that is may not use /etc/inetd.conf. How can you find out what services are running?

Explanation / Answer

(1).

Command Prompt:

$ /bin/bash                                                                                                                                

$ echo $TERM                                                                                                                             

xterm-256color //output of $TERM command

The $TERM variable is for use by applications to take advantage of capabilities of that terminal.

For example, if a program want's to display colored text, it must first find out if the terminal you're using supports colored text, and then if it does, how to do colored text.

The way this works is that the system keeps a library of known terminals and their capabilities. On most systems this is in /usr/share/terminfo (there's also termcap, but it's legacy not used much any more).

So lets say you have a program that wants to display red text. It basically makes a call to the terminfo library that says "give me the sequence of bytes I have to send for red text for the xterm terminal". Then it just takes those bytes and prints them out.
You can try this yourself by doing tput setf 4; echo hi. This will get the setf terminfo capability and pass it a parameter of 4, which is the color you want.

Source: https://unix.stackexchange.com/questions/93376/which-terminal-type-am-i-using

(2).

Command Prompt:

bash-4.4$ ps                                                                                                                                     

  PID TTY          TIME CMD                                                                                                                      

   18 pts/1    00:00:00 sh                                                                                                                       

   20 pts/1    00:00:00 bash                                                                                                                     

   21 pts/1    00:00:00 ps                                                                                                                       

Command Prompt:

bash-4.4$ w                                                                                                                                      

22:55:31 up 1 day, 11:37,  0 users,  load average: 5.22, 5.42, 5.13                                                                             

USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT

Full path name really means the full path to that file or folder from the filesystem's / directory.

For example, the full path to your script is:

Or, the full path name to the grep executable is

/bin/grep

As for the ./my_script, the symbol . stands for the current directory, so you actuallly say "Look under the current directory for a file or folder named my_script"

(3)

If both terminals belong to the same user, you can send your output to the virtual device that is used as the particular terminal's tty.

So you can use the output from w, which includes the TTY information, and write directly to that device.

(If the device mentioned by w was pts/7)

Another option is to use the number of a process that is connected to that device. Send your output to /proc/<process number>/fd/1.

Command Prompt:

Assuming the process number that you found that runs in that terminal is 5555.

Note that this direct write is only allowed if the user that attempts to write is the same user that owns the other terminal.

(4)

As stated in question (3) that this direct write is only allowed if the user that attempts to write is the same user that owns the other terminal. If you don't own other terminal then you need to have root access.

(5)

getty, short for "get tty", is a Unix program running on a host computer that manages physical or virtual terminals (TTYs). When it detects a connection, it prompts for a username and runs the 'login' program to authenticate the user.

mgetty is a modem-aware getty. It supports modems with the Hayes AT command set and is especially designed for supporting modems that are used to send faxes and to dial out as well as dial in. These features are not required for a serial console.

(6)

The stty command sets certain I/O options for the device that is the current standard input. This command writes output to the device that is the current standard output.

-a option displays all the stty settings in a user friendly readable format as shown below.

Command Prompt:

bash-4.4$ stty -a                                                                                                                                

speed 38400 baud; rows 34; columns 145; line = 0;                                                                                                

intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;         

rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;                                                                            

-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts                                                                                

-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8                                     

opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0                                                                  

isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc