This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:adahmane:portfolio:unixproject6 [2013/12/12 04:44] – adahmane | user:adahmane:portfolio:unixproject6 [2013/12/12 05:36] (current) – adahmane | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Case Study 0x6: Device Files====== | ||
+ | The sixth case study in the greatest class I will ever take. | ||
+ | |||
+ | =====Objectives===== | ||
+ | Understand the use of device files within the Unix environment. | ||
+ | |||
+ | =====Procedure===== | ||
+ | Shown below, I have navigated to /dev and listed the files. I then continued to discover what types of files were in the directory. | ||
+ | |||
+ | <cli> | ||
+ | lab46:~$ cd /dev | ||
+ | lab46:/dev$ ls | ||
+ | MAKEDEV | ||
+ | block hvc3 | ||
+ | char | ||
+ | console | ||
+ | core | ||
+ | cpu_dma_latency | ||
+ | disk | ||
+ | fd | ||
+ | full | ||
+ | hvc0 | ||
+ | hvc1 | ||
+ | lab46:/dev$ file full | ||
+ | full: character special | ||
+ | lab46:/dev$ file net | ||
+ | net: directory | ||
+ | lab46:/dev$ file loop0 | ||
+ | loop0: block special | ||
+ | lab46:/dev$ file shm | ||
+ | shm: sticky directory | ||
+ | lab46:/dev$ file root | ||
+ | root: symbolic link to `xvda1' | ||
+ | </ | ||
+ | |||
+ | Here are three block devices: | ||
+ | |||
+ | <cli> | ||
+ | lab46:/dev$ ls block | ||
+ | 202:1 202:2 202:3 | ||
+ | lab46:/dev$ file block/ | ||
+ | block/ | ||
+ | lab46:/dev$ file block/ | ||
+ | block/ | ||
+ | lab46:/dev$ file block/ | ||
+ | block/ | ||
+ | </ | ||
+ | |||
+ | And three character devices: | ||
+ | |||
+ | <cli> | ||
+ | lab46:/dev$ ls char/ | ||
+ | 10:1 10:63 1:1 | ||
+ | 10: | ||
+ | 10:59 | ||
+ | 10:60 | ||
+ | 10:61 | ||
+ | 10:62 | ||
+ | lab46:/dev$ file char/10:1 | ||
+ | char/10:1: symbolic link to `../ | ||
+ | lab46:/dev$ file char/10:62 | ||
+ | char/10:62: symbolic link to `../ | ||
+ | lab46:/dev$ file char/4:51 | ||
+ | char/4:51: symbolic link to `../ | ||
+ | </ | ||
+ | |||
+ | After using the df command, I can see: | ||
+ | * The root directory is mounted on /dev/xvda1 | ||
+ | * /home is mounted on nfs:/home (which I assume exists on a separate machine? hence nfs) | ||
+ | * /tmp is mounted on /dev/xvda2 | ||
+ | |||
+ | <cli> | ||
+ | lab46:~$ df | ||
+ | Filesystem | ||
+ | / | ||
+ | tmpfs | ||
+ | udev 738M | ||
+ | tmpfs | ||
+ | / | ||
+ | nfs:/ | ||
+ | nfs:/ | ||
+ | </ | ||
+ | |||
+ | I have no stinking clue where the system swap is located. But thanks to the df command, I can see that Lab46 uses Xen Virtual Disks (since the server is virtual while running on top of Xen Server) and NFS for the storage of our home directories and mail! NFS... Pretty sure that's located on a different system and it's been mounted as a drive on this system. Meow. | ||
+ | |||
+ | ===== User-to-user messaging ===== | ||
+ | |||
+ | The permissions on my two TTY files are shown below: | ||
+ | |||
+ | <cli> | ||
+ | lab46:/ | ||
+ | /dev/pts/0 | ||
+ | lab46:/ | ||
+ | 0: character special | ||
+ | lab46:/ | ||
+ | crw--w---- | ||
+ | crw--w---- | ||
+ | </ | ||
+ | |||
+ | I personally have read/write access and the tty group has write access. | ||
+ | Here's what I get with the who command... | ||
+ | |||
+ | <cli> | ||
+ | lab46:/ | ||
+ | adahmane + pts/0 2013-12-11 22:33 | ||
+ | lab46:/ | ||
+ | is y | ||
+ | </ | ||
+ | |||
+ | My current messaging status is y (which means my terminal is available). | ||
+ | Changing that to n ought to remove the write access from the tty group. That's my assumption... Let's see! | ||
+ | |||
+ | <cli> | ||
+ | lab46:/ | ||
+ | lab46:/ | ||
+ | is n | ||
+ | lab46:/ | ||
+ | adahmane - pts/0 2013-12-11 22:33 | ||
+ | lab46:/ | ||
+ | crw------- | ||
+ | crw--w---- | ||
+ | </ | ||
+ | |||
+ | WOO! Correct. Since we are all part of the tty group, we are given the ability to print to another person' | ||
+ | Taking away the write access from the tty group (with the use of "mesg n") will prevent anyone from printing to my terminal! | ||
+ | |||
+ | Mini-mind-blow #7428307940 - Since everything is a file and /dev/pts/0 is my current terminal session, | ||
+ | I could theoretically redirect output to that file and it would be the same as using the echo command! Again, let's see... | ||
+ | |||
+ | <cli> | ||
+ | lab46:/ | ||
+ | meow | ||
+ | lab46:/ | ||
+ | meow | ||
+ | lab46:/ | ||
+ | -bash: /dev/pts/: Is a directory | ||
+ | lab46:/ | ||
+ | NAME | ||
+ | adahmane + pts/0 2013-12-11 22:33 | ||
+ | smeas + pts/2 2013-05-10 16:24 01:05 1516 (li583-226: | ||
+ | alius + pts/ | ||
+ | bh011695 + pts/ | ||
+ | smeas + pts/ | ||
+ | jmendoza + pts/ | ||
+ | jvanzil4 + pts/ | ||
+ | cclay + pts/ | ||
+ | vcordes1 + pts/ | ||
+ | jkosty6 | ||
+ | jlapham1 + pts/ | ||
+ | jkosty6 | ||
+ | jvanzil4 - pts/ | ||
+ | jmendoza + pts/8 2013-12-11 23:17 00:23 11439 (pool-96-238-196-119.bing.east.verizon.net) | ||
+ | lab46:/ | ||
+ | wow.very_shell.much_command. | ||
+ | lab46:/ | ||
+ | -bash: / | ||
+ | </ | ||
+ | |||
+ | Well, I think that shows my understanding of the pts stuff. Just another way to make text appear on my screen! | ||
+ | Really, any command could be redirected to /dev/pts/0 (or whatever port I'm on) to display text on my terminal! | ||
+ | As you can see above, I attempted to harass John Kosty but it didn't work out as well as I had hoped... | ||
+ | |||
+ | =====The terminal pointer===== | ||
+ | |||
+ | <cli> | ||
+ | lab46:~$ cat /etc/motd | ||
+ | | ||
+ | | | __ _| |__ / | |_/ / . Basic System Usage: | ||
+ | | |__/ _` | '_ \\_ _/ _ \ . Events and News: Type ' | ||
+ | |_____\__, | ||
+ | --------------------------- | ||
+ | c o r n i n g - c c . e d u . . . . . . . . . . . . . . . . . . . . . . . . . | ||
+ | |||
+ | Lab46 is the Computer & Information Science Department' | ||
+ | | ||
+ | | ||
+ | .. . . . . . . . . . .. | ||
+ | | ||
+ | | ||
+ | | ||
+ | .. . . . . . . . . . .. | ||
+ | _ | ||
+ | .-./*) | ||
+ | _/ | ||
+ | U U 'You can filter data with the ' | ||
+ | lab46:~$ cat /etc/motd > /dev/tty | ||
+ | | ||
+ | | | __ _| |__ / | |_/ / . Basic System Usage: | ||
+ | | |__/ _` | '_ \\_ _/ _ \ . Events and News: Type ' | ||
+ | |_____\__, | ||
+ | --------------------------- | ||
+ | c o r n i n g - c c . e d u . . . . . . . . . . . . . . . . . . . . . . . . . | ||
+ | |||
+ | Lab46 is the Computer & Information Science Department' | ||
+ | | ||
+ | | ||
+ | .. . . . . . . . . . .. | ||
+ | | ||
+ | | ||
+ | | ||
+ | .. . . . . . . . . . .. | ||
+ | _ | ||
+ | .-./*) | ||
+ | _/ | ||
+ | U U 'You can filter data with the ' | ||
+ | </ | ||
+ | |||
+ | Apparently I just did something very similar above. Kinda. This method allowed me to redirect the output of the cat to my terminal session. Nifty! | ||
+ | |||
+ | =====Something and nothing===== | ||
+ | |||
+ | I'm not even going to type this one into the terminal... I know that redirecting to null won't show me anything. We learned this in class one day. It could be useful for cronjobs so as not to receive any output from the completion of the task! That's just one of a million or more examples. | ||
+ | |||