Monday, June 28, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Printing filename before printing lines

Posted: 28 Jun 2021 10:21 AM PDT

Am using the following bash function to print specific ranges lines from files.

Currently I print the filename on each line. But I would really like to have the filename at the beginning of the output for each file, just as is done by head.

print-lines () {      na=$1      nb=$2      dir=$3        find "$dir" \( -name \*.org -o -name \*.texi \)  \       -exec awk -v a="$na" -v b="$nb"             \                   'FNR >= a && FNR <= b {print FILENAME ": " $0}' {} +        }  

I have two files like this

foo:  a  b  c  d  e     bar:  1  2  3  4  5  

Let the command be print-lines 2 4. I want the result to be

==> foo <==    b  c  d    ==> bar <==    2  3  4  

Umderstanding the output of resizefs -d 32

Posted: 28 Jun 2021 09:57 AM PDT

After shrinking an ext4 file system with resize2fs M I mounted it to realize it has only 57% used. So I ran

$ resize2fs -d 32 -M rootfs-2021-06-28.img  resize2fs 1.44.5 (15-Dec-2018)  fs has 9698 inodes, 1 groups required.  fs requires 115683 data blocks.  With 1 group(s), we have 16352 blocks available.  Added 4 extra group(s), blks_needed 115683, data_blocks 147424, last_start 30686  Last group's overhead is 16416  Need 84997 data blocks in last group  Final size of last group is 101413  Estimated blocks needed: 232485  The filesystem is already 232485 (4k) blocks long.  Nothing to do!  

I guess that 115683 data blocks plus 16416 overhead make the 57% of 232485, but I fail to add up those numbers to 232485 blocks. Honestly, I don't understand that calculation. The man page admits

KNOWN BUGS

The minimum size of the filesystem as estimated by resize2fs may be incorrect, especially for filesystems with 1k and 2k blocksizes.

But I have 4k block size.

If resize2fs is the wrong tool for small numbers of blocks, please recomment a different approach to shrink the file system.

How to restore grub after cloning hard disk for a dual boot laptop

Posted: 28 Jun 2021 09:48 AM PDT

I had a dual boot (Windows/Linux Mint) laptop with a 500GB SSD, and replaced the SSD with a 1TB SSD using the procedure described below. When I reboot, it boots directly into Windows, without grub menu. Why did this happen, and how can I restore the grub menu?

This is what I did:

  1. Boot the laptop from a live bootstick (running Linux Mint)
  2. Use dd to copy the whole 500GB SSD to a network drive
  3. Shut down the laptop and replace the SSD by a 1GB SSD.
  4. Boot again with a live bootstick and use dd to copy the file on the network drive back to the SSD.
  5. Reboot without live bootstick

I know that this leaves half of my new SSD unused; I was hoping to fix that later.

dd worked correctly, or at least I can mount all partitions including live partitions from a live bootstick.

Here are some hardware details:

Laptop: Dell XPS 15 (9550)

Old SSD: PM951 NVMe SAMSUNG 512GB

New SSD: Kingston Technology KC2500 M.2 1000 GB PCI Express 3.0 3D TLC NVMe

Pastebin link, from Boot-Repair: http://paste.ubuntu.com/p/DkMGvNXdYq/

In case it matters: Windows fast boot was disabled when I cloned the disk.

Bash variables do not expand inside array if declare is used

Posted: 28 Jun 2021 09:54 AM PDT

Recently I decided to read a bit more on the bash built-ins declare, local, and readonly, which led me to switch from:

local variable_name  variable_name='value'  readonly variable_name  

To:

variable_name='value'  declare -r variable_name  

This change cut down the number of lines written and allowed me to set a few attributes, like telling bash that the value of a variable is an integer, which was nice. However, while creating a function that will serve as an alias for cURL, I noticed that variables inside an array never expand if I use declare, but expand just fine with local and readonly.

Here is an example:

#!/usr/bin/env bash    set -o errexit -o errtrace -o pipefail -o nounset  IFS=$'\n\t'    curl() {      curl_version="$(command curl --version | awk 'NR==1 {print $2}')"    declare -r curl_version      curl_args=(      --user-agent "curl/${curl_version}"      --silent      --fail    )      command curl "${curl_args[@]}" \      "${@}"    }    curl --url 'https://httpbin.org/get'  

Because the variables do not expand for whatever reason, the --user-agent part of the array makes the script exit with an error, since as far as bash knows, this is an unbound variable, and those are not allowed because of set -o nounset.

I have been trying to get this to work for a few days now, so I guess it is time to throw the towel and ask for help. Can anyone point me in the right direction to understand what I am doing wrong, please?

EDIT:

Forgot to mention, but the variable does expand if I declare it in the same line, like declare -r variable_name. The problem is, if I do that, I hit SC2155 from ShellCheck, hence why I am trying to declare after the value is set.

Wine can’t run program - how to fix

Posted: 28 Jun 2021 09:50 AM PDT

Linux Version: Ubuntu Virtual Box VM

I'm trying to use Wine but when I run programs in it I get a wall of errors. I'm not sure how to fix them.

