Wednesday, November 10, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Merge text and Json files

Posted: 10 Nov 2021 09:48 AM PST

I have a text file that looks like this

AWSDynamoDB/01629227303395-c3801363/_started  AWSDynamoDB/01629227303395-c3801363/data/57sxfwx54y63xo46yhna6qgf3e.json.gz  

Have a JSON file that looks like this.

{      "TagSet": [test:tag]  }  {      "TagSet": [foo:bar]  }  

I'd like to merge these files in a way that the output will look like this.

    AWSDynamoDB/01629227303395-c3801363/_started         {              "TagSet": [test:tag]          }      AWSDynamoDB/01629227303395-c3801363/data/57sxfwx54y63xo46yhna6qgf3e.json.gz      {              "TagSet": [test:tag]          }  

or this.

   AWSDynamoDB/01629227303395-c3801363/_started                             "TagSet": [test:tag]                        AWSDynamoDB/01629227303395-c3801363/data/57sxfwx54y63xo46yhna6qgf3e.json.gz                          "TagSet": [foo:bar]            

I tried using

paste input.txt output.json | pr -t -e24  

But its not giving me the output that I am looking. How can I achieve this?

WiFi interface configured as AP is down after system restart

Posted: 10 Nov 2021 09:48 AM PST

I'm trying to setup my WiFi interface in AP mode using hostapd. However, after system restart startup hangs for about 2min on:

A start job is running for Wait for Network to be Configured  

It seems that WiFi interface is not getting UP and that is why systemd-networkd-wait-online.service hangs. It does not if I set WiFi interface as ignored in systemd-networkd-wait-online.service, but this does not solve the general problem.

After system startup I see this output after I execute ip addr command:

3: wlxc04a0010118a: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000      link/ether c0:4a:00:10:11:8a brd ff:ff:ff:ff:ff:ff  

As I expected interface is DOWN.

sudo ip link set wlxc04a0010118a up does not change interface status. To bring it UP and fix my issue I have to execute systemctl restart hostapd.service

Then ip addr command returns:

3: wlxc04a0010118a: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether c0:4a:00:10:11:8a brd ff:ff:ff:ff:ff:ff      inet 172.24.1.1/24 brd 172.24.1.255 scope global wlxc04a0010118a         valid_lft forever preferred_lft forever  

I would like to fix that and have WiFi AP configured after system startup without this manual step as other services rely on this interface and eventualy have to be also started manualy when interface is up. I tried many things but still cannot solve this. I would appreciate your help.

My /etc/hostapd/hostapd.conf:

interface=wlxc04a0010118a  # Use the nl80211 driver with the brcmfmac driver  driver=nl80211  ssid=Wifinetwork  hw_mode=g  channel=6  ieee80211n=1  wmm_enabled=1  # Enable 40MHz channels with 20ns guard interval  #ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]  macaddr_acl=0  auth_algs=1  ignore_broadcast_ssid=0  wpa=2  wpa_key_mgmt=WPA-PSK  wpa_passphrase=Wifipassword  rsn_pairwise=CCMP  

Interface configuration: /lib/systemd/network/80-wifi-ap.network:

[Match]  Name=wlxc04a0010118a    [Network]  Address=172.24.1.1/24  DHCPServer=no  IPForward=ipv4  IPMasquerade=no  

/etc/dnsmasq.conf:

interface=wlxc04a0010118a      # Use interface wlan0    listen-address=172.24.1.1  # Explicitly specify the address to listen on    bind-dynamic      # Bind to the interface to make sure we aren't sending things elsewhere    server=8.8.8.8       # Forward DNS requests to Google DNS    domain-needed        # Don't forward short names    bogus-priv           # Never forward addresses in the non-routed address spaces.    dhcp-option=6,172.24.1.1,192.168.1.1  domain=domain1  dhcp-range=172.24.1.50,172.24.1.150,12h   

Result of systemctl status hostapd.service before hostapd restart:

