date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,558,535,463,000
I'm on Windows 7 and I run a Debian VM under Vbox. On my Windows 7 I've the c:\temp folder that I want to share. I added it : I had an hard time to permanently mount that folder with Virtual box (had to install Guest Additions, etc.. ) but now it is solved. What I need to do is edit /etc/fstab file and add the foll...
with mount you use a device? No. One provides a source, a.k.a. a "what" (alongside a "where" and a "vfstype", and some options). That does not have to be a block device name. It is something that only has meaning in conjunction with the type of filesystem. In the case of vboxsf mounts, the "what" is the name of ...
How Virtual Box shared folder are handled in Debian ?
1,558,535,463,000
We have a customized Linux distro (created via buildroot) running on an embedded platform. There's this relay module we need to connect to it through an USB port (the module is based on an ATmega32U2 microcontroller). When testing the device on Windows, the driver was installed through a .inf and everything worked jus...
As suggested in the comments, the inclusion of the "CDC-ACM" module in the kernel solved the problem. The relay module is recognized as "ttyACM0" and it's working just fine.
Why does my USB device not appear on /dev?
1,558,535,463,000
This is a RedHat system running a postgres database. Nothing seems to have broken. Do I need to request a restore? That would destroy a day's worth of work, so I'm not eager to do that. A couple of things I've read that would perhaps fix things, but I've never used, don't know much about, etc. udevadm trigger /sbi...
Just reboot, dev will be back as it was, it's not actual files, just devices, although there maybe some symbolic links there good chmod ignores them :) EDIT: Just put my money where my mouth is... find /dev -exec ls -la '{}' \; > /home/mike/dev-perms1 sudo chmod -Rv 777 /dev sudo reboot find /dev -exec ls -la '{}' \;...
chown /dev by mistake
1,558,535,463,000
I've got some sort of home entertainment system running an old version of Linux 2.6. It has a SATA > USB bridge system and a couple of USB ports. What I want to do is use it as Network Attached Storage. Now, luckily, it has an open and accessible telnet server running. The problem is, I can't find where the kernel, n...
mknod /dev/mtdblock0 c 31 0 You created a character device. You wanted a block device. So use b instead of c in the mknod command. Block device numbers and character device numbers are independent. Block device 31:0 is unrelated to character device 31:0. Your kernel has no driver for character device 31:0, hence the “...
Failing to create /dev entry from sysfs, No such device or address
1,558,535,463,000
I am modifying some dated code (from year 2011; see here) that accesses a USB endpoint in the path: /sys/class/usb_endpoint/usbdevBUS.DEVICE_epENDPOINT/device where "BUS", "DEVICE", and "ENDPOINT" vary. However, my Linux setup (Slackware 14.2; kernel 4.4.14) doesn't have paths of this form. How do I access USB endpo...
They are under /sys/bus/usb. For example, ls /sys/bus/usb/devices/1-0\:1.0/ep_81/ bEndpointAddress bLength direction power uevent bInterval bmAttributes interval type wMaxPacketSize
How do I access USB endpoints with recent Linux kernels?
1,558,535,463,000
I have been given a box that has /dev/mapper/root mounted as / and mapped to /dev/dm-0. It has /dev/mapper/home mounted as /home and mapped to /dev/dm-2. The dm-0 device is 5G and the dm-2 device is 2T. I've been asked to swap them: make / 2T and /home 5G. I have resized, deleted, and added logical volumes. Is there a...
There's no direct way to swap two devices, but this isn't what you need anyway. Keep root as / and home as /home, shrink home to the desired smaller size, and enlarge root using the space that was freed up. Depending on the filesystems, you may or may not need to unmount them to resize them. Ext4 filesystems can be en...
Swap /dev/mapper/* devices
1,558,535,463,000
$ stat new File: ‘new’ Size: 928 Blocks: 8 IO Block: 4096 regular file Device: 804h/2052d Inode: 28188755 Links: 1 Access: (0622/-rw--w--w-) Uid: ( 1000/ t) Gid: ( 1000/ t) Access: 2015-12-19 06:33:07.842559147 -0500 Modify: 2013-06-11 12:54:44.944836000 -0400 Change: 2015-03...
Well, hex 804 is actually two bytes, typically written as 0x0804. The first byte is 0x08 (the "major" number), the second is 0x04 (the "minor" number). Converting them to decimal, that's where 8, 4 comes from. You can find out what the 8 means from /proc/devices, which gives block device 8 as sd, which is SCSI disk. I...
Major and minor numbers of a partition
1,558,535,463,000
Background: I am currently in the process of updating a Industrial PC + software from Debian 4 (etch) to Debian 7 (Wheezy) due to hardware obsolescence, one of the few pieces of hardware being shared between the old and new systems is a Sunix 5008 parallel port. We use the parallel port to talk to some custom hardware...
Having looked into this further it seems that this is due to the driver only being partially implemented, critical ioctls seem to be stubbed out.
Sunix Low Level Parallel port driver not working
1,558,535,463,000
I was running a small instance on Amazon EC2. I'm trying to migrate it to a micro as it requires very minimal processing power. One thing I just learned though, is that micro instances do not come with ephemeral storage like the other instance sizes. Here is the fstab file from the small instance. I just added the nob...
The AMI will work fine, as-is. The only reason you would need it is if your workflow/application needs it.
Do I need ephemeral storage?
1,708,371,103,000
Out of curiosity I've decided to call cat on one of my nvme devices with the following command : sudo cat /dev/nvme0n1p1 It started printing out gibberish but now I wonder : what data does this actually represent ? Is it data from somewhere on the disk ?
Yes it is the data from all of the partition. You could even use this for e.g. creating an image of the partition. You may test this if you have a smaller partition available, e.g. a EFI-boot partition that often is no more than half a gigabyte. lsblk #nvme0n1 259:0 0 476.9G 0 disk #├─nvme0n1p1 259:1 0 2...
Printing out the contents of /dev/nvme devices : what does it represent?
1,708,371,103,000
I am begginer in LINUX, sorry if my question isn't the best. I have a c++ app that uses OpenCV lib. This app runs at startup via a service(using systemctl). My app needs as arguments, the id of usb camera devices. I have 2 usb camera. When I switch off these devices, the output of ls /dev/video* is: /dev/video1 If I...
I find out the easiest solution, using the next command: v4l2-ctl --list-devices This is the output: vi-output, ov5693 2-0036 (platform:15700000.vi:2): /dev/video2 HBV HD CAMERA (usb-3530000.xhci-2.1.2): /dev/video0 HBV HD CAMERA (usb-3530000.xhci-2.1.3): /dev/video1 After that, I made a script to take...
How can I find the usb devices camera?
1,708,371,103,000
I have a device (a video card) that I need only two programs (expressed as paths, e.g. /usr/bin/myprogram) to access. The device has a /dev file (e.g. /dev/mydev1), but I can also use other references if required (bus id, vendor/product id etc.). Is there anything that I can do (e.g. udev rules), that prevents any pro...
The classic unix solution would be to create a system group (e.g. groupadd -r vidcard), then set the permissions of the device to only allow root and members of that group to access it. In Linux, that would take the form of an udev rule, as /dev is regenerated from scratch at every boot. The rule might look something ...
Is it possible to make a device accessible exclusively by certain programs?
1,708,371,103,000
I'm about to automate the installation of Debian by using the preseed mechanism (preseed file added to initrd). The computers to be provisioned have multiple SATA disks. I would like to specify in the preseed file precisely what partition to put on what disk. This is possible, of course, by specifying the associated d...
The summarize the answer, based a comment from @MarkPlotnick: The key is to understand, that there are multiple device files representing the same drive. The most well known are /dev/sda, /dev/sdb etc. where the ordering is not well defined. However, drives can also be refered to by using the device files in /dev/disk...
How to specify reproducible disk partitions in Debian preseed file when device file ordering (sda, sdb ...) may change?
1,708,371,103,000
I am trying to understand how linux filesystems work, but the only linux system I have is my android phone (rooted) so I am asking on the basis of what I see oin the android phone using adb shell. From here and here I have read that every hardware connected to the android system is seen by the OS as a file. So /dev/...
Your tldp links are a bit historic. And if you look at /dev just as part of the filesystem, you miss the essence of this subsystem. A.B's comment mentions major/minor; but his link is just the raw list. Here allocated devices kernel.org HTML there are some additional infos. I think "everything is a file" is rather mi...
Understanding /dev folder in linux (android)
1,530,856,319,000
I was looking at the udev information but couldn't find out anywhere. What does DEVLINKS signify also what are these values dev/disk/by-id/mmc-008G30_0xf281d20d & /dev/disk/by-path/platform-3400000.sdhci ? output for above command
DEVLINKS are unique names for a given device. In this case this is a a mass storage device, mmcblk0. The 2 DEVLINKS that this command is returning can be used when you want to address this storage device to query against it or reconfigure it. You'll typically see devices go by multiple names, in this case the SD card ...
what is DEVLINKS in the output of udevadm info --query=property --name=/dev/mmcblk0
1,530,856,319,000
(this is similar to my How to tell virsh: save state of VM and vdisk, but not attached disk? but for VirtualBox and raw devices) How do I tell VirtualBox to NOT preserve the state of raw attached devices when snapshotting? Details: I created a VMDK on the host machine as follows: VBoxManage internalcommands cre...
You must unmount the device before making the snapshot. Otherwise, when resuming, the state of the device would not match the state of the disk cache in the guest kernel, which would result in massive corruption. After you've unmounted the device, detach it from the virtual machine before making the snapshot.
VirtualBox: do not preserve attached device changes when snapshotting (how?)
1,530,856,319,000
My question may looks trivial... But it's because despite of my long experience of linux/unix/osx systems, I found myself lacking some basic notions. I created a little bluetooth/arduino switch to control some appliances at home. It's a simple program like shown here http://www.tinkernut.com/2014/03/arduino-bluetooth-...
After many reading, and thanks to Bibek_G's answer which helped me to find some links on the internets, I finally understood what I need and how to make thing work. Actually, what I want to do doesn't need screen... The right command was : sudo echo 1 > /dev/cu.HC-06-DevB It didn't work at the beginning because I did...
Send a message to a "screen" to be received by a device on /dev
1,530,856,319,000
I'm logged on to a remote machine and I'm trying to determine how many video cards are installed. The machine was built for CUDA operations so it's likely to have more than one NVIDIA card. > lspci | grep -E "VGA|3D" gives 02:00.0 3D controller: NVIDIA Corporation GF110GL [Tesla M2090] (rev a1) 03:00.0 3D controller:...
For the nvidia case, it turns out that nvidia-smi -L does what I'm looking for: LIST OPTIONS: -L, --list-gpus Display a list of GPUs connected to the system. > nvidia-smi -L GPU 0: Tesla M2090 (UUID: GPU-29ca4022-cf9d-d39f-8c46-...) GPU 1: Tesla M2090 (UUID: GPU-1e282221-0aac-9a10-a46c-...) GPU 2: ...
How many distinct video cards do I have?
1,530,856,319,000
I'm trying to build a Linux Device Driver for a Devkit 8000. I'm getting the following errormessage: When I try to follow it's directions I get asked a bunch of yes/no questions I don't really understand. In the end, I get to choose between 25 different processors(?): Here's my makefile: ifeq ($(KERNELRELEASE),) KE...
You haven't said where you got the source you are using, but evidently there's an invalid .config in it. This is used to set various options, such as the processor type. There are literally hundreds of these options with intricate dependencies upon one another (e.g., what processor you choose will affect what other ...
Can't Make a LDD for a Devkit8000
1,530,856,319,000
I am using Linux Fedora Core 4 (have to work with a legacy system) and trying to burn DVDs as a non-root user using the growisofs utility. I seem to be getting this error message at the end of the burn process every time: Error trying to open /dev/dvd exclusively ... retrying in 1 second. The output is here: 99.18% d...
That message is likely the desktop environment attempting to mount the newly detected DVD out from under the burning software. It's been ages since I've had a FC4 system around, so I can't really provide you specifics. But I would look to disable the desktops ability to mount DVD automatically. There's probably someth...
Getting message "Error trying to open /dev/dvd exclusively" at the end of a DVD burning process when using growisofs
1,530,856,319,000
I am using Linux Fedora 4 and would like a non-root user to be able to write to DVDs using the DVD drive. I was able to do this by adding write access to the group of the device file /dev/scd0 and have added the user to the relevant group. However, whenever the machine is rebooted, the device file reverts back to its ...
Try the following: # echo 'SUBSYSTEM=="scsi", KERNEL=="scd[0-9]", ATTRS{type}=="5" GROUP="optical", MODE="0666"' > /etc/udev/rules.d/80-cdrom.rules test the rule # udevadm test $(udevadm info -q path -n /dev/sr0) 2>&1 load the rule # udevadm control --reload-rules Update Looks like FC4 udev predated udevadm. I pu...
Permission of DVD device file not being retained when machine is rebooted
1,530,856,319,000
The device tree for LCD4 cape is located at /lib/firmware/BB-BONE-LCD4-01-00A1.dts When I looked into it, the declaration of those GPIO buttons confuse me. There are five buttons according to schematic revision A1 here link, none of them are mapped to GPIO0_3, which is UART2. But in the dts file, GPIO0_3(on P9_21) is ...
Angstrom mailing list says this error will be corrected in the next Angstrom release. It can also be corrected by recompiling entire kernel with modified dts file. LCD device tree is bundled with kernel directly and cannot be loaded dynamically like other virtual capes.
Beaglebone Black Device Tree for LCD4 cape
1,373,288,721,000
I have an external microSD card plugged into my machine via a USB stick. I believe it was auto-mounted because I can see $ ls /media/me 7538-3DFD I believe it is mounted to /dev/sda1 because I see $ sudo fdisk -l Disk /dev/loop0: 4 KiB, 4096 bytes, 8 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/...
/dev/sda and /dev/sda1 are "block devices" that simply read and write "disk blocks (clusters)".. When a block device is "mounted" (man mount), the device is interpreted by a "filesystem", and connected to the file system at /media/me/7538-3DFD.
Why can't I directly ls /dev/sda1
1,373,288,721,000
I am looking for a way to put zeros and burn myiso.iso in parallel. The command dd if=/dev/zero of=/dev/sdb && (sleep 1; dd if=myiso.iso of=/dev/sdb) should be ok since the speed at which zeros are written is inferior to the speed at which the iso is written. How would you verify that the iso is written only after ze...
If you're trying to ensure the USB key only contains the image and the remaining space is all zeros, you could do this instead: cat myiso.iso /dev/zero > /dev/sdb There doesn't seem to be much point in writing all zeros and then the image on top...
How can I run 2 dd in parallel writing on the same device
1,373,288,721,000
I'm trying to create a backup script that saves my thumbdrive as an image. I'm planning on having it automatic. I've always seen the thumbdrive listed as /dev/sdb, and created a script that will save it as a gzipped tarball. While trying to make a copy of it via dd, I noticed this error: dd: failed to open ‘/dev/sdb’:...
Why does reading a device require admin permissions? Firstly there are couple of issues here mount'ing the physical storage device and the partitions it contains. Accessing and manipulating the files on it. If the filesystem is permissions based, e.g. ext2,3,4 then permissions are defined on a per file basis. In...
Why does reading a device require admin permissions?
1,373,288,721,000
Leaving aside the need for that, I wanted to write (create a file) into /sys/devices/pci0000:00/{one-of-the-devices}/. Running touch a returns touch: cannot touch 'a': Permission denied. (I read somewhere that giving write permissions to the given folder is not enough — if one of the parent folders in the hierarchy do...
Yes, most virtual file systems like /proc and /sys on Linux can’t be used arbitrarily, because they don’t store files, they provide access to objects internal to the kernel. So it’s not that virtual file systems that the OS refreshes/writes to intermittently — virtual file systems don’t store data which is refreshed...
Are there specific folders in the file system that cannot be written to?
1,373,288,721,000
I have read that the /dev directory contains device files that points to device drivers. Now my question is, is every single file in the /dev directory is a device file, or does the /dev directory contains other types of files?
Typically you may find (b)lock, (c)har, (s)ocket, (l)inks and (d)irectories in /dev. You can see the type with ls -l. However, depending on the OS, you may find other files in there. eg on NetBSD there is a shell script /dev/MAKEDEV, which is meant to help with the creation of these device entries. As with your oth...
Is every single file in the /dev directory is a device file?
1,373,288,721,000
If I only have the following information, how can I figure out what this device is ? # df -Ph /dev/cciss/c0d0p1 I know that "sd" are SCSI disk, "hd" are IDE disk etc. So what about "cciss" ? What other command lines can I use to get more details about this device? I'm using RHEL systems.
This is a drive on a SmartArray controller (controller 0, drive 0, partition 1). You’ll find more information in the kernel’s cciss documentation, and you can use the CCISS Utilities to get more details about the drive. If you’re interested in the actual drive details rather than the RAID information from the HBA, you...
How to get more informations about this device?
1,373,288,721,000
is there any shell command, can let me know, current open device or device already in operation. For example, I use minicom to open a device /dev/ttyUSB0 or /dev/ttyS0, after I use program open this device, how can I check it under shell it already open? I tried dmesg but seems doesn't work for me
I think lsof is the tool that should be used for. It will list all the files that are being used by a process. May be fuser can also be used if you want do not know the process id.
how to know which device was open
1,373,288,721,000
When I open Nautilus and I go to the other locations I can see my unmounted hdd wich name is /dev/sda1 and it's real name is HDD. How can I found the real name of /dev/sda1 from the command line?
By real name, you mean the LABEL. This can be viewed with lsblk -f or ls -l /dev/disk/by-label or sudo blkid -o list
How to find out the real name of mountable devices?
1,373,288,721,000
I read this in "RH413 Red Hat Server Hardening" course that we mount the filesystems with nodev which then does not allow the special files/devices to be mounted from it. However, it did not show an example. I, however, did the following thing on my RHEL machine and I found that we cannot associate the special charact...
Firstly... I found that we cannot associate the special character device with any file created by dd command The experiment you have shown does not create a file with dd, it tries to write to a special character device using dd. 1) What are device files? Device files can be thought of as a link to a device in your ...
What is the default behaviour when we mount filesystem with `nodev` option?
1,373,288,721,000
I'm having a problem on Linux Debian 9.6. Although I have UIO support compiled into the kernel, the /dev/uioX device files are not beeing created. root@machine:~# zcat /proc/config.gz | grep UIO CONFIG_UIO=y # CONFIG_UIO_CIF is not set CONFIG_UIO_PDRV_GENIRQ=y CONFIG_UIO_DMEM_GENIRQ=y # CONFIG_UIO_AEC is not set # CON...
UIO device nodes are only allocated when a device is registered, e.g. when you probe a PCI device using the generic PCI UIO driver: echo "8086 10f5" > /sys/bus/pci/drivers/uio_pci_generic/new_id In the driver, this corresponds to a uio_register_device call. See the UIO howto for details.
UIO device files /dev/uioX are not created on Linux Debian
1,373,288,721,000
Given a device file (ex: /dev/sda) how can I get a list of all relevant partitions? Expected input: /dev/sda Expected output: /dev/sda1 /dev/sda2 /dev/sda3 ... I know there are many ways to get information about block devices, such as lsblk, blockdev, fdisk, and blkid to name a few, but I want a solution that is th...
With ls: $ ls -1 /dev/sda?* /dev/sda1 /dev/sda2 /dev/sda3 Or, with lsblk (which is LVM-aware): $ lsblk -lpo NAME /dev/sda NAME /dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/mapper/home-root /dev/mapper/home-swap_1
Given a block device file, how can I list all relevant partions?
1,373,288,721,000
Some time ago, I remember reading an article on randomization in computing, and how random you can actually get a system to be. The article came about, if I'm not mistaken, because of some seemingly minor change in the code, but resulted in a big security vulnerability. I can't find the article, and I can't recall wha...
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, t...
Random bug in Linux
1,373,288,721,000
Is there a way to hide an ext4 partition from e.g Thunar? And the open file/save dialog , I think they come from the same source.
Assuming you mean hiding an unmounted partition from thunar, add a row in your /etc/fstab, using none as the mount point and fs type columns ;)
Hidden ext4 partition?
1,373,288,721,000
I've been learning to use udev and noticed that when I run udevadm test --action="add" /sys/block/sdc I see the following: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:59 IMPORT 'scsi_id --export --whitelisted -d /dev/sdc' /usr/lib/udev/rules.d/60-persistent-storage.rules:50 starting 'scsi_id --export --whiteli...
The --whitelisted option appears to do a "wet run" (as opposed to "dry run") because without it scsi_id does not appear to be doing anything at all. see source: https://github.com/systemd/systemd/blob/bab787396444466e5a71e5f01b1924646959f6e0/src/udev/scsi_id/scsi_id.c#L407 static int scsi_id(char *maj_min_dev) { ...
Why does udev automatically whitelist my RAID card and what is the function of this whitelisting?
1,373,288,721,000
I am currently studying device drivers in an operating systems course and am getting confused regarding the difference between the "inode" structs and "cdev" structs. Could someone clarify the differences between these two structures and what they're meant to achieve?
Your question doesn’t mention any specific context; this answer describes struct cdev and struct inode. The two are fundamentally different. struct cdev represents a character device, giving access to a driver; it points to the implementations of the various operations supported by a character device. struct inode rep...
What's the difference between structures "cdev" and "inode" in the context of device driver programming?
1,373,288,721,000
I want to create something file-like (that can be read like a common file), which everytime it is read, it gets its output from a command. For instance, if I do echo $RANDOM > test, then I can call cat test and it will display the generated random number. Except that I would need that everytime I call cat test (or re...
Use named pipes functionality: mkfifo myfancypipe; while true; do bash -c 'echo $RANDOM' > myfancypipe; done Now go to another terminal and each time you will call: cat myfancypipe You will get info from echo $RANDOM
How can I create a pseudo-file that gets its content from a command everytime it is read
1,373,288,721,000
man pvcreate says pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be used in a VG. A PV can be a disk partition, whole disk,meta device, or loopback file. What is a meta device? Thanks.
In LVM parlance, a meta device is a device created from some other device or set of devices. Examples include devices created by the MD layer (/dev/md1 etc.), representing aggregated devices, and devices created by LVM itself, representing logical volumes (so it is possible to create a PV from an LV...).
What is a meta device?
1,373,288,721,000
With ls -l, I found a series of devices like ram0, ram1 etc. I looked at the output closely and (for example) brw------- 1 root root 1, 3 Jan 6 11:34 /dev/ram3 crw-rw-rw- 1 root root 1, 3 Jul 15 1970 /dev/null Hmmm, they only differs by device type (block and character). I tried reading and writing to ram3, but to ...
The block devices are completely separate from character devices. The fact that the device major/minor numbers are equal means nothing at all: you can think of the block/character device bit as an extra, most significant bit in the device numbers. Conceptually, the device numbers are indexes into the kernel's big tabl...
Use /dev/ramX as their corresponding special devices?
1,373,288,721,000
I have a FAT32 filesystem mounted. After changing a file on it, I can read the file back and still see the old version. My changes don't actually persist until I unmount and remount the partition. Is this behavior normal? If yes, why does it make sense or why is it needed? Is there a way to set it up so changes appear...
The linux, just like most other operating systems, do cache the disk IO operations. You could force the kernel to flush its buffers with sync command after you performed a file modifications. However, this degrades the performance of the whole system as all currently 'dirty' buffers are flushed to the disks with this ...
Changes to files don't show up until the partition is unmounted
1,373,288,721,000
root@host [/etc]# iostat -xk Linux 2.6.32-279.19.1.el6.x86_64 (host.superhostsite.com) 01/13/2013 _x86_64_ (24 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 12.53 0.19 3.72 0.18 0.00 83.38 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq...
You want to use find as specified in your link, but with an additional -mount flag, that will restrict find to the current filesystem, and ignore any others. -mount Don't descend directories on other filesystems. An alternate name for -xdev, for compatibility with some other versions of ...
What files are being updated or written in /dev/sda?
1,373,288,721,000
I can't find any explanation about this file in the official documentation, I just know from the official documentation in devices.txt that this file is: "234 = /dev/btrfs-control Btrfs control device".
It's defined in fs/btrfs/super.c in kernel source code, and used for various BtrFS-specific ioctl() system calls. Generally, unless you are developing the libbtrfs library of the btrfs-progs package, you don't need to care about it. But if you are curious, seeDocumentation/btrfs-ioctl.rst in btrfs-progs package, read ...
What file is /dev/btrfs-control?
1,373,288,721,000
I recently set up a debian 12 VPS with a new hosting company. It has: /media/cdrom -> cdrom0/ /media/cdrom0/ And in /etc/fstab: /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0 Debian VPSs in my old hosting company do not have that. The new hosting company is well-known and reputable, but I was ...
Impossible to tell without knowing your hoster's setup more closely. But the obvious reasons I'd see are: The CDROM mount entry is a leftover from the debian provisioning process (and could have been removed, which your old hoster did correctly) The entry is for when you mount a disk image through your hoster's mana...
Why does VPS with stock Debian contain cdrom device?
1,373,288,721,000
I have a drive that is about 1TB big. It is mostly free space. When you add up the size of all the partitions, it is less than 256GB. I have another drive that is 256GB. I would like to clone the data from the 1TB drive to the 256GB drive. Is this possible? Obviously the source is bigger than the destination, but I'm ...
Thank you for adding the details. As you have Windows installed, be sure you have a current Windows Recovery Media. This USB stick can be created by your Windows. Search for Recovery media in the Windows start menu or just run C:\Windows\System32\RecoveryDrive.exe This will help if your Windows should not boot anymo...
dd not enough space
1,373,288,721,000
My question is related to the way device nodes are implemented in Linux. I know there are pseudo files systems like udev or devtmpfs available - in this case there is no real storage behind and the file system is an illusion presented to applications by kernel drivers. However, my questions remain valid for: The way ...
In the POSIX model, all files use an inode, regardless of their type. A directory entry is only a name pointing to an inode; file type, permissions etc. are stored in the inode. So device nodes involve an inode too. You can see this by running ls -li /dev: each entry has a corresponding inode number. Device nodes ar...
Are device nodes stored as files or just special entries in directories?
1,373,288,721,000
I am currently working with an Embedded Linux Board and need to use the serial port, which is represented by the device file /dev/ttyS0. Upon running the command ls -l, I observed that the major and minor numbers for this device are 247 and 0, respectively. However, according to the Linux Allocated Devices Guide, thes...
It's possible that you have a different module that creates the device and the module determines the major & minor numbers. Use the commands readlink /sys/dev/char/247\:0/device/driver udevadm info -a -n /dev/ttyS0 to find out what module is controlling the device. It may not be the usual PNP subsystem and serial dri...
How to change the major and minor number of a device file?
1,373,288,721,000
Aside from FreeBSD or Linux operating systems' design structure and C programming knowledge, are datasheets enough as additional references in making device drivers?
No, they're not. A datasheet contains data about what the device can do. For example, an airplane's datasheet would contain things like maximum speed, maximum safe altitude, maximum lift, expected transport capacity, kilogram of fuel per mile under some model flight assumptions … these kinds of things. But: a plane's ...
Datasheets as references in making device drivers
1,373,288,721,000
I'm trying to write a udev rule to disable (and re-enable) my trackpad when a USB mouse is connected. Currently, my rule looks like: ACTION=="add", ATTRS{bInterfaceProtocol}=="02", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceSubClass}=="01", ENV{REMOVE_CMD}="/usr/bin/synclient TouchpadOff=0", RUN+="/usr/bin/synclien...
I think, you should use sudo your_user for the utility, or pass DISPLAY environmant variable, so it could communicate with Xorg driver. And, make sure you have synaptics driver active... Try running synclient as root with cleared environment (simulate run by udev) - i'm guessing, it won't do anything.
udev rule not working on Arch to disable touchpad when USB mouse connected
1,373,288,721,000
If i have an operating system with multiple users logged in via ssh, is there any way i can find which physical machine is associated with each /dev/pts/N (where N is an integer)? All i know is the who and ps -aux commands that will show which user or process is associated with the device files, but can i get any ...
A pseudo-terminal is not associated with a "physical machine". It's associated with a running process (e.g., ssh session, or a gui terminal window, a window in screen/tmux, etc). You can use ps to find what processes are using a given pts device, and potentially backtrack from there. For what you're trying to do, the ...
Find physical machine associated with /dev/pts/N
1,373,288,721,000
I am currently trying to solve a forensic file hunt training question. There were hints given, that there is a LUKS container and that we need to find the LUKS header in order to go on with the next training question. From the information given along with the question, the header can be identified with this magic numb...
Is there a "smart" way to search for a specific file header? Basically you are searching for a specific bytestring, so it would best to search the binary data directly instead of xxd output, which can produce false negatives (as well as potential false positives), i.e with: grep -oba "$(printf '\x4c\x55\x4b\x53\xba\...
Search full device for magic number as hex
1,637,935,119,000
I have created CentOS 7 VM in oracle VM box with the disk size of 10 GB. When I run fdisk -l /dev/sda command, it reports that the disk size is 10.7 GB. Can someone explain why fdisk shows higher disk space than the actual disk space?
If you look at the fdisk output, you can see that the disk is reported as being exactly 10*1024*1024*1024 bytes. That suggests that whatever created that disk actually created it to be 10 GiB, although your screenshot shows that VirtualBox calls it GB, but I just take that as (yet another) indication that Oracle sucks...
Discrepancy of disk size in fdisk command output
1,637,935,119,000
I'm running ubuntu linux and I have a bluetooth mouse that I would like to capture evdev events from. The problem is that the event device can potentially be different any time I connect the mouse: sometimes it's /dev/input/event17, sometimes /dev/input/event16, etc. /dev/input/by-id and /dev/input/by-path aren't gett...
Use udevadm info to query device attributes, then creat udev rule which would create symlink in /dev/ to easy access the device by your custom name. See https://wiki.archlinux.org/index.php/Udev#udev_rule_example
Is there a reliable path to specific device events?
1,637,935,119,000
I'm using virt-manager and I am trying to select a USB device. It's telling me some valuable device information: but I don't know where to find that other than using: udevadm info --query=all --name=/dev/sde | grep 058f E: ID_VENDOR_ID=058f and udevadm info --query=all --name=/dev/sde | grep 6387 E: ID_MODEL_ID=6387...
Looks like your usb.ids is outdated. No idea what your distro is but this file is normally stored somewhere in /usr/share and you can safely update it from the Internet: http://www.linux-usb.org/usb.ids 058f: Alcor Micro Corp. 6387: Flash Drive
How can I find a drive specified by a ID_VENDOR_ID:ID_MODEL_ID more easily?
1,637,935,119,000
I'm doing debugging for a program that uses UDP socket. The program creates a socket but after that due to some other problems the program gets stuck and I cannot kill it properly. So I close the command shell and the process goes into 'defunct' state. I guess the socket has not been released in this process because n...
I think lsof -iUDP is what you're looking for: $ sudo lsof -iUDP COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME avahi-dae 726 avahi 12u IPv4 21843 0t0 UDP *:mdns avahi-dae 726 avahi 13u IPv6 21844 0t0 UDP *:mdns avahi-dae 726 avahi 14u IPv4 21845 0t0 UDP *:463...
where can I find socket files? ( I want unlink it and remove it..)
1,637,935,119,000
thank you for taking a look at this question. I am writing a simple misc char device with read and write operations. Please keep reading ... The following code prints the required text in TEXT only once when i do cat /dev/mydevice01 This is the code to the read function. static ssize_t my_read(struct file *file, char...
I figured it out myself, I'll leave the answer here to anyone else looking for something similar. static ssize_t my_read(struct file *file, char __user *buff, size_t count, loff_t *ppos) { char *print_str = TEXT; int len = TEXT_LENGTH; return simple_read_from_buffer(buff, count, ppos, print_st...
Writing a simple misc char device driver with read and write operations
1,637,935,119,000
In order to bypass the operating system cache when reading a file, I used O_DIRECT flag when calling open(). In Wikipedia it says that there is no difference between the two. Yet, does defining a HD (or more specifically a partition) as a raw device allows to avoid using a file system? (In this Stack Overflow post a c...
No, accessing the raw device does not need a filesystem. Well, you could say you are using a virtual filesystem /dev but that's only needed to expose the name of the device, after that your i/o is going to the device. But there are many levels of cache/buffering. Filesystem is just one of them, the system will have it...
Does a raw device need a file system?
1,637,935,119,000
Short version: How, from device information such as /devices/pci0000:00/0000:00:13.1/usb6/6-3 and /dev/bus/usb/006/015, I get a path such as /dev/ttyUSB0 or /dev/serial/by-path/pci-0000:00:13.1-usb-0:3:1.0-port0? Detailed version: I have a script which detects that an USB device of a specific type (an Arduino) was plu...
DEVPATH actually exists in sysfs, so you can find all child devices under the directory with that name. If you know for sure there's a single TTY device right under your DEVPATH, echo /sys/devices/pci0000:00/0000:00:13.1/usb6/6-3/*/tty/* will reveal its name (ttyUSBx). However, when your parent device appears and your...
How do I get the `/dev/ttyUSB0` from `/dev/bus/usb/006/015`?
1,637,935,119,000
I have a kernel module that reads usb keyboard input specifically from /dev/input/event2 and /dev/input/event3. On some devices the keyboard doesn't get assigned event2 and event3, it gets assigned /dev/input/event3 and /dev/input/event4 which of course causes the module to miss input. I have pored over the udev rules...
A kernel module that reads events by opening specific files instead of using the kernel API to get events is quite unusual, to put it mildly. The way I would solve this is to use dd or a hexeditor to patch the kernel module to use some other paths instead, them create those paths as symlinks with udev.
Possible to force udev to create specific device event number, or change device event numbers
1,637,935,119,000
I have a cloud server, where a block device (/dev/xvdb1 with filesystem ext3) is attached . I want to create a persistent symlink (/dev/test_link) which should always target to (/dev/xvdb1) using udev rules. OS -> 16.04 ubuntu
You should start with using udevadm monitor when attaching your target device, or udevadm info --name=/dev/xvdb1 --attribute-walk, when already attached, to have a look at how udev sees your device. Than you can create udev rules which match only the special device. Also blkid would be a good starter, where you can s...
Creating Persistant Symbolic Link -Linux
1,637,935,119,000
I am using a proprietary PCI card from Sensoray in my Ubunut 14.04 machine (I intend to upgrade to 18.04 soon). The card comes with the source code for the driver and a Makefile to build and install the driver. The portion of the Makefile relevant to the driver is here: ################################################...
It very much looks like the custom driver does not generate the needed udev events (one would have to look at the driver to confirm this). So the proper way would be to fix the driver to generate the events. In the simplest case, you'd have code similar to this. In a more complicated case, you can have additional udev...
Correct way to fix missing device file in /dev?
1,637,935,119,000
The following code was tested on RedHat 7 using df verison 8.2 and lsblk version 2.23.2. This is important as the lsblk utility has signficantly more output options than the RedHat 6 version (2.17.2) It is rather easy to determine the filesystem that contains a file: df -h /path/to/file | tail -n 1 | awk '{print $1}'...
Looking at the code you've provided, it seems that you want to be able to map a file on a filesystem back to a physical disk on which it resides. There appears to be no consideration of RAID, LVM, or encrypted filesystems. The following code will print the disk device(s) that contain the specified file. For RAID and L...
Programmatically identify block device of filesystem [closed]
1,637,935,119,000
There is already: $ umount -l . But is there a way to unmount silently? This means, in example: If a photo on the unmounted partition is inside of a device, then Linux should preferrably keep it in the cache, the file managers should still display the files and folders, and the cached files should be accessible unti...
Obviously you have found no approach in man umount. So long as devices are accessed through device-mapper (/dev/mapper/ / /dev/dm-*), you can implement surprising re-mappings with dmsetup. Conveniently this includes remove [-f|--force] device_name Removes a device. It will no longer be visible to dm...
U(n)mount sthealthily without notifying applications or clearing cache. (testing purposes)
1,637,935,119,000
I'm experimenting with a software defined device, trying to force it to work with block size = 512 bytes, but it looks like the Linux doesn't want that. I've forced the device to report minimal blocks numbers for the SCSI INQUIRY command: hekto@ubuntu3:~$ sudo sg_inq -p 0xb0 /dev/sde VPD INQUIRY: Block limits page (S...
I suggested to use strace(1) to understand the syscalls(2) done by your fdisk command, i.e. to run as root: strace fdisk -l /dev/sde you have discovered that it uses some ioctl like BLKIOMIN and BLKPBSZGET I don't know how the kernel computes these parameters; perhaps read sd(4).
fdisk with option '-l' - how does it get info about device?
1,637,935,119,000
I'm going to create a bootable USB drive using dd, e.g. dd bs=1M if=myiso.iso of=/dev/sdc But I thought maybe beforehand I should fill the device with zeroes: dd bs=1M if=/dev/zero of=/dev/sdc Is this step necessary? What would be the advantages of filling the device with zeroes before writing, and the repercussions...
When you dd you are writing whatever file system your myiso.iso is to the device. Whatever partition table myiso.iso has (and it would have to have one if the iso is of a bootable image) then that partition table if it is valid is going to represent just the size and contents of myiso.iso. So if you have a 32GB usb s...
Is it necessary to fill a device with zeroes before writing an ISO to it?
1,637,935,119,000
lsdev|wc -l lsdev: 0514-521 Cannot find information in the predefined device configuration database for the customized device pkcs11. 80 If I remove with odmdelete the pkcs11 device(or pseudodevice), then at reboot it is re-created and gives me this error again. I know it is an ssl-related device, but w...
As Jeff Schaller mentions - the cause is probably a missing fileset. To answer your question - the error message is occurring because lsdev is trying - and failing to find anything - with something similar to: odmget -q uniquetype="adapter/pseudo/pkcs11" PdDv If you can get to installp sources I would expect the file...
AIX: lsdev error on pkcs11 device
1,637,935,119,000
What happens when writing to a device driver? For example: echo "some text" > /proc/device_driver I'm guessing that echo has a write-call that somehow invokes the write-function in the driver. What are the "steps" from the echo-function to the drivers write function?
As explained in the The Linux Kernel Module Programming Guide (5.2. Read and Write a /proc File), the kernel calls a function associated with the driver during the driver's initialization to read the data from userspace into the kernel. The echo program does not know anything special about the kernel; the kernel does ...
What happens when writing to a device driver? [duplicate]
1,637,935,119,000
How bytes received on UART device are stored in some serial Linux devices /dev/ttyS? How to read them? What is the procedure? Should that device file be closed, when new data is arriving?
How are received bytes stored? From the user space's point of view, they are not stored at all. How to read them? If you mean only to read them, simply cat /dev/ttyS... will do. Some more information as to how to deal with serial interfaces can be seen in multitude of answers and comments in this page and in the inter...
Linux UART IO File
1,637,935,119,000
I have a device plugged to a CentOS server that changes randomly from /dev/ttyUSB0 to /dev/ttyUSB1 and vice versa. The device I'm trying to connect is this one. How can I debug this?
The device probably gets disconnected while you're using it; check your dmesg output after it changed to /dev/ttyUSB1. When it gets disconnected, the old name /dev/ttyUSB0 is not immediately released (I'm not sure why, maybe because some program still has an open handle to the device file...?). Then the device reconne...
How to debug a device that changes from /dev/ttyUSB0 to /dev/ttyUSB1 at will?
1,637,935,119,000
I would like to connect my iRiver Story HD to my ubuntu 12.04 machine but as I connect it I get this error: Unable to mount Story HD Error mounting: mount: wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper program, or other error In some cases useful info is found...
Ok, the problem was that I was running kernel 3.2.0-35 and I did an upgrade to 3.2.0-36 without a the restart, therefore my kernel was not able to load appropriate modules. Now after restarting it all works fine :)
Problem mounting my iRiver story HD on Ubuntu
1,705,831,660,000
# debugfs -R 'stat <INODE>' /dev/sdaX or # debugfs -R 'stat FILENAME' /dev/sdaX> display file creation time etc. How to run this command if the DEVICE is a NAS mounted e.g. on /MOUNTPOINT/VOL-1 with address 192.168.1.1:/VOL-1 ?
As @Archemar already mentioned, debugfs may not work on a NFS-share. However, you can access the NAS via ssh USERNAME@NAS-IP and execute debugfs and stat locally on your NAS. Depending on its OS and the versions of the respective command you may get the requested information. Unfortunately in my case, the NAS does ...
debugfs on a NAS
1,705,831,660,000
I want to permanently change the device name of a network interface using a portable script. The interface gets the ugly name of enp02fghjkl1. I want to give a pretty name of netface1. I have tried using ip link and nmcli and so many other things to change the device name permanently, and I can change it, but I cannot...
Step 1. The robust solution that worked for me: These four lines that must exist in the network-script file: /etc/sysconfig/network-scripts/ifcfg-somename1 NAME=somename1 DEVICE=somename1 HWADDR=FE:FF:GG:11:00:10 UUID=b623cbaa-ffe2-3456-7890-1a23b465cd67 Caveat: The file cannot have HWADDR and MACADDR at the same ...
How can I permanently change a network device name in CentOS8?
1,705,831,660,000
I have just install brightnessctl to control my screen brightness, but can only run it as root. Doing otherwise prints the suggestion I "get write permission for device files". What is the correct way to do this? I would also like to be able to set volume with amixer without root privileges, which I assume is the same...
Many device access problems can be resolved through group membership changes. You can find the device name by watching sudo journalctl --follow as you connect your device. OR ls -1 /dev >dev.before, connect the device, wait 10 seconds, ls -1 /dev >dev.after;diff dev.{before,after}. Specifically, if ls -l shows that t...
How do I "get write permission for device files" in Linux?
1,705,831,660,000
Im currently working on a remote ubuntu 18.04 server where i need to set up a new raid array (raid1) and then mount it as an available partition to the active filesystem. The first step for me is to understand what going on at the moment. I know that there are 2 hard drives inside the active system that are connected ...
If that is the full lsblk output, then I'm afraid it shows only one physical storage device, nvme0n1. Your nvme0n1 is partitioned into three partitions, each individually set up for software-RAID1 mirroring. That gives you three software-RAID devices: md0, md1 and md2. Each of those corresponds to a single software-RA...
How do i read this raid information output?
1,576,159,762,000
I'm not sure if this is a "unix" question, but I'm in dire straits: I'm running Mint 18.1 Serena 64bit. I'm trying to burn a Windows 10 ISO to a USB drive so that I can boot from it via selecting it in the boot order. I've just downloaded the ISO straight from Microsoft and opened a brand new Sandisk 32gb flash drive....
Turns out Linux has a hard time making an a USB bootable with a Windows ISO. I used woeusb and was able to create the USB correctly.
"No partition active" when booting from a USB
1,576,159,762,000
Under Linux, is there any way to get a yes/no answer to whether or a CD/DVD drive contains a disc which isn't mounted but which can be mounted or written to?
You can use blkid to get the info of a possible mounted block device: blkid It will output something like: /dev/sr0: UUID="2013-05-31-23-04-19-00" LABEL="Blah" TYPE="iso9660" PTTYPE="dos" [root@arch32-vm ~]# echo $? 0 If empty will output 2.
How to determine if an unmounted CD/DVD is in the drive?
1,576,159,762,000
I would like to measure the read times of all mounted USB devices. I found that hdparm is suited for this: $ sudo hdparm -tT /dev/sdb1 However, I would like to attach several devices and iterate over /dev/bus/usb/<bus>/<address>. This gives me an error: $ sudo hdparm -tT /dev/bus/usb/003/002 read(2097152) returned 62...
You could do something like this: for i in $(cat /proc/partitions | grep -v "[0-9]$\|name" | awk '{ print $4 }'); do hdparm -tT /dev/"$i"; done This loops through the /proc/partitions and retrieves the device names before passing those values to hdparm, which is meant to be run on devices, not partitions (e.g. /dev/s...
Measure USB read times for all devices using hdparm
1,576,159,762,000
Is it possible to reduce a mounting lv safely at RHEL6/CentOS6 with ext4 file system? If it is, how can I do that?
As per RedHat documentation you can't reduce mounted filesystem. Check here for detailed document
Lvreduce online on RHEL 6 or centos 6 with ext4 file systems
1,576,159,762,000
I installed Linux Mint 16 32-bit edition on my netbook and a friend's laptop. When we Skype, I can see her live image, and I can see my own live image, so everything looks and sounds right on my end. On her end, she can see neither of our webcam images--just a static avatar for me, and a black box where her webcam ima...
Even more bizarre, the situation "fixed itself" when I came to visit. I started Skype and it just worked normally--webcam detected and could see both parties on her end. Maybe it was a loose cable or something? I still can't understand even that explanation, though--how it could be 'not detected' but functioning by...
Two Linux Mint 16 systems Skyping--one can see both parties on webcam, the other can see neither
1,576,159,762,000
My understanding is that the input to /dev/dsp should be an 8-bit unsigned PCM signal/character stream. yet $ cat a.c #include <stdio.h> #include <math.h> int main(){ uint32_t t; uint8_t out; for(t=0;t<8000;++t){ out=(sin((double)t/8000*2*M_PI)+1)/2*0xff; putchar(out); //fprintf(std...
Waited a long while and looked at it again, everything is working exactly as it should. I replaced the out variable with out=0x80+t%2; to see if I could hear a single bit transition, and it has the exact same volume as the original, but at a higher frequency. So I am literally hearing the transitions in the audio le...
Why does "/dev/dsp" output with a 'Pulse-density modulation' (sort of)?
1,576,159,762,000
Why every device in Linux is a file or folder ? what are the advantages ? and what is the necessity of /dev/sda1 , /dev/sda2 or /dev/sda3 file ? it's size is 0 bytes .and after mounting the hard disk the files are located in /media folder . why /dev/sda1 or such files necessary?
I'll try to answer the question "Why every device in Linux is a file" specifically geared towards data storage (as the question takes them as an example). More in-depth answers regarding the POSIX philosophy may be interesting, too. The base concept here is, that virtually every operation in a computer essentially co...
Why every device in Linux is a file or folder ? what are the advantages? [closed]
1,576,159,762,000
I'm trying to figure out which of these could be a physical USB device: /dev/hda /dev/hda1 /dev/bin /dev/sda /dev/sda2 What's the difference between hda and sda? Between hda and hda1? Which could be USB devices?
/dev/hda1 : No this is a partition /dev/bin/ : No this doesn't exist /dev/sda2 : No , this again is a partition /dev/hdx is used to represenet IDE devices So the correct answer is.... /dev/sda
Which of the following is a Linux representation of a physical USB device?
1,576,159,762,000
I was reading about device files in FreeBSD, but my understanding is not great. To practice, I thought up the following scenario. I suspect that the problem can be solved using device files. Imagine that I am a part time spy and I need to generate some one-time pad. I could go to my secure FreeBSD box and write some /...
Yes, you can treat the device file as a raw device file, and read/write data from/to it using the same APIs used to access normal files. In most cases, you can use dd, or simply cat data to/from the device file. Keep in mind that there are several practical differences between raw devices and real files on a filesyste...
How can I treat my disk like one big file?
1,373,125,672,000
When comparing files, and updating a source code repository, I like to use vimdiff. To copy changes made from one file to the other, I usually use a key sequence like this:- Shift + V (select line) k or j; { or }; Up or down arrow keys (select more lines) y (copy selected lines) Ctrl + w, left/right arrow (move to ot...
do (diff obtain) and dp (diff put) is what you need. Here is a small list of other helpful normal mode commands in this context. ]c - advance to the next block with differences [c - reverse search for the previous block with differences do (diff obtain) - bring changes from the other file t...
What's the recommended way of copying changes with vimdiff?
1,373,125,672,000
I wanted to be clever and compare a remote file to a local file without first manually downloading it. I can get the contents of the remote file by ssh user@remote-host "cat path/file.name" However, piping that to diff ssh user@remote-host "cat path/file.name" | diff path/file.name gives me this: diff: missing oper...
Use - to represent the standard input: ssh user@remote-host "cat path/file.name" | diff path/file.name -
Can't pipe into diff?
1,373,125,672,000
Is it possible to view two files side-by-side in Vim? If so, how can I set up my editor to do this, and is there a way to diff between the two files within Vim? I am aware of the :next and :prev commands, but this is not what I'm after. It would really be nice to view the two files in tandem.
Open the side by side view: Ctrl+w v Change between them: Ctrl+w h or l You can then open another file for comparison in one side by entering a command such as: :e file2.txt Checkout the vimdiff command, part of the vim package, if you want a diff-like view, e.g.: vimdiff file1.txt file2.txt
Comparing two files in Vim
1,373,125,672,000
There are tools providing coloured output: dwdiff -c File1 File2 # word level diff grep --color=always # we all know this guy ... The question is: How to convert their colored output of arbitrary program into coloured html file? Other output formats might be suitable as well (LaTeX would be great). I think html is go...
The answer to this question is probably what you want. It links to these tools, which do the conversion you're looking for: Perl package HTML::FromANSI aha, a C-language program (github repo)
Converting colored output into html
1,373,125,672,000
I am using diff -r a b to recursively compare directories a and b. It often happens though that there are some broken links (the same broken links in both a and b directories and pointing to the same, non-existing targets). diff then outputs error messages for those cases and exits with a non-zero exit code, however ...
For version 3.3 or later of diff, you should use the --no-dereference option, as described in Pete Harlan's answer. Unfortunately, older versions of diff don't support ignoring symlinks: Some files are neither directories nor regular files: they are unusual files like symbolic links, device special files, named pip...
Recursively compare two directories with diff -r without output on broken links
1,373,125,672,000
I've two configuration files, the original from the package manager and a customized one modified by myself. I've added some comments to describe behavior. How can I run diff on the configuration files, skipping the comments? A commented line is defined by: optional leading whitespace (tabs and spaces) hash sign (#) ...
According to Gilles, the -I option only ignores a line if nothing else inside that set matches except for the match of -I. I didn't fully get it until I tested it. The Test Three files are involved in my test: File test1: text File test2: text #comment File test3: changed text #comment The comma...
How to diff files ignoring comments (lines starting with #)?
1,373,125,672,000
I'm connected on a host via ssh and I'd like to compare (let's say with diff) a certain config file against its counterpart on an another host, also accessible via ssh, without having to manually download the remote file first before running the diff.
ssh user@remote_host "cat remote_file.txt" | diff - local_file.txt Source
Run a diff between local and remote files
1,373,125,672,000
I'm trying to use diff to compare two directory trees while ignoring certain sub-directories, but I cannot get it to work. This is what my file structure looks like: temp/ |-- d1/ | |-- f1.txt | `-- ignoreme/ | `-- f2.txt `-- d2/ |-- f1.txt `-- ignoreme/ `-- f2.txt I'm trying to get it to ig...
The -x or --exclude options for GNU diff take a filename globbing pattern that the name of each file and directory will be matched against. If the pattern matches a particular name, that name is excluded from comparison. The pattern is applied to the basename of files and directories, not to pathnames, which means th...
How does "diff --exclude" work?
1,373,125,672,000
I have two big files (6GB each). They are unsorted, with linefeeds (\n) as separators. How can I diff them? It should take under 24h.
The most obvious answer is just to use the diff command and it is probably a good idea to add the --speed-large-files parameter to it. diff --speed-large-files a.file b.file You mention unsorted files so maybe you need to sort the files first sort a.file > a.file.sorted sort b.file > b.file.sorted diff --speed-large-...
Diffing two big text files
1,373,125,672,000
Most applications are smart about using the full width of the terminal available to them. My shell does, screen, vim, etc. However, diff in side-by-side mode (-y), does not. This angers me. It uses 126 character width, which is not even half of my 270 block width terminal. Looking through the man page does not reveal ...
$ alias diff='diff -W $(( $(tput cols) - 2 ))' ought to do it. You'll want to add it to ~/.bashrc as well. The - 2 is mainly paranoia, in case something (embedded double-width Unicode?) expands enough to make the line wrap; if you want, you can just use $ alias diff='diff -W $(tput cols)'
Make diff Use Full Terminal Width in Side-by-Side Mode
1,373,125,672,000
I have the following code that I run on my Terminal. LC_ALL=C && grep -F -f genename2.txt hg38.hgnc.bed > hg38.hgnc.goi.bed This doesn't give me the common lines between the two files. What am I missing there?
Use comm -12 file1 file2 to get common lines in both files. You may also needs your file to be sorted to comm to work as expected. comm -12 <(sort file1) <(sort file2) From man comm: -1 suppress column 1 (lines unique to FILE1) -2 suppress column 2 (lines unique to FILE2) Or using grep command you need to ad...
Common lines between two files [duplicate]
1,373,125,672,000
I have two files which look identical to me (including trailing whitespaces and newlines) but diff still says they differ. Even when I do a diff -y side by side comparison the lines look exactly the same. The output from diff is the whole 2 files. Any idea what's causing it?
Odd .. can you try cmp? You may want to use the '-b' option too. cmp man page - Compare two files byte by byte. This is one of the nice things about Unix/Linux .. so many tools :)
diff reports two files differ, although they are the same!
1,373,125,672,000
How can I use the diff command to compare 2 commands' outputs? Does something like this exist? diff ($cat /etc/passwd) ($cut -f2/etc/passwd)
Use process substitution: diff <(cat /etc/passwd) <(cut -f2 /etc/passwd) <(...) is called process substitution. It converts the output of a command into a file-like object that diff can read from. While process substitution is not POSIX, it is supported by bash, ksh, and zsh.
How do I diff the outputs of two commands? [duplicate]
1,373,125,672,000
Diff is a great tool to display the changes between two files. But how to display the similarities of two text files (while ignoring the differences)? I.e. sample input: a: Foo Bar X Hello World 42 b: Foo Baz Hello World 23 Pseudo output (something like this): @@ 2,3 =Hello World Just sorting both files and using c...
How about using diff, even though you don't want a diff? Try this: diff --unchanged-group-format='@@ %dn,%df %<' --old-group-format='' --new-group-format='' \ --changed-group-format='' a.txt b.txt Here is what I get with your sample data: $ cat a.txt Foo Bar X Hello World 42 $ cat b.txt Foo Baz Hello World 23...
Output the common lines (similarities) of two text files (the opposite of diff)?
1,373,125,672,000
I want to diff two sets of mod_rewrite rules. The set of lines are about 90% identical, but the order is so different that diff basically says they are completely different. How can I see which lines are truly different between two files, regardless of their line number?
sort can be used to get the files into the same order so diff can compare them and identify the differences. If you have process substitution, you can use that and avoid creating new sorted files. diff <(sort file1) <(sort file2)
diff where lines are mostly the same but out of order?
1,373,125,672,000
With diff -r I can do this task, however it takes so long because diff checks file's content. I want something that determine that two files are the same regarding of their size, last modified, etc. But no checking bit by bit the file (for example a video takes sooo long). Is there any other way?
rsync compares only metadata by default. rsync -n -a -i --delete source/ target/ explanation: -n compare but do not actually copy or delete <-- THIS IS IMPORTANT!!1 -a compare all metadata -i print one line of information per file --delete also report files which are in target but not in source note: it is importan...
Compare directories but not content of files
1,373,125,672,000
I would like to create a patch from a specific gcc branch comparing it to the official releases; so when I unpack the tarball from the stable release, I can apply the patch and get the equivalent of what was in that specific branch . It's the first time I need to create a patch, so it's my very first time doing this a...
Yes, this is a good way to create a patch. In short: To create patch for single file your command may look like diff -Naru file_original file_updated > file.patch where -N: treat absent files as empty -a: treat all files as text -r: recursively compare any subdirectories found -u: output NUM (default 3) lines of uni...
Is this a good way to create a patch?