date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,291,622,291,000 |
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?
Update:
Based on the initial wording of the question, there has been some debate over the usefulness of /dev/random vs /d... |
Unlimited.
In Linux, comparing the kernel functions named random_read and random_read_unlimited
indicates that the etymology of the letter u in urandom isunlimited.
This is confirmed by line 114:
The /dev/urandom device does not have this limit [...]
Update:
Regarding which came first for Linux, /dev/random or /de... | What does the letter 'u' mean in /dev/urandom? |
1,291,622,291,000 |
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 command:
mount /dev/cdrom /media/cdrom
we are mounting the CDROM device to /media/cdrom and eventually are able to acc... |
One reason is that block level access is a bit lower level than ls would be able to work with. /dev/cdrom, or dev/sda1 may be your CD ROM drive and partition 1 of your hard drive, respectively, but they aren't implementing ISO 9660 / ext4 - they're just RAW pointers to those devices known as Device Files.
One of the t... | Why do we need to mount on Linux? |
1,291,622,291,000 |
$ 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/self/fd/0
crw--w---- 1 tim tty 136, 2 2011-08-07 09:54 /dev/pts/2
lrwx------ 1 tim tim 64 2011-08-07 09:54 /proc/self/fd/0... |
Almost all the files under /dev are device files. Whereas reading and writing to a regular file stores data on a disk or other filesystem, accessing a device file communicates with a driver in the kernel, which generally in turn communicates with a piece of hardware (a hardware device, hence the name).
There are two t... | Understanding /dev and its subdirs and files |
1,291,622,291,000 |
I deleted my /dev/null. How can I restore it?
|
mknod /dev/null c 1 3
chmod 666 /dev/null
Use these command to create /dev/null or use null(4) manpage for further help.
| How to create /dev/null? |
1,291,622,291,000 |
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 /dev/zero?
|
Yes, both accept and discard all input, but their output is not the same:
/dev/null produces no output.
/dev/zero produces a continuous stream of NULL (zero value) bytes.
You can see the difference by executing cat /dev/null and cat /dev/zero.
Try cat /dev/null > file and you will find an empty file.
Now try cat ... | Difference between /dev/null and /dev/zero |
1,291,622,291,000 |
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 that UNIX & Linux sys admins had done on their own system when they where new. Many of them involved the use of the mkno... |
mknod was originally used to create the character and block devices that populate /dev/. Nowadays software like udev automatically creates and removes device nodes on the virtual filesystem when the corresponding hardware is detected by the kernel, but originally /dev was just a directory in / that was populated durin... | What is the mknod command used for? |
1,291,622,291,000 |
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 with it. Unfortunately there is no newly created file in /dev/ nor can be seen anything in dmesg output. So this seems to ... |
Unfortunately serial ports are non-PlugNPlay, so kernel doesn't know which device was plugged in. After reading a HowTo tutorial I've got the working idea.
The /dev/ directory of unix like OSes contains files named as ttySn (with n being a number). Most of them doesn't correspond to existing devices. To find which on... | How to find which serial port is in use? |
1,291,622,291,000 |
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?
|
The files in /dev are actual devices files which UDEV creates at run time. The directory /sys/class is exported by the kernel at run time, exposing the hierarchy of the hardware through sysfs.
From the libudev and Sysfs Tutorial
excerpt
On Unix and Unix-like systems, hardware devices are accessed through special file... | Difference between /dev and /sys/class? |
1,291,622,291,000 |
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. IDE/SATA/SCSI drives normally only have a drive letter and partition number.
For example: /dev/nvme0n1p2
I got to won... |
In NVM Express and related standards, controllers give access to storage divided into one or more namespaces. Namespaces can be created and deleted via the controller, as long as there is room for them (or the underlying storage supports thin provisioning), and multiple controllers can provide access to a shared names... | What are nvme namespaces? How do they work? |
1,291,622,291,000 |
Let’s say I have 50 USB flash drives.
I assume they get to be /dev/sda to /dev/sdz. What comes after /dev/sdz?
|
It will go to /dev/sdaa, /dev/sdab, /dev/sdac, etc.
Here is a comment from the source code:
/**
* sd_format_disk_name - format disk name
* @prefix: name prefix - ie. "sd" for SCSI disks
* @index: index of the disk to format name for
* @buf: output buffer
* @buflen: length of the output buffer
*
* SCSI dis... | What happens when Linux goes out of letters for drives? |
1,291,622,291,000 |
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 Debian distribution kernel 3.2.0-4-amd64
I am trying to understand what difference this option brings. Without this option, /... |
devtmpfs is a file system with automated device nodes populated by the kernel. This means you don't have to have udev running nor to create a static /dev layout with additional, unneeded and not present device nodes. Instead the kernel populates the appropriate information based on the known devices.
On the other han... | using devtmpfs for /dev |
1,291,622,291,000 |
Does this concept only apply to terminal drivers (which is what most sites cover) or to any driver in general?
|
The terms raw and cooked only apply to terminal drivers. "Cooked" is called canonical and "raw" is called non-canonical mode.
The terminal driver is, by default a line-based system: characters are buffered internally until a carriage return (Enter or Return) before it is passed to the program - this is called "cooked... | What’s the difference between a “raw” and a “cooked” device driver? |
1,291,622,291,000 |
(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 amount of devices files in it, and couldn't make sense of all of them:
max@linux-vwzy:/dev> ls
adsp disk fd0... |
Some of these have man pages (in section 4; leave out the final digit(s) and in a few cases such as sda the final letter).
For a more definitive, but usually less easy to read answer, look in the kernel documentation. First determine whether the device is a block device or a character device, and its major and minor n... | What do the device files in /dev actually do? |
1,291,622,291,000 |
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 program in C/C++ that reacts to mouse clicks,
I assume I need to use a system call to hook some function to the kernel,
o... |
If you're writing a real-world program that uses the mouse in Linux, you're most likely writing an X application, and in that case you should ask the X server for mouse events. Qt, GTK, and libsdl are some popular C libraries that provide functions for accessing mouse, keyboard, graphics, timers, and other features n... | How do mouse events work in linux? |
1,291,622,291,000 |
First some specs: my computer is an HP EliteBook 8460p. It comes with an integrated Chicony HP HD webcam.
My issue is that a lot of applications (well, at least Skype and guvcview) are displaying multiple lines for the same webcam; indeed, if I do ls -l /dev | grep video, I get the following:
crw-rw---- 1 root video ... |
The second device provides metadata about the video data from the first device. The new devices were introduced by this patch:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=088ead25524583e2200aa99111bea2f66a86545a
More information on the V4L metadata interface can be found here:
https:... | Multiple /dev/video for one physical device |
1,291,622,291,000 |
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 difference between /dev,
/media and /mnt? Following is what I
have found from internet but I still
have little idea:
/dev... |
There are a lot of questions here and I'll do my best to answer them. I'm certain that those more knowledgeable than I will be able to help you further. (I'd appreciate if those people could help me out too.)
In *nix, everything is a file. For example, your CD-ROM is a file.
/dev - Here you'll find physical devices a... | Mounting a device — role of /dev, /media and /mnt, and the mount command [closed] |
1,291,622,291,000 |
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 what the baud rate of the serial connection is?
|
The stty utility sets or reports on terminal I/O characteristics for the device that is its standard input. These characteristics are used when establishing a connection over that particular medium. cat doesn't know the baud rate as such, it rather prints on the screen information received from the particular connecti... | How does cat know the baud rate of the serial port? |
1,291,622,291,000 |
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 filesystem, some files actually exist, for example: /usr/bin/bash is one that exists. However, (as far as I understand it), so... |
So there are basically two different types of thing here:
Normal filesystems, which hold files in directories with data and metadata, in the familiar manner (including soft links, hard links, and so on). These are often, but not always, backed by a block device for persistent storage (a tmpfs lives in RAM only, but i... | How does Linux differentiate between real and unexisting (eg: device) files? |
1,291,622,291,000 |
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 that I can show a user a sensible device name?
For example, I might encounter this situation when parsing /proc/mounts.
I'... |
Parse the root= parameter from /proc/cmdline.
| Find out what device /dev/root represents in Linux? |
1,291,622,291,000 |
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 PRI NI CPU% RES SHR IO_RBYTES IO_WBYTES S TIME+ Command
4598 root 20 0 15.5 1820 1596 4096 ... |
They do count as I/O, but not of the type measured by the fields you’re looking at.
In htop, IO_RBYTES and IO_WBYTES show the read_bytes and write_bytes fields from /proc/<pid>/io, and those fields measure bytes which go through the block layer. /dev/zero doesn’t involve the block layer, so reads from it don’t show up... | Why don't reads from /dev/zero count as IO_RBYTES? |
1,291,622,291,000 |
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 way?
So far, I've been able to use them successfuly on OS X, Arch Linux and CentOS.
|
This is a feature of the shell and not the operating system.
So, for example,on Solaris 10 with ksh88 as the shell:
% cat < /dev/tcp/localhost/22
ksh: /dev/tcp/localhost/22: cannot open
However if we switch to bash:
% bash
bash-3.2$ cat < /dev/tcp/localhost/22
SSH-2.0-Sun_SSH_1.1.5
So bash interprets the /dev/tcp bu... | Are /dev/{udp,tcp} standardized or available everywhere? |
1,291,622,291,000 |
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 root on it, the danger is obvious: Anybody with such a USB stick can gain root privileges on my computer if I have an entr... |
Because access to the underlying device is controlled only by file permissions by default, so if your USB stick contains a POSIX filesystem with a world-writable device node corresponding to a real device in the system, you can use that device node to access the corresponding device as a "plain" user. Imagine a device... | Why is "nodev" in /etc/fstab so important? How can character devices be used for hacking? |
1,291,622,291,000 |
$ 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/self/fd/0
crw--w---- 1 tim tty 136, 2 2011-08-07 09:54 /dev/pts/2
lrwx------ 1 tim tim 64 2011-08-07 09:54 /proc/self/fd/0... |
/dev/fd and /proc/self/fd are exactly the same; /dev/fd is a symbolic link to /proc/self/fd. /proc/self/fd is part of a larger scheme that exposes the file descriptor of all processes (/proc/$pid/fd/$number). /dev/fd exists on other unices and is provided under Linux for compatibility. /proc/*/fd is specific to Linux.... | How does /dev/fd relate to /proc/self/fd/? |
1,291,622,291,000 |
I would like to bind/unbind my usb device - a wireless adapter.
echo -n "1-1:1.0" > /sys/bus/usb/drivers/ub/unbind
So to able to do that, I need the bus ID. lsusb prints out the following:
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus ... |
As I was grepping for the productVendor 😠I kept thinking this can't be so hard (though inventive)... Might as well RTFM. man lsusb:
-t, --tree
Tells lsusb to dump the physical USB device hierarchy as a tree. Verbosity can be increased twice with the v option.
...twice. TWICE. lsusb -tvv:
/: Bus 06.... | how to get bus id of an usb device |
1,291,622,291,000 |
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 resolved by doing mknod /dev/null c 1 3; chmod 666 /dev/null. Why does moving a regular file to this special file resul... |
Looking at the source code for mv, http://www.opensource.apple.com/source/file_cmds/file_cmds-220.7/mv/mv.c :
/*
* If rename fails because we're trying to cross devices, and
* it's a regular file, do the copy internally; otherwise, use
* cp and rm.
*/
if (lstat(from, &sb)) {
warn("%s", from);
return (1);
}... | mv a file to /dev/null breaks dev/null |
1,291,622,291,000 |
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 tv:// -vo caca will display the output of /dev/video in ascii art. I would like to make that available on /dev/video1 so ... |
For sure. Here are two suggestions:
Behind the scenes CLI. Use V4L2VD to create a virtual video device such as /dev/videoVirt1 and pipe through mplayer for the effects. Even some similar examples in the notes.
Use a fat desktop program such as webcamstudio to create the pipes and do your skype/broadcast wonders - sti... | Manipulating /dev/video |
1,291,622,291,000 |
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?
|
The following bash code is set to work with the byte being representred in binary. However you can easily change it to handle ocatal, decimal or hex by simply changing the radix r value of 2 to 8, 10 or 16 respectively and setting b= accordingly.
r=2; b=01111110
printf -vo '\\%o' "$(($r#$b))"; </dev/zero tr '\0' "... | How can I put a bit mask on /dev/zero so that I can get bytes other than zero? |
1,291,622,291,000 |
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 as per ifconfig:
root@TIBERIUS: ~ > ifconfig | grep Link
br-lan Link encap:Ethernet HWaddr 00:23:CD:20:C3:B0
eth0 ... |
You can check /sys:
anthony@Zia:/sys/class/net$ ls -l /sys/class/net/
total 0
lrwxrwxrwx 1 root root 0 Dec 11 15:38 br0 -> ../../devices/virtual/net/br0
lrwxrwxrwx 1 root root 0 Dec 11 15:38 lan -> ../../devices/pci0000:00/0000:00:1e.0/0000:07:01.0/net/lan
lrwxrwxrwx 1 root root 0 Dec 11 15:38 lo -> ../../devices/virt... | How can I tell whether a network interface is physical (device) or virtual (alias)? |
1,291,622,291,000 |
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 this command but somehow I feel it's not gonna end up well for my machine so I guess I'd like to know how dangerous is pl... |
I'm curious as to exactly why you'd want to run such a command if you think it might damage your computer...
/dev/nvram provides access to the non-volatile memory in the real-time clock on PCs and Ataris. On PCs this is usually known as CMOS memory and stores the BIOS configuration options; you can see the information... | Is /dev/nvram dangerous to write to? |
1,291,622,291,000 |
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 delete one -- specifically for both types of file. If I delete a block device file, say /dev/sda, what effect -- if any --
... |
Those are simply (special) files. They only serve as "pointers" to the actual device. (i.e. the driver module inside the kernel.)
If some command/service already opened that file, it already has a handle to the device and will continue working.
If some command/service tries to open a new connection, it will try to acc... | What happens if you delete a device file? |
1,291,622,291,000 |
While trying to understand this other question, I encountered /dev/sda0 being mentioned.
I have some experience in Linux and I'm used to this scheme where sda, sdb, … are devices and sda1, sda2, … , sdb1, sdb2, … are partitions (each inside the respective device). In this scheme sda0, sdb0, … do not appear. I don't re... |
I’m not aware of /dev/sda0 ever being a standard device name, even on other Unix systems. And as far as I can tell, references to sda0 are likely mistakes rather than indications of a custom setup.
Even in cases where the devices are named in output, users still confuse the numbers. For example, this forum post explic... | What is `/dev/sda0`? Is it a standard thing? |
1,291,622,291,000 |
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 Linux system for the /dev/disk/by-label directory to be properly populated?
|
On most modern Linux systems, pretty much everything under /dev is put there by udev.
On my Debian machine, /dev/disk/by-label comes from several files under /lib/udev/rules.d For example, here is a rule from 60-persistent-storage.rules:
ENV{ID_FS_LABEL_ENC}=="?*", ENV{ID_FS_USAGE}=="filesystem|other", \
S... | What causes /dev/disk/by-label to be populated? |
1,291,622,291,000 |
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.
|
Making /dev/null a named pipe is probably the easiest way. Be warned that some programs (sshd, for example) will act abnormally or fail to execute when they find out that it isn't a special file (or they may read from /dev/null, expecting it to return EOF).
# Remove special file, create FIFO and read from it
rm /dev/n... | Monitor what is being sent to /dev/null? |
1,291,622,291,000 |
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 startup script that creates most of the device nodes which on my system (no changing hardware) are most the same anyway.
... |
There are various alternatives to udev out there. Seemingly Gentoo can use something called mdev. Another option would be to attempt to use udev's predecessor devfsd. Finally, you can always create all the device files you need with mknod.
Note that with the latter there is no need to create everything at boot time si... | Are there alternatives to using `udev`? |
1,291,622,291,000 |
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/bash
while :
do
cat /dev/input/mice | read -n 1
date
sleep 1
done
But it doesn't seem to print anything to the terminal... |
Try the following command :
xdotool getmouselocation 2>&1 |
sed -rn '${s/x:([0-9]+) y:([0-9]+) .*/\1x\2/p}'
See http://www.semicomplete.com/projects/xdotool/
| bash script to detect and record mouse movements? |
1,365,982,813,000 |
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 with root priveledges. Is there any way I can all a non-root user to open this one specific device file without having t... |
Yes, you may write an udev rule.
In /etc/udev/rules.d make a file 30-mydevice.rules (number has to be from 0 to 99 and decides only about the script running order; name doesn't really matter, it has just to be descriptive; .rules extension is required, though)
In this example I'm assuming your device is USB based and ... | How to grant non-root user access to device files |
1,365,982,813,000 |
What do I need to do to have read permissions on /dev/hidraw*?
I'm seeing stuff about udev rules and saw this on the net, but the world of udev is like a foreign land to me, and if there's some sort of a simpler solution where I just add myself to a group that'd be dandy...
(Ubuntu 13.10 Preview)
Feel free to retag th... |
I gave up running around trying to figure out some other means of doing it than udev rules, and instead just learned a bit about udev and wrote a flippin' rule. The following line was placed in a .rules file (I named mine 99-hidraw-permissions.rules) located under /etc/udev/rules.d.
KERNEL=="hidraw*", SUBSYSTEM=="hidr... | /dev/hidraw: read permissions |
1,365,982,813,000 |
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 the extra character, is there any reason not to do this ? Is either of these "nicer" to the underlying implementation of /dev/nul... |
By definition /dev/null sinks anything written to it, so it doesn't matter if you write in append mode or not, it's all discarded. Since it doesn't store the data, there's nothing to append to, really.
So in the end, it's just shorter to write > /dev/null with one > sign.
As for the edited addition:
The open(2) manpa... | Should I use single or double angle brackets to redirect to /dev/null? |
1,365,982,813,000 |
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<>/dev/tcp/www.google.com/80
I noticed that this works as well:
</dev/tcp/www.google.com/80
Why are these symbols required ... |
Because that's a feature of the shell (of ksh, copied by bash), and the shell only.
/dev/tcp/... are not real files, the shell intercepts the attempts to redirect to a /dev/tcp/... file and then does a socket(...);connect(...) (makes a TCP connection) instead of a open("/dev/tcp/..."...) (opening that file) in that ca... | Why are < or > required to use /dev/tcp |
1,365,982,813,000 |
I want to automatically test if a piece of software reacts as expected if an essential SQLite DB file fails to be read (causing an I/O error). Exactly that happened some days ago at a client. We manually fixed it but now I want to create automatic code to fix it and need access to a broken file to test that.
As everyt... |
You can use dmsetup to create a device-mapper device using either the error or flakey targets to simulate failures.
dmsetup create test --table '0 123 flakey 1 0 /dev/loop0'
Where 123 is the length of the device, in sectors and /dev/loop0 is the original device that you want to simulate errors on. For error, you don... | Special File that causes I/O error |
1,365,982,813,000 |
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.
My question is: Can I send the audio signal to a (for instance) WAV file instead of my audio devices? How?
|
Yes.
Actually there are lots of ways. You can set up a sound dummy sound card device that you can just rip the data out of the device ... however this isn't a very useful format.
More useful to you is something like the arecord utility that allows you to eavesdrop on the alsa output stream and save it to several known... | Can I setup a loopback audio device? |
1,365,982,813,000 |
I wrote this rule for testing purpose:
SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Kingston", ATTRS{serial}=="001CC0EC34A2BB318709004B", ATTRS{idVendor}=="0951", ATTRS{idProduct}=="1642", SYMLINK+="pen", NAME="pendrak"
based on the following info:
# udevadm info --name=/dev/sdb --attribute-walk
Udevadm info starts with... |
According to udev manual, there's no way to change the names of files in the /dev/ directory:
NAME
The name to use for a network interface. The name of a device node
cannot be changed by udev, only additional symlinks can be created.
So, in my case I should write rules similar to these:
KERNEL=="sd?3", ACTION=="add",... | Is there a way to change device names in /dev directory? |
1,365,982,813,000 |
I am using ZFS since a while now without problems. I am still excited about it, and I highly trust it. But from time to time, new questions come to my mind (in particular after having read some documentation, which sometimes increases the number of questions instead of reducing it).
In this case, I have added a new vd... |
In order to view the current value of a specific setting like ashift, you will need to use the zdb command instead of the zpool command.
Running zdb on its own with no arguments will give you a view of any pools found on the system, and their vdevs, and disks within the vdevs.
root@pve1:/home/tim# zdb
pm1:
version... | With ZFS on Linux, how do I list device (vdev) specific properties? |
1,365,982,813,000 |
I've been reading the Advanced Linux Programming book and it mentions about virtual terminals which, if I understood it correctly, it is a Linux-specific feature (not in Unix) to allow multiple login consoles in a non X11 system. You create virtual terminals by pressing ALT-F2. I'm running Linux Mint and in my /dev fo... |
These are specifically virtual console devices, in Linux terminolgy. Supporting virtual consoles on the same physical device isn't unique to Linux (for example, BSD calls them “hardware terminal ports”).
Linux doesn't have a mechanism for creating console devices on demand. The 63 consoles are not always active (you n... | Why are there so many virtual terminal devices? |
1,365,982,813,000 |
I'm trying to clarify which is the most useful (in terms of functionality) method of interacting with devices in Linux. As I understand, device files expose only part of functionality (address blocks in block devices, streams in character devices, etc...). ioctl(2) seems to be most commonly used, yet some people says... |
ioctl tends to go hand-in-hand with a /dev entry; your typical code would do
fd=open("/dev/mydevice",O_RDRW);
ioctl(fd,.....);
This is perfectly standard Unix behaviour. Inside the kernel driver you can put access controls (eg only root can do some things, or require a specific capability for more fine grained acces... | Usage difference between device files, ioctl, sysfs, netlink |
1,365,982,813,000 |
I am beginner in device driver programming.
I don't get the difference between device drivers and device files in Linux.
Can anyone explain the difference?
|
A device driver is a piece of software that operates or controls a particular type of device. On modern, monolithic kernel operating systems these are typically part of the kernel. Many monolithic kernels, including Linux, have a modular design, allowing for executable modules to be loaded at runtime. Device drivers c... | Difference between Device file and device drivers |
1,365,982,813,000 |
Device files are not files per se. They're an I/O interface to use the devices in Unix-like operating systems. They use no space on disk, however, they still use an inode as reported by the stat command:
$ stat /dev/sda
File: /dev/sda
Size: 0 Blocks: 0 IO Block: 4096 block special ... |
The short answer is that it does only if you have a physical filesystem backing /dev (and if you're using a modern Linux distro, you probably don't).
The long answer follows:
This all goes back to the original UNIX philosophy that everything is a file. This philosophy is part of what made UNIX so versatile, because y... | Why do special device files have inodes? |
1,365,982,813,000 |
If you ran the following, what would happen?
# Do not run.
# cat /dev/random > ~/randomFile
Would it be written until the drive runs out of space, or would the system see a problem with this and stop it (like with an infinite symlink loop)?
|
It writes until the disk is full (usually there is still some space reserved for the root user). But as the pool of random data is limited, this could take a while.
If you need a certain amount of random data, use dd.
For 1MB:
dd if=/dev/random iflag=fullblock of=$HOME/randomFile bs=1M count=1
Other possibilities are... | Writing /dev/random to file? |
1,365,982,813,000 |
So i was just wondering if my explanations of udev and how it works seem correct and my understanding is correct please let me know.
SO my understanding of udev is that it is a dynamic device manager on Linux which runs as a daemon.
when a change to a device occurs such as if a device is plugged in the kernel sends ... |
UDEV
Udev stand for "userspace /dev" it is a device manager for the Linux kernel. It is part of systemd (an init system used to bootstrap user space and manage user processes).
Originally udev was independent from systemd, it was merged with systemd in 2012, this lead to some complication for distribution running with... | How does udev/uevent work? |
1,365,982,813,000 |
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 I rather like an answer that works on all (or at least the most popular) Unix systems. I had this problem with Linux in ... |
Using udev:
You can get useful information querying udev (on systems that use it - almost all desktop-type Linuxes for sure). For instance, if you want to know which attached drive is associated with /dev/sdb, you can use:
udevadm info --query=property --name=sdb
It will show you a list of properties of that device, ... | If I connect a physical device, how can I ever know which device file belongs to it? |
1,365,982,813,000 |
How or where does Linux determine the assignment of a network device? Specifically, wlan0 or wlan1 for wireless USB devices.
I plugged in a TP USB wireless a while ago, and it was assigned wlan0. I removed it. This week I plugged in an Edimax USB wireless device and it comes up as wlan1. I removed it today to try a se... |
Udev is the system component that determines the names of devices under Linux — mostly file names under /dev, but also the names of network interfaces.
Versions of udev from 099 to 196 come with rules to record the names of network interfaces and always use the same number for the same device. These rules are disabled... | wlan number assignment |
1,365,982,813,000 |
I use Linux Mint 13 MATE, and I'm trying to set up notifications when I plug/unplug devices.
First of all, I found udev-notify package, but unfortunately it almost doesn't work for me: it works for very little time (1-2 minutes), and then, if I connect/disconnect any device, it crashes:
Traceback (most recent call las... |
Well, after many hours of googling and asking on forums, I got it working (it seems). Anyone who wants to get nice visual and/or audio notification when some USB device is plugged/unplugged can install my script, see installation details below.
First of all, answers on my own questions.
1. How to get actual title of t... | Call notify-send from an udev rule |
1,365,982,813,000 |
I have a USB barcode scanner at /dev/input/event0 (/dev/input/by-id/usb-Metrologic_Metrologic_Scanner-event-kbd), and scanning a barcode causes it to send keypress events. I'm capturing these keypresses using the libdevinput Ruby library, which works great. The issue is that each barcode is also entered as a username,... |
I found out that I need to send an EVIOCGRAB ioctl to the device, which grabs it for exclusive use.
Here's how to do it in Ruby:
#!/usr/bin/env ruby
BARCODE_SCANNER = "/dev/input/by-id/usb-Metrologic_Metrologic_Scanner-event-kbd"
require 'rubygems'
require 'libdevinput'
require 'ffi'
require 'ffi/tools/const_generato... | Can I stop Linux from listening to a USB input device as a keyboard, but still capture events with a program? |
1,365,982,813,000 |
I have 3 SATA devices on my system. They show up under /proc/scsi/scsi, although these are not SCSI devices. Why do my SATA devices show up under the SCSI directory?
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: WDC WD2500AAJS-6 Rev: 01.0
Type: Direct-Acc... |
They show up as SCSI devices because the drivers speak SCSI to the next kernel layer (the generic disk driver). This isn't actually true of all SATA drivers on all kernel versions with all kernel compile-time configurations, but it's common. Even PATA devices can appear as SCSI at that level (again, that depends on th... | Why do my SATA devices show up under /proc/scsi/scsi? |
1,365,982,813,000 |
I'm working through questions from Unix The Textbook (chapter 8, #16, page 207):
Give chmod command lines that perform the same tasks that the mesg
n and mesg y commands do. (Hint: Every hardware device, including
your terminal, has an associated file in the /dev directory.)
I believe the answer is:
mesg n = chm... |
No, /dev/stdin and /dev/stdout are the wrong device. These are not terminal devices, they're aliases for standard input and standard output respectively. Standard input and standard output are, by definition, file descriptors that applications expect to be open and have a conventional meaning (file descriptor 0 and 1 ... | Would chmod 000 /dev/stdin disable terminal forever? |
1,365,982,813,000 |
How can I find out when a device is connected to my FreeBSD machine? Lets say I plug in a USB device, HDMI device, Bluetooth or something like that.
Can I have a console output to say [device] and gives some output about the device?
|
All other answers are good, if you want only to check if a device is connected (checking kernel messages with dmesg, check in /var/log files and use some tools like usbconfig, pciconf or camcontrol).
But, if you want more (handle a message and execute a program or something like that when you plug your device), you ca... | Find when new hardware is connected on FreeBSD |
1,365,982,813,000 |
I need to get the title of the attached USB device. I can do that with lsusb.
udev allows some substitutions when I write rules: say, we can use $kernel to get name of the device, or $devpath to get path to the device.
But problem is that lsusb returns string like that:
Bus 005 Device 032: ID 0403:6001 Future Technolo... |
Firstly, we need to prepend /sys to the path returned by udev, so that path becomes something like: /sys/devices/pci0000:00/0000:00:1d.0/usb5/5-2. Then go to this directory, and there will be several files in it. Among others, there are busnum and devnum files, they contain these "logical" numbers. So, in bash script,... | Map physical USB device path to the Bus/Device number returned by lsusb |
1,365,982,813,000 |
I'm not sure what is wrong here but when running fdisk -l I don't get an output, and when running
fdisk /dev/sdb # I get this
fdisk: unable to open /dev/sdb: No such file or directory
I'm running Ubuntu 12.10 Server
Can someone please tell me what I'm doing wrong? I want to delete /dev/sdb2-3 and just have one p... |
On most non-embedded Linux installations, and many embedded installations, /dev is on a RAM-backed filesystem, not on the root partition. Most current installations have /dev as a tmpfs filesystem, with the udev daemon creating entries when notified by the kernel that some hardware is available. Recent kernel offer th... | /dev/sdb: No such file or directory (but /dev/sdb1 etc. exists) |
1,365,982,813,000 |
Context
I'm automating SD card imaging from an existing dd factory image. The SD card is always connected through an external USB card reader and thus appears in the system as a SCSI block device /dev/sd*.
Currently the syntax of my command is: write-image DEVICE where DEVICE is the SD card block device, eg. /dev/sdd.... |
Have a look under the /sys/ directory. In particular, /sys/block/ contains symlinks to block devices in /sys/devices/.
/sys/block/sdX/removable looks like it will read as 1 for a removable device, and 0 otherwise. This gives you a basic check for removability.
I'm not sure if there's a better way to check if it's a US... | Find out if a specific device is an USB mass storage |
1,365,982,813,000 |
According with the FHS about /dev at:
6.1.3. /dev : Devices and special files
it contains:
The following devices must exist under /dev.
/dev/null
All data written to this device is discarded. A read from this device will return an EOF condition.
/dev/zero
This device is a source of zeroed out data. All... |
If you're using Linux, it's never "mandatory" to redirect to /dev/null instead of /dev/zero. As you've noticed, you'll get the same result either way.
That said, you should always redirect to /dev/null if you're discarding data. Because everyone understands that writing to /dev/null means throwing the data away; it's ... | When is mandatory use /dev/zero over /dev/null for write/discard purpose? |
1,365,982,813,000 |
I made a script to rotate my Wacom Bamboo tablet 180 degrees. It works fine when I execute it as myself (user) or root, but when started from udev (i.e. when plugging the tablet into a usb port) it won't work.
Udev rules:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="056a", ATTRS{idProduct}=="00d1", ATTRS{manufacturer}=="Wacom... |
There is a fairly easy workaround, you can add something like this to your xorg.conf (or a file in xorg.conf.d, as I've done):
anthony@Watt:/etc/X11/xorg.conf.d$ cat 55-local-wacom.conf
Section "InputClass"
Identifier "Wacom Left Handed"
MatchDriver "wacom"
Option "Rotate" "half"
EndSection
Chec... | Why doesn't xsetwacom work from udev? |
1,365,982,813,000 |
From this answer the solution is to
modprobe loop max_loop=64
Which makes me allowed to use 64 loopback devices then
mknod -m 660 /dev/loop8 b 7 8
To create the devices. I did this for 8, 9, 10 and 8,9 works but 10 does not.
I then tried loopa to loopf and tried to mount a 11th device and i get the error
Error: Fai... |
Make sure you are running mknod -m 660 /dev/loop10 b 7 10. The format is mknod -m 660 /dev/loop<ID> b 7 <ID> where ID is the same.
Update [07/10/2014]
I also found a good blog post to always have more at boot. See https://yeri.be/xen-failed-to-find-an-unused-loop-device
Update [05/25/2016]
I run a CentOS server, and I... | How do I setup more then 10 loopback device? |
1,365,982,813,000 |
Is there a default program where I can check if my audio devices are in silent?
Edit: By silence, I mean that if there is something playing on that (not just activated or opened)
Something like this:
if [[ device0 is silent ]] ; then
radio $RANDOM
fi
Edit 2: What I'm trying to achieve is a script that plays radio... |
If you're using PulseAudio (Gnome-based Linux distributions tend to use PulseAudio, you can check if one is running with ps -C pulseaudio) and you want to know whether some applications are sending any data to any "sink", you could do:
pacmd list-sink-inputs | grep -c 'state: RUNNING'
Still with PulseAudio, if you wa... | Testing if audio devices / sound cards are currently playing? |
1,365,982,813,000 |
I plug an external HDD into my laptop. I try to find out the information by
$ udevadm info -a -n /dev/sdb
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match,... |
The walk is over the different software components (drivers) that handle the device; this corresponds by and large to the hardware devices and buses that are involved in connecting to the device. This is mostly unrelated to the physical arrangement of the devices: most of them are inside the same chip anyway.
Taking t... | Understand output of `udevadm info -a -n /dev/sdb` |
1,365,982,813,000 |
I have a USB rocket launcher that I wish to experiment with through libusb. However, libusb cannot claim the interface; presumably because the output of usb-devices lists 'usbhid' as the driver for the device.
From reading around on the internet, I've only come to the conclusion that I need to detach this driver from ... |
If you simply run the libusb program as root,
usb_detach_kernel_driver_np()
actually works as expected.
| Prevent claiming of novelty usb device by usbhid so I can control it with libusb? |
1,365,982,813,000 |
Using the following command.
rsync --archive --delete --partial --progress --recursive --no-links --no-devices --quiet source target
Using --no-links and --no-devices already.
Getting the error messages such as this.
rsync: mknod "/mnt/shared/backup/var/spool/postfix/dev/log" failed: Operation not permitted (1)
Make... |
rsync -a --no-specials --no-devices would tell rsync to skip these files. It will still print an information message, but it would return 0 if no other error occurs.
If there's a set of known paths that you don't want to transfer, you could exclude them altogether. Also, do pass the -x option to skip all mounted files... | How to skip special / socket files during rsync transfer? |
1,365,982,813,000 |
Predictable network interface names are not supposed to change when hardware is added or removed. Isn't that the whole point of the naming scheme???
My wireless interface was named wlp3s0.
I installed an ASUS Xonar DX 7.1 Channels PCI Express x1 Interface Sound Card in a free PCI slot and my wireless interface name ch... |
Predictable network interface names are not supposed to change when
hardware is added or removed. Isn't that the whole point of the naming
scheme???
Long story short, this is nothing new; it's expected/intended. Therefore, you don't need to file a bug, unless you want to ask your PC-maker to support Linux better (B... | Why did the interface name of my wireless card change when I added a sound card? |
1,365,982,813,000 |
I am trying to figure out why the following device is not setup to its driver on my Creator CI20. For reference I am using a Linux kernel v4.13.0 and doing the compilation locally:
make ARCH=mips ci20_defconfig
make -j8 ARCH=mips CROSS_COMPILE=mipsel-linux-gnu- uImage
From the running system I can see:
ci20@ci20:~# f... |
A working solution to get the driver to bind to the device is:
cgublock: jz4780-cgublock@10000000 {
compatible = "simple-bus", "syscon";
#address-cells = <1>;
#size-cells = <1>;
reg = <0x10000000 0x100>;
ranges;
cgu: jz4780-cgu@10000000 {
compatible = "ingenic,jz4780-cgu";
re... | How to debug a driver failing to bind to a device on Linux? |
1,365,982,813,000 |
On Linux, is there a way for a shell script to check if its standard input is redirected from the null device (1, 3) *, ideally without reading anything?
The expected behavior would be:
./checkstdinnull
-> no
./checkstdinnull < /dev/null
-> yes
echo -n | ./checkstdinnull
-> no
EDIT
mknod secretunknownname c 1 3
exec... |
On linux, you can do it with:
stdin_is_dev_null(){ test "`stat -Lc %t:%T /dev/stdin`" = "`stat -Lc %t:%T /dev/null`"; }
On a linux without stat(1) (eg. the busybox on your router):
stdin_is_dev_null(){ ls -Ll /proc/self/fd/0 | grep -q ' 1, *3 '; }
On *bsd:
stdin_is_dev_null(){ test "`stat -f %Z`" = "`stat -Lf %Z /d... | How to check if stdin is /dev/null from the shell? |
1,365,982,813,000 |
I have observed that between repeated boots of the same system, the mapping between the device names /dev/sda, /dev/sdb/... and the physical hard drives stays the same.
However I am not sure if it remains the same if I plug the hard drives into different sockets on the motherboard or if I add/remove drives.
What gua... |
The drive names are (on a typical Linux system) decided by the kernel (as the device must first be detected there), and may later be modified by udev. How it decides which hardware maps to which block special file is an implementation detail that will depend your udev configuration, kernel configuration, module setup,... | According to which algorithm does Linux assign the hard drive letters? |
1,365,982,813,000 |
I'm creating a live-USB and don't understand precisely: what happens when I copy a file (or even a file system) directly to a device node (as opposed to a file system)?
|
The shell will open the device /dev/sdX. All output of the cat command, which ends up being the contents of debian.iso, is written directly to that device.
The end result is that debian.iso is written byte-for-byte to the start of the disk underlying /dev/sdX.
In effect, the device node makes it appear that the low-l... | What happens when I do "cat debian.iso > /dev/sdX"? |
1,432,265,534,000 |
If /dev is suppose to list all the devices that is connected, like usb, hdd, webcam, how come on my ubuntu 15 VM I don't see a monitor? I am running the desktop edition so there should be a monitor.
Or maybe it is named something different?
|
Device files on Unix systems in general are just one way for user programs to access device drivers; there isn't a one-to-one mapping from devices files to physical hardware, and not all hardware has a device file (or even a device driver). The kernel itself doesn't use device files to interact with hardware.
As point... | why isn't monitor listed under /dev in linux? |
1,432,265,534,000 |
Given a device file, say /dev/sdb, is it possible to determine what driver is behind it?
Specifically, I want to determine what driver my storage devices are using. fdisk -l lists 2 devices: /dev/sda and /dev/sdb. One is a SATA hard drive and the other is a USB Mass Storage device - actually an SD card.
How do I deter... |
Run udevadm info -a -n /dev/sda and parse the output. You'll see lines like
DRIVERS=="ahci"
for a SATA disk using the ahci driver, or
DRIVERS=="usb-storage"
for an USB-connected device. You'll also be able to display vendor and model names for confirmation. Also,
ATTR{removable}=="1"
is present on removable devices... | What driver is behind a certain device file? |
1,432,265,534,000 |
I'm trying to transfer some existing backups from one system to another. The older backup system seems to have managed to back up special files like /dev/hda, /dev/tty0, and /dev/null which look like they were created as some part of an OS build process.
So I tried to rsync them to the new machine but I keep getting ... |
It is not --special that "should" sync the devices, it is the --devices indirect switch. For that the man page says:
--devices
This option causes rsync to transfer character and block device
files to the remote system to recreate these devices. This
option has no effect if the receiving rsy... | rsync's relationship with special files |
1,432,265,534,000 |
How can I obtain information about the amount of current negotiated by a device attached to a USB port?
I am looking for information similar to this presented by OS X in terms of current available and current required.
|
Take a look at the command lsusb. Specifically lsusb -v or lsusb -vv. Check the man page for it as well.
For example here's a wireless mouse on my laptop (Fedora 14):
% sudo lsusb -v
Bus 002 Device 003: ID 046d:c521 Logitech, Inc. Cordless Mouse Receiver
Device Descriptor:
bLength 18
bDescriptorType... | Query USB current |
1,432,265,534,000 |
I know /dev/tcp/<host>/<port> is a magic path handled specifically by some shells in redirections. But according to man bash:
If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally
[...]
On the Linux box I am using right now, the... |
I think the Bash documentation is somewhat misleading on this topic. Looking at the code, even going back to version 2.04 where network redirections were introduced, /dev/tcp and /dev/udp works as follows:
at build time, the configure script checks to see whether various networking features are supported; if so, if n... | Which Unix-like system really provides the /dev/tcp special file? |
1,432,265,534,000 |
Linux System Info:
OS: GNU/Linux x86_64
Kernel: 3.13.0-24-generic
Distro: Linux Mint 17 Qiana, Cinnamon 64-bit 2.2.16
[Based On: Ubuntu 14.04.5 LTS, Trusty Tahr]
Due to a disability (spinal injury) which includes finger impairment, I have made some alterations so that I can use my keyboard's C... |
Answering my own question...
Setting up CapsLock as act as a left mouse button turned out to be much simpler than expected. [Note: The physical mouse left mouse button continues to behave as normal.]
Map CapsLock to the left mouse button (66 is the CapsLock key code):
$ xmodmap -e "keycode 66 = Pointer_Button1"
Map ... | Using CapsLock as left mouse button; mostly works but fails with a few things |
1,432,265,534,000 |
When reading from dev/urandom, with say head or dd, it’s of course expected that the output is always random and different.
How is this handled by UNIX at a low level? Is the file naturally truncated on reading or instead is the file actually an interface for a symmetric cipher or equivalent and as such “reading” is a... |
/dev/urandom is a character device, not a regular file. Opening it provides an interface to a driver, usually in the kernel, which handles reads; every time a program reads from /dev/urandom, a call is made to the driver, and the driver determines how to provide appropriate content (same as any other character device ... | Reading from dev/urandom - system behaviour |
1,432,265,534,000 |
I can see the difference between /dev/tty and /dev/tty0 by testing the provided method from this question. But I really wonder about the practical usage of those devices (like situations they will be used).
|
/dev/tty is the controlling tty of the current process, for any process that actually opens this special file. It isn’t necessarily a virtual console device (/dev/ttyn), and can be a pty, a serial port, etc. If the controlling tty isn’t a virtual console, then the process has not to interact with console devices even ... | How Linux uses /dev/tty and /dev/tty0 |
1,432,265,534,000 |
What are exactly mknod command parameters?
I want to create a jail in chroot. So I need to do:
mknod /var/chroot/bind/dev/null c 1 3
mknod /var/chroot/bind/dev/random c 1 8
What are c, 1, 3 and 8?
|
mknod is creating a device file, usually to be located in the /dev branch, but not necessarily like your example shows.
The first parameter is telling which kind of device to create, here c for character device. Other choices might be b for block devices, p for fifo (pipe).
The second parameter is the major number, it... | What are exactly mknod command parameters? |
1,432,265,534,000 |
The Linux Programming Interface states:
Each device driver registers its association with a specific major device ID, and this association provides the connection between the device special file and the device driver.
Is it possible to obtain the list of those associations?
|
Documentation/admin-guide/devices.txt in the kernel source code documents the allocation process and lists all the allocated device numbers. sd gets a whole bunch of major device numbers because of the large number of devices it can handle: major 8 covers /dev/sda to /dev/sdp, major 65 covers /dev/sdq to /dev/sdaf, 66... | How to get a list of major number -> driver associations |
1,432,265,534,000 |
When I have run fsck in the past I have always run it on what I thought was a filesystem partition, ie. fsck -yf /dev/sdaN, where N is the partition number on disk A. A friend of mine recently ran fsck on his brand new disk and it reported a bunch of errors using fsck -yf /dev/sda. I am curious, what is the difference... |
When fsck runs, it should first try to locate the superblock of a filesystem to begin traversing the filesystem's structure in order to validate it. Since the /dev/sda device corresponds to whole drive, the first portion of the disk will likely contain the partition table or Master Boot Record and fsck will not be abl... | What happens if I run fsck on /dev/sda instead of /dev/sda1? |
1,432,265,534,000 |
The udev rules I've created so far only deal with devices being added or removed, i.e.:
ACTION=="add"... or ACTION=="remove"...
I've come across an example of a rule that seems to deal with device state changes as well:
ACTION=="add|change", KERNEL=="sd[b-z]", ATTR{queue/rotational}=="1", RUN+="/usr/bin/hdparm -B 127 ... |
"change" corresponds, for example, to removing or inserting an sdcard in a sdcard reader, or changing the hard disc inside a usb-to-sata enclosure. The device itself is not added nor removed, but the media is no longer the same.
| In udev, what kind of device events match ACTION=="change"? |
1,432,265,534,000 |
I'm doing a study about how CD-ROM can be mounted virtually and all I could find out was mounting using loop devices.
mount -o loop disk1.iso /mount-point
This is fairly easy.
I understand that /dev/sr0 is a block device and it point to some buffer in kernel and the kernel device driver puts the filesystem (ot whatev... |
The thing here is that /dev/sr0 is linked to a kernel device driver. That device driver will allow access to a physical CDROM if available through that node; VMWare and VirtualBox emulate hardware as you mention and hence the kernel and device driver think they're communicating with hardware.
The /dev/sr0 doesn't poin... | Mount an ISO virtually using /dev/sr0 device |
1,432,265,534,000 |
I've been using FTDI usb serial cables on OSX with really no thought for years. Now, I'm trying to get the same cables working on Linux (Linux Mint, Debian Edition 2). What I understand so far is...
1) I need the kernel modules ftdi_sio and usbserial. These weren't showing up at start up, so I added them to a file in ... |
Argh and grumble. I should have paid better attention to the output of dmesg | grep ftdi. There was ftdi stuff in there, but I didn't recognize any of it. In particular one brltty was showing up. I should have googled it. At which point I would have discovered this is the "Braille Display" thing. So apparently, defaul... | How to get /dev/ttyUSB* to show up? |
1,432,265,534,000 |
I noticed that the mknod command required root privileges when a creating a node other than a regular file, FIFO or a Unix socket.
Why is that? How can a regular user harm a system or compromise other users' privacy with the mknod command that he can't when creating regular files?
|
If you could call mknod arbitrarily, then you could create device files owned and accessible by you for any device. The device files give you unlimited access to the corresponding devices; therefore, any user could access devices arbitrarily.
For instance, suppose /dev/sda1 holds a file system to which you have no acc... | Why does mknod require root privileges? |
1,432,265,534,000 |
I just tried burning both a Debian CD and a Debian DVD from their .iso files and I've got a weird behavior: the checksum of the CD is correct but the one of the DVD ain't.
Here's what working:
downloaded the two .iso files
verified the checksum of the two .iso files
burn the CD debian-7.1.0-amd64-CD-1.iso to a CD
ve... |
In addition to Gilles answer,
If you still have the ISO image, you could use cmp instead of checksums. It would tell you at which byte the difference happens. It would also make the check faster as if there is an error early on, it would tell you right away, whereas the checksum always has to read the entire media.
$ ... | How to take sha-1, sha-256 or MD5 of CDs / DVDs? |
1,432,265,534,000 |
I am dealing with an embedded system which has some memory that is accessible by a file descriptor (I have no idea what am I saying, so please correct me if I am wrong).
This memory is 32 kB and I want to fill it with 0x00 to 0xFFFFFFFF. I know this for text files:
exec {fh} >> ./eeprom;
for i in {0..32767}; do echo $... |
perl -e 'print pack "L*", 0..0x7fff' > file
Would write them in the local system's endianness.
Use:
perl -e 'print pack "L>*", 0..0x7fff'
perl -e 'print pack "L<*", 0..0x7fff'
To force big-endian or little-endian respectively regardless of the native endianness of the local system.
See perldoc -f pack for details.
W... | How to write binary values into a file in Bash instead of ASCII values |
1,432,265,534,000 |
From my understanding, Arch Linux uses Consistent Network Device Naming where the network devices are no longer named eth0, eth1, etc.
I use the proprietary MATLAB software which requires a device eth0 for activation. As a work around they suggest turning off consistent network device naming here. I don't think this ... |
Have you tried creating a blank /etc/udev/rules.d/80-net-name-slot.rules?
Since Udev v197, udev has implemented predictable network interface names, by creating a blank file in that path then rebooting, you should have your interface names back to what they were.
Reference: Predictable Network Interface Names
| Creating eth0 with consistent network device naming |
1,432,265,534,000 |
The Linux kernel's simple naming for a storage device (e.g. /dev/sda, /dev/sdb) can change randomly across boots. Is that true for NVMe storage devices too? These have names such as /dev/nvme0n1p1 and /dev/nvme0n1p2, etc.
|
Short: No. You can not rely on the name of the descriptor. And you most likely never will.
The NVMe naming standard describes:
nvme0: first registered device's device controller
nvme0n1: first registered device's first namespace
nvme0n1p1: first registered device's first namespace's first
partition
So the overall na... | persistent device naming for NVMe storage devices |
1,432,265,534,000 |
Trying lots of different Linux distributions on all kinds of hardware, I find myself typing commands like this quite often:
sudo dd if=xubuntu-13.10-desktop-amd64.iso of=/dev/sdc bs=10240
Needless to say, sooner or later I will mistype the destination and wipe a harddrive instead of the intended USB drive. I would li... |
I think you can use UDEV to do what you want. Creating a rules file such as/etc/udev/rules.d/99-thumbdrives.rules you'd simply add a rule that will allow either a Unix group or user access to arbitrary USB thumb drives.
KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", OWNER="<user>", GROUP="<group>", MODE="066... | Writing raw images safely to USB sticks |
1,432,265,534,000 |
I have a 3G/GPS device that creates 5 tty nodes, although it's only one physical USB connection. Basically, a multi port usb-serial adapter.
I'm trying to create some udev rules to make sure those nodes always have the same name, or at least a symlink to them.
I can indeed find the device at /sys/devices/platform/pxa2... |
Your rules all have syntax errors in them:
= is for assignment == is for comparison, so you were not actually looking at what DEV equaled, you were assigning it.
You need , between all the statements, there were none before SYMLINK+=.
Fist Rule
ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:... | Udev rule to match multiple node USB device |
1,432,265,534,000 |
What I'm looking for is a way to pass in arbitrary data through STDIN, and have it get tar'd up as if its a normal file.
I tried this
$ echo test | tar -cf test.tar /dev/stdin
and that gives me a test.tar file with the contents dev/stdin. The stdin file is a link to /proc/self/fd/0.
What I want instead is for dev... |
I don't think you can do what you want here. The problem with your approach is that tar deals in files and directory trees, which you're not providing it with commands such as this:
$ echo test | tar -cf test.tar /dev/sdtin
Even when you attempt to "wrap" your strings in temporary files using subshells such as this:
... | Make tar from /dev/stdin file |
1,432,265,534,000 |
Context:
Due to missing drivers for my 2-in-1 convertible, folding the screen back only triggers a lid switch event. This causes the laptop to suspend or, when "Suspend when laptop lid is closed" is disabled in Gnome, still causes all input devices to be disabled (including the touchscreen, which renders the tablet mo... |
You can test unbinding the driver on the parent device. This will remove the child device input0 - along with any other child devices that were there.
cd /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00
echo PNP0C0D:00 | sudo tee driver/unbind
A second example, based on the other input device you mention:
cd /sys/dev... | How to completely inhibit lid switch events? |
1,432,265,534,000 |
If all four primary partitions exist on an IDE drive, they are numbered
as follows:
/dev/hda1
/dev/hda2
/dev/hda3
/dev/hda4
We have also the partitions on a disk with one primary partition and the sole extended partition might be numbered as
follows:
/dev/hda1 (primary)
/dev/hda2 (extended)
This naming strategy... |
From terminal, you type parted /dev/hda
then type print
as result:
Number Start End Size Type File system Flags
1 32.3kB 107MB 107MB primary ext3 boot, raid
2 107MB 250GB 250GB primary raid
| How to know if /dev/hda2 is Primary partition or Extended partition |
1,432,265,534,000 |
Directly related: Prevent claiming of novelty usb device by usbhid so I can control it with libusb?
I want to access an RFID reader (works as HID device) from a program that uses libusb-0.1. In the code, the kernel driver is correctly detached with usb_detach_kernel_driver_np (no errors), but is seems that whenever my... |
I've solved this part of the problem:
OPTIONS=="ignore_device" was removed from the kernel (commit)
blacklist usbhid didn't do anything, not even blocked my keyboard
A configuration file in /etc/modprobe.d with options usbhid quirks=0xdead:0xbeef:0x0004 did not work because usbhid was not compiled as module
So, I ad... | Prevent usbhid from claiming USB device |
1,432,265,534,000 |
My system has to auto-mount USB devices; how can I be notified when a USB device is plugged in? Where can I read more about this subject?
I would like to handle this problem via C or a shell script.
|
Udev support running external programs
KERNEL=="sdb", RUN+="/usr/bin/my_program"
| How to be notified when a USB device was plugged in? |
1,432,265,534,000 |
I have created the a chroot jail in combination with unionfs-fuse so that I don't need to install another system inside it.
However, the resulting system's /dev entries are not readable.This is causing problems with programs needing access to /dev/random, /dev/null and /dev/urandom.
I tried to solve the issue myself b... |
The explanation lies in the mount.fuse man page:
Filesystems are mounted with nodev,nosuid by default, which can only be overridden by a privileged user
With the nodev option, the kernel bans all access to devices in the mounted filesystem. With the nosuid option, the kernel ignores setuid and setgid attributes. Bot... | chroot with unionfs-fuse, can't access /dev/* |
1,432,265,534,000 |
While seeing the manual for swapon command the priorty option is described as
-p, --priority priority
Specify the priority of the swap device. priority is a value
between -1 and 32767. Higher numbers indicate higher
priority. See swapon(2) for a full description of swap
... |
man 2 swapon describes priorities thus:
Each swap area has a priority, either high or low. The default priority is low. Within the low-priority areas, newer areas are even lower priority than older areas.
All priorities set with swapflags are high-priority, higher than default. They may have any nonnegative value ... | What is swap priority and why does it matter |
1,432,265,534,000 |
So I recently asked this question, which lead me to run this command:
$ du -sk /dev/*
Which outputs about 353 different entries that look like this:
0 /dev/sdt
0 /dev/stderr
0 /dev/stdin
0 /dev/stdout
0 /dev/systrace
0 /dev/tty
0 /dev/tty.Bluetooth-Incoming-Port
0 /dev/tty.Bluetooth-Modem
0 /dev/tt... |
They're device nodes:
In Unix-like operating systems, a device file or special file is an
interface for a device driver that appears in a file system as if it
were an ordinary file. [...] They allow software to interact with a device
driver using standard input/output system calls, which simplifies many
tasks... | Why does the UNIX system need so many [0-byte] drives at /dev/* [duplicate] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.