● hostapd.service - Hostapd IEEE 802.11 Access Point       Loaded: loaded (/etc/systemd/system/hostapd.service; enabled; vendor preset: enabled)       Active: active (running) since Wed 2021-11-10 16:42:02 UTC; 4min 48s ago      Process: 780 ExecStartPre=/sbin/ip link set wlxc04a0010118a up (code=exited, status=0/SUCCESS)      Process: 794 ExecStart=/usr/sbin/hostapd -B /etc/hostapd/hostapd.conf -P /var/run/hostapd.pid (code=exited, sta>     Main PID: 966 (hostapd)        Tasks: 1 (limit: 4596)       Memory: 2.4M       CGroup: /system.slice/hostapd.service               └─966 /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf -P /var/run/hostapd.pid    Nov 10 16:41:58 domain1 systemd[1]: Starting Hostapd IEEE 802.11 Access Point...  Nov 10 16:41:58 domain1 hostapd[794]: Configuration file: /etc/hostapd/hostapd.conf  Nov 10 16:42:00 domain1 hostapd[794]: Using interface wlxc04a0010118a with hwaddr c0:4a:00:10:11:8a and ssid ">  Nov 10 16:42:02 domain1 hostapd[794]: wlxc04a0010118a: interface state UNINITIALIZED->ENABLED  Nov 10 16:42:02 domain1 hostapd[794]: wlxc04a0010118a: AP-ENABLED  Nov 10 16:42:02 domain1 systemd[1]: hostapd.service: Can't open PID file /run/hostapd.pid (yet?) after start: >  Nov 10 16:42:02 domain1 systemd[1]: Started Hostapd IEEE 802.11 Access Point.  

Result of systemctl status hostapd.service after hostapd restart:

 hostapd.service - Hostapd IEEE 802.11 Access Point       Loaded: loaded (/etc/systemd/system/hostapd.service; enabled; vendor preset: enabled)       Active: active (running) since Wed 2021-11-10 17:32:36 UTC; 6min ago      Process: 1499 ExecStartPre=/sbin/ip link set wlxc04a0010118a up (code=exited, status=0/SUCCESS)      Process: 1514 ExecStart=/usr/sbin/hostapd -B /etc/hostapd/hostapd.conf -P /var/run/hostapd.pid (code=exited, s>     Main PID: 1522 (hostapd)        Tasks: 1 (limit: 4596)       Memory: 816.0K       CGroup: /system.slice/hostapd.service               └─1522 /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf -P /var/run/hostapd.pid    Nov 10 17:32:30 domain1 systemd[1]: Stopping Hostapd IEEE 802.11 Access Point...  Nov 10 17:32:30 domain1 systemd[1]: hostapd.service: Succeeded.  Nov 10 17:32:30 domain1 systemd[1]: Stopped Hostapd IEEE 802.11 Access Point.  Nov 10 17:32:30 domain1 systemd[1]: Starting Hostapd IEEE 802.11 Access Point...  Nov 10 17:32:30 domain1 hostapd[1514]: Configuration file: /etc/hostapd/hostapd.conf  Nov 10 17:32:34 domain1 hostapd[1514]: Using interface wlxc04a0010118a with hwaddr c0:4a:00:10:11:8a and ssid>  Nov 10 17:32:36 domain1 hostapd[1514]: wlxc04a0010118a: interface state UNINITIALIZED->ENABLED  Nov 10 17:32:36 domain1 hostapd[1514]: wlxc04a0010118a: AP-ENABLED  Nov 10 17:32:36 domain1 systemd[1]: hostapd.service: Can't open PID file /run/hostapd.pid (yet?) after start:>  Nov 10 17:32:36 domain1 systemd[1]: Started Hostapd IEEE 802.11 Access Point.  

What happens when an SD card gets connected

Posted: 10 Nov 2021 09:39 AM PST

I'm still quite confused as to how this works exactly.

When we connect an SD card to a computer running a Linux system, this is my understanding (Please feel free to correct on the smallest of details which are incorrect ) :

Linux identifies the device as an SD card by an identifier stored on the SD card. Along with this identifier, there is an SD card controller which takes care about reading and writing from and to the card.

In Linux, the SD card shows up as a block device in /dev . An SD card driver will then get loaded into the kernel and connected to use with the device file. This SD card driver takes care about writing and reading to and from the SD card controller on the SD card.

Now, when we wish to format the SD card and use a particular filesystem for it such as FAT32, where does this filesystem controller code come into all this? Does it get written onto the card, or just on the Linux computer? Thanks in advance.

Custom system locale results in unreadable output

Posted: 10 Nov 2021 09:33 AM PST

I try to define a custom locale on Debian Bullseye, and everything is going well until I set the custom locale as the system locale. After I set the custom locale as the system locale output becomes unreadable.

Let's install a stock locale as the golden standard

$ echo "el_GR.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen  $ sudo locale-gen  $ LC_ALL=el_GR.utf8 ncal      Νοέμβριος 2021      Δε  1  8 15 22 29     Τρ  2  9 16 23 30     Τε  3 10 17 24        Πε  4 11 18 25        Πα  5 12 19 26        Σα  6 13 20 27        Κυ  7 14 21 28  

Creating a custom locale

I intentionally don't make any customization to demonstrate that the problem doesn't originate from the customization.

$ sudo mkdir -p /usr/local/share/i18n/locales/  $ sudo cp /usr/share/i18n/locales/el_GR /usr/local/share/i18n/locales/el_GR@test  $ sudo localedef -c -v -f UTF-8 --no-archive -i /usr/local/share/i18n/locales/el_GR@test el_GR.UTF-8@test  $ echo "el_GR.UTF-8@test UTF-8" | sudo tee -a /etc/locale.gen  $ sudo locale-gen  $ LC_ALL=el_GR.utf8@test ncal      Νοέμβριος 2021      Δε  1  8 15 22 29     Τρ  2  9 16 23 30     Τε  3 10 17 24        Πε  4 11 18 25        Πα  5 12 19 26        Σα  6 13 20 27        Κυ  7 14 21 28  

Everything looks well at the moment.

Setting it as the system locale

$ sudo update-locale LANG=el_GR.UTF-8@test  

and after logging out and logging back in:

$ ncal      ÎÎ¹Î¿Ï 2021      Îε  1  8 15 22 29     Î¤Ï  2  9 16 23 30     Τε  3 10 17 24        Πε  4 11 18 25        Πα  5 12 19 26        Σα  6 13 20 27        ÎÏ    7 14 21 28          $ LC_ALL=el_GR.utf8 ncal      ÎÎ¹Î¿Ï 2021      Îε  1  8 15 22 29     Î¤Ï  2  9 16 23 30     Τε  3 10 17 24        Πε  4 11 18 25        Πα  5 12 19 26        Σα  6 13 20 27        ÎÏ    7 14 21 28        

And what about the stock locale?

$ sudo update-locale LANG=el_GR.UTF-8  

and after logging out and logging back in everything becomes fine with the custom locale as well as with the stock one:

$ ncal      Νοέμβριος 2021      Δε  1  8 15 22 29     Τρ  2  9 16 23 30     Τε  3 10 17 24        Πε  4 11 18 25        Πα  5 12 19 26        Σα  6 13 20 27        Κυ  7 14 21 28    $ LC_ALL=el_GR.utf8@test ncal      Νοέμβριος 2021      Δε  1  8 15 22 29     Τρ  2  9 16 23 30     Τε  3 10 17 24        Πε  4 11 18 25        Πα  5 12 19 26        Σα  6 13 20 27        Κυ  7 14 21 28  

What am I doing wrong and how to fix it?

TAR returns 1 on big directories - how to ignore this?

Posted: 10 Nov 2021 09:04 AM PST

I'm running the following sequence for backup purposes:

$> set -o pipefail  $> tar -c /vary/large/folder1 /very/large/folder2 | xz ... | gpg ... | aws ...  $> echo "${PIPESTATUS[0]} ${PIPESTATUS[1]} ${PIPESTATUS[2]} ${PIPESTATUS[3]}"  1 0 0 0  

When I run tar on smaller directories, the return value is always 0. But when I try to backup larger folders (+10G), the return value is always 1. The manpage of tar states:

RETURN VALUE 1 Some files differ. If tar was invoked with the --compare (--diff, -d) command line option, this means that some files in the archive differ from their disk counterparts. If tar was given one of the --create, --append or --update options, this exit code means that some files were changed while being archived and so the resulting archive does not contain the exact copy of the file set.

What can I do to prevent tar returning 1 which spoils the sequence of my backup script? I want/need to ignore files that have changed during the backup, so how can I ignore files that differ? Is there any "best way" to handle huge directories with tar - how would you solve this error?

Thanks in advance.

AppImage - Where is state saved between instances?

Posted: 10 Nov 2021 09:22 AM PST

If you're running an AppImage application, and you make settings changes to it (or anything else that would change the state of the application), are those changes saved within the AppImage file itself? And if so, how do you preserve those settings upon upgrading to a later version of that AppImage application?

iptables Forwarding and port blocking

Posted: 10 Nov 2021 08:34 AM PST

I have created the following Network in Virtual Box:

Linux Internal PC with 1 Static IP: 10.10.10.2

Linux Gateway/Firewall with 2 Static IP's and 1 NAT: 10.10.10.3 | 11.11.11.2 | NAT Network Card

Linux DMZ Server with 1 Static IP: 11.11.11.3

The targets:
1)Internet on 10.10.10.X and 11.11.11.X via Linux Gateway. (Only port 80, 443 allowed to the internet, everything else block)
2)Access to DMZ server from 10.10.10.X only via port 22,80,443 (everything else blocked from Linux Gateway

The iptables in Linux Gateway I have until now is:

iptables -F    #Linux Gateway to Internet from 10.10.10.X  iptables -A FORWARD -i enp0s8 -o enp0s3 -j ACCEPT  iptables -A FORWARD -i enp0s3 -o enp0s8 -m state --state RELATED,ESTABLISHED -j ACCEPT  iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE    #Linux Gateway to Internet from 11.11.11.X  iptables -A FORWARD -i enp0s9 -o enp0s3 -j ACCEPT  iptables -A FORWARD -i enp0s3 -o enp0s9 -m state --state RELATED,ESTABLISHED -j ACCEPT    #Linux Gateway to DMZ  iptables -A FORWARD -i enp0s8 -o enp0s9 ACCEPT  iptables -A FORWARD -i enp0s9 -o enp0s8 -m state --state RELATED,ESTABLISHED -j ACCEPT  iptables -t nat -A POSTROUTING -o enp0s9 -j MASQUERADE    #Allow only port 80,443 to Internet  iptables -A INPUT -p tcp -m tcp -m multiport --dports 80,443 -j ACCEPT  iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT  iptables -A INPUT DROP  iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT  iptables -A OUTPUT DROP  iptables -A FORWARD DROP  

I am not sure if its correct and also I have to add the restriction for ports with destination to DMZ.

Autostart script not working in Qtile on Manjaro

Posted: 10 Nov 2021 08:01 AM PST

I have Qtile installed on Manjaro, and in the config.py I have it set to run and autostart script autostart.sh. However, when I start Qtile it does not run, I get no errors or anything. I have to run the script manually every time I start Qtile.

This is what I have in my config.py:

from libqtile import hook  import os  import subprocess    @hook.subscribe.startup_once  def autostart():      home = os.path.expanduser('~/.config/qtile/autostart.sh')      subprocess.call([home])  

This is what I have in my autostart.sh

#!/bin/bash    xrandr --output HDMI1 --left-of eDP1 &  nitrogen --restore &  picom -f &  

Implementing DB Security with Linux

Posted: 10 Nov 2021 09:47 AM PST

I have installed cygwin64 and have been practising linux commands and Shell programming. I am creating a project where I want to restrict file permissions, authenticate user, and execute procedures stored in Database. As I am not very well versed with this, I have been trying different methods. Can I do this in cygwin64? I do not want to download the virtualbox. I could not get administrator priviledges in cygwin64, not even with a run as administrator selection. The prompt remains a $. Please help.

Elementary OS stuck, doesn't boot

Posted: 10 Nov 2021 07:35 AM PST

enter image description here

I have no idea what went wrong. I know how to chroot. I am a student and this is my only computer. I have some urgent work pending so please help me if you can. I have encrypted luks drive.

Unable to connect telnet to mysql listen ip port from remote host

Posted: 10 Nov 2021 08:20 AM PST

I m able to telnet locally to mysql process like below:

I have also made sure MySQL process is listening on all IPs by setting bind-address = 0.0.0.0 as evident below:

root@localhost:~# netstat -plutn | grep mysql  tcp        0      0 0.0.0.0:33060           0.0.0.0:*               LISTEN      39288/mysqld  tcp        0      0 0.0.0.0:7306            0.0.0.0:*               LISTEN      39288/mysqld  

and

root@localhost:~# telnet 82.165.32.59 7306  Trying 82.165.32.59...  Connected to 82.165.32.59.  Escape character is '^]'.  >Host 'linux' is not allowed to connect to this MySQL serverConnection closed by foreign host  

I opened the firewall port 7306 and reloaded the firewall using the below commands:

root@localhost:~# firewall-cmd --zone=public --permanent --add-port=7306/tcp  Warning: ALREADY_ENABLED: 7306:tcp  success  root@localhost:~#  firewall-cmd --reload  success  root@localhost:~# firewall-cmd --list-all  public    target: default    icmp-block-inversion: no    interfaces:    sources:    services: dhcpv6-client ssh    ports: 443/tcp 80/tcp 7306/tcp    protocols:    masquerade: no    forward-ports:    source-ports:    icmp-blocks:    rich rules:  

However, when telnet from a remote host it fails like below:

$ telnet 82.165.32.59 7306  Trying 82.165.32.59...    telnet: connect to address 82.165.32.59: Connection timed out  

My OS is:

root@localhost:~# uname -a  Linux localhost 5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux    root@localhost:~# lsb_release -a  No LSB modules are available.  Distributor ID: Ubuntu  Description:    Ubuntu 20.04.3 LTS  Release:        20.04  Codename:       focal  

I tried restarting the firewall service as below:

root@localhost:~# systemctl restart firewalld  

I also flushed the IPTABLES using the below script but it did not help:

root@localhost:~# cat fw.stop  #!/bin/sh  echo "Stopping IPv4 firewall and allowing everyone..."  ipt="/sbin/iptables"  ## Failsafe - die if /sbin/iptables not found  [ ! -x "$ipt" ] && { echo "$0: \"${ipt}\" command not found."; exit 1; }  $ipt -P INPUT ACCEPT  $ipt -P FORWARD ACCEPT  $ipt -P OUTPUT ACCEPT  $ipt -F  $ipt -X  $ipt -t nat -F  $ipt -t nat -X  $ipt -t mangle -F  $ipt -t mangle -X  $ipt -t raw -F  $ipt -t raw -X  

Can you please suggest?

Can't restart MariaDB after adding datadir line to my.cnf file

Posted: 10 Nov 2021 07:27 AM PST

Having a issue getting MariaDB to restart after adding the following line to the [mysqld] section of my.cnf:

datadir = /home/mysql  

It won't restart. Could this be a permissions issue. This is the directory that holds all my SQL data. Here is what systemctl status mysql.service shows

● mariadb.service - MariaDB database server     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)     Active: failed (Result: exit-code) since Wed 2021-11-10 08:33:00 CST; 36s ago       Docs: man:mysqld(8)             https://mariadb.com/kb/en/library/systemd/    Process: 14438 ExecStart=/usr/lib/mysql/mysql-systemd-helper start (code=exited, status=1/FAILURE)    Process: 14425 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCCESS)    Process: 14412 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install (code=exited, status=0/SUCCESS)   Main PID: 14438 (code=exited, status=1/FAILURE)     Status: "MariaDB server is down"    Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10  8:33:00 0 [Note] /usr/sbin/mysqld (mysqld 10.4.17-MariaDB-log) starting as process 14438 ...  Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10  8:33:00 0 [Warning] Could not increase number of max_open_files to more than 1024 (request: 32214)  Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10  8:33:00 0 [Warning] Changed limits: max_open_files: 1024  max_connections: 151 (was 151)  table_cache: 421 (was 2000)  Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10  8:33:00 0 [Warning] Can't create test file /home/mysql/law-amp3.lower-test  Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: [87B blob data]  Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10  8:33:00 0 [ERROR] Aborting  Nov 10 08:33:00 law-amp3 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE  Nov 10 08:33:00 law-amp3 systemd[1]: Failed to start MariaDB database server.  Nov 10 08:33:00 law-amp3 systemd[1]: mariadb.service: Unit entered failed state.  Nov 10 08:33:00 law-amp3 systemd[1]: mariadb.service: Failed with result 'exit-code'.  

