This is our fourth post on Linux Directory structure series. Some of the posts already covered are
- Linux Directory Structure explained: /boot folder
- Linux Directory Structure explained: /bin folder
- What is lost+found directory in Linux/Unix?
Today we will see what is /dev folder and it’s uses. Linux/Unix treat everything as files. One classic example is it treats hardware devices too as files. All hardware files are present in /dev(Device ) folder. If we observe the /dev folder you can find files/folders related to different hardware’s present in the machine.
Below are some hardware files and their uses and explanation.
This is a hardware file used to keep track of time when system goes hibernation or suspended when it is idle. When your system goes hibernation most of your hardware will be shutdown, HDD rotation is reduced to as low as possible in order to save power. This file is very much useful to keep track of system time, to do calender updates to user etc. You can say in other words that /dev/alarm will have current time status. This file is used in portable devices such as laptops and mobiles mostly. Click here to know more about this file.
This file is used to mount remote directories locally. This is done automatically when user tries to login by mounting remote directory. The mounting is done by using this hardware file. With out this hardware file we can not do automount in a Linux box.
3. /dev/block folder
This folder is legacy location for your block devices. This is still existing to support legacy applications.
4. /dev/cdrom, /dev/dvd, /dev/cdrw, /dev/dvd-rw etc
These files corresponds to Compact-Disk(/dev/cdrom or /dev/cdrw) hardware or to Digital Versatile Disk(/dev/dvd or /dev/dvd-rw) hardware. These files are required to mount your local CDrom and DVD’s so that you can access the content of the file. Know how to mount your CD/DVD in Linux.
This is the folder where char files are located in legacy machines. This is still kept to support legacy applications.
Know what is the difference between char and block file here.
6. /dev/console, /dev/tty, /dev/tty1 to /dev/tty63, /dev/ttyS, /dev/ttyS0 to /dev/ttyS31 files and /dev/pts folder
These device files are called as terminals or consoles which are char files used for communication between user and system. /dev/console file is used in Runlevel 1 and none of these terminals are available for access on runlevel 1. tty(Teletype) is a device file to do remote connection so that we can work remotely The name is derived from typewriters which are default communicating devices in early stages of Computers. The terminals range from tty0 to tty63 and serial port terminals(ttys or ttyS) are from 0 to 31. We have pseudo terminals which is used when users login from remote machines, these virtual terminals are kept in /dev/pts folder in most Linux flavors.
7. /dev/loop(/dev/loop0 to /dev/loop7)
A loop device is a Pseudo device useful for mounting Virtual CD(ISO files), HDD etc. The loop devices are useful for mounting already formatted drive and access the data in a folder mounted on different filesystem. Virtual devices are nothing but a hardware file created by kernel/OS so that we can use them as a physical drives. These loop devices are also used by virtual softwares such as KVM, VMWARE to mount CD-ROM’s, HDD(.img files for example) as physical devices in your Virtual machine. Planing to mount your ISO file, know it how to do it here.
8. /dev/sda, /dev/hda etc
These files corresponding to hard disks and storage devices such as USB hard disks, SATA disks and External HDD’s. For Intel machines you may find /dev/hda, /dev/hdb, /dev/hdc, /dev/hdd corresponds to Primary master, Primary slave, Secondary master and Secondary Slave devices. Partitions with in disks are created as /dev/sda1, sda2 etc and so on.
9. /dev/random and /dev/urandom
Used for generating random chars for Kernel purpose.
10. /dev/null and /dev/zero
Used for generating empty files, observing unwanted outputs etc. Click here to know the difference
This file is used to connect your mobile or GPRS/3G enabled devices to connect and communicate. This is pseudo file which communicates with GPRS enabled hardware file to send data. Click here to know how to connect internet using your GPRS/3G enabled device.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix- June 29, 2020
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018