Tuesday, November 2, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Command Line ZIP - How to ZIP an entire folder, but dodge the other zips present?

Posted: 02 Nov 2021 10:25 AM PDT

I've been tasked to update a few of our sites and so, before doing so, I have to zip the public_html folder so I have a backup.

Problem is, public_html has a bunch of other ZIPs that are older backups that I don't want to delete in case my backup fails or for some other reason, we need to go back 2-3 backups.

But, since they are there and get caught in every backup, the backup file grows and grows because it contains basically every single previous backup within it.

So is there a way to tweak the zip command line call so it gets all files, except any .zip or .gzip file it finds?

How to check if process with pid X is the one you expect

Posted: 02 Nov 2021 09:51 AM PDT

In our application, we start some background processes. The pid of these processes is saved to a file.

pids values are re-used when the maximum is reached or when the system is rebooted.

How can I reliably check that the process with pid X is still the same process for which X was stored.

I've read https://serverfault.com/questions/366474/whats-a-proper-way-of-checking-if-a-pid-is-running and https://stackoverflow.com/questions/3043978/how-to-check-if-a-process-id-pid-exists but these solutions never check if the process that has pid X is the still same process as the one for which the pid was stored.

I need this info to reliably

  • check the process is still running
  • kill the process without risking to kill a different process that now has pid X

related https://serverfault.com/questions/279178/what-is-the-range-of-a-pid-on-linux-and-solaris

I will post my current solution. I'd like to know if it's a sensible approach and if there are better ways to do this.

How to prevent zsh from storing "up" commands to history?

Posted: 02 Nov 2021 09:35 AM PDT

For example, say I do a command like appbuild by hitting up arrow ten times in a row. Now, if I want to go back to the last unique command before that, I have to hit up ten times in a row.

Any way to change this preference? IIRC Bash did not do this.

Grub navigation problems

Posted: 02 Nov 2021 09:22 AM PDT

My problem is, that I can't navigate in my bootloader. When I try to select another option it automatically jumps back to the first option. It looks like as if someone's constantly pressing the arrow up and arrow left key. Even when my keyboards not attached to the computer.

This problem persists when I change the boot order so it boots up windows first. The same problem's not appearing on my debian, atleast I haven't experienced it yet.

Here are two videos I recorded to explain the problem better: https://imgur.com/a/0tkTJFV

Thank you in advance.

Touchpad Gestures not working in Pop OS

Posted: 02 Nov 2021 09:16 AM PDT

I tried demo mode of pop os 21.04 in my Dell Inspiron 5559 laptop. Everything working fine except touchpad Gestures.

Is there any reason? If I install pop os will gestures work? Is there any way to make sure it before installing?

I'm just a beginner to Linux

Logical volume not found in volume group

Posted: 02 Nov 2021 10:08 AM PDT

I need to increase the size of centos_s0106ac9e17b4312300-root

I am trying sudo lvextend -L +10G /dev/mapper/centos_s0106ac9e17b4312300-rootJESSE

but getting Logical volume rootJESSE not found in volume group centos_s0106ac9e17b4312300.

sda                                   8:0    0 447.1G  0 disk    ├─sda1                                8:1    0   200M  0 part    ├─sda2                                8:2    0     1G  0 part    └─sda3                                8:3    0 445.9G  0 part      ├─centos_s0106ac9e17b4312300-swap 253:8    0  31.4G  0 lvm       ├─centos_s0106ac9e17b4312300-home 253:9    0 364.5G  0 lvm       └─centos_s0106ac9e17b4312300-root 253:10   0    50G  0 lvm   /mnt/centos_s0106ac9e17b4312300-rootJESSE    [liveuser@localhost-live /]$ sudo vgdisplay    --- Volume group ---    VG Name               centos00    System ID                 Format                lvm2    Metadata Areas        1    Metadata Sequence No  4    VG Access             read/write    VG Status             resizable    MAX LV                0    Cur LV                3    Open LV               0    Max PV                0    Cur PV                1    Act PV                1    VG Size               930.31 GiB    PE Size               4.00 MiB    Total PE              238160    Alloc PE / Size       238159 / <930.31 GiB    Free  PE / Size       1 / 4.00 MiB    VG UUID               nfnzo3-i6kf-w6Fi-qSgD-UQcj-EAL3-0qrmXK         --- Volume group ---    VG Name               centos_s0106ac9e17b43123    System ID                 Format                lvm2    Metadata Areas        1    Metadata Sequence No  4    VG Access             read/write    VG Status             resizable    MAX LV                0    Cur LV                3    Open LV               0    Max PV                0    Cur PV                1    Act PV                1    VG Size               <485.09 GiB    PE Size               4.00 MiB    Total PE              124182    Alloc PE / Size       124181 / 485.08 GiB    Free  PE / Size       1 / 4.00 MiB    VG UUID               VyxNSf-Ke6x-wVkq-t4Up-UyjQ-Jron-yWLflf         --- Volume group ---    VG Name               centos_s0106ac9e17b4312300    System ID                 Format                lvm2    Metadata Areas        1    Metadata Sequence No  4    VG Access             read/write    VG Status             resizable    MAX LV                0    Cur LV                3    Open LV               1    Max PV                0    Cur PV                1    Act PV                1    VG Size               445.93 GiB    PE Size               4.00 MiB    Total PE              114159    Alloc PE / Size       114158 / <445.93 GiB    Free  PE / Size       1 / 4.00 MiB    VG UUID               Swvxel-gX0y-q1xF-ZMeU-irH8-9KCu-RHpBPp         --- Volume group ---    VG Name               nvmeVg    System ID                 Format                lvm2    Metadata Areas        7    Metadata Sequence No  11    VG Access             read/write    VG Status             resizable    MAX LV                0    Cur LV                3    Open LV               0    Max PV                0    Cur PV                7    Act PV                7    VG Size               <325.94 GiB    PE Size               4.00 MiB    Total PE              83440    Alloc PE / Size       83200 / 325.00 GiB    Free  PE / Size       240 / 960.00 MiB    VG UUID               sM2ZQz-ke7H-543U-EylK-pO25-0G6S-jhV57f  