Debian 11 issue with locale: No such file or directory

Posted: 10 Nov 2021 07:47 AM PST

The problem I encounter with Debian bullseye (v11):

If I execute locale -a, I get the following output:

locale: Cannot set LC_CTYPE to default locale: No such file or directory  locale: Cannot set LC_MESSAGES to default locale: No such file or directory  locale: Cannot set LC_COLLATE to default locale: No such file or directory  C  C.UTF-8  POSIX  aa_DJ  aa_DJ.iso88591  aa_DJ.utf8  aa_ER  aa_ER.utf8  ...  zh_TW  zh_TW.big5  zh_TW.euctw  zh_TW.utf8  zu_ZA  zu_ZA.iso88591  zu_ZA.utf8  

Also, if I try to use tlmgr (package manager for LateX), I get the following:

perl: warning: Setting locale failed.  perl: warning: Please check that your locale settings:          LANGUAGE = "en_US:fr:en_GB",          LC_ALL = "en-US.UTF-8",          LC_MESSAGES = "en_US.UTF-8",          LC_CTYPE = "en_US.UTF-8",          LC_COLLATE = "en_US.UTF-8",          LANG = "fr_FR.UTF-8"      are supported and installed on your system.  perl: warning: Falling back to a fallback locale ("fr_FR.UTF-8").  tlmgr: no action given; try --help if you need it.  