00f:err:service:process_send_command receiving command result timed out  0009:err:dmloader:IDirectMusicLoaderImpl_SetObject : could not attach stream to file L"C:\windows\system32\drivers\gm.dls", make sure it exists  0009:err:winediag:MIDIMAP_drvOpen No software synthesizer midi port found, Midi sound output probably won't work.  0009:err:ole:CoGetClassObject class {87fc0268-9a55-4360-95aa-004a1d9de26c} not registered  0009:err:ole:CoGetClassObject no class object {87fc0268-9a55-4360-95aa-004a1d9de26c} could be created for context 0x1  0009:err:ole:CoGetClassObject class {efe6629c-81f7-4281-bd91-c9d604a95af6} not registered  0009:err:ole:CoGetClassObject no class object {efe6629c-81f7-4281-bd91-c9d604a95af6} could be created for context 0x1  0009:err:ole:CoGetClassObject class {efca3d92-dfd8-4672-a603-7420894bad98} not registered  0009:err:ole:CoGetClassObject no class object {efca3d92-dfd8-4672-a603-7420894bad98} could be created for context 0x1  0009:err:ole:CoGetClassObject class {efe6629c-81f7-4281-bd91-c9d604a95af6} not registered  0009:err:ole:CoGetClassObject no class object {efe6629c-81f7-4281-bd91-c9d604a95af6} could be created for context 0x1  0009:err:ole:CoGetClassObject class {efca3d92-dfd8-4672-a603-7420894bad98} not registered  0009:err:ole:CoGetClassObject no class object {efca3d92-dfd8-4672-a603-7420894bad98} could be created for context 0x1  0009:err:ole:CoGetClassObject class {efe6629c-81f7-4281-bd91-c9d604a95af6} not registered  0009:err:ole:CoGetClassObject no class object {efe6629c-81f7-4281-bd91-c9d604a95af6} could be created for context 0x1  

Can't connect to Battlenet gateways in Starcraft Remastered (both Crossover and Lutris)

Posted: 28 Jun 2021 08:30 AM PDT

I am having trouble running Starcraft Remastered on Linux. I have a dual boot laptop (Windows 10 and Manjaro) that has NVIDIA Optimus, and I use Prime Render Offloading. I am using Linux kernel 5.12.9-1. I recently updated my system with 'pamac -S update'. I usually use Crossover to play Starcraft Remastered on Linux.

However, ever since the last Starcraft Remastered update, I have been unable to connect to any Battle.net gateways on Starcraft Remastered. I don't even see the gateways as that entire section is empty. I can click on the Ok button, and it supposedly connects me to a gateway, but then I can't join any games. I can't see the names of the games or any of the messages in the chat. Again, it's totally empty. I can play in Windows 10, but I much prefer to spend the majority of my time in Linux. I had this problem previously (the second to the last update to Starcraft Remastered), but installing Korean and then uninstalling it worked. This time, that didn't work for me.

Things I have already tried but didn't work:

  • I copied the Starcraft folder as well as the Battle.net folder to the respective folders in Crossover (/home/gameofdronez/.cxoffice/Battle.net_Desktop_App/dosdevices/c:/Program Files (x86)/)

  • I installed Lutris and installed Starcraft Remastered. I also tried various profiles other than Starcraft Remastered (Overwatch, Starcraft II, and Blizzard Battle.net). I even tried various Wine staging versions including 5.0, nfsworld-5.4, 5.7-11, and 6.10-5.

  • I ran 32 bit client instead of 64 bit client, in both Crossover and Lutris.

  • I installed Korean and then uninstalled Korean.

  • Ran the 32 bit client in Windows. Then switched to Linux, uninstalled Starcraft in Lutris, copied the Starcraft folder from my Windows drive to the respective folder in Lutris, opened the Blizzard Battle.net app through Lutris, chose the Starcraft folder to install from (where Lutris stores games), and then launched the 32 bit client through Lutris.

Does anyone have other ideas I can try?

What is a good configuration to use for a multi-station kiosk functionality?

Posted: 28 Jun 2021 08:26 AM PDT

I need to set up a multi-station kiosk functionality for in-wall mounting. Ultimately all the machines, about 12 or so, will talk to a central control computer. I run Arch.

So, it seems I have 3 basic options to do this:

(1) Screen only. This idea is that the stations are just touch screens, not computers. Great for simplicity, but there are some challenges. For example, can you even run 12 touch screens from one computer? What do I do? Fit 12 video cards in a server? Server boards I have seen don't even have that many slots. Another problem is that I am running a monitor cable a long distance. It's hard to find monitor cables over 8 feet and I think there are distance limitations on the signal.

(2) Terminal. So, this idea is to use kind of a dumb terminal as the touch screen. So, my idea here is that I run remote sessions with, say, VNC. However, do computer terminals even exist anymore? This solution would use ethernet which seems more viable than having 100 foot video cables.

(3) Computer. Finally, I could set up each station to be a computer. The problem with this approach is tablet computers have power buttons on their bezel and other stuff like that that obviously we do not want on a wall mounted unit. They assume a laptop-like use case. So, should I go this route and try to find tablets with no power buttons on the front? It also has a potentially more complicated programming problem because I have to negotiate a communication between two different computers OR I can configure the remote to act like a dumb terminal, but in that case I am putting this big, hot computer in the wall and not really using it.