confused about awk scripting

Posted: 02 Nov 2021 09:48 AM PDT

directions state your script file will be tested on our system with the following command:

awk -f ./awk4.awk input.csv  

Write an awk script that will accept the following file and output the name and grade fields

task1

apparently, I created a bash script and it needs to be an awk script that will run with awk -f from the command line. below is my code. is there an easy way to convert my bash scripts into awk scripts without having to redo everything? really confused about the directions.

#!/usr/bin/awk -f  ##comment create an awk script that will accept the following file and output the name and grade fields  ##comment specify the delimiter as ","  awk -F, '    /./ {  ##comment print the name and grade, which is first two fields  print $1" "$2    }' $1  

How to expand a variable on console/shell prompt

Posted: 02 Nov 2021 08:52 AM PDT

How do we expand a variable, ie. a '$' preceded name, to its value content on bash readline ?

How to flip linux console?

Posted: 02 Nov 2021 09:40 AM PDT

I want to flip the image output of the linux console when not in XServer.

I saw an issue that is similar to this here:

https://askubuntu.com/questions/237963/how-do-i-rotate-my-display-when-not-using-an-x-server

The thing that changes is that I don't want to rotate the output, I need to actually vertically flip it.

If it is possible I would also like to apply it at every boot.

sed + delete all lines between two matching patterns and instead of them add a word as x=yes

Posted: 02 Nov 2021 08:09 AM PDT

here example of script

when I did successfully deletion between two matching patterns ( the first is cat <<EOF | more and the second is read x )

the script

#!/bin/sh    cat <<EOF | more    .  .  .  .      EOF    echo -n "Do you agree with the License? [yes/no] "  read x    .  .  .  

my sed command

sed -i '/^cat <<EOF | more/,/^\read x/d' test.sh  

now I want to add to sed ability to add the parameter x=yes insted of all deletion lines as above

is it possible to add this ability in my sed command ?

example of expected results

#!/bin/sh    x=yes  

Can't resize partition using gparted from Live CD

Posted: 02 Nov 2021 09:22 AM PDT

When I go to resize my ext4 main partition of Linux to free up some space as unallocated, after clicking "Apply", gparted shows me an error.

I am using latest version of gparted live and installed OS is Bodhi Linux.