I searched the issue, and tried the following:

  • dpkg-reconfigure locales and selecting only used locales (fr utf8, en-us utf8 and en-gb utf8)
  • dpkg-reconfigure locales and selecting all locales (as you can see above)
  • locale-gen
  • restarting the PC with each change
  • editing /etc/default/locale

More information

cat /etc/default/locale gives:

#  File generated by update-locale  LANG=en_US.UTF-8  LANGUAGE=en_US.UTF-8  LC_ALL=en_US.UTF-8  LC_CTYPE=en_US.UTF-8  LC_MESSAGES=en_US.UTF-8  LC_COLLATE=en_US.UTF-8  

ls /usr/share/locale/en gives:

LC_MESSAGES  

ls /usr/share/locale/en/LC_MESSAGES gives:

accounts-service.mo  gtk30-properties.mo  iso_3166-2.mo  kcoreaddons5_qt.qm  kwidgetsaddons5_qt.qm  cups-pk-helper.mo    gtk30.mo  

Questions

  • Should I reconfigure locales and only select used locales?
  • The error message says that it expects file/folder that does not exist. Where should this file/folder be located? in /usr/share/locale/en?
  • How to solve this issue (non-blocking, because all applications seem to work, but annoying)?

If you have suggestions for documentations to read to dive deeper on this issue I'm also all hear.

Thank you.

Edits

Questions from @StéphaneChazelas

Output of locale

locale: Cannot set LC_CTYPE to default locale: No such file or directory  locale: Cannot set LC_MESSAGES to default locale: No such file or directory  locale: Cannot set LC_ALL to default locale: No such file or directory  LANG=fr_FR.UTF-8  LANGUAGE=en_US:fr:en_GB  LC_CTYPE="en-US.UTF-8"  LC_NUMERIC="en-US.UTF-8"  LC_TIME="en-US.UTF-8"  LC_COLLATE="en-US.UTF-8"  LC_MONETARY="en-US.UTF-8"  LC_MESSAGES="en-US.UTF-8"  LC_PAPER="en-US.UTF-8"  LC_NAME="en-US.UTF-8"  LC_ADDRESS="en-US.UTF-8"  LC_TELEPHONE="en-US.UTF-8"  LC_MEASUREMENT="en-US.UTF-8"  LC_IDENTIFICATION="en-US.UTF-8"  LC_ALL=en-US.UTF-8  

Output of strace locale 2>&1 | grep ENOENT:

