Question

In: Computer Science

You can use the "cat" command to list the content of a file. For example: cat...

You can use the "cat" command to list the content of a file. For example:

cat /etc/fstab

lists the content of the file /etc/fstab in the terminal window that you are currently using.

If you use a redirection of the standard output of the "cat' command:

cat /etc/fstab > foo

then a file named "foo" is created in the local directory and the content of the file /etc/fstab is listed by the "cat" command into the file "foo", which then contains a copy of the content of the file/etc/fstab. In that case, no output is printed to the terminal.

Execute the following command:

cat /etc/fstab > /dev/tty

What is the result? Explain why (do a search in the Unix manual: man -f tty for some help).

Solutions

Expert Solution


The fstab file present in /etc/fstab is a system configuration file that contains all disks, disk partitions, and their options.
Each file system is described on a separate line. Mount command will use this file to determine which options should be used when mounting the specified device.

Below are the contents of the fstab file
cat /etc/fstab

The below command will write the contents of /etc/fstab in foo file.
cat /etc/fstab > foo
We can view the contents of the foo file using the cat command. As mentioned no output will be printed to the terminal.

But when we execute the command cat /etc/fstab > /dev/tty


Contents are printed on the terminal because /dev/tty is a special file representing the 'controlling terminal' for the current process.

when you execute
ls -lrt /dev/tty
crw-rw-rw- 1 root tty 5, 0 Oct 18 11:50 /dev/tty

C in the beginning represents that it is a character device.

Also if we use "cat /dev/tty" , the input will be echoed again.
here I have entered '1' and '1' got echoed to the terminal and I have again entered 'numbers' and that too got duplicated on the terminal.



Related Solutions

1. At the command prompt, use the where command to locate the where.exe file. Copy and...
1. At the command prompt, use the where command to locate the where.exe file. Copy and paste the full path and filename for the where.exe file into the space provided below. 2. At the command prompt, enter the following command and press enter. find "free beer" "c:\Program Files (x86)\Notepad++\*.txt" This command searches for the string "free beer" in all .TXT files in the Notepad++ program folder. According to the output of the find command, which of the files listed below...
PART 5: Learn about commands used to view contents of files: use the cat command to...
PART 5: Learn about commands used to view contents of files: use the cat command to review the contents of the /home/test/passwd.bak type:   cat passwd.bak 2. now add the |more to the last command (see what happens when you push the up arrow curser key-it recalls the last command) 3. now try to cat the passwd.bak file but look at the first few lines and then the last few lines using the head and tail commands type:  head passwd.bak   and    tail...
Question6: Write a program to read the file 202010mid.txt, store the content in a list of...
Question6: Write a program to read the file 202010mid.txt, store the content in a list of tuples, then print the list. [6 marks] Question7: Write Python code to do the following operations using request library. [12 marks] Check if the following webpage is available or not: https://edition.cnn.com/news.html [4 marks] Send a get request to the following webpage and show the result: http://api.open-notify.org/iss-pass.json [4 marks] The webpage from part 2 is expecting some parameters as shown from the results. Now create...
5 – What cmdlet will add content to a file? 7 - How would you use...
5 – What cmdlet will add content to a file? 7 - How would you use the command from question 5 to write the date in a text file?
Which command do you use to find the process that’s holding a file open? 1. w...
Which command do you use to find the process that’s holding a file open? 1. w 2. ps 3. top 4. fuser
For the following questions, list the entire path for the indicated file. If you use the...
For the following questions, list the entire path for the indicated file. If you use the variables ORACLE_BASE or ORACLE_HOME, be sure to list their values as well. Find the location of the instance of your database (ORCL). Find the location of the file init.ora . What purpose does this file serve? Find the location of the files listener.ora and tnsnames.ora. Identify which file is on the client and which file is on the server. Find the location of the...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name it as “mysedfile”: Name Class1 Class2 Class3 Tom 92 94 88 Nancy 91 85 95 Lisa 99 77 96 Jerry 84 98 90 2. Please use sed command(s) to complete the following tasks. display Tom’s record. display Lisa’s record. display both Tom’s and Lisa’s records. remove the blank line(s) from “mysedfile.” replace all the digits with *.
Open two windows in Ubuntu, and list the content of the /dev/fd folder. Can you explain...
Open two windows in Ubuntu, and list the content of the /dev/fd folder. Can you explain the difference observed from the two windows? The name /dev/fd is actually a symbolic link to /proc/self/fd. The name self is also a symbolic link pointing to a number, which is the process ID of the current process. Therefore, the number pointed to by self is different if viewing from different windows.
Question 1 What Unix command can be used to change the access permission of a file...
Question 1 What Unix command can be used to change the access permission of a file ?   and how ? Explain how pipe works in Unix. Give one example; Explain how redirect works in Unix and give an example. Explain the structure of Unix file system and how absolute and relative paths work What is UML ?   Briefly explain two types of diagrams in UML. Briefly explain two types of testing methods for software development and the major stages in...
Use the Excel data file found in the Course Content from Module #1. Be sure to...
Use the Excel data file found in the Course Content from Module #1. Be sure to submit your file through the Project #4 drop box for this week. Masterfoods USA states that their color blends were selected by conducting consumer preference tests, which indicated the assortment of colors that pleased the greatest number of people and created the most attractive overall effect. On average, they claim the following percentages of colors for M&Ms® milk chocolate candies: 24% blue, 20% orange,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT