Questions tagged [devices]

devices refers to questions about the Unix/Linux device special files, normally these are under /dev. Do not use this tag for physical devices (for that use e.g. usb or pci).

Filter by
Sorted by
Tagged with
221
votes
14answers
864k views

How do I find out what hard disks are in the system?

I need to know what hard disks are available, including ones that aren't mounted and possibly aren't formatted. I can't find them in dmesg or /var/log/messages (too much to scroll through). I'm hoping ...
114
votes
9answers
21k views

Why is /dev/null a file? Why isn't its function implemented as a simple program?

I am trying to understanding the concept of special files on Linux. However, having a special file in /dev seems plain silly when its function could be implemented by a handful of lines in C to my ...
111
votes
7answers
38k views

How are “/dev” Linux files created?

There are special files in Linux that are not really files. The most notable and clear examples of these are in the dev folder, "files" like: /dev/null - Ignores anything you write to the file /dev/...
86
votes
3answers
10k views

What does the letter 'u' mean in /dev/urandom?

I understand that reads to /dev/random may block, while reading /dev/urandom is guaranteed not to block. Where does the letter u come into this? What does it signify? Userspace? Unblocking? Micro? ...
83
votes
4answers
320k views

How can I find available network interfaces?

This is in regard to linux, but if anyone knows of a general *nix method that would be good. I booted a system yesterday with an ethernet cable plugged in. "NetworkManager" is not installed, so once ...
70
votes
3answers
80k views

What is stored in /dev/pts files and can we open them?

According to my knowledge, /dev/pts files are created for ssh or telnet sessions.
68
votes
3answers
56k views

When to use /dev/random vs /dev/urandom

Should I use /dev/random or /dev/urandom? In which situations would I prefer one over the other?
67
votes
9answers
21k views

Why do we need to mount on Linux?

I understand what mounting is in Linux, and I understand device files. However I do not understand WHY we need to mount. For example, as explained in the accepted answer of this question, using this ...
67
votes
3answers
81k views

What are character special and block special files in a unix system? [duplicate]

How are character special files and block special files different from regular files in a Unix-like system? Why are they called “character special” and “block special” respectively?
67
votes
4answers
21k views

Why are network interfaces not in /dev like other devices?

I'm mostly curious, but why aren't network interfaces in /dev? Are there any other kinds of devices that aren't represented as a node under /dev?
62
votes
2answers
29k views

How to create /dev/null?

I deleted my /dev/null. How can I restore it?
50
votes
3answers
45k views

Understanding /dev and its subdirs and files

$ ls -l /dev/stdin /dev/fd/0 lrwx------ 1 tim tim 64 2011-08-07 09:53 /dev/fd/0 -> /dev/pts/2 lrwxrwxrwx 1 root root 15 2011-08-06 08:14 /dev/stdin -> /proc/self/fd/0 $ ls -l /dev/pts/2 /proc/...
49
votes
4answers
64k views

What is the mknod command used for?

I just started using Ubuntu as my main OS and I wanted to learn about things I should not do, and learn by the bad things people have done in the past. I came across these email about horror stories ...
32
votes
1answer
107k views

How to find which serial port is in use?

The Question: I plugged in a device (i.e. GSM modem) through a serial port (a.k.a. RS-232), and I need to see with which file in /dev/ filesystem this device was tied up, to be able to communicate ...
31
votes
1answer
10k views

What do the device files in /dev actually do?

(Not a duplicate of Understanding /dev and its subdirs and files) I was browsing around my filesystem and for the first time I took a second to analyze my /dev directory. I was surprised by the ...
29
votes
1answer
22k views

Difference between /dev and /sys/class?

What is the difference between the device representation in /dev and the one in /sys/class? Is one preferred over the other? Is there something one offers and the other doesn't?
28
votes
5answers
3k views

How does Linux differentiate between real and unexisting (eg: device) files?

This is a rather low-level question, and I understand that it might not be the best place to ask. But, it seemed more appropriate than any other SE site, so here goes. I know that on the Linux ...
26
votes
2answers
14k views

What’s the difference between a “raw” and a “cooked” device driver?

