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 ...


15

The kernel lists them by name in /sys, both separately in (e.g.) the tree of PCI devices -- although finding them there if you don't know where they are to start with is not simple -- and together via symlinks in /sys/class/net. E.g.: > ls /sys/class/net em1 lo wlp6so Another example: > ls /sys/class/net lo p6s1 wlan0 If you are not sure which is ...


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 ...


10

The simplest method I know to list all of your interfaces is ifconfig -a EDIT If you're on a system where that has been made obsolete, you can use ip link show


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 ...


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

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

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

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

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

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

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

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

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

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 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

If I understand you right then there is some file system on /dev/sdb that you have mounted. What matters here are the permissions in the file system that resides on /dev/sdb, the permissions of /dev/sdb are completely irrelevant for your question. Except that with permissions 0666 anyone can bypass the access control mechanisms for that file system and ...


3

A Solution: The problem is that this serial port is non-PlugNPlay, and a system do not know which device was plugged in. Anyway, after reading a HowTo I get the working idea. An *nix-OS already have in /dev/ a files like ttySn where a n ending is a number. Most of this files is dumb i.e. doesn't correspond to an existing devices. But some of those is going ...


3

The RTC subsystem went through a major redesign since at least 2006 and since then doesn't have a statically assigned major number, now. This is a rather major trend in the Linux kernel for various device drivers (device-mapper for example also dynamically allocates its device-number region). The reason behind this is that the vast amount of available ...


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’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.: ...



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