Is there alternative to avant browser in linux to open java applet?

Posted: 28 Jun 2021 08:52 AM PDT

I have an oracle forms website and is based on java and I used to open the web page in windows with Avant browser but I didn't find an alternative for in Linux , I can't open the java applet with firefox I don't know is there any plugin to do that in firefox so my question how can I open the java applet in Linux , is there in firefox a plugin or something to render a java web page or there is an alternative to Avant browser in linux ?

laptop keyboard locks up after closing lid

Posted: 28 Jun 2021 09:42 AM PDT

I have a Dell Latitude 5500 and a Dell Latitude 7550. The 5500 has Debian 10 and KDE, and the 7550 has Ubuntu 20.04 with KDE. In both laptops, if I close the lid, when I open it later the built-in laptop keyboard is completely locked-up and I can't type anything. The trackpad still works though and I am able to click on "switch user". When I do this and get prompted to login again, the laptop keyboard starts working again on both laptops.

I'm not sure if this is an issue, but I have an external 10-port USB hub plugged into the laptops. I have an external keyboard and mouse plugged into them. The external keyboard also locks up, but the external mouse also works.

Why would closing the laptop lid cause the keyboard to lock up? Is there anything I can do to fix it?

dmesg output:

[Sat Jun 26 10:46:51 2021] usb 2-1.4: Disable of device-initiated U1 failed.  [Sat Jun 26 10:46:51 2021] usb 2-1.4: Disable of device-initiated U2 failed.  [Sat Jun 26 10:46:51 2021] usb 2-1.4: reset SuperSpeed Gen 1 USB device number 5 using xhci_hcd  [Sat Jun 26 10:46:52 2021] usb 2-1.4: reset SuperSpeed Gen 1 USB device number 5 using xhci_hcd  [Sat Jun 26 23:15:15 2021] usb 2-1.4: Disable of device-initiated U1 failed.  [Sat Jun 26 23:15:15 2021] usb 2-1.4: Disable of device-initiated U2 failed.  [Sat Jun 26 23:15:15 2021] usb 2-1.4: reset SuperSpeed Gen 1 USB device number 5 using xhci_hcd  [Sat Jun 26 23:15:16 2021] usb 2-1.4: reset SuperSpeed Gen 1 USB device number 5 using xhci_hcd  [Mon Jun 28 01:54:59 2021] usb 2-1.4: Disable of device-initiated U1 failed.  [Mon Jun 28 01:54:59 2021] usb 2-1.4: Disable of device-initiated U2 failed.  [Mon Jun 28 01:54:59 2021] usb 2-1.4: reset SuperSpeed Gen 1 USB device number 5 using xhci_hcd  [Mon Jun 28 01:54:59 2021] usb 2-1.4: reset SuperSpeed Gen 1 USB device number 5 using xhci_hcd  [Mon Jun 28 07:34:57 2021] usb 2-1: USB disconnect, device number 2  [Mon Jun 28 07:34:57 2021] usb 2-1.3: USB disconnect, device number 4  [Mon Jun 28 07:34:57 2021] usb 2-1.4: USB disconnect, device number 5  [Mon Jun 28 07:34:57 2021] usb 1-1: USB disconnect, device number 2  [Mon Jun 28 07:34:57 2021] usb 1-1.2: USB disconnect, device number 4  [Mon Jun 28 07:34:57 2021] usb 1-1.3: USB disconnect, device number 6  [Mon Jun 28 07:34:57 2021] usb 1-1.3.2: USB disconnect, device number 8  [Mon Jun 28 07:34:57 2021] usb 1-1.3.4: USB disconnect, device number 9  [Mon Jun 28 07:34:57 2021] usb 1-1.4: USB disconnect, device number 7  [Mon Jun 28 07:35:06 2021] usb 1-1: new high-speed USB device number 10 using xhci_hcd  [Mon Jun 28 07:35:06 2021] usb 1-1: New USB device found, idVendor=2109, idProduct=2812, bcdDevice=85.80  [Mon Jun 28 07:35:06 2021] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0  [Mon Jun 28 07:35:06 2021] usb 1-1: Product: USB2.0 Hub          [Mon Jun 28 07:35:06 2021] hub 1-1:1.0: USB hub found  [Mon Jun 28 07:35:06 2021] hub 1-1:1.0: 4 ports detected  [Mon Jun 28 07:35:06 2021] usb 2-1: new SuperSpeed Gen 1 USB device number 11 using xhci_hcd  [Mon Jun 28 07:35:06 2021] usb 2-1: New USB device found, idVendor=2109, idProduct=0812, bcdDevice=85.81  [Mon Jun 28 07:35:06 2021] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0  [Mon Jun 28 07:35:06 2021] usb 2-1: Product: USB3.0 Hub          [Mon Jun 28 07:35:06 2021] usb 2-1: Manufacturer: VIA Labs, Inc.   [Mon Jun 28 07:35:06 2021] hub 2-1:1.0: USB hub found  [Mon Jun 28 07:35:06 2021] hub 2-1:1.0: 4 ports detected  [Mon Jun 28 07:35:06 2021] usb 1-1.2: new full-speed USB device number 11 using xhci_hcd  [Mon Jun 28 07:35:07 2021] usb 2-1.3: new SuperSpeed Gen 1 USB device number 12 using xhci_hcd  [Mon Jun 28 07:35:07 2021] usb 2-1.3: New USB device found, idVendor=2109, idProduct=0812, bcdDevice=85.81  [Mon Jun 28 07:35:07 2021] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0  [Mon Jun 28 07:35:07 2021] usb 2-1.3: Product: USB3.0 Hub          [Mon Jun 28 07:35:07 2021] usb 2-1.3: Manufacturer: VIA Labs, Inc.   [Mon Jun 28 07:35:07 2021] hub 2-1.3:1.0: USB hub found  [Mon Jun 28 07:35:07 2021] hub 2-1.3:1.0: 4 ports detected  [Mon Jun 28 07:35:07 2021] usb 1-1.2: New USB device found, idVendor=046d, idProduct=0a8f, bcdDevice= 0.12  [Mon Jun 28 07:35:07 2021] usb 1-1.2: New USB device strings: Mfr=3, Product=1, SerialNumber=0  [Mon Jun 28 07:35:07 2021] usb 1-1.2: Product: Logitech USB Headset  [Mon Jun 28 07:35:07 2021] usb 1-1.2: Manufacturer: Logitech USB Headset  [Mon Jun 28 07:35:07 2021] usb 2-1.4: new SuperSpeed Gen 1 USB device number 13 using xhci_hcd  [Mon Jun 28 07:35:07 2021] usb 2-1.4: New USB device found, idVendor=2109, idProduct=0812, bcdDevice=85.81  [Mon Jun 28 07:35:07 2021] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0  [Mon Jun 28 07:35:07 2021] usb 2-1.4: Product: USB3.0 Hub          [Mon Jun 28 07:35:07 2021] usb 2-1.4: Manufacturer: VIA Labs, Inc.   [Mon Jun 28 07:35:07 2021] hub 2-1.4:1.0: USB hub found  [Mon Jun 28 07:35:07 2021] hub 2-1.4:1.0: 4 ports detected  [Mon Jun 28 07:35:08 2021] input: Logitech USB Headset Logitech USB Headset as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.2/1-1.2:1.3/0003:046D:0A8F.0007/input/input34  [Mon Jun 28 07:35:08 2021] hid-generic 0003:046D:0A8F.0007: input,hidraw1: USB HID v1.11 Device [Logitech USB Headset Logitech USB Headset] on usb-0000:00:14.0-1.2/input3  [Mon Jun 28 07:35:08 2021] usb 1-1.3: new high-speed USB device number 12 using xhci_hcd  [Mon Jun 28 07:35:08 2021] usb 1-1.3: New USB device found, idVendor=2109, idProduct=2812, bcdDevice=85.80  [Mon Jun 28 07:35:08 2021] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0  [Mon Jun 28 07:35:08 2021] usb 1-1.3: Product: USB2.0 Hub          [Mon Jun 28 07:35:08 2021] hub 1-1.3:1.0: USB hub found  [Mon Jun 28 07:35:08 2021] hub 1-1.3:1.0: 4 ports detected  [Mon Jun 28 07:35:08 2021] usb 1-1.4: new high-speed USB device number 13 using xhci_hcd  [Mon Jun 28 07:35:08 2021] usb 1-1.4: New USB device found, idVendor=2109, idProduct=2812, bcdDevice=85.80  [Mon Jun 28 07:35:08 2021] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0  [Mon Jun 28 07:35:08 2021] usb 1-1.4: Product: USB2.0 Hub          [Mon Jun 28 07:35:08 2021] hub 1-1.4:1.0: USB hub found  [Mon Jun 28 07:35:08 2021] hub 1-1.4:1.0: 4 ports detected  [Mon Jun 28 07:35:08 2021] usb 1-1.3.2: new low-speed USB device number 14 using xhci_hcd  [Mon Jun 28 07:35:09 2021] usb 1-1.3.2: New USB device found, idVendor=046d, idProduct=c00e, bcdDevice=11.10  [Mon Jun 28 07:35:09 2021] usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0  [Mon Jun 28 07:35:09 2021] usb 1-1.3.2: Product: USB-PS/2 Optical Mouse  [Mon Jun 28 07:35:09 2021] usb 1-1.3.2: Manufacturer: Logitech  [Mon Jun 28 07:35:09 2021] input: Logitech USB-PS/2 Optical Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3.2/1-1.3.2:1.0/0003:046D:C00E.0008/input/input35  [Mon Jun 28 07:35:09 2021] hid-generic 0003:046D:C00E.0008: input,hidraw2: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:14.0-1.3.2/input0  [Mon Jun 28 07:35:09 2021] usb 1-1.3.4: new low-speed USB device number 15 using xhci_hcd  [Mon Jun 28 07:35:09 2021] usb 1-1.3.4: New USB device found, idVendor=046d, idProduct=c31c, bcdDevice=64.02  [Mon Jun 28 07:35:09 2021] usb 1-1.3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0  [Mon Jun 28 07:35:09 2021] usb 1-1.3.4: Product: USB Keyboard  [Mon Jun 28 07:35:09 2021] usb 1-1.3.4: Manufacturer: Logitech  [Mon Jun 28 07:35:09 2021] input: Logitech USB Keyboard as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4:1.0/0003:046D:C31C.0009/input/input36  [Mon Jun 28 07:35:09 2021] hid-generic 0003:046D:C31C.0009: input,hidraw3: USB HID v1.10 Keyboard [Logitech USB Keyboard] on usb-0000:00:14.0-1.3.4/input0  [Mon Jun 28 07:35:09 2021] input: Logitech USB Keyboard Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4:1.1/0003:046D:C31C.000A/input/input37  [Mon Jun 28 07:35:09 2021] input: Logitech USB Keyboard System Control as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1.3/1-1.3.4/1-1.3.4:1.1/0003:046D:C31C.000A/input/input38  [Mon Jun 28 07:35:09 2021] hid-generic 0003:046D:C31C.000A: input,hiddev0,hidraw4: USB HID v1.10 Device [Logitech USB Keyboard] on usb-0000:00:14.0-1.3.4/input1  [Mon Jun 28 07:35:25 2021] kscreen_backend[162047]: segfault at 10 ip 00007fdb6825df6b sp 00007ffd034223b0 error 4 in KSC_XRandR.so[7fdb68246000+1b000]  [Mon Jun 28 07:35:25 2021] Code: 73 1c e8 58 97 fe ff 49 8b 3c 24 48 8d 73 14 e8 eb 96 fe ff 49 8b 3c 24 48 8d 73 24 e8 2e 93 fe ff e8 e9 b9 fe ff 49 8b 3c 24 <0f> b7 70 10 48 89 c5 e8 d9 92 fe ff 48 89 ef e8 e1 8f fe ff 4c 89  

