Project 5-1 In this hands-on project, you view and create device files. 1. Boot
ID: 3904596 • Letter: P
Question
Project 5-1 In this hands-on project, you view and create device files. 1. Boot your Fedora Linux virtual machine. After your Linux system has loaded, switch to a command-line terminal (tty2) by pressing Ctrl+Alt+F2. Log in to the terminal using the user name of root and the password of LNXrocks!. 2. At the command prompt, type ls –l /dev/tty6 and press Enter. What device does /dev/tty6 represent? Is this file a block or character device file? Why? What are the major and minor numbers for this file? 3. At the command prompt, type rm –f /dev/tty6 and press Enter. Next, type ls –l /dev/tty6 at the command prompt and press Enter. Was the file removed successfully? 4. Switch to the command-line terminal (tty6) by pressing Ctrl+Alt+F6 and attempt to log in to the terminal using the user name of root and the password of LNXrocks!. Were you successful? 5. Switch back to the command-line terminal (tty2) by pressing Ctrl+Alt+F2, type the command mknod /dev/tty6 c 4 6 at the command prompt, and press Enter. What did this command do? Next, type ls –l /dev/tty6 at the command prompt and press Enter. Was the file re-created successfully? 6. At the command prompt, type reboot and press Enter. After your Linux system has loaded, switch to a command-line terminal (tty6) by pressing Ctrl+Alt+F6 and log in to the terminal using the user name of root and the password of LNXrocks!. Why were you successful? 7. At the command prompt, type ls –l /dev/tty? and press Enter. What is similar about all of these files? Is the major number different for each file? Is the minor number different for each file? Why? 8. At the command prompt, type find /dev and press Enter to list all of the filenames underneath the /dev directory. Are there many files? Next, type du –s /dev at the command prompt and press Enter. How large in kilobytes are all files within the /dev directory? Why? 9. At the command prompt, type cat /proc/devices | more and press Enter. Which devices and major numbers are present on your system? What character devices have a major number of 4? How does this compare with what you observed in Step 2? 10. Type exit and press Enter to log out of your shell.
Explanation / Answer
solution:-
[root@Server ~]# ls -l /dev/tty6
crw------- 1 root root 4, 6 Jun 15 14:13 /dev/tty6
What device does /dev/tty6 represent?
Basically, it is a unix virtual terminal for controlling process a current user is running. There are 7 virtual terminal a linux OS offers and tty6 is the 6th one.
Is this file a block or character device file? Why?
here “c” represents character device file. This are special type of files used in unix which is used to communicate with hardware peripheral devices currently present on the system.
What are the major and minor numbers for this file?
The major number is 4 and minor number is 6.
3) Was the file removed successfully?
Ans) yes, the file will be removed.
4) Were you successful?
No, we can’t login. Because the file does not exist.
5) function of mknod /dev/tty6 c 4 6
Ans) This command is used to create device file which are usually kept in /dev directory. The option c 4 6 denotes character device file and 4 and 6 are major and minor number.
Was the file re-created successfully?
Ans) Yes, the file recreated successfully.
6) At the command prompt, type reboot and press Enter. After your Linux system has loaded, switch to a command-line terminal (tty6) by pressing Ctrl+Alt+F6 and log in to the terminal using the user name of root and the password of LNXrocks!. Why were you successful?
Ans) Yes, it was successfully. We can now login in virtual terminal 6 also.
7. At the command prompt, type ls –l /dev/tty? and press Enter. What is similar about all of these files?
Ans) Each of the files are character files and have similar permissions for only the user.
Is the major number different for each file? Is the minor number different for each file? Why?
[root@Server ~]# ls -l /dev/tty
crw-rw-rw- 1 root tty 5, 0 Jun 15 2018 /dev/tty
the major and minor number is different because on linux the major:minor number is unique for each type of device.
At the command prompt, type find /dev and press Enter to list all of the filenames underneath the /dev directory. Are there many files?
Yes there are many character device files.
du –s /dev at the command prompt and press Enter. How large in kilobytes are all files within the /dev directory? Why?
Ans) [root@Server ~]# du -s /dev
308 /dev
The size will not be shown in Kilo Byte because those sizes are allocated on run time.
At the command prompt, type cat /proc/devices | more and press Enter. Which devices and major numbers are present on your system?
Ans) All the numbers shown in below output are major numbers.
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
6 lp
7 vcs
10 misc
13 input
14 sound
21 sg
29 fb
99 ppdev
116 alsa
Block devices:
1 ramdisk
259 blkext
7 loop
8 sd
9 md
11 sr
What character devices have a major number of 4? How does this compare with what you observed in Step 2?
Ans) 4 /dev/vc/0
4 tty
4 ttyS
All virtual terminal will have a major number of 4.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.