Listing the Contents of the Linux / dev System Directory Below The / (Root) Directory
Many of the important Linux system directories, such as the / dev directory, are located directly below the / (root) directory.
Now look at the contents of the / dev directory and find out what Linux uses it for.
Examples of Using the Linux ls Command to the List System Directories and the / dev Directory
The following command lists the contents of the / directory – from any directory. The "-l" option of the ls command is not required here.
$ Ls / Notice the dev directory, which is below the / (root) directory in the full path of / dev.
Viewing the Contents (Directories and Files) in the / dev Directory Path
Now run the following command to see the contents of the / dev directory, without having to change directory.
$ Ls / dev Example of Using the Linux nl Command To Number Lines of Output
The Linux nl (n umber l ine ) command can be used to count and display the number of lines in a file or the output of a command.
In the folloinwg example, the output of the ls command is "piped" (with the vertical bar symbol) to the nl command to display a count of the output of the command.
$ Ls -l / dev | nl This shows the device driver files for many different types of Linux hardware devices that are located in / dev and a count of the number of them.
The Linux mount command is used to mount a filesystem by assigning a mount point (such as a directory below the / mnt directory) to a hard disk partition or other disk device, such as a CD-ROM drive.
After the partition or device has been mounted, it can be accessed by application Linux software programs, utilities and commands.
Example of Using the Linux mount Command
For example, the following command:
$ Mount / dev / cdrom / mnt / cdrom causes the device file named cdrom in the / dev directory to be mounted "onto" the cdrom directory below / mnt.
The cdrom directory becomes the "mount point" for the CD and this allows you to access the filesystem of the CD.
The files in the / (root) directory of the CD become accessible below the full path of / mnt / cdrom.
Linux Commands Training Tips: On more current Linux systems, the mount command may not be required and your devices may automatically mount below the / media directory. For example, if you put a CD in your drive and it automatically appears on your Linux desktop, you do not need to use the mount command to do the steps in the command example above. The Linux ls command and dev system directory concepts covered here apply to ALL Linux distributions and versions, including Ubuntu, openSUSE, Debian, SUSE, Fedora, Slackware and Red Hat Linux.