access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US.UTF-8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US.utf8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US/LC_CTYPE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US.UTF-8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US.utf8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US.utf8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  openat(AT_FDCWD, "/usr/lib/locale/en-US/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)  

ls /usr/lib/locale gives:

C.UTF-8  locale-archive  

Strange dpkg-reconfigure locales output

If I'm not wrong, dpkg-reconfigure locales should list locales and say for each of them "up to date" if already generated. But in my case, it re-process each locale and says "done":

perl: warning: Setting locale failed.  perl: warning: Please check that your locale settings:    LANGUAGE = "en_US:fr:en_GB",    LC_ALL = "en-US.UTF-8",    LC_MESSAGES = "en_US.UTF-8",    LC_CTYPE = "en_US.UTF-8",    LC_COLLATE = "en_US.UTF-8",    LANG = "fr_FR.UTF-8"      are supported and installed on your system.  perl: warning: Falling back to a fallback locale ("fr_FR.UTF-8").  locale: Cannot set LC_CTYPE to default locale: No such file or directory  locale: Cannot set LC_MESSAGES to default locale: No such file or directory  locale: Cannot set LC_ALL to default locale: No such file or directory  /usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory  /usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory  /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory  Generating locales (this might take a while)...    aa_DJ.UTF-8... done    aa_DJ.ISO-8859-1... done    aa_ER.UTF-8... done    aa_ER.UTF-8@saaho... done    aa_ET.UTF-8... done    af_ZA.UTF-8... done    af_ZA.ISO-8859-1... done    agr_PE.UTF-8... done    ak_GH.UTF-8... done    am_ET.UTF-8... done    an_ES.UTF-8... done    an_ES.ISO-8859-15... done    anp_IN.UTF-8... done    ar_AE.UTF-8... done    ar_AE.ISO-8859-6... done    ar_BH.UTF-8... done    ar_BH.ISO-8859-6... done    ar_DZ.UTF-8... done    ar_DZ.ISO-8859-6... done    ar_EG.UTF-8... done    ar_EG.ISO-8859-6... done    ar_IN.UTF-8... done    ar_IQ.UTF-8... done    ...  

PXE Server Build

Posted: 10 Nov 2021 07:15 AM PST

So what if I already have a DHCP server and a DNS Server, How do I build it with out those components? Would DHCP and DNS Conflict with what I already have?

HAPROXY - Redirect request to another server

Posted: 10 Nov 2021 08:22 AM PST

Through a HAProxy I have to redirect requests of the type http://my server/vo-tcs to a server with IP address 172.22.80.40 (SRV1). I state that on SRV1 the Joomla CMS is installed and it is installed in a subdirectory called vo-tcs.

If I do not activate the SEO (within the Joomla configuration) everything works correctly and the requests are of the type

http://mioserver/vo-tcs/index.php?option=com_wrapper&view=wrapper&Itemid=155  

then everything works correctly.

If instead I activate the Joomla SEO and the URL is of the type

http://mioserver/vo-tcs/tna  

then I get the error message 404 (page not found).

Could you give me a hand? I am attaching the configuration.

frontend Local_Server  mode http  bind *:80  acl is_vo-tcs path_beg -i /vo-tcs  use_backend be_vo-tcs if is_vo-tcs    backend be_vo-tcs  mode http  reqrep ^([^\ ]*\ /)vo-tcs[/]?(.*)     \1\2  http-request set-header X-Forwarded-Port %[dst_port]  http-request add-header X-Forwarded-Proto https if { ssl_fc }  http-request set-path %[path,regsub(^/?,/vo-tcs/)]  option httpchk HEAD / HTTP/1.1rnHost:localhost  server web7 172.22.80.40:80  

bash: trap reaction - different timing

Posted: 10 Nov 2021 08:22 AM PST

GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)

[curious ~]# cat ./trap-term  #!/bin/bash  trap 'echo TRAP' TERM  sleep 30  [curious ~]# ./trap-term & sleep 3; kill -TERM %1  [1] 3141     <... pause - 3s>  [curious ~]# Terminated  TRAP  [1]+  Exit 143                ./trap-term  

Reaction is immediate (3s)?!

[curious ~]# cat ./tt  #!/bin/bash  ./trap-term & sleep 3; kill -TERM %1  [curious ~]# ./tt <... pause - 3s>  [curious ~]# <... pause - 30s> TRAP  

Reaction agrees with bash doc:

If Bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes.

The question is why the first variant is so much faster than other??

Update:

Test in another distro:

Ubuntu 20.04.3 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64); GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu): the same first result with "Terminated" and "TRAP" after 3s

@zevzek "there are no jobs in shell scripts"??!

curious ~$ cat ./ttj   #!/bin/bash   ./trap-term & sleep 3; jobs; kill -TERM %1   curious ~$ ./ttj   [1]+  Running                 ./trap-term &   curious ~$ TRAP  

Free up mysql space on low-disk PC

Posted: 10 Nov 2021 07:47 AM PST

I have a PC with a small disk:

Filesystem      Size  Used Avail Use% Mounted on  /dev/root       3.5G  3.1G  249M  93% /  devtmpfs        459M     0  459M   0% /dev  tmpfs           463M     0  463M   0% /dev/shm  tmpfs           463M   36M  428M   8% /run  tmpfs           5.0M  8.0K  5.0M   1% /run/lock  tmpfs           463M     0  463M   0% /sys/fs/cgroup  /dev/mmcblk0p1   63M   25M   38M  40% /boot  tmpfs            64M  140K   64M   1% /mnt/ramdisk  

I have a simple database, but one of the tables has more than 5 million rows, taking up a lot on such a small record:

# ls -lh /var/lib/mysql/datalogger/  total 1.1G  ...  -rw-rw---- 1 mysql mysql 1.1G Nov 10 09:56 avg_values.ibd  ...  

My goal, done on other similar computers without so much space occupied (about half in that table) was to run a query that deleted data more than 6 months old. The query is irrelevant to the case. after the query, running optimize NO_WRITE_TO_BINLOG table avg_values; free up ibd space.

The problem with the computer in question, is that -as I believe- the available space is very limited, you can not perform queries on such a large table (by cache, I understand), causing instability in communications, even when the query has a limit:

MariaDB [datalogger]> select * from avg_values limit 10;  ERROR 2006 (HY000): MySQL server has gone away  No connection. Trying to reconnect...  Connection id:    5  Current database: datalogger    ERROR 2013 (HY000): Lost connection to MySQL server during query  

With other smaller tables there are usually no problems (although it also indicates error):