Output of grep "GRUB_CMDLINE_LINUX_DEFAULT=" /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"  

What is the maximum linux installation size?

Posted: 28 Jun 2021 07:46 AM PDT

Let's say that I install every package avaible for a given linux distribution, how big would it be?

Obviously that size would depend on distribution and package choices, also there's no theorical limit if we sum every software avaible on github plus whatever software be developable.

For this sake let's consider only official packages from main, contribution and extra repositories.

Btw how functional that installation would be?

boot Debian default kernel with lilo results in kernel panic

Posted: 28 Jun 2021 07:26 AM PDT

I have server with Debian 10 installed.

I am using custom kernel, with lilo boot loader. This is my /etc/lilo.conf:

boot=/dev/sda  root=/dev/sda1  map=/boot/map    lba32    prompt  timeout=50    default=linux    image=/boot/vmlinuz-5.10.46  label=Linux  read-only  append="rootfstype=ext4 net.ifnames=0 loglevel=4 console=tty0 2"  

Now I want to boot the default Debian distribution kernel. I have installed the debian kernel image:

apt-get install linux-image-amd64  

and added the entry to /etc/lilo.conf:

image=/boot/vmlinuz-4.19.0-17-amd64  label=4.19.0-17-amd64  initrd=/boot/initrd.img-4.19.0-17-amd64  read-only  append="rootfstype=ext4 net.ifnames=0 loglevel=4 console=tty0 2"  

However, when I boot this kernel, I get kernel panic.

enter image description here

How can I boot default debian distribution kernel with lilo?

How to press a key of a peripheral device (not keyboard) from terminal/python?

Posted: 28 Jun 2021 08:57 AM PDT

I have recently acquired a dial indicator and a keyboard like device that when attached to the dial indicator it types the value of the dial indicator on the computer. It is similar to a keyboard. Here is the store page of the device with more information: https://shop.mitutoyo.eu/web/mitutoyo/en/mitutoyo/01.01.02/USB%20Input%20Tool/index.xhtml

What I am trying to achieve is that instead of my physically pressing the button on this device, I want to write a software that automatically presses the button to get the data every X seconds.

The device is in /dev/input and numbered "event14", I have managed to read the data when I physically press the button. But I could not figure how to let the software digitally presses it and retrieve the information.

Any help or resources are appreciated.

Stop systemd from flooding logs with "Ignoring unknown escape sequence"

Posted: 28 Jun 2021 08:23 AM PDT

This is my service

[Unit]  Description=Cleanup service I made    [Service]  ExecStart=/home/me/scripts/cleanup.sh -d /home/me/scripts/testfolder/ -f ".*/*.[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}.*.log"  User=root  Group=root  

The service runs, but my logs are getting FLOODED with

/lib/systemd/system/cleanup.service:5: Ignoring unknown escape sequences: ".*/*.[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}.*.log"

I have tested the script, I know it works. And I know it works in crontab as well.

What I tried:

  • Tried putting everything in double quotes
  • Changed ExecStart to "/bin/bash -c ""
  • Tried using the systemd-escape chars for directory path (replacing "/" with "-"). However this is for paths not the regex.

That entry is a regex, I cant really change its entry. Do I need to escape in a different way? Or simpler, how do I tell systemd to ignore the problem and stop dumping "Ignoring unknown sequences" into syslog. Just run the script as is?

How to use the shred command the right way?

Posted: 28 Jun 2021 09:43 AM PDT

I got to know about shred yesterday.

I want to know the proper way of removing files with it.


Should I first shred the file and then use rm to remove it?

$shred <file>

$rm <file>

Or should I just use the shred command with the -u option?

$shred -u <file>


Which of these is better? :)

The word monitor in pactl list confused me

Posted: 28 Jun 2021 08:09 AM PDT

I knew the concepts:sink and source in PulseAudio, clients can send audio to "sinks" and receive audio from "sources",So sinks are outputs (audio goes there), sources are inputs (audio comes from there),what is monitor then?

The below text is abstract from pactl list

Sink #11      State: SUSPENDED      Name: alsa_output.pci-0000_09_00.6.analog-stereo      Description: Family 17h (Models 10h-1fh) HD Audio Controller Analog Stereo      Driver: module-alsa-card.c      Sample Specification: s16le 2ch 48000Hz      Channel Map: front-left,front-right      Owner Module: 7      Mute: no      Volume: front-left: 50463 /  77% / -6.81 dB,   front-right: 50463 /  77% / -6.81 dB              balance 0.00      Base Volume: 65536 / 100% / 0.00 dB      Monitor Source: alsa_output.pci-0000_09_00.6.analog-stereo.monitor      Latency: 0 usec, configured 0 usec      Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY       Properties:          alsa.resolution_bits = "16"          device.api = "alsa"          device.class = "sound"          alsa.class = "generic"          alsa.subclass = "generic-mix"          alsa.name = "ALC662 rev3 Analog"          alsa.id = "ALC662 rev3 Analog"          alsa.subdevice = "0"          alsa.subdevice_name = "subdevice #0"          alsa.device = "0"          alsa.card = "1"          alsa.card_name = "HD-Audio Generic"          alsa.long_card_name = "HD-Audio Generic at 0xfccc0000 irq 60"          alsa.driver_name = "snd_hda_intel"          device.bus_path = "pci-0000:09:00.6"          sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:09:00.6/sound/card1"          device.bus = "pci"          device.vendor.id = "1022"          device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"          device.product.id = "15e3"          device.product.name = "Family 17h (Models 10h-1fh) HD Audio Controller"          device.string = "front:1"          device.buffering.buffer_size = "352768"          device.buffering.fragment_size = "176384"          device.access_mode = "mmap+timer"          device.profile.name = "analog-stereo"          device.profile.description = "Analog Stereo"          device.description = "Family 17h (Models 10h-1fh) HD Audio Controller Analog Stereo"          alsa.mixer_name = "Realtek ALC662 rev3"          alsa.components = "HDA:10ec0662,10ec0000,00100300"          module-udev-detect.discovered = "1"          device.icon_name = "audio-card-pci"      Ports:          analog-output-lineout: Line Out (priority: 9000, available)          analog-output-headphones: Headphones (priority: 9900, not available)      Active Port: analog-output-lineout      Formats:          pcm    Source #15      State: SUSPENDED      Name: alsa_output.pci-0000_09_00.6.analog-stereo.monitor      Description: Monitor of Family 17h (Models 10h-1fh) HD Audio Controller Analog Stereo      Driver: module-alsa-card.c      Sample Specification: s16le 2ch 48000Hz      Channel Map: front-left,front-right      Owner Module: 7      Mute: no      Volume: front-left: 27537 /  42% / -22.59 dB,   front-right: 27537 /  42% / -22.59 dB              balance 0.00      Base Volume: 65536 / 100% / 0.00 dB      Monitor of Sink: alsa_output.pci-0000_09_00.6.analog-stereo      Latency: 0 usec, configured 0 usec      Flags: DECIBEL_VOLUME LATENCY       Properties:          device.description = "Monitor of Family 17h (Models 10h-1fh) HD Audio Controller Analog Stereo"          device.class = "monitor"          alsa.card = "1"          alsa.card_name = "HD-Audio Generic"          alsa.long_card_name = "HD-Audio Generic at 0xfccc0000 irq 60"          alsa.driver_name = "snd_hda_intel"          device.bus_path = "pci-0000:09:00.6"          sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:09:00.6/sound/card1"          device.bus = "pci"          device.vendor.id = "1022"          device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"          device.product.id = "15e3"          device.product.name = "Family 17h (Models 10h-1fh) HD Audio Controller"          device.string = "1"          module-udev-detect.discovered = "1"          device.icon_name = "audio-card-pci"      Formats:          pcm  

Get Monitor Source: alsa_output.pci-0000_09_00.6.analog-stereo.monitor from Sink #11.
Get Monitor of Sink: alsa_output.pci-0000_09_00.6.analog-stereo from Source #15.

1.Why Monitor of Sink is a kind of source ,instead Monitor Source is a kind of sink?
2.Can i write Monitor Source as Monitor of Source,vice verse ,Can i write Monitor of Sink as Monitor Sink?

Using the wrong libstdc++ file

Posted: 28 Jun 2021 08:18 AM PDT

I have downloaded the package luxafor-cli and I keep getting this error when trying to run it.

Error: /snap/core/current/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/user/.npm-packages/lib/node_modules/@fatso83/luxafor-cli/node_modules/usb/build/Release/usb_bindings.node)  

It seems as if it looks for the GLIBCXX library in snapcore, it only has up to 3.4.21. When i try and run

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX   