Does this concept only apply to terminal drivers (which is what most sites cover) or to any driver in general?
25
votes
1answer
3k views

Why don't reads from /dev/zero count as IO_RBYTES?

I am emptying out a hard drive on some Linux 4.x OS using this command: sudo sh -c 'pv -pterb /dev/zero > /dev/sda' And I opened another tty and started sudo htop and noticed this: PID USER ...
25
votes
3answers
6k views

mv a file to /dev/null breaks dev/null

If I do: touch file; mv file /dev/null as root, /dev/null disappears. ls -lad /dev/null results in no such file or directory. This breaks applications which depend on /dev/null like SSH and can be ...
25
votes
2answers
26k views

How do mouse events work in linux?

This is mostly out of curiosity, I'm trying to understand how event handling works on a low level, so please don't reference me to a software that'll do it for me. If for example I want to write a ...
24
votes
2answers
47k views

How does cat know the baud rate of the serial port?

I regularly use cat to view debugging information in the console from my FPGA development board over the serial connection, but I never have had to tell linux what the baud rate is. How does cat know ...
24
votes
1answer
35k views

using devtmpfs for /dev

I have noticed the following option in the kernel: CONFIG_DEVTMPFS Device Drivers -> Generic Driver Options -> Maintain devtmpfs to mount at /dev And I see that it is enabled by default in the ...
23
votes
2answers
56k views

set baud speed for tty

