Tag Info

Hot answers tagged

10

Moving a file to the location of an already existing file replaces the existing file. In this case the /dev/null device file is replaced, just as any normal file would be. To avoid this use the -i (interactive, warns before overwriting) or -n (no clober) option for mv. /dev/null only performs its special function as a bit-bucket then the device is opened as ...


8

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 connection. As an example stty -F /dev/ttyACM0 ...


8

/dev/sgxx is a SCSI-generic device, which allows sending and receiving of raw SCSI commands. When you write to the device, you are expected to start the write with a SCSI header, which defines the operation you wish to do. Writing random data to an sg device is really a bad idea. You'll be sending random SCSI commands, which might not even exist (hence ...


8

Umm, because you overwrite the special file with normal one? What did you expect to happen? dev/null is not a directory, it is a file pointing to a null device. When you mv something to it, you delete the original and replace it with whatever you moved: $ file /dev/null /dev/null: character special $ sudo mv file /dev/null $ file /dev/null /dev/null: ...


8

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); } return (S_ISREG(sb.st_mode) ? ...


6

cat just uses whatever settings the port is already configured for. With this little C snippet you can see the baud rate currently set for a particular serial port: get-baud-rate.c #include <termios.h> #include <unistd.h> #include <stdio.h> int main() { struct termios tios; tcgetattr(0, &tios); speed_t ispeed = ...


6

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 files (also called device files or ...


5

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 hand the standard /dev handling requires ...


5

Potential Method #1 I think you can do it with these commands: disable echo 0 > /sys/bus/pci/slots/$N/power enable echo 1 > /sys/bus/pci/slots/$N/power Where $N is the number of the PCI slot. lspci -vv may help to identify the device. This is not very well documented... Potential Method #2 I came across this thread on U&L, similar ...


5

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 by default starting from udev 174, but ...


5

lsblk will list all block devices. It lends itself well to scripting: $ lsblk -io KNAME,TYPE,SIZE,MODEL KNAME TYPE SIZE MODEL sda disk 149.1G TOSHIBA MK1637GS sda1 part 23.3G sda2 part 28G sda3 part 93.6G sda4 part 4.3G sr0 rom 1024M CD/DVDW TS-L632M lsblk is present in util-linux package and is thus far more universal than proposed ...


5

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 USB device, but readlink /sys/block/sde ...


4

Since both "Can I see what HDD I have installed?" and "How do I determine the make & model of my storage devices?" are marked as duplicates of this question, I'm surprised no-one mentioned hdparm and smartctl. Having a look at a few machines, seems that either of them (when it's not both) is often found already installed in standard (even old) linux ...


4

It represent the bitmask for events supported by the device. Sample of devices entry for a AT Keyboard: I: Bus=0011 Vendor=0001 Product=0001 Version=ab41 N: Name="AT Translated Set 2 keyboard" P: Phys=isa0060/serio0/input0 S: Sysfs=/devices/platform/i8042/serio0/input/input2 U: Uniq= H: Handlers=sysrq kbd event2 B: PROP=0 B: EV=120013 B: KEY=20000 200 20 ...


4

As far as I know, both CDs and DVDs consist of a certain number of fixed-size blocks. The image that you're burning may not be a multiple of the block size, in which case the last block will contain some trailing garbage. So when you run dd if=/dev/sr0 (which is an obfuscated way of writing md5sum </dev/sr0), the trailing garbage is included in the hash. ...


4

The files in /dev/pts are "pseudo-ttys". They're like named pipes to an extent, but they also imitate old serial-connection terminals, like VT-100s. Pseudo-ttys do the work of transferring bytes from keyboard to program, and from program to output device, which sounds simple. But that answers your explicity question: the kernel stores nothing in /dev/pts/0 ...


4

Nothing is stored in /dev/pts. This filesystem lives purely in memory. Entries in /dev/pts are pseudo-terminals (pty for short). Unix kernels have a generic notion of terminals. A terminal provides a way for applications to display output and to receive input through a terminal device. A process may have a controlling terminal — for a text mode application, ...


4

The files in /dev are device files, they are not real files. They don't, usually, have content on disk (a few representing raw disks do). There is nothing in the file. If you do ls -l /dev, you will see all there is to these "files": A name, some special bits, see first character of mode (is is not d=directory, -=regular file, l=symlink, it is c=character ...


3

Yes, you can find the information in /sys/block/$DEVICE/slaves. If you only have the canonical name you can use readlink to get the details, e.g: devdm="$(readlink -f /dev/mapper/extern-1-crypt)" dm="${devdm#/dev/}" ls /sys/block/$dm/slaves/ If you want to remove all you can just utilize directly the sys filesystem: echo 1 > ...


3

If it uses the normal kernel watchdog interface, that's at /dev/watchdog, which is 10, 130 here. It may also export another one (/dev/watchdog0, etc.). You can find that by querying sysfs: $ cat /sys/class/watchdog/watchdog0/dev 253:0 $ cat /sys/class/watchdog/watchdog0/uevent MAJOR=253 MINOR=0 DEVNAME=watchdog0 And indeed: $ ls -l /dev/watchdog0 ...


3

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't need the subsequent arguments as it ...


3

This RNG comes as part of a Trusted Platform Module. Unless your computer was part of an order for a large organization, the TPM is disabled by default, because it can make your computer unbootable if misconfigured, and because it can make your computer more traceable¹. If you want to use the RNG, you'll have to enable it in the BIOS. The Thinkpad wiki has ...


3

Short-term solution: % sudo modprobe dummy % sudo ip l set dev dummy0 name MyEth11 % sudo ip ad ad 192.168.255.254/30 dev MyEth11 % ip ad show dev MyEth11 14: MyEth11: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN link/ether 6e:73:12:ad:db:8e brd ff:ff:ff:ff:ff:ff inet 192.168.255.254/30 scope global MyEth11 % sudo ip l set MyEth11 up


3

All devices have a major, minor number pair. The major number is a larger, more generic category (e.g. hard disks, input/output devices etc...) while the minor number is more specific (i.e. tells what bus the device is connected to). Check the kernel documentation for more examples.


3

Devd runs BEFORE rc and therefore before devfs - this was carefully chosen by its creator - you can see his reasoning here: http://www.usenix.org/events/bsdcon03/tech/full_papers/losh/losh.pdf (Chapt. 7.2) Devd runs entirely in user space, there is no issue with root privileges. Unless you choose to sudo - which is what you did. Use devd.conf to set a ...


3

Device controllers are typically bus arbiters. You're often not talking to the devices on a given bus directly but to the controller. The controller is then determining when and how to send commands to the devices on it's bus based on what you've requested through the controller. Wikipedia has the following on the subject, ...


3

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. $ cmp /dev/cdrom /path/to/cdrom.iso In ...


3

Data written to /dev/null doesn't go anywhere. Since it isn't written to any file, there is no file size to have any impact on. If a program writes to /dev/null, the system call takes place. But the system call returns almost immediately without writing the data anywhere. So there is I/O from the application's point of view, but not from the hardware's ...


3

Software random number generators are not the only source of entropy in the system. Actually they are not sources of entropy at all - software RNGs use external entropy sources to supply entropy to the system. The real source is always a physical one (be it a dedicated hardware RNG, temperature sensors, audio input, timing of network packets, user inputs or ...


3

In short: none of the two programs will work correctly. The output from the two programs will be merged and sent out the serial port. The input coming in through the serial port will be seen by only one of the programs (some input will end up at one of the programs, some input will end up at the other, randomly). Because of this, programs normally using ...



Only top voted, non community-wiki answers of a minimum length are eligible