Tag Info

Hot answers tagged

46

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 things mount determines is HOW to use ...


14

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 and unifies user-space I/O ...


12

Basically, and to put it easily, the operating system needs to know how to access the files on that device. mount is not only "giving you access to the files", it's telling the OS the filesystem the drive has, if it's read only or read/write access, etc. /dev/cdrom is a low-level device, the operating system functions wouldn't know how to access them... ...


11

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 since the nodes can be created on disk and ...


9

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 corresponding to one of the audio ...


8

Modern Linux kernels support the devtmpfs file system (do not confuse with ancient devfs), which creates all device nodes dynamically as soon as the kernel discovers them. (In fact, latest udev releases require this; you'll find that udev doesn't create any device nodes anymore, only symlinks.) Similarly, firmware loading has been moved into the kernel as ...


7

You can read or write /dev/cdrom (eg, using dd or cat) but when you do that you are just reading or writing the raw bytes of the device. That can be useful in various circumstances (like cloning a partition), but generally we want to see the directories and files stored on the device. When you mount a device you're basically telling the kernel to use a ...


6

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 able to locate the superblock for a ...


6

For consistency Imagine you have some partitions on the first hard drive in your system. For example, /dev/sda2. You later decide that the drive isn't large enough so you purchase a second one and add it to the system. All of a sudden, that becomes /dev/sda and your current drive becomes /dev/sdb. Your partition is now /dev/sdb2. Using your proposed ...


6

For tcp, just checking $?. If connection failed, $? won't be 0: $ >/dev/tcp/google.com/81 bash: connect: Network is unreachable bash: /dev/tcp/google.com/81: Network is unreachable $ echo $? 1 It will take time for bash to realize that the connection failed. You can use timeout to trigger bash: $ timeout 1 bash -c '>/dev/tcp/google.com/80' ...


5

If the filesystem takes over the whole disk, OS X currently uses a name like /dev/disk5. If the disk is partitioned, it adds an s# suffix, like /dev/disk5s2 for the second partition. (s is short for "slice," a BSDism functionally equivalent to a partition.) Disks are numbered sequentially in discovery order by the OS, on boot, so you may have to experiment ...


5

You could pipe through SSH. Example using dd: dd bs=1M if=/dev/disk | ssh -C target dd bs=1M of=disk.img If the network connection breaks during transfer, you can resume if you know how much was copied. For example if you're sure at least 1000MiB were transferred already (check the file size of disk.img): dd bs=1M skip=1000 if=/dev/disk | ssh -C target ...


5

There are several advantages to the current arrangement. They can be grouped into advantages of block special files and advantages of mountpoints. Special files are files that represent devices. One of the Ideas that unix was built on is everything is a file. This makes many things simple, for example user interaction is just file reads and writes on a tty ...


4

POSIX general defines three special files: /dev/tty /dev/console /dev/null In addition, / and /tmp are also defined by POSIX. /dev/zero, /dev/urandom or /dev/random are defined in some UNIX-like operating systems. Some operating systems may not define them, or implement with different names. Note POSIX direcory structure and files /dev/zero ...


4

Not every file under /dev is a device file that has major/minor numbers. Example $ ls -l |grep initctl prw-------. 1 root root 0 Sep 17 13:27 initctl $ stat initctl File: ‘initctl’ Size: 0 Blocks: 0 IO Block: 4096 fifo Device: 5h/5d Inode: 8882 Links: 1 Access: (0600/prw-------) Uid: ( 0/ root) Gid: ...


4

It won't work, if the filesystem was installed in a partition (e. g. sda1). fsck and its brethren are tools for performing maintenance on filesystems (hence the name: filesystem ccheck), not of block devices. It is, I suppose, theoretically possible to put a filesystem directly onto a block device by way of something like mke2fs -j /dev/sda, but this is ...


4

The /sys filesystem (sysfs) contains files that provide information about devices: whether it's powered on, the vendor name and model, what bus the device is plugged into, etc. It's of interest to applications that manage devices. The /dev filesystem contains files that allow programs to access the devices themselves: write data to a serial port, read a ...