Here is the error Image given(https://www.dropbox.com/s/rxp8ldzupbbf01w/IMG20211102212641.jpg?dl=0)

Main image of gparted(https://www.dropbox.com/s/utdo5aejtbesyxj/IMG20211102212847.jpg?dl=0)

How to duplicate line and search and replace on second line with sed?

Posted: 02 Nov 2021 08:06 AM PDT

I'm willing to do the following :

before:

éva  test  frédéric  

After:

éva  eva  test  frédéric  frederic  

For now I can duplicate the lines containing the 'é' caracter but i'm not sure how to search and replace in the capture group.

Here is what I've got so far :

echo 'éva\ntest\nfrédéric' | sed 's/\(.*é.*\)/&\n\1/'  

Can I do that with sed ? If not I'll be glad to work with awk...

Removing leading `# ` with awk

Posted: 02 Nov 2021 08:17 AM PDT

I am using the following bash function to capture lines between ## mode: rec and ## # End of rec, but am not able to remove the leading # on the result.

capture ()  {   local efile="$1"     local begorg endorg    begorg='^[[:space:]]*## mode: org$'   endorg='^[[:space:]]*## # End of org$'   awk -v bego="$begorg" -v endo="$endorg" \     '$0 ~ bego { flag=1; next }       $0 ~ endo { flag=0; }       flag { sub(/^[[:space:]]*#[[:space:]]*/,""); print }' "$efile"  }  

This is the input

file: test.sh

## mode: org  ## * Using case statement  ## # End of org  case $arg in   ("V")     echo "Author"     ;;   (*)     ## mode: org     ## ** Silent Error Reporting Mode (SERM) in getopts     ## *** Detects warnings without printing built-in messages.     ## *** Enabled by colon {:} as first character in shortopts.     ## # End of org     break     ;;  esac     ## mode: org   ## HDG: Handling function argument parsing with getopts   ## Rmk: No call to {shift} is required with getopts   ## Rmk: No hyphen {-} required when searching option names   ## + Case patterns do not start with option hyphen {-} because   ## + getopts strips off the hyphen and makes the value of {arg}   ## + to be just the option letter.   ## Rmk: Separating options from non-options with --   ## + {getopts} stops processing options when the argument is not   ## + defined as an option in {shortopts}; or if the argument is   ## + "--", which explicitly terminates the list of options.   ## Rmk: Using -- as value to an option   ## + An option value can be -- without it being considered a   ## + separator between options and non-options.   ## + Example { edvart-getopts -g "--" }.   ## Rmk: Explicitly testing for {--}   ## + There is no need to test for {--} when using {getopts}.   ## # End of org  

But I am getting this result

# * Using case statement    # ** Silent Error Reporting Mode (SERM) in getopts  # *** Detects warnings without printing built-in messages.  # *** Enabled by colon {:} as first character in shortopts.    # HDG: Handling function argument parsing with getopts  # Rmk: No call to {shift} is required with getopts  # Rmk: No hyphen {-} required when searching option names  # + Case patterns do not start with option hyphen {-} because  # + getopts strips off the hyphen and makes the value of {arg}  # + to be just the option letter.  # Rmk: Separating options from non-options with --  # + {getopts} stops processing options when the argument is not  # + defined as an option in {shortopts}; or if the argument is  # + "--", which explicitly terminates the list of options.  # Rmk: Using -- as value to an option  # + An option value can be -- without it being considered a  # + separator between options and non-options.  # + Example { edvart-getopts -g "--" }.  # Rmk: Explicitly testing for {--}  # + There is no need to test for {--} when using {getopts}.  # HDG: Silent Error Reporting Mode (SERM) in getopts  # Rmk: Detects warnings without printing built-in messages.  # Rmk: Enabled by colon {:} as first character in shortopts.  

The expected output is

* Using case statement     ** Silent Error Reporting Mode (SERM) in getopts  *** Detects warnings without printing built-in messages.  *** Enabled by colon {:} as first character in shortopts.    HDG: Handling function argument parsing with getopts  Rmk: No call to {shift} is required with getopts  Rmk: No hyphen {-} required when searching option names  + Case patterns do not start with option hyphen {-} because  + getopts strips off the hyphen and makes the value of {arg}  + to be just the option letter.  Rmk: Separating options from non-options with --  + {getopts} stops processing options when the argument is not  + defined as an option in {shortopts}; or if the argument is  + "--", which explicitly terminates the list of options.  # Rmk: Using -- as value to an option  + An option value can be -- without it being considered a  + separator between options and non-options.  + Example { edvart-getopts -g "--" }.  Rmk: Explicitly testing for {--}  + There is no need to test for {--} when using {getopts}.  HDG: Silent Error Reporting Mode (SERM) in getopts  Rmk: Detects warnings without printing built-in messages.  Rmk: Enabled by colon {:} as first character in shortopts.  

Check dd's progress without USR1?

Posted: 02 Nov 2021 09:13 AM PDT

I'm on a Linux busybox 1.27 only system so no output=progress available, no busybox's own implementation of pv which is pipe_progress nor pv itself.

I have two questions. The first is based on https://www.linux.com/training-tutorials/show-progress-when-using-dd/. It says that by sending the USR1 signal to dd it "pauses" the process and dd after printing its current status will continue with the job it was doing. I'm trying to do some benchmark tests with dd so I would like to have minimal impact on the dd operation. I want to get an output of the current operation every second because the data that's passing through dd is fluctuating and it is important to me to recognize when the transfer rate drops.

First question: Is it true that 'dd' "pauses" every time it receives a USR1 signal?

If dd pauses every second then I'll be adding hours to the operation when tens of gigabytes are being transferred.

Second question: Assuming yes as an answer to the first question, I would like to know if it's possible to get dd to print its current status without sending any signal to the process, maybe some kind of redirection for STDOUT (like 2>&1)?

What I'm referring to is:

# bs with 1Mib so I can have more control on the test.  dd if=/dev/zero of=/dev/null bs=1048576 count=1024    # Printing current operation status.  sudo kill -USR1 $dd_pid   

How to debug a loop in systemd-shutdown / initrd ? (Arch Linux)

Posted: 02 Nov 2021 08:41 AM PDT

I've recently installed Arch Linux to a virtual disk, under a custom configuration for root on ZFS. This was in using some scripting I've put together for managing a multiboot configuration, with separate boot and root pools, each to be used both for Arch and FreeBSD. Presently, the ZFS pool configuration was created with FreeBSD under a VM. The Arch Linux installation was then created from another VM, where Arch was installed on an Ext4 partition. With Arch installed on the boot/root ZFS configuration and after some configuration for Grub, the Arch installation on ZFS now boots successfully.

Presently, the virtual disk with the ZFS pools on it is running under a separate virtual machine. Arch Linux is the only OS installed on that machine's virtual disk, at this time. It boots successfully now, with a corresponding Grub2 configuration. However, I'm noticing a loop during shutdown.

[ 1561.324253] systemd-shutdown[1]: Sending SIGKILL to remaining processes...  [ 1561.336930] systemd-shutdown[1]: Unmounting file systems.  [ 1561.341650] [563]: Remounting '/var' read-only in with options 'noxattr,noacl'.  [ 1561.783555] [564]: Unmounting '/var'.  [ 1561.790194] [565]: Remounting '/usr' read-only in with options 'noxattr,noacl'.  [ 1561.796853] [566]: Remounting '/' read-only in with options 'noxattr,noacl'.  [ 1561.803420] systemd-shutdown[1]: All filesystems unmounted.  [ 1561.809423] systemd-shutdown[1]: Deactivating swaps.  [ 1561.813672] systemd-shutdown[1]: All swaps deactivated.  [ 1561.818688] systemd-shutdown[1]: Detaching loop devices.  [ 1561.824354] systemd-shutdown[1]: All loop devices detached.  [ 1561.829085] systemd-shutdown[1]: Stopping MD devices.  [ 1561.833346] systemd-shutdown[1]: All MD devices stopped.  [ 1561.837982] systemd-shutdown[1]: Detaching DM devices.  [ 1561.842299] systemd-shutdown[1]: All DM devices detached.  [ 1561.847501] systemd-shutdown[1]: All filesystems, swaps, loop devices, MD devices and DM devices detached.  [ 1561.856852] systemd-shutdown[1]: Successfully changed into root pivot.  [ 1561.863478] systemd-shutdown[1]: Returning to initrd...  [ 1562.306958] shutdown[1]: Syncing filesystems and block devices.  [ 1562.311377] shutdown[1]: Sending SIGTERM to remaining processes...  [ 1562.316903] shutdown[1]: Sending SIGKILL to remaining processes...  [ 1562.329374] shutdown[1]: Unmounting file systems.  [ 1562.334319] sd-remou[569]: Remounting '/' read-only in with options 'noxattr,noacl'.  [ 1562.346902] sd-umoun[570]: Unmounting '/oldroot/sys/kernel/config'.  [ 1562.354595] sd-umoun[571]: Unmounting '/oldroot/sys/fs/fuse/connections'.  [ 1562.361525] sd-umoun[572]: Unmounting '/oldroot/sys/kernel/tracing'.  [ 1562.368232] sd-umoun[573]: Unmounting '/oldroot/sys/kernel/debug'.  [ 1562.373715] sd-umoun[574]: Unmounting '/oldroot/dev/mqueue'.  [ 1562.380105] sd-umoun[575]: Unmounting '/oldroot/dev/hugepages'.  [ 1562.386843] sd-umoun[576]: Unmounting '/oldroot/sys/fs/bpf'.  [ 1562.391984] sd-umoun[577]: Unmounting '/oldroot/sys/fs/pstore'.  [ 1562.397417] sd-umoun[578]: Unmounting '/oldroot/sys/fs/cgroup'.  [ 1562.404234] audit: type=1334 audit(1635363440.667:81): prog-id=8 op=UNLOAD  [ 1562.410100] sd-umoun[579]: Unmounting '/oldroot/dev/pts'.  [ 1562.414579] audit: type=1334 audit(1635363440.667:82): prog-id=6 op=UNLOAD  [ 1562.420101] sd-umoun[580]: Unmounting '/oldroot/dev/shm'.  [ 1562.426852] sd-umoun[581]: Unmounting '/oldroot/sys/kernel/security'.  [ 1562.432165] sd-umoun[582]: Unmounting '/oldroot/usr'.  [ 1562.443869] sd-remou[583]: Remounting '/oldroot/run' read-only in with options 'noxattr,noacl'.  [ 1562.456905] sd-umoun[584]: Unmounting '/oldroot/run'.  [ 1562.461323] sd-umoun[585]: Unmounting '/oldroot'.  [ 1562.466800] sd-umoun[585]: Failed to unmount /oldroot: Device or resource busy  [ 1562.473458] sd-umoun[586]: Unmounting '/oldroot/dev'.  [ 1562.478395] sd-umoun[587]: Unmounting '/oldroot/sys'.  [ 1562.483288] sd-umoun[588]: Unmounting '/oldroot/proc'.  [ 1562.488082] sd-umoun[589]: Unmounting '/oldroot'.  [ 1562.493279] shutdown[1]: All filesystems unmounted.  [ 1562.498851] shutdown[1]: Deactivating swaps.  [ 1562.502456] shutdown[1]: All swaps deactivated.  [ 1562.506839] shutdown[1]: Detaching loop devices.  [ 1562.511505] shutdown[1]: All loop devices detached.  [ 1562.515404] shutdown[1]: Stopping MD devices.  [ 1562.520083] shutdown[1]: All MD devices stopped.  [ 1562.523666] shutdown[1]: Detaching DM devices.  [ 1562.527617] shutdown[1]: All DM devices detached.  [ 1562.531822] shutdown[1]: All filesystems, swaps, loop devices, MD devices and DM devices detached.  [ 1562.540145] shutdown[1]: Successfully changed into root pivot.  [ 1562.544940] shutdown[1]: Returning to initrd...  

I've only encountered this with the Arch Linux installation on ZFS. Using the same systemd, mkinitcpio, linux, and zfs-linux versions under another VM installation, with Arch on an Ext4 partition there, there's no such loop occurring during shutdown in that machine. May it be due to the root on ZFS configuration?

I'm at a loss for trying to figure out how to debug this loop any further.

To my best guess, this may be related to some scripting for systemd-shutdown on mkinticpio, such that was introduced in 2013 (Bächler2013).

What appears to be the main code in the mkinitcpio-generate-shutdown-ramfs service, introduced around that time - an excerpt of /usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service

[Service]  Type=oneshot  # /tmp could be umounted at this point  # use /run as temporary directory  Environment=TMPDIR=/run  ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -k none -c /dev/null -d /run/initramfs  

Furthermore, the contents of the file /usr/lib/initcpio/install/sd-shutdown

#!/bin/bash    build() {      add_binary /usr/lib/systemd/systemd-shutdown /shutdown        if type -P kexec >/dev/null; then          add_binary kexec      fi  }    help() {      cat <<HELPEOF  This hook adds systemd-shutdown to the initramfs. This is only  if the image is extracted to /run/initramfs before shutdown.  HELPEOF  }    # vim: set ft=sh ts=4 sw=4 et:    

I'm not certain if that's actually making it into the shutdown process, on the VM - the system might not meet the stated preconditions for that much.

I've tried masking the mkinitcpio-generate-shutdown-ramfs service under systemd, then running mkinitcpio -P again, rebooting ... and it still goes into that loop during system shutdown.

The system is still usable under the VM installation - at least, up to the point of that event in the shutdown, when the machine begins to loop indefinitely. Ideally I'd like to be able to work this knot out of the configuration, before installing anything beside Arch or putting this onto a machine's internal hard disk.

I'm not certain what may be resulting in the message, Failed to unmount /oldroot: Device or resource busy. It may be something related to the root on ZFS installation? But that's just a guess, really.

To my own perspective, the systemd-shutdown process - is it running under initrd, from what the console output says? I believe it seems nontrivial to debug, at this point.

I'm certain I could continue towards using Arch for keeping the Grub configuration up to date, after installing FreeBSD beside Arch, in the ZFS pool configuration under the VM's virtual disk. If it's possible to fix this issue with the shutdown loop under Arch, however, I'd like to be able to maintain the Arch installation as a working desktop system - in the VM installation, or finally on the PC's hard disk.

While I'm at a loss for trying to figure out how to debug this loop any further, for that loop during shutdown, maybe there's a patch that I just haven't found yet?

Update

I've found source code for systemd-shutdown, at the version in use on Arch Linux. I think it looks like some fairly straightforward code. There may not be a lot there about the 'oldroot' mount point, or how it could become unmountable under systemd-shutdown.

It doesn't appear to be due to logging. I've set Storage=volatile in /etc/systemd/journald.conf and created a oneshot systemd service that runs /usr/bin/journalctl --flush after boot. The /var/ filesystem gets successfully umounted now, and I don't believe I'm loosing all of the log data across reboots.

The loop is still occurring during the shutdown, however, along with the message Failed to unmount /oldroot... from systemd-shutdown. Is there something hanging it up by side effect?

How do I consistently name audio devices?

Posted: 02 Nov 2021 09:54 AM PDT

I have a couple of amateur radios that I connect to my Linux computer over USB. The radios present themselves as sound cards, and are visible like so:

$ aplay -l  [...]  card 1: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 2: CODEC_1 [USB Audio CODEC], device 0: USB Audio [USB Audio]    Subdevices: 1/1    Subdevice #0: subdevice #0    $ arecord -l  **** List of CAPTURE Hardware Devices ****  card 1: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 2: CODEC_1 [USB Audio CODEC], device 0: USB Audio [USB Audio]    Subdevices: 0/1    Subdevice #0: subdevice #0  

They show up on USB as:

$ lsusb | grep Audio  $ lsusb | grep Aud  Bus 001 Device 102: ID 08bb:2901 Texas Instruments PCM2901 Audio Codec  Bus 001 Device 099: ID 08bb:2901 Texas Instruments PCM2901 Audio Codec  

The problem here is that I have software that wants to talk to one of them, but it doesn't know which one. The software (js8call and wsjtx) simply allows me to select the name from a dropdown, and remembers the name chosen.

The names in this dropdown are:

alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo  alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.2  

Other software (e.g. direwolf) wants the device in "plughw:2,0" format, where the other radio is "plughw:1,0".

But it's not consistent which is which. It depends on when Linux detected them, which in the best case is the order that I plugged them in, and in the normal case it's a race condition, since both are plugged in and are using the same power supply, so they boot up at the same time when I turn on the power.

So, how do I make Linux name these two sound devices in a consistent way, so that I don't have to edit config files, and change settings in a UI, every time they happen to have been detected in a different order?

Why am I not able to give write permission to users using chmod in linux?

Posted: 02 Nov 2021 09:23 AM PDT

The current file permissions look like this:

$ ls -l file  -rwxrwxr-x 1 chiranjitd chiranjitd 0 Oct 30 14:52 file  

Now I try to give write permissions using chmod:

$ chmod +x+r+w file  

After that, the file permissions still look like this:

$ ls -l file  -rwxrwxr-x 1 chiranjitd chiranjitd 0 Oct 30 14:52 file  

The write permission is not given to the others. Why is this happening?

Center text with printf

Posted: 02 Nov 2021 09:27 AM PDT

printf "%*s\n" $(((${#fname}+$COLUMNS)/2)) "$fname"  

I get this error:

line 9: (7+)/2: syntax error: operand expected (error token is ")/2")  

This works in the terminal but not in my script. Do you have any ideas?

Custom daemon: which user could I use to run as, to avoid using root?

Posted: 02 Nov 2021 08:57 AM PDT

I want to write a daemon that launches after boot, before login, that does background communication over USB-rawhid with an Arduino microcontroller.

I would like to run this daemon as non-root.

I would also like to avoid creating a new user, just for this daemon.

Are there any system-generic users that could be (re)used for this?

I see in my /etc/shadow a user listed, named daemon but...

# su daemon  This account is currently not available.  

I am currently targeting:

It would be a bonus if this generic user would be available in default Debian and Ubuntu installs.

UFW not allowing to boot debian 11

Posted: 02 Nov 2021 08:44 AM PDT

I installed debian 11 on dell 5505 SE and installed UFW. But when I start my pc it shows "a start job is running for Uncomplicated firewall (xxx min / nolimit)". And goes on.. I restarted and booted into debian recovery mode and uninstalled UFW, there is no boot issue How can I fix the UFW issue boot splash

speedtest-cli: ValueError: invalid literal for int() with base 10: ''

Posted: 02 Nov 2021 09:08 AM PDT

On 3 machines I get:

$ speedtest-cli   Retrieving speedtest.net configuration...  Traceback (most recent call last):    File "/usr/bin/speedtest-cli", line 11, in <module>      load_entry_point('speedtest-cli==2.1.2', 'console_scripts', 'speedtest-cli')()    File "/usr/lib/python3/dist-packages/speedtest.py", line 1986, in main      shell()    File "/usr/lib/python3/dist-packages/speedtest.py", line 1872, in shell      speedtest = Speedtest(    File "/usr/lib/python3/dist-packages/speedtest.py", line 1091, in __init__      self.get_config()    File "/usr/lib/python3/dist-packages/speedtest.py", line 1173, in get_config      ignore_servers = list(  ValueError: invalid literal for int() with base 10: ''  

I have tested one of these machines on two different internet connections with the same result.

Why is it not working?

Void Linux - Broadcom network adapter [14e4:43a0] appears, but will not connect to a network

Posted: 02 Nov 2021 09:21 AM PDT

Void Linux with kernel 5.9.16_1. I'm using NetworkManager on KDE Plasma 5.

Whenever I attempt to connect to a network with this adapter, Plasma says "configuring interface" for a while, and then it says "The WiFi network could not be found."

I installed broadcom-wl-dkms from the Void repo, and the device is using the wl driver. This allowed NetworkManager to detect the interface. NetworkManager can use it to see networks, but that's it.

Lines from sudo dmesg that I can tell are relevant:

[    4.469892] cfg80211: Loading compiled-in X.509 certificates for regulatory database  [    4.471136] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'  [    4.471862] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2  [    4.471863] cfg80211: failed to load regulatory.db  [    4.505347] wl: loading out-of-tree module taints kernel.  [    4.505349] wl: module license 'MIXED/Proprietary' taints kernel.  [    4.505349] Disabling lock debugging due to kernel taint  [    4.509529] wl 0000:05:00.0: enabling device (0000 -> 0002)  [    4.527434] wlan0: Broadcom BCM43a0 802.11 Hybrid Wireless Controller 6.30.223.271 (r587334)  [    4.584803] wl 0000:05:00.0 wlp5s0: renamed from wlan0  

This error is because there is no /lib/firmware/regulatory.db file. I installed dcma and there is a /lib/firmware/dcma/regulatory.bin file. I've looked and I can't find any packages that would have regulatory.db. I'm not sure where else I should look for it, or if I can somehow generate it from regulatory.bin.

Edit: I downloaded regulatory.db and regulatory.db.p7s from this repository and copied them both to /lib/firmware

Now this is what I get from sudo dmesg:

[    4.440473] cfg80211: Loading compiled-in X.509 certificates for regulatory database  [    4.441633] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'  [    4.476573] wl: loading out-of-tree module taints kernel.  [    4.476576] wl: module license 'MIXED/Proprietary' taints kernel.  [    4.476577] Disabling lock debugging due to kernel taint  [    4.480880] wl 0000:05:00.0: enabling device (0000 -> 0002)  [    4.498936] wlan0: Broadcom BCM43a0 802.11 Hybrid Wireless Controller 6.30.223.271 (r587334)  [    4.567005] wl 0000:05:00.0 wlp5s0: renamed from wlan0  

So it looks like cfg80211 is doing alright, either the necessary firmware is missing or isn't being loaded by anything. How do I get it to load the firmware?

I tried wpa_supplicant, but it kept printing wlp5s0: CTRL-EVENT-SCAN-FAILED ret=-22 retry=1 until I stopped it.

Can't use SSH public/private key pairs after moving home to NFS server

Posted: 02 Nov 2021 08:19 AM PDT

I'm trying to understand why moving home directories on (2) different VMs screws up SSH public/private key authentication on one, but not the other. I am in the process of moving all of my local user accounts' home directory to an NFS server; the new home will be /VM-home/username. I copied the current home directories with rsync -auv, so the permissions are correct (0700 on $HOME/.ssh). After changing my home directory in /etc/passwd, I rebooted each system.

As you can see, the SSH connection works as expected on ArcoLinux, but fails on CentOS. I know that CentOS sees my new home, as logging on via Virt-Manager works; I've even deleted the old home just to make sure it wasn't being used. I would like to get this solved before continuing to reconfigure my other VMs.

$ ssh -v qemu-arcolinux

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017  debug1: Reading configuration data /etc/ssh/ssh_config  debug1: /etc/ssh/ssh_config line 19: Applying options for *  debug1: Connecting to qemu-arcolinux [192.168.122.19] port 22.  debug1: Connection established.  debug1: identity file /home/me/.ssh/id_rsa type 0  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_rsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_dsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_dsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ecdsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ecdsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ed25519 type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ed25519-cert type -1  debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3  debug1: Remote protocol version 2.0, remote software version OpenSSH_8.1  debug1: match: OpenSSH_8.1 pat OpenSSH* compat 0x04000000  debug1: Authenticating to qemu-arcolinux:22 as 'summersd'  debug1: SSH2_MSG_KEXINIT sent  debug1: SSH2_MSG_KEXINIT received  debug1: kex: algorithm: curve25519-sha256  debug1: kex: host key algorithm: ecdsa-sha2-nistp256  debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none  debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY  debug1: Server host key: XXXXXXXXXX  debug1: Host 'qemu-arcolinux' is known and matches the ECDSA host key.  debug1: Found key in /home/me/.ssh/known_hosts:9  debug1: rekey after 134217728 blocks  debug1: SSH2_MSG_NEWKEYS sent  debug1: expecting SSH2_MSG_NEWKEYS  debug1: SSH2_MSG_NEWKEYS received  debug1: rekey after 134217728 blocks  debug1: SSH2_MSG_EXT_INFO received  debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>  debug1: SSH2_MSG_SERVICE_ACCEPT received  debug1: Authentications that can continue: publickey  debug1: Next authentication method: publickey  debug1: Offering public key: RSA XXXXXXXXXX /home/me/.ssh/id_rsa  debug1: Server accepts key: pkalg rsa-sha2-512 blen 279  debug1: Authentication succeeded (publickey).  Authenticated to qemu-arcolinux ([192.168.122.19]:22).  debug1: channel 0: new [client-session]  debug1: Requesting no-more-sessions@openssh.com  debug1: Entering interactive session.  debug1: pledge: exec  debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0  debug1: Remote: /VM-home/me/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding  debug1: Remote: /VM-home/me/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding  debug1: Requesting X11 forwarding with authentication spoofing.  debug1: Sending environment.  debug1: Sending env LANG = en_US.UTF-8  Last login: Tue Jan 14 19:00:50 2020 from 192.168.122.1  

$ ssh -v qemu-centos

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017  debug1: Reading configuration data /etc/ssh/ssh_config  debug1: /etc/ssh/ssh_config line 19: Applying options for *  debug1: Connecting to qemu-centos [192.168.122.16] port 22.  debug1: Connection established.  debug1: identity file /home/me/.ssh/id_rsa type 0  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_rsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_dsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_dsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ecdsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ecdsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ed25519 type -1  debug1: key_load_public: No such file or directory  debug1: identity file /home/me/.ssh/id_ed25519-cert type -1  debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3  debug1: Remote protocol version 2.0, remote software version OpenSSH_7.8  debug1: match: OpenSSH_7.8 pat OpenSSH* compat 0x04000000  debug1: Authenticating to qemu-centos:22 as 'me'  debug1: SSH2_MSG_KEXINIT sent  debug1: SSH2_MSG_KEXINIT received  debug1: kex: algorithm: curve25519-sha256@libssh.org  debug1: kex: host key algorithm: ecdsa-sha2-nistp256  debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none  debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY  debug1: Server host key: XXXXXXXXXX  debug1: Host 'qemu-centos' is known and matches the ECDSA host key.  debug1: Found key in /home/me/.ssh/known_hosts:3  debug1: rekey after 134217728 blocks  debug1: SSH2_MSG_NEWKEYS sent  debug1: expecting SSH2_MSG_NEWKEYS  debug1: SSH2_MSG_NEWKEYS received  debug1: rekey after 134217728 blocks  debug1: SSH2_MSG_EXT_INFO received  debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,null>  debug1: SSH2_MSG_SERVICE_ACCEPT received  debug1: Authentications that can continue: publickey  debug1: Next authentication method: publickey  debug1: Offering public key: RSA XXXXXXXXXX /home/me/.ssh/id_rsa  debug1: Authentications that can continue: publickey  debug1: Trying private key: /home/me/.ssh/id_dsa  debug1: Trying private key: /home/me/.ssh/id_ecdsa  debug1: Trying private key: /home/me/.ssh/id_ed25519  debug1: No more authentication methods to try.  me@qemu-centos: Permission denied (publickey).  

Why doesn't Linux support OLED screens brightness control?

Posted: 02 Nov 2021 08:58 AM PDT

AFAIK, currently, all laptop OLED screens are Samsung screens, and they all use Pulse-Width Modulation (PWM) to adjust brightness.

Windows support this feature, while Linux doesn't...

  • Where should this feature be implemented (i.e., the Linux kernel, Intel Graphics drivers, etc.)?

Why linux drop packets in netif_receive_skb?

Posted: 02 Nov 2021 10:00 AM PDT

I have a linux box where we see a lot of (30%) TCP retransmission in tcpdump when receiving (downloading) files from outside. Using the dropwatch utility we see many packet drops in kernel function net_receive_skb(). That means data have been received on the NIC, but later some of them are dropped in the kernel when processing the packets. The many dropped packets can explain the necessity of retransmissions.

dropwatch output is like the following:

dropwatch -l kas   Initalizing kallsyms db  dropwatch> start  Enabling monitoring...  Kernel monitoring activated.  Issue Ctrl-C to stop monitoring  1 drops at tcp_rcv_established+906 (0xffffffff814d0a66)  6 drops at unix_dgram_connect+4ac (0xffffffff8151890c)  6 drops at unix_dgram_connect+4ac (0xffffffff8151890c)  19 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  5 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  9 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  7 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  6 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  14 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  15 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  2 drops at __netif_receive_skb+49f (0xffffffff8147b4ef)  2 drops at inet_csk_reset_xmit_timer.clone.1+265 (0xffffffff814d9cb5) ^CGot a stop message  dropwatch> exit  Shutting down ...  

The system is a CentOS 6.2 with a 2.6.32 kernel (centOS package name 2.6.32-696.el6.x86_64). So I looked into the version of netif_receive_skb in kernel source code, trying to find the reason for the packet drops. And I see there is only one place calling kfree_skb (near the end of the function) that will leave a trace on dropped packets. The code is:

int netif_receive_skb(struct sk_buff *skb)  {      struct packet_type *ptype, *pt_prev;      struct net_device *orig_dev;      struct net_device *null_or_orig;      int ret = NET_RX_DROP;      __be16 type;        if (!skb->tstamp.tv64)          net_timestamp(skb);        if (skb->vlan_tci && vlan_hwaccel_do_receive(skb))          return NET_RX_SUCCESS;        /* if we've gotten here through NAPI, check netpoll */      if (netpoll_receive_skb(skb))          return NET_RX_DROP;        if (!skb->iif)          skb->iif = skb->dev->ifindex;        null_or_orig = NULL;      orig_dev = skb->dev;      if (orig_dev->master) {          if (skb_bond_should_drop(skb))              null_or_orig = orig_dev; /* deliver only exact match */          else              skb->dev = orig_dev->master;      }        __get_cpu_var(netdev_rx_stat).total++;        skb_reset_network_header(skb);      skb_reset_transport_header(skb);      skb->mac_len = skb->network_header - skb->mac_header;        pt_prev = NULL;        rcu_read_lock();    #ifdef CONFIG_NET_CLS_ACT      if (skb->tc_verd & TC_NCLS) {          skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);          goto ncls;      }  

No comments:

Post a Comment