MariaDB [datalogger]> select * from raw_values;  ERROR 2006 (HY000): MySQL server has gone away  No connection. Trying to reconnect...  Connection id:    5  Current database: datalogger    +----+---------------------+-------------------+------+-------+  | id | timestamp           | channel           | raw  | value |  +----+---------------------+-------------------+------+-------+  |  1 | 2021-11-10 09:46:51 | AI1               |    1 | 0.011 |  |  2 | 2021-11-10 09:46:51 | AI2               |    1 | 0.011 |  |  3 | 2021-11-10 09:46:51 | AI3               |    2 | 0.022 |  |  4 | 2021-11-10 09:46:51 | AI4               |    2 | 0.022 |  |  5 | 2021-11-10 09:46:51 | pyr1_sensor1_data |  113 |   113 |  |  6 | 2021-11-10 09:46:51 | pyr1_body_temp    |   42 |    42 |  |  7 | 2021-11-10 09:46:51 | pyr2_sensor1_data | NULL |  NULL |  |  8 | 2021-11-10 09:46:51 | pyr2_body_temp    | NULL |  NULL |  |  9 | 2021-11-10 09:46:46 | AI1               |    1 | 0.011 |  | 10 | 2021-11-10 09:46:46 | AI2               |    1 | 0.011 |  | 11 | 2021-11-10 09:46:46 | AI3               |    2 | 0.022 |  | 12 | 2021-11-10 09:46:46 | AI4               |    2 | 0.022 |  | 13 | 2021-11-10 09:46:46 | pyr1_sensor1_data |  115 |   115 |  | 14 | 2021-11-10 09:46:46 | pyr1_body_temp    |   42 |    42 |  | 15 | 2021-11-10 09:46:46 | pyr2_sensor1_data | NULL |  NULL |  | 16 | 2021-11-10 09:46:46 | pyr2_body_temp    | NULL |  NULL |  | 17 | 2021-11-10 09:46:52 | AI1               |    1 | 0.011 |  | 18 | 2021-11-10 09:46:52 | AI2               |    1 | 0.011 |  | 19 | 2021-11-10 09:46:52 | AI3               |    2 | 0.022 |  | 20 | 2021-11-10 09:46:52 | AI4               |    2 | 0.022 |  | 21 | 2021-11-10 09:46:52 | pyr1_sensor1_data |  112 |   112 |  | 22 | 2021-11-10 09:46:52 | pyr1_body_temp    |   42 |    42 |  | 23 | 2021-11-10 09:46:52 | pyr2_sensor1_data | NULL |  NULL |  | 24 | 2021-11-10 09:46:52 | pyr2_body_temp    | NULL |  NULL |  +----+---------------------+-------------------+------+-------+  24 rows in set (0.02 sec)  

Is there any way I can run these queries, especially with this little disk in order to free up space?

How to Send a Signal or Data to C++ Program from Bash Script

Posted: 10 Nov 2021 07:18 AM PST

As the title states I would like a to be able to send a signal, alert, message, or something to a C++ program while it is executing from a bash script. I have seen some solutions where a script will start the program with arguments, but I need it to occur while the program is already up and running. Is there any way to do that? Basically while the script runs in the background if an error occurs I would like it to be reported to the program directly, rather than be logged somewhere in the OS. I am using Redhat 8.

Thank you

Splitting a small file into 512 byte segments changes it, but splitting it in 1k segments doesn't

Posted: 10 Nov 2021 08:48 AM PST

So I'm trying to split a 64MB file FileCarve.001 into 512 byte segments (each block is 512 bytes long). I need to make sure the file has the same data when split into smaller files, so I cat all the files to standard out and pipe it into sha256sum (there's a lot of files, so I need to do this with find and xargs).

Splitting the file in 512 byte segments seems to garble the data when the output gets split by the split command.

$ dd if=FileCarve.001 bs=512 | split -b512 - splits/img  131072+0 records in  131072+0 records out  67108864 bytes (67 MB, 64 MiB) copied, 4.10824 s, 16.3 MB/s  $ sha256sum FileCarve.001   3e64100044099b10060f5ca3194d4d60414941c7cb26437330aba532852a60cd  FileCarve.001  $ find splits/ -type f -print0 | xargs -0 cat | sha256sum  25b37f28204895e5d0b1cb160c5fa599d15188baf7e529ccc92a10fdb3f0515a  -  

But splitting the file in 1 kilobyte segments (1000 bytes) seems to work just fine.

$ dd if=FileCarve.001 bs=512 | split -b1k - splits/img  131072+0 records in  131072+0 records out  67108864 bytes (67 MB, 64 MiB) copied, 2.06029 s, 32.6 MB/s  $ sha256sum FileCarve.001   3e64100044099b10060f5ca3194d4d60414941c7cb26437330aba532852a60cd  FileCarve.001  $ find splits/ -type f -print0 | xargs -0 cat | sha256sum  3e64100044099b10060f5ca3194d4d60414941c7cb26437330aba532852a60cd  -  

Why are they different? Is there something I don't understand about the way blocks work on a storage device?

In response to a comment: I did clear out the split/ directory on each run.

How to update R on Linux mint

Posted: 10 Nov 2021 07:19 AM PST

I am not able to update R version 3.* on 4.*

What I have done according to this page:

I checked /etc/apt/sources.list    #deb cdrom:[Linux Mint 19.2 Tina - Release amd64 20190729]/ bionic contrib main non-free  