4

/dev/cdrom refers to a device file. This is not the contents of whatever disc you might wish to insert into your optical drive, but rather it is a reference to the bit of hardware (and probably software drivers) that you might call on to show that to you. When you mount /dev/cdrom to some path in your tree you attach its contents to your file system. The ...


4

I think about this in the following manner: mount is a tool that tells the system to interpret the contents of some files as directory trees. The filesystem has directories and files, and each file is a label for some string of bytes. /dev/cdrom is a file, it represents the string of bytes stored on the CD. You can read this very long string directly, but ...


4

I'd call it historical reasons. Not that the other answers are wrong, but there's a bit more to the story. Compare Windows: Windows started as a single-computer, single-user OS. That single computer probably had one floppy drive and one hard drive, no network connection, no USB, no nothing. (Windows 3.11 had native networking capabilities; Windows 3.1 ...


3

You can do this using udev. Create a file in /etc/udev/rules.d with the suffix .rules, e.g. local.rules, and add a line like this to it: ACTION=="add", KERNEL=="i2c-[0-1]*", MODE="0666" MODE=0666 is rw for owner, group, world. Something you can do instead of, or together with that, is to specify a GID for the node, e.g: GROUP="pi" If you use this ...


3

I'm never quite sure if spelunking in sysfs is the best way to do things (am I supposed to use udevadm?), but at least it's discoverable $ DEV=p8p1 $ readlink /sys/class/net/$DEV/device/driver ../../../../bus/pci/drivers/tg3 It won't work for devices like lo which are "virtual" (/sys/devices/virtual/). They don't have the link to an underlying device ...


3

I can try to trap the Interrupt at a lower level and inform the gtkmm application. No, that is a kernel space activity. Fortunately, the kernel does report the outcome of certain events via interfaces accessible from userland. It's a little ambiguous in your question whether you want to detect when a block device is attached, or when a filesystem is ...


3

What is a Terminal? A terminal consists of a screen and keyboard that one uses to communicate remotely with a computer (the host). One uses it almost like it was a personal computer but the terminal is remote from its host computer that it communicates with (on the other side of the room or even on the other side of the world). Question 1 /dev/tty ...


3

Weeeeellll..... A kernel module is something very specific: A part of the kernel that's being loaded as a module (i.e. dynamically), after the core kernel starts. That can be anything. In order to use the hardware you need some parts that reside in the mostly kernel for two reasons: In order to be able to perform hardware operations that cannot be done ...


3

I’ve been able to do this with an udev rule, after some trickery (and using lsusb to find out the vendor and product ID of the device in flash mode): $ cat /etc/udev/rules.d/nxt.rules # disable NXT in flash mode ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="6124", RUN="/bin/sh -c '/bin/echo -n $kernel:1.0 | /usr/bin/tee ...


3

On Debian typically the selected syslogd package takes care of creating the /dev/xconsole pipe. You probably have rsyslog installed; look at the /etc/init.d/rsyslog script and search for create_xconsole which is the shell function that creates /dev/xconsole; it's trivial to modify that to create a second file.


3

I would set the group of the repetierHost application to uucp and then set the SGID bit (as long as it is a real binary and not script): chgrp uucp repetierHost chmod g+s repetierHost If the repetierHost is a script you could consider moving that to repetierHost.sh and write a small C programming wrapper repetierHost that calls repetierHost.sh E.g.: ...


3

Yes. The camera light will be on while the camera is in use. In this case, Motion is taking the feed and streaming it through the Motion web server. This happens whether or not people are connected to your stream. Assuming you're only using Motion I would edit the motion.conf in order to add authentication for the stream and also enable logging (to see ...


3

I was surprised to discover that my Mac Book Air does have a /dev/sdt character special device. Since I could not fathom its nature, I looked up my copy of Mac OS X for Unix Geeks. At page 60, there is the list of all entries in /dev. sdt is indeed mentioned, with the unenlightening explanation: sdt Undocumented It is its only mention in ...



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