How do I set the baud speed for a specific tty (in this case a serial port)? I tried using stty -F /dev/tty.iap ispeed 19200 But get the error Invalid argument for every speed I try (2400, 4800, ...
22
votes
1answer
16k views

Difference between /dev/null and /dev/zero

When trying to redirect to /dev/null and /dev/zero, the output it is discarded. It seems both /dev/null and /dev/zero accept and discard all input. So, what is the difference between /dev/null and /...
21
votes
3answers
3k views

What happens if you delete a device file?

I roughly know about the files located under /dev. I know there are two types (character/block), accessing these files communicates with a driver in the kernel. I want to know what happens if I ...
20
votes
8answers
3k views

How can I put a bit mask on /dev/zero so that I can get bytes other than zero?

How can I put a bit mask on /dev/zero so that I can have a source not only for 0x00 but also for any byte between 0x01 and 0xFF?
20
votes
2answers
10k views

Manipulating /dev/video

I'd like to take the video stream from /dev/video0, apply some effects or changes and make the result available on /dev/video1. /dev/video0 ---> Apply Effects ---> /dev/video1 For example, mplayer ...
19
votes
3answers
7k views

Is /dev/nvram dangerous to write to?

I found information that nvram is used for BIOS flashing/backup and that it contains some bios related data. Would cat /dev/random > /dev/nvram permanently brick computer? I'm quite tempted to type ...
19
votes
1answer
9k views

Why is “nodev” in /etc/fstab so important? How can character devices be used for hacking?

I am learning about linux security and struggling to understand why a USB stick with a character device on it is potentially dangerous. If I have a USB stick with a bash executable that has setuid ...
19
votes
1answer
9k views

Difference between /dev and /sys

Exactly what is the difference between devfs and sysfs? Both seem to maintain a list of hardwares attached to the system. Then why the need for 2 separate fs even arose? As far as I can get /sys ...
19
votes
3answers
7k views

Monitor what is being sent to /dev/null?

Just for fun: Is there a way to monitor/capture/dump whatever is being written to /dev/null? On Debian, or FreeBSD, if it matters, any other OS specific solutions are also welcome.
18
votes
2answers
7k views

bash script to detect and record mouse movements?

I need to be able to record the mouse movements every so often (every .2 of a second for example) and have them in a coordinate representation instead of a diff. I found the following script: #!/bin/...
18
votes
3answers
61k views

How to Reset/Cycle Power to a PCIe Device?

I have a PCIe device that only works correctly when the computer is fully powered off then on again. Issuing a simple reboot or reboot -p command does not appear to cycle the power to the PCIe card, ...
18
votes
2answers
2k views

Should I use single or double angle brackets to redirect to /dev/null?

Most answers here [1] [2] [3] use a single angle bracket to redirect to /dev/null, like this : command > /dev/null But appending to /dev/null works too : command >> /dev/null Except for ...
17
votes
2answers
11k views

How does /dev/fd relate to /proc/self/fd/?

$ ls -l /dev/stdin /dev/fd/0 lrwx------ 1 tim tim 64 2011-08-07 09:53 /dev/fd/0 -> /dev/pts/2 lrwxrwxrwx 1 root root 15 2011-08-06 08:14 /dev/stdin -> /proc/self/fd/0 $ ls -l /dev/pts/2 /proc/...
16
votes
4answers
35k views

How can I tell whether a network interface is physical (device) or virtual (alias)?

I have a small home router running OpenWrt (Kind of embedded Linux for routers). It has five Ethernet ports, one labeled WAN and four labeld LAN 1 to 4. It has the following Network Interfaces defined ...
16
votes
3answers
34k views

Mounting a device — role of /dev, /media and /mnt, and the mount command [closed]

I have several closely related questions about what happens when I insert a CD. The files on the CD /media/Ubuntu\ 11.04\ i386/, but from what I've seen /dev/cdrom is also involved. What is the ...
16
votes
3answers
30k views

How to grant non-root user access to device files

I have device file that appears in /dev when a specific board is plugged in. The read and write operations to it work just fine, but in order to open the device file the program needs to be executed ...
15
votes
4answers
9k views

Are there alternatives to using `udev`?

While I understand the greatness of udev and appreciate the developers' effort, I was simply wondering if there is an alternative to it. For instance, I might imagine there should be a way to make ...
15
votes
5answers
23k views

Find out what device /dev/root represents in Linux?

On linux, there is a /dev/root device node. This will be the same block device as another device node, like /dev/sdaX. How can I resolve /dev/root to the 'real' device node in this situation, so ...
15
votes
4answers
13k views

Can I setup a loopback audio device?

If I can send audio to the output devices, then I can record the same audio as a wave. With filesystems, you can just setup a loopback filesystem and write binary data on a file instead of a device. ...
15
votes
1answer
1k views

What are nvme namespaces? How do they work?

I've recently begun supporting Linux installed on devices with built-in nvme ssds. I noticed the device files had an extra number, beyond a number identifying the drive number and the partition number....
14
votes
2answers
3k views

Are /dev/{udp,tcp} standardized or available everywhere?

I've recently learned about the /dev/udp and /dev/tcp pseudo-devices here. Are they specific to some GNU/Linux distributions or can I find them on other unix systems? Are they standardized in some ...
14
votes
2answers
43k views

PKCS#7 signature not signed with a trusted key

Installed Ubuntu with SIP disabled on MacBook 2017 - 0 issues, booted in seconds. I have been building it out and created a problem while trying to make the WiFi work. At some point (it was very late)...
14
votes
2answers
17k views

What causes /dev/disk/by-label to be populated?

I've noticed that Linux distributions typically have a /dev/disk/by-label directory, but this isn't always the case (For example, the CirrOS Linux test image doesn't have one). What's required on a ...
13
votes
2answers
1k views

Why are < or > required to use /dev/tcp

When trying to call /dev/tcp/www.google.com/80, by typing /dev/tcp/www.google.com/80 Bash says no such file or directory. When looking at other people's code online, they use syntax such as 3<&...
13
votes
4answers
2k views

Trouble with understanding the concept of mounting

Having read both What is meant by mounting a device in Linux? and understanding "mount" as a concept in the OS, I have a problem where it is stated that All accessible storage must have ...
13
votes
2answers
15k views

Using bash's `/dev/udp`, how would I know if the port was open?

I do not have access to netcat or nmap so I'm trying to use bash and the /dev/udp/ special files to test ports. I could do something like: echo "" > /dev/udp/example.com/8000 But $? is always 0 ...
13
votes
4answers
6k views

If I connect a physical device, how can I ever know which device file belongs to it?

Say I plug in several USB drives which don't get automatically mounted. How can I find out which device file belongs to which physical device, so I can mount it for example? I'm running Mac OS X but ...