I ran:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9  [sudo] heslo pro linux:      Executing: /tmp/apt-key-gpghome.H9fjVZrS2l/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9  gpg: klíč 51716619E084DAB9: „Michael Rutter <marutter@gmail.com>" 1 nový podpis  gpg: Celkový počet zpracovaných klíčů: 1  gpg:         nové podpisy: 1  linux@linux-HP-Pavilion-dv6-Notebook-PC:~$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'  linux@linux-HP-Pavilion-dv6-Notebook-PC:~$ sudo apt install r-base  Načítají se seznamy balíků… Hotovo  Vytváří se strom závislostí         Načítají se stavové informace… Hotovo  r-base je již nejnovější verze (3.4.4-1ubuntu1).  Následující balíky byly nainstalovány automaticky a již nejsou potřeba:    libllvm9 linux-headers-4.15.0-20 linux-headers-4.15.0-20-generic    linux-image-4.15.0-128-generic linux-image-4.15.0-20-generic    linux-image-4.15.0-74-generic linux-modules-4.15.0-128-generic    linux-modules-4.15.0-20-generic linux-modules-4.15.0-74-generic    linux-modules-extra-4.15.0-128-generic linux-modules-extra-4.15.0-20-generic    linux-modules-extra-4.15.0-74-generic  Pro jejich odstranění použijte „sudo apt autoremove".  0 aktualizováno, 0 nově instalováno, 0 k odstranění a 245 neaktualizováno.  linux@linux-HP-Pavilion-dv6-Notebook-PC:~$ sudo apt install r-base  Načítají se seznamy balíků… Hotovo  Vytváří se strom závislostí         Načítají se stavové informace… Hotovo  r-base je již nejnovější verze (3.4.4-1ubuntu1).  Následující balíky byly nainstalovány automaticky a již nejsou potřeba:    libllvm9 linux-headers-4.15.0-20 linux-headers-4.15.0-20-generic    linux-image-4.15.0-128-generic linux-image-4.15.0-20-generic    linux-image-4.15.0-74-generic linux-modules-4.15.0-128-generic    linux-modules-4.15.0-20-generic linux-modules-4.15.0-74-generic    linux-modules-extra-4.15.0-128-generic linux-modules-extra-4.15.0-20-generic    linux-modules-extra-4.15.0-74-generic  Pro jejich odstranění použijte „sudo apt autoremove".  0 aktualizováno, 0 nově instalováno, 0 k odstranění a 245 neaktualizováno.  linux@linux-HP-Pavilion-dv6-Notebook-PC:~$ r -- version    Příkaz 'r' nebyl nalezen, ale je možné jej nainstalovat pomocí:    sudo apt install r-cran-littler    linux@linux-HP-Pavilion-dv6-Notebook-PC:~$ R --version  R version 3.4.4 (2018-03-15) -- "Someone to Lean On"  Copyright (C) 2018 The R Foundation for Statistical Computing  Platform: x86_64-pc-linux-gnu (64-bit)    R is free software and comes with ABSOLUTELY NO WARRANTY.  You are welcome to redistribute it under the terms of the  GNU General Public License versions 2 or 3.  For more information about these matters see  http://www.gnu.org/licenses/.  

The version is still 3.4.4.

What is an effective way to automatically append file extensions to extensionless files?

Posted: 10 Nov 2021 08:02 AM PST

I wrote a bash script today during my lunch break that finds extensionless files in a directory and appends a file extension to those files.

The script is relatively long because I added a bunch of flags and stuff like directory selection and whether to copy or overwrite the file, but the meat and potatoes of its functionality can be replicated simply with this:

#recursively find files in current directory that have no extension  for i in $(find . -type f ! -name "*.*"); do      #guess that extension using file      extfile=$(file --extension --brief $i)      #select the first extension in the event file spits something weird (e.g. jpeg/jpe/jfif)       extawk=$(echo $extfile | awk -F/ '{print $1}')      #copy the file to a file appended with the extension guessed from the former commands      cp -av $i $i.$extawk  done  

It's a bit tidier in my actual script—I just wanted to split commands up on here so I could comment why I was doing things.

My question: Using find in combination with file in the manner I have chosen is likely not the most fool-proof way to go about doing this—what is the best way to recursively guess and append extensions for a bulk group of diverse filetypes among several directories?

fail2ban / FirewallD error: invalid port/service `1-65535' specified

Posted: 10 Nov 2021 08:57 AM PST

I am running a CentOS 8.4 server. When I do a systemctl status firewalld I see the daemon is active and running, but I see the following error repeated five times:

ERROR: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.4 (nf_tables): invalid port/service `1-65535' specified

FirewallD version is 0.8.2.

The error disappears when I stop fail2ban.

Any thoughts on what may be causing this?

Thank you.

Taskwarrior Question : Howto show completed projects?

Posted: 10 Nov 2021 08:06 AM PST

to show all completed tasks the command is in Taskwarrior :

task status:completed all

but what is the command for showing only the completed projects

(not including the completed tasks !)

How to mount a xfs volume to centOS 7 ec2 instance /home directory

Posted: 10 Nov 2021 08:05 AM PST

I created t2.medium instance and attached ebs volume to the instance

Here are some useful information.

sudo pvs

  PV         VG      Fmt  Attr PSize    PFree  /dev/xvdb1 vg_home lvm2 a--  <200.00g    0  

sudo vgs

  VG      #PV #LV #SN Attr   VSize    VFree  vg_home   1   1   0 wz--n- <200.00g    0  

sudo lvs

 LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert    lv_home vg_home -wi-a----- <200.00g  

lsblk

NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT  xvda                202:0    0   50G  0 disk  └─xvda1             202:1    0   50G  0 part /  xvdb                202:16   0  200G  0 disk  └─xvdb1             202:17   0  200G  0 part    └─vg_home-lv_home 253:0    0  200G  0 lvm  

lsblk -lf

NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT  xvda  xvda1           xfs               0356e691-d6fb-4f8b-a905-4230dbe62a32   /  xvdb  xvdb1           LVM2_member       qSmSpW-MRuF-WrUE-jJL8-N182-xOgA-57kdkB  vg_home-lv_home xfs               b4fadb7e-714c-4cdd-a5dd-43df5ef19b84  

So I need to mount vg_home-lv_home to /home directory.

I can mount this volume by running sudo mount /dev/vg_home/lv_home /home

Then its mounted. After that, I terminated my ssh session and try to ssh again. ssh -i <key> centos@<ec2_public_ip>. I can't ssh into ec2 instance, error is Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

It makes sense, because I mounted /dev/vg_home/lv_home to /home. and .ssh folder has gone from /home

Then I restarted the ec2 instance and I can ssh it again.

So my question is how can I mount xfs volume to /home directory?

I created a mountpoint /mnt/home and copied /home then unmounted from mnt/home and mounted to /home. Then I can't connected to ec2 instance at all (with restart).

So what is the best practice/method to mount a volume to ec2 instance /home directory?

-Thank you

Excessive CPU usage with vlock as tmux lock-command

Posted: 10 Nov 2021 09:49 AM PST

I am running tmux, configured to lock my sessions via /etc/tmux.conf:

set-option -g lock-command "/usr/bin/vlock -c"  set-option -g lock-after-time 300  