I have up til .29. So my guess is I have to get the package to look for the library there instead. How do I manage that?

Bash: writing to global variables from a subshell

Posted: 28 Jun 2021 08:51 AM PDT

I'm trying to move some getopts logic to a funciton, so I can use it more than once, giving users more flexibility in the order in which they specify arguments:

print-usage() {  echo "myssh [options] <host> [options] [-- ssh-options...]" >&2  exit 1  }    extra_args=()    parse-args() {    while getopts ":hvV:" opt; do      case ${opt} in        (h)  print-usage ;;        (v)  extra_args+=('-L 5900:localhost:5900')    ;;        (V)  extra_args+=("-L $OPTARG:localhost:5900") ;;        (\?) echo "Invalid option: -$OPTARG" >&2       ;;        (:)  echo "Invalid option: -$OPTARG requires an argument" >&2 ;;      esac    done    echo $((OPTIND -1))  }    shift $(parse-args $@)    host=$1  shift    shift $(parse-args $@)    ssh $host $extra_args $@    

My problem is that parse-args() { ... extra_args+=(...) } doesn't affect the global variable extra_args. I get that a sub-shell can't write to parent-scoped variables, and we should normally use stdout, but I'm already using stdout for the shift integer.

How would one normally address this problem?

ulimit: what is the maximum core file size value

Posted: 28 Jun 2021 09:45 AM PDT

I want to set unlimited core file size with ulimit inside docker. I can't do this by

ulimit -c unlimited  

because parameters for docker are set by framework, that doesn't accept unlimited parameter. So I need to set it by passing direct value. I found that 9223372036854775807 is the max value, but when I set it, I get:

ulimit: 9223372036854775807: limit out of range  

How can I find max value which I can pass to ulimit -c ?

Remove old kernels on CentOS 8

Posted: 28 Jun 2021 09:44 AM PDT

On CentOS 7.X I use the following command to clean up unused old kernel:

package-cleanup --oldkernels --count=1  

But it no longer works on CentOS 8.X, does anyone know the correct command?

SMART test failed, but all attributes is OK

Posted: 28 Jun 2021 09:48 AM PDT

I've been experiencing problems with my HDD, so I ran a self-test on it. As you can see, the test failed, but all individual attributes are OK. How do I know what the problem is with the drive?

1

Boot Ubuntu ISO under qemu

Posted: 28 Jun 2021 09:44 AM PDT

Probably a very simple issue: I'm trying to boot the offical Ubuntu 20.04.2 ISO image under qemu. For this purpose I've first created a disk image:

qemu-img create ubuntu-20.04.2.0.img 10G  

And then tried:

qemu-system-x86_64 -enable-kvm -hda ubuntu-20.04.2.0.img -cdrom ubuntu-20.04.2.0-desktop-amd64.iso -boot d -m 512  

Which results in a kernel panic because "no working init" was found. I've encountered this issue before when trying to boot an image for the wrong architecture but I don't see what the problem is here.

I3 can't properly use the clipboard

Posted: 28 Jun 2021 10:34 AM PDT

Alright this is a problem I've been facing for months. Im not sure if this is a problem with i3 or urxvt. I can't get the clipboard to work properly. I can copy text from my browser and paste it on the terminal but NOT the other way around. For some reason hitting Ctrl-Shift-C allows me to copy text between terminals but not to my browser. I installed clipster and saw that when I copy something on Firefox it goes to the CLIPBOARD clipboard whereas when I copy something from the terminal it goes into the PRIMARY clipboard. I also tried tosynchronize them by adding the following to my xinitrc file:

autocutsel -fork -selection CLIPBOARD  autocutsel -fork -selection PRIMARY  

but it didn't help, what gives? How do I fix this?

Files holder application like dropover and yoink for Mac

Posted: 28 Jun 2021 08:42 AM PDT

I've recently switched back from macOS to Linux Mint. The only thing I miss about Mac is having a utility that could hold my files for copying and pasting while I switch between the desktops.

Yoink worked in a way that when you drag a file to a configured area (say left edge) a mini window appears. You can drag your files there and the window stays on that edge even if you are switching between the desktops. You can easily then pick the files and drop where you actually want those.

