Let's talk about device files under /dev and their functions!
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Let's talk about device files under /dev and their functions!
New linux user here. My brother introduced me to it a year or two ago and since I have shunned mac and Windows and only have Debian 10 or Kali on every computer I own.
My questions is this: What are some of the most interesting files in /dev and how can we make practical use of them??
I've already learned how to use /dev/zero with the dd command to basically completely wipe a block device like a hard drive. And I understand that you can use /dev/random to generate random numbers.
What, in ya'll's opinion are some other practical things that can be done with the device files in /dev?
Thanks in advance for the practical insight!
Arc1c_f0x
Last edited by Arct1c_f0x; 07-24-2020 at 01:11 PM.
Thanks, Scasey I'll start reading about /dev/null !
Hey, Dugan. You might know how I can use /dev/random in a bash script in a specific way.
Let me explain. I'm writing a .sh file called "Bedtime routine.sh". When I execute this file by typing sudo ./Bedtime routine.sh, the program will start, ask how long till I want the computer to shutdown and then play a selection of mozart at random from the mozart directory on my computer. I already completed the first part. My problem now is how might I use /dev/random to supply my program with some sort of value that selects a mozart piece at random from the specified directory?
This is what is looks like so far:
#!/bin/bash
# program that asks shutdown time and plays mozart file at random until shutdown.
Basically device files i.e. those files in /dev are an interface to a device driver that looks like an ordinary file. They are used for keyboards, mice, hard drives, printers, legacy parallel or serial ports, audio, optical drives. tty terminals, framebuffers and so on.
Those special files like /dev/null are known as pseudo-devices
/dev/null, /dev/random, /dev/urandom, /dev/full or /dev/zero
With modern distributions /dev is a virtual filesystem that exists only in memory and created when the system boots.
The shuf command is an easy way to use random numbers.
The site's a pretty informative site. It's one of my favorites. I'm still learning new stuff with Linux and that's one of the many awesome resources out there.
I should probably compile a list of the various sites I've found over the years. Hmm... Maybe I'll have time to do that in the near future.
The site's a pretty informative site. It's one of my favorites. I'm still learning new stuff with Linux and that's one of the many awesome resources out there.
I should probably compile a list of the various sites I've found over the years. Hmm... Maybe I'll have time to do that in the near future.
Sounds like something for the LQ Blog. I’m looking forward to it. 😉
Sounds like something for the LQ Blog. I’m looking forward to it. 😉
That's not a terrible idea. I've got a few blog articles, all but one written while probably drinking wine! I'm also not willing to maintain another blog for it - or dedicate a terrible amount of time to writing a site just for it. So, that's a good idea and I've got a ton of links. Thanks!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.