(The aim is to replace GNU screen -- to see if it behaves better with the various terminal emulators I use -- which has idle 300 lockscreen in its config.)

Every now and again, if I allow a session to lock and leave it for a few days, I can return to the session to find that vlock is consuming most of my CPU (top shows %CPU at 96-98):

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND  19002 root      20   0   48176   8888   1040 R  98.7  1.8  13:00.60 vlock  

While this is happening, a large number of log entries occur in both /var/log/secure and /var/log/audit/audit.log -- one or two every second, e.g.:

==> /var/log/audit/audit.log <==  type=USER_AUTH msg=audit(1502738594.043:4705): pid=19002 uid=0 auid=0 ses=14 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=? acct="root" exe="/usr/bin/vlock" hostname=? addr=? terminal=pts/0 res=failed'    ==> /var/log/secure <==  Aug 14 20:23:14 hostname.local vlock[19002]: pam_unix(vlock:auth): auth could not identify password for [root]  Aug 14 20:23:14 hostname.local vlock[19002]: pam_succeed_if(vlock:auth): requirement "uid >= 1000" not met by user "root"  

None of the tty consoles appear to be locked -- they all appear logged out. The tmux process appears to be the owner of the vlock process (at least, according to ps):

# ps -ef | grep vlock  root     19002  4102  0 Aug09 ?        00:21:35 /usr/bin/vlock -c  root     25318 24147  0 20:41 pts/7    00:00:00 grep --color=auto vlock    # ps -ef | grep 4102  root      4102     1  0 Aug02 ?        00:00:00 tmux new-session -t root  root     19002  4102  0 Aug09 ?        00:22:25 /usr/bin/vlock -c  

I guess the ? suggests that both tmux and vlock have 'divorced' themselves somehow from their respective terminals, but I don't know how to resolve, short of kill -9 19002.

I also guess that the audit.log entries mean a missing SELinux exception, but this only seems to happen after a few days of vlock running, where I'd have thought a problem there would always happen.

Again, I guess the pam_succeed_if messages in secure suggest that something is attempting to validate username/password and failing because the UID of root is less than 1000, but I can't find the process doing that. Besides, I have no users with UID >= 1000, because I haven't set other users up yet. Again, I would expect this to be a problem all the time, rather than just after a few days.

If I connect via SSH and allow tmux to either reattach or merge sessions (tmux new-session -t $USER), I can see the same session as before; if that session then idles for 5 mins, I can use another SSH session to see the second instance of vlock, this time owned by tmux, and sshd:

root     26751 22688  0 21:02 pts/4    00:00:00 /usr/bin/vlock -c  root     22688 22681  0 20:22 pts/4    00:00:00 tmux new-session -t root  root     22681   838  0 20:22 ?        00:00:00 sshd: root@pts/4  root       838     1  0 Aug02 ?        00:00:00 /usr/sbin/sshd -D  

Pertinent versions, that I can think of:

  • /etc/redhat-release: CentOS Linux release 7.3.1611 (Core)
  • uname -a: Linux server.local 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • tmux -V: tmux 1.8
  • vlock -v: 1.15.5

I'm not wedded to vlock if a more-suitable alternative exists in Base or EPEL. If not, I guess I'll try setting lock-command to tmux detach-client to force a disconnection rather than a lock, but I did like the locking paradigm.

What else can I look at to prevent this spin-wait problem? For its perceived faults, GNU Screen never seemed to take up resources like this...

Update #1

OK, I can reliably recreate this now:

  1. Login to the server via SSH
  2. Create/attach the tmux session (I do this in my login script, FWIW)
  3. Allow that session to idle and start locking
  4. Kill the SSH client on my workstation (i.e. an unclean shutdown of my client)
  5. vlock will start spinning

I suppose I can get around it using the following in a script, which I execute using a per-minute cron job:

ps -ef                            \  | grep -F '/usr/bin/vlock'        \  | grep -Fv 'grep'                 \  | awk '$6 == "?" { print $2 }'    \  | xargs -r kill -9  

...but that feels like a bit of a hack.

Better suggestions are welcome.

Installing Packages in PyCharm

Posted: 10 Nov 2021 09:05 AM PST

I'm using Mint Cinnamon (very new) and tryign to get some packages in PyCharm. When I use the package installer for Numpy or Pandas I get the error message:

collect2: error: ld returned 1 exit status  

And if I try to upgrade pip in the terminal I get:

PermissionError: [Errno 13] Permission denied: 'download.py'  

What steps should I take to get these packages into PyCharm. Project interpreter is '/usr/bin/python3.4

How to script with systemd-cgtop?

Posted: 10 Nov 2021 09:01 AM PST

The manpage for systemd-cgtop says that if there is no attached tty it will do one iteration and then print it out, saying that this would be useful in scripts.

However when I try to do this from a script, it does not work as advertised:

#!/bin/bash  line=$(systemd-cgtop|grep ezdose)  echo $line  

Running the script as so:

$ bash test.sh  (hangs with no output)  

How do you work this?

Why only one active group at a time?

Posted: 10 Nov 2021 08:22 AM PST

As far as I understand the users in Unix system can belong to multiple groups and one of them will become the primary group for that user. Others will be supplementary groups. All of this User/Group infrastructure is facilitated by /etc/group and /etc/passwd files.

Now group permission of the user is determined exclusively by the active group which can be changed by newgrp command. The active group on login is the primary group defined in /etc/passwd file. So the question is what is the fundamental reason on why the designers chose to have this concept of a single active group even though allowing the user to have more than one supplementary groups? What would be the issue if all the groups were active simultaneously?

mpd to remote dlna

Posted: 10 Nov 2021 09:21 AM PST

I currently use an mpd with 4 configured outputs, wired to speakers in the ceilings as home-made "multiroom" audio system.

I would like to add wireless speakers, e.g. one like this.

The question is:

How can I tell mpd that there is an output which is in fact remote a dlna/upnp (even aiyplay would be fine) ip-device ?

Is it possible at all ?

Edit 1:

I found a way, though through pulseaudio and not dlna (which could be a use for one of my Raspberry Pis).

Case insensitive search in man pages

Posted: 10 Nov 2021 08:59 AM PST

Is there a way to search man pages case-insensitively? Using the '/' search feature matches exact case.

No comments:

Post a Comment