This helped me in a lot of cases like:

  • Drag the file from the browser and the drop in another tab (normally you'd have to first download the file)
  • easy copy-pasting files between windows or desktops.

I am starving for a Linux alternative.

Linux Mint 19.1->19.2 upgrade broke Cinnamon - driver issue?

Posted: 28 Jun 2021 10:06 AM PDT

Updating broke Cinnamon for me. I was on 19.1 Tessa, Cinnamon edition, and updated to 19.2 through the Update Manager. Now when I boot I get the message "Cinnamon just crashed. You are currently running in Fallback Mode" and I have the option of restarting Cinnamon, but it immediately crashes again. I've tried with kernel versions 5.0.0.23, 5.0.0-20, and 4.15.0-55. My graphics card is an RX480.

I tried running cinammon --replace in the terminal. The output can be found here.

I tried booting into recovery mode then selecting the option to continue into a normal boot. I then got a message saying that "Your system is currently running without video hardware acceleration." However, Cinnamon is working fine. This is Mint 19.2, Cinnamon version 4.2.3, and kernel version 5.0.0-23-generic.

This is the output of running cinnamon --replace on the working Cinnamon desktop I get from booting through recovery mode. Conspicuously, the crashing version has the line cinnamon: ../src/gallium/drivers/radeonsi/si_state_viewport.c:239: si_emit_guardband: Assertion `left <= -1 && top <= -1 && right >= 1 && bottom >= 1' failed. where the working version is starting to add systrays.

Finally, I tried booting normally but selecting Cinnamon with software rendering at the login screen. It worked fine. Then I tried to restart Cinnamon and got this output with the same error message with the driver. It definitely seems like a driver issue, but I don't know how to resolve it.

Edit: this is the subject of a bug discussion on Github. It seems to have to do with the position of monitors in a multi-monitor setup.

sub-shell inside sed

Posted: 28 Jun 2021 10:17 AM PDT

I can append to the start of a file fine with:

sed -i '1s/^/word\n/' file  

I'm reading that if I use double quotes I can expand variables, so I try:

sed -i "1s/^/$(printenv)\n/" file  

I end up getting back:

sed: -e expression #1, char 15: unterminated `s' command  

What is happening here. Is it related to the contents of the variable or something else?

progress command doesn't show mv progress

Posted: 28 Jun 2021 09:08 AM PDT

I installed progress by brew install progress

% progress -v  progress version 0.13  

And while I'm using mv command I used progress -w, but it failed with wrong permission error.

progress -w  No command currently running: cp, mv, dd, tar, cat, rsync, grep, fgrep, egrep, cut, sort, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, adb, gzip, gunzip, bzip2, bunzip2, xz, unxz, lzma, unlzma, zcat, bzcat, lzcat, or wrong permissions.  

Should I change permission somewhere to use progress? What am I doing wrong?

I'm using macOS Sierra version 10.12.6.

More Info

I executed progress -w just after mv command that moved about 30GB data from internal SSD to external HDD. And I checked after the error message of progress, the mv command was still working.

% which mv  /usr/local/opt/coreutils/libexec/gnubin/mv  % mv --version  mv (GNU coreutils) 8.27  Copyright (C) 2017 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.  This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.    Written by Mike Parker, David MacKenzie, and Jim Meyering.  

Kernel Panic on CentOS - Google Compute Engine Instance

Posted: 28 Jun 2021 08:02 AM PDT

I'm getting a kernel panic error in a CentOS instance of Google Compute Engine. I'm able to see the error and already figure out how to solve it, but I can't get into the GRUB menu trough the serial console.

dracut: Mounted root filesystem /dev/sda1  dracut: Loading SELinux policy  type=1404 audit(1479929075.614:2): enforcing=1 old_enforcing=0 auid=4294967295 ses=4294967295  dracut: SELinux: Could not open policy file <= /etc/selinux/targeted/policy/policy.24: No such file or directory   /sbin/load_policy: Can't load policy and enforcing mode requested: No such file or directory  dracut Warning: Initial SELinux policy load failed.  dracut FATAL: Initial SELinux policy load failed. Machine in enforcing mode. To disable selinux, add selinux=0 t  o the kernel command line.  dracut Warning:   dracut Warning: Boot has failed. To debug this issue add "rdshell" to the kernel command line.  dracut Warning: Signal caught!  dracut Warning: Boot has failed. To debug this issue add "rdshell" to the kernel command line.  Kernel panic - not syncing: Attempted to kill init!  Pid: 1, comm: init Not tainted 2.6.32-642.11.1.el6.x86_64 #1  Call Trace:       [<ffffffff815482b1>] ? panic+0xa7/0x179       [<ffffffff8112aea0>] ? perf_event_exit_task+0xc0/0x340       [<ffffffff81081f97>] ? do_exit+0x867/0x870       [<ffffffff8119b735>] ? fput+0x25/0x30       [<ffffffff81081ff8>] ? do_group_exit+0x58/0xd0       [<ffffffff81082087>] ? sys_exit_group+0x17/0x20       [<ffffffff8100b0d2>] ? system_call_fastpath+0x16/0x1b  

The CentOS version is 6.7 and this happened after a yum update. I'm just trying to get into GRUBs menu to append "selinux=0" to boot into Permissive mode, but it seems that it's not possible through the serial console. I would appreciate any help.

bash: test if $WORD is in set

Posted: 28 Jun 2021 10:36 AM PDT

I am looking for a construct in bash, to decide if a variable $WORD is one of defined words. I need something like this:

if "$WORD" in dog cat horse ; then       echo yes  else      echo no  fi  

does bash have such construct? If not, what would be the closest?

What is AT&T’s Link Editor Command Language?

Posted: 28 Jun 2021 07:41 AM PDT

The man page for ld makes reference to AT&T's Link Editor Command Language, however a Google search does not offer a satisfactory explanation as to what AT&T's Link Editor Command Language is or was, other than pointing to said man pages, whereas I expect a Wikipedia page coming up in the first five results.

It seems like there is a vital piece of computing history missing here. Does anyone have some reference or historical documentation on this language? Something we can put in Wikipedia to preserve for posterity?

No comments:

Post a Comment