Monday, August 2, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to set up a variable in .env file and using it in a .conf file

Posted: 02 Aug 2021 10:32 AM PDT

I have a .conf file that has a label and variable that I'm trying to move to a .env file. How can I accomplish this?

This is what I have in my .conf file

[[inputs.snmp]] #Label      agents = ["1.1.1.1:111","2.2.2.2:111","2.3.3.3:111"] #Variable      version = 2 #Variable  

I'm trying to have something like this in the .env file

VAR_FOR_CONF_FILE='[[inputs.snmp]]\n    agents= ["1.1.1.1:111","2.2.2.2:111","2.3.3.3:111"]\n    version=2'  

I was hoping I could use $VAR_FOR_CONF_FILE in my .conf file instead of [[inputs.snmp]]agents = ["1.1.1.1:111","2.2.2.2:111","2.3.3.3:111"]

but I keep getting this error Error parsing data: line 7: invalid TOML syntax for $VAR_FOR_CONF_FILE (Im not sure if I'm getting this error because I have the syntax wrong in my .env file or I'm declaring $VAR_FOR_CONF_FILE incorrectly in my .conf file)

Am I doing it incorrectly (or is it even possible to do what I'm trying to accomplish)?

(Note: I'm trying to accomplish this so I can simply use $VAR_FOR_CONF_FILE instead of hard coding things in the .conf file)

Fix/Repair Can't find a SQUASHFS superblock

Posted: 02 Aug 2021 09:56 AM PDT

I have an old filesystem backup that I made and compressed into a squashfs. It was stored on an ext4 filesystem, and I suspect it suffered from some bitrot. I don't have a backup of the file. Is there any way I might be able to rescue this filesystem?

$ unsquashfs olddrive.sfs  Can't find a SQUASHFS superblock on olddrive.sfs  

Extract lines into separate files between two non-empty fields in the same column

Posted: 02 Aug 2021 10:39 AM PDT

I've got a csv mappings.csv shown below. I'd like to extract a block of records into separate files relating to each record that has a non-empty first field. The files are shown after mappings.csv.

$ cat mappings.csv  TEST1,,,a,a,a,a  ,,,b,b,b,b  ,,,c,c,c,c  TEST2,,,aa,aa,aa,aa  ,,,bb,bb,bb,bb  ,,,cc,cc,cc,cc  ,,,dd,dd,dd,dd  TEST3,,,aaa,aaa,aaa,aaa  ,,,bbb,bbb,bbb,bbb  

Output files based on mappings.csv is below:

$ cat TEST1.csv  TEST1,,,a,a,a,a  ,,,b,b,b,b  ,,,c,c,c,c  
$ cat TEST2.csv  TEST2,,,aa,aa,aa,aa  ,,,bb,bb,bb,bb  ,,,cc,cc,cc,cc  ,,,dd,dd,dd,dd  
$ cat TEST3.csv  TEST3,,,aaa,aaa,aaa,aaa  ,,,bbb,bbb,bbb,bbb  

I'm able to use awk to print lines that have a non-empty first field, but can't figure out how to expand and print subsequent records up to the next non-empty first field:

$ awk -F',' '$1' mappings.csv  TEST1,,,a,a,a,a  TEST2,,,aa,aa,aa,aa  TEST3,,,aaa,aaa,aaa,aaa  

The other aspect of this problem is separating out the results into separate files. One thing I could do is use the matching record numbers to print out lines between the two. Something kind of like this:

$ awk -F',' '$1 {print NR}' mappings.csv  1  4  8  

Shared library fetching fails if LD_LIBRARY_PATH isn't exported

Posted: 02 Aug 2021 10:36 AM PDT

By looking at /etc/ld.so.conf.d there is a libc.conf file that point to /usr/local/lib that contains the .so file necessary to run my application correctly. Even running ldconfig -v it is showed that the above path is set yet when I launch my program it fails to run the library contained in there. I must export LD_LIBRARY_PATH="/usr/local/lib" in order to correctly execute it but I need it to be set every time a new shell is open, so I tried to add the environment variable either to /etc/environment or /home/user/.profile or even /home/user/.bashrc without any success.

What's the correct way to set that variable permanently and why it is failing to pick the library even though a .conf file is pointing to the correct path?

EDIT:

ldd /usr/local/lib

asant@ANTONIO-PC:~$ ldd /usr/local/lib/libsqlcipher.so          linux-vdso.so.1 (0x00007fff25d9e000)          libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f133d2f2000)          libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f133d2cf000)          libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f133d0dd000)          /lib64/ld-linux-x86-64.so.2 (0x00007f133d6c5000)  asant@ANTONIO-PC:~$ ldd /usr/local/lib/libsqlcipher.so.0          linux-vdso.so.1 (0x00007ffcaede4000)          libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f02bb35d000)          libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f02bb33a000)          libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f02bb148000)          /lib64/ld-linux-x86-64.so.2 (0x00007f02bb730000)  asant@ANTONIO-PC:~$ ldd /usr/local/lib/libsqlcipher.so.0.8.6          linux-vdso.so.1 (0x00007ffe7daa7000)          libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff66585b000)          libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff665838000)          libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff665646000)          /lib64/ld-linux-x86-64.so.2 (0x00007ff665c2e000)  

summarize consecutive lines containing identical values in a specific field using sed (or awk)?

Posted: 02 Aug 2021 10:34 AM PDT

So far I've been able to get around sed's more advanced features like look-ahead/look-behind across multiple lines but I'd like to understand how tasks like the following can be achieved with sed as I have the feeling that my approach of doing this e.g. within python is not necessary and can also be done within a filter pipeline on cmd.

a stripped example of the data coming in is like this:

1b41cf70 0  1cb8dd19 1  620f0b67 2  620f0b67 3  f35d35fe 4  3a6fb62a 5  620f0b67 6  620f0b67 7  620f0b67 8  b958a7ea 9  f35d35fe 10  f35d35fe 11  620f0b67 12  

the first columns width is always identical (contains a shortened hash-value) and the second columns content is completely odered, numerical and without gaps (and therefore potentionally unnecessary besides providing orientation on lenghtier lists).

the desired output would be either like this (putting the index of the last consecutive occurance into an additional column):

1b41cf70 0  1cb8dd19 1  620f0b67 2 3  f35d35fe 4  3a6fb62a 5  620f0b67 6 8  b958a7ea 9  f35d35fe 10 11  620f0b67 12  

or even better with aggregated numbers of repeating values (math expressions (adding) seem to be more easily done with awk but my skills with that are even worse, so this is just to illustrate what other outcomes would be desireable):

1b41cf70 0  1cb8dd19 1  620f0b67 2 +1  f35d35fe 4  3a6fb62a 5  620f0b67 6 +2  b958a7ea 9  f35d35fe 10 +1  620f0b67 12  

I tried to follow several similar but yet different questions found across the SO-space but could not wrap my head around possibly simpler parts possibly leading to a solution like why sed '$!N;/^\([^\ ]\+\)\ [0-9]\+\n\1\ /{P;d}' sampledata will cut lines with indexes 3,7,11 but not 8.

My system has GNU sed version 4.8 and awk version 5.1.0 installed and I'd love to learn how I could use one of them to get this done. And no, this is not homework but lengthy lists of hashes with plenty of redundancy that need to be compacted and compared. ;)

Unix command to cut between strings

Posted: 02 Aug 2021 10:44 AM PDT

my file:

Informatica(r) PMCMD, version [10.2.0 HotFix2], build [1911.0401],  Workflow run status: [Failed]  

Output I need is Failed

Output I am getting is 10.2.0 HotFix2

Command used:

grep "Workflow run status:" test.txt | cut -d'[' -f2 | cut -d']' -f1  

How can sudo be hidden in a command?

Posted: 02 Aug 2021 09:01 AM PDT

On linux mint 20+, I don't have to type "sudo apt upgrade". I only type "apt upgrade", the prompt asks for sudo password and the command is executed with elevated privileges.

How is that achieved?

Should nameservers be separated by comma, or semicolon in .config connman files

Posted: 02 Aug 2021 08:31 AM PDT

I want to create interface-specific config for my Ethernet connection by editing:

/etc/connman/lib/connman/ethernet_<mac>_cable.config  

The docs say that:

Nameservers=servers Comma separated list of nameservers.

but when I manually enter new list of nameservers with:

connmanctl config ethernet_<mac>_cable --nameservers 1.1.1.1 8.8.8.8  

they appear in:

/etc/connman/lib/connman/ethernet_<mac>_cable/settings  

as semicolon separated list:

1.1.1.1;8.8.8.8  

Do these two files use different syntax?

wlan0 not showing up on virtualbox in Kali Linux

Posted: 02 Aug 2021 09:02 AM PDT

Hello I just installed Kali Linux on a virtual box on a Mackbook pro, and when I try ifconfig it just shows me eth0, eth1, lo, as well when I try iwconfig it tells me no wireless extension. I have internet on the virtual box, but how can I make it to it can shows me the wifi connection. As well on the top right network button it doesn't show me the possibility of wifi connection.

Wifi slow when directly connected to router but fast through mobile hotspot

Posted: 02 Aug 2021 09:36 AM PDT

I have had this problem with Mint 18.0 and I installed Mint 20.2 on my laptop hoping the issue would go away. But it hasnt. My mint wifi speed when connected to Home router is around 2mbps where the plan is of 20mbps and I get that 20mbps speed on all the mobile and another windows laptop connected to it. interestingly if I connect my mint laptop to my phone(through hotspot) which is connected to this router I get 20mbps speed on my laptop.

I have no idea whats happening or how to debug the issue. Any advice on how to figure out the issue or solutions would be appreciated. If you need any more information, please ask.

$ iwconfig

wlp3s0    IEEE 802.11  ESSID:"FTTH-BBB6"              Mode:Managed  Frequency:2.432 GHz  Access Point: 14:A7:2B:96:BB:B6               Bit Rate=72.2 Mb/s   Tx-Power=22 dBm               Retry short limit:7   RTS thr:off   Fragment thr:off            Power Management:off            Link Quality=69/70  Signal level=-41 dBm              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0            Tx excessive retries:0  Invalid misc:80   Missed beacon:0    lo        no wireless extensions.    enp2s0    no wireless extensions.  

$ lspci

00:00.0 Host bridge: Intel Corporation Broadwell-U Host Bridge -OPI (rev 09)  00:02.0 VGA compatible controller: Intel Corporation HD Graphics 5500 (rev 09)  00:03.0 Audio device: Intel Corporation Broadwell-U Audio Controller (rev 09)  00:14.0 USB controller: Intel Corporation Wildcat Point-LP USB xHCI Controller (rev 03)  00:16.0 Communication controller: Intel Corporation Wildcat Point-LP MEI Controller #1 (rev 03)  00:1b.0 Audio device: Intel Corporation Wildcat Point-LP High Definition Audio Controller (rev 03)  00:1c.0 PCI bridge: Intel Corporation Wildcat Point-LP PCI Express Root Port #1 (rev e3)  00:1c.2 PCI bridge: Intel Corporation Wildcat Point-LP PCI Express Root Port #3 (rev e3)  00:1c.3 PCI bridge: Intel Corporation Wildcat Point-LP PCI Express Root Port #4 (rev e3)  00:1c.4 PCI bridge: Intel Corporation Wildcat Point-LP PCI Express Root Port #5 (rev e3)  00:1d.0 USB controller: Intel Corporation Wildcat Point-LP USB EHCI Controller (rev 03)  00:1f.0 ISA bridge: Intel Corporation Wildcat Point-LP LPC Controller (rev 03)  00:1f.2 SATA controller: Intel Corporation Wildcat Point-LP SATA Controller [AHCI Mode] (rev 03)  00:1f.3 SMBus: Intel Corporation Wildcat Point-LP SMBus Controller (rev 03)  02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)  03:00.0 Network controller: Intel Corporation Wireless 3160 (rev 93)  04:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon 520 Mobile] (rev 83)  

Mounting anything during gentoo installation breaks everything using official live cd

Posted: 02 Aug 2021 08:29 AM PDT

It doesn't matter what I mount. Even mounting tmpfs (with mount -vt tmpfs none /mnt) doesn't work.

I'm trying to install Gentoo in a VirtualBox VM, but everything stops working after mounting the the root partition (using mount -v /dev/sda2 /mnt). It breaks with btrfs, ext4, vfat and xfs.

mount returns without any errors and prints mount: /dev/sda2 mounted on /mnt..

After mounting, even running ls prints -bash: ls: command not found.

I tried the ISO from 25.07.2021 and 01.08.2021.

I use a GPT partition table and have enabled EFI in the VirtualBox settings. Disabling EFI doesn't help.

# gdisk -l /dev/sda  GPT fdisk (gdisk) version 1.0.7    Partition table scan:    MBR: protective    BSD: not present    APM: not present    GPT: present    Found valid GPT with protective MBR; using GPT.  Disk /dev/sda: 41943040 sectors, 20.0 GiB  Model: VBOX HARDDISK     Sector size (logical/physical): 512/512 bytes  Disk identifier (GUID): 7AAC6D43-015D-458A-866E-B6CEEB08FDC9  Partition table holds up to 128 entries  Main partition table begins at sector 2 and ends at sector 33  First usable sector is 34, last usable sector is 41943006  Partitions will be aligned on 2048-sector boundaries  Total free space is 2014 sectors (1007.0 KiB)    Number  Start (sector)    End (sector)  Size       Code  Name     1            2048         1050623   512.0 MiB   EF00  EFI system partition     2         1050624        41943006   19.5 GiB    8300  Linux filesystem  

Replace var placeholder results in an unwanted new line

Posted: 02 Aug 2021 08:09 AM PDT

I wish to replace ${var} placeholders in a nginx.conf file with env vars loaded from .env file (docker). I choose the ${var} syntax myself in line with docker-compose.

  • content .env file:
    DOMAIN_NAME=sub.domain.net  DB_USER=admin  ...  

Doing sed string replace on this line e.g. is giving me headaches.

  • Text input:
    server_name ${DOMAIN_NAME};  
  • command:
    source .env    export DOMAIN_NAME    sed -i "s/\${DOMAIN_NAME}/$DOMAIN_NAME/g" "$docker_root"/nginx/nginx.conf  
  • desired outcome:
    server_name sub.domain.net;  
  • but what I get is:
    server_name sub.domain.net  ;  

It doesn't even matter what follows the ${var} replacement. If I add a space and a word behind the placeholder, the word also ends up on the second line.

I used envsubst first and saw the same behavior there first. Then I tried with sed wich is doing the same :)

I tried a variety of escape slashes, single quotes and double quotes with no result.

What's going on here?

dd command ruining files

Posted: 02 Aug 2021 07:12 AM PDT

I recently was trying to flash from an IMG file with dd, and it took a lot shorter than normal, and when I checked the drive, it had names like

\u2584\u00bc\u2591+\u03c6\u256bv\u2559.|  

I don't know if I'm being stupid, or if it's a drive error. This is the code I used:

sudo dd if=~/Downloads/tails-amd64-4.20.img of=/dev/sdd1 bs=1M  

How to escape ANSI format on remote SSH command?

Posted: 02 Aug 2021 08:59 AM PDT

I wanted to change the title of the window using the command as described here over SSH, however I kept get getting the error:

033]sh: Hello: command not found  Connection to host closed.  

with the command:

ssh.exe user@host -t 'echo -en "\033];Hello World\007"'  

No matter how I try to escape them, it seems to somehow return error. Tried:

ssh.exe user@host -t 'echo -en "\\033];Hello World\\007"'  ssh.exe user@host -t "echo -en \'\\033];Hello World\\007\'"  

Any idea how to fix this?

sed regex fails to capture the entire paragraph containing the pattern

Posted: 02 Aug 2021 08:13 AM PDT

I have this XML file (example)

<This is a line of text with a year=2020 month=12 in it  This line of text does not have a year or month in it  This year=2021 is the current year the current month=1  This is the year=2021 the month=2/>      <This is a line of text with a year=33020 month=12 in it  This line of text does not have a year or month in it  This year=33020 is the current year the current month=1  This is the year=33020 the month=2/>  

Using the sed installation provided by my Linux distribution ( sed (GNU sed) 4.2.2) I search within this file with the following regexp:

 sed -En 'N;s/\<(This.*2020.*[\s\S\n]*?)\>/\1/gp' test2.txt  

However, it captures only this string:

<This is a line of text with a year=2020 month=12 in it  This line of text does not have a year or month in it  

But I try to capture the entire first paragraph between < and > that contains the pattern.

What am I doing wrong here?

Fail2ban Regex help for banning sshd connection attempts

Posted: 02 Aug 2021 08:45 AM PDT

This is a tricky questions (for me)

I'm trying to setup fail2ban to BAN all connection attempts to my ssh server that don't login.

Now, my issue is.. everything, in the file filter.d/sshd.conf.

for me it's incomprehensible, jibbrish, I simply can't understand the regex (I can't understand regex at all, and believe me, I've tried) in that configuration file.

I want to scan and ban on this line of the log: (since it shows a connection that only connected)

Connection closed by 192.168.0.2 port 12210 [preauth]

now, as I wrote earlier, I have NO idea how or where to write/put it in the configuration file (didn't want to clog the forum with an standard file) This one

so if someone would be so kind of help me what I should write, and where I should put it in the configuration file.

And, if possible, explain (or at least try to) what you're doing?

Scripting with find and awk

Posted: 02 Aug 2021 07:18 AM PDT

I would like to find the port that a process (for example apache2) is listening on and print only this (tcp) port number to a file, file1.txt.

  • Here is the command I tried:

    $ ss -atpln | grep 'apache2' | awk -F':' '{print $2}' > file1.txt  
  • Here is my output (to file1.txt):

    80     *  

How can I ensure that only the port number (80), NOT the '*', is my output?


Edit by Ed Morton to add the important information the OP provided in a comment:

Please note that this sequence from my system:

$ ss -atpln | grep apache2  

Output is:

LISTEN 0 511 :80 *:* users:(("apache2",pid=55338,fd=4),("apache2",pid=55337,fd=4),("apache2",pid=856,fd=4))  

How to match pattern in line and insert it after another pattern

Posted: 02 Aug 2021 07:20 AM PDT

I have a file with 2 lines

1, output /test here      2, output /test here  

I want to transform it like this:

1, output /test 1 here      2, output /test 2 here  

so that the string before the , is copied behind the /test string.

How can I do this with awk or sed?

How to enable auto logout in fish shell?

Posted: 02 Aug 2021 09:14 AM PDT

A quick google search says I could enable auto logout (for text consoles) by setting a TMOUT parameter. However, I discovered later that this would only work with the bash shell.

Is there a way I could set a timer for auto logout if my default shell was fish?

What is the purpose? Security, of course. I want it to lock when it's idle for 1 minute.

New command shortcut setting doesn't work

Posted: 02 Aug 2021 09:13 AM PDT

I want to modify the command of PrintScreen key to one that takes the screenshoot and ask me the name of the file through a pop up window. From terminal below line did the job:

gnome-screenshot -f `zenity --entry`  

But when I put that command in the keyboard shortcuts, it doesn't work, nothing happens:

enter image description here

Note 1: How could I define in the command that saves the screenshot renamed in the Pictures folder?, I couldn't do it. I tried:

gnome-screenshot -f "~/Pictures/"`zenity --entry`    ** (gnome-screenshot:8259): CRITICAL **: 03:28:05.490: Unable to save the screenshot: Error opening file "/home/[username]/~/Pictures/PicTest": No such file or directory  

Note 2: I also notice that using the command I mentioned at the beginning, when I write the name it also takes the first string and the rest is ignored. Let's say I call the pic taken as "Screenshot taken" then the pic is saved only as "Screenshot"

Thanks for your help.

Is it with GNU parallel possible to split on character count, but provide full lines only?

Posted: 02 Aug 2021 09:43 AM PDT

I would like to split an input file on character count (ASCII is fine), combined with new lines as well. That is, every group of 10000 character should be seen as one record to be piped into the child process, but if that 10000th character does not happen to be at the end of line, the whole line should be included (and thus more that 10000 characters are provided). Each line should be considered as a single entity, which cannot be split.

Is that possible with GNU parallel (or possibly with a chain of other tools which might be useful)?

I get "Forbidden You don't have permission to access / on this server" every time I log in

Posted: 02 Aug 2021 10:48 AM PDT

I use Arch Linux.

Every time I logged on, a browser window popped up on its own showing an error message. I did not open the browser, and I didn't go to the website by clicking a link.

The message says

Forbidden

You don't have permission to access / on this server.

Apache/2.4.6 (Red Hat Enterprise Linux) Server at nmcheck.gnome.org Port 80

The message looks like this:

this is what it looks like

I don't know what kind of permission I am lacking here (I am new to Linux).

How to filter ARP-Requests with Nftables using a Raspberry Pi as AP (using hostapd)

Posted: 02 Aug 2021 07:40 AM PDT

I´m trying to filter ARP-requests coming from certain IP-addresses in my network. I tried :

table arp filter {          chain input {                  type filter hook input priority 0; policy drop;                  arp saddr ip 192.168.2.1 counter accept #ISP-Router                  arp saddr ip 192.168.1.100 counter accept #Laptop                  arp operation reply counter accept}}  

It should drop all ARP-requests not coming from either the router or the laptop. But requests send by my smartphone are still recieved by my laptop. (My Pi acts as routed access point, it is connected to the ISP-Router via ethernet and uses interface wlan for AP function.)

Then I tried to use table netdev with ingress hook because (at least in theory) it should resolve first:

table netdev wlan {          chain wlanFilter {                  type filter hook ingress device wlan0 priority 0;                  meta protocol arp counter drop # ARP-requests were still getting from smartphone to laptop, but ARP-Cache on Pi was incomplete afterwards                    meta pkttype {broadcast, multicast} counter drop # didn´t filter ARP Broadcast}}  

I also tried to use the hostapd function ap_isolate=1. Same result.

I use Raspberry Pi OS with kernel version 5.10.17-v7+, hostapd version 2.8-devel, nft version 0.9.6, dnsmasq version 2.80. ip_forward is active and NAT aswell. I wasn´t using a bridge but to be thoroughly: I tried table bridge with similar rules, no success. I then changed the whole setup to bridged access point instead of routed. I tried all rulesets again. Didn´t work either.

Could it be, that Hostapd forwards packets to the local network before packetfilter like Nftables are enforced? Or is there something wrong with my ruleset? Or is it something else altogether?

What is the command in Awesome Window manager to let go of a key that has not been let go of?

Posted: 02 Aug 2021 10:17 AM PDT

My v key is locked up after I use the below snippet in my rc.lua file.

Background

Hotkey combinations are usually all pressed together at the same time.

I am using the function key Fn which works as a key chain only because of the way it works with the firmware on my ThinkPad.

Key chain means you press the Fn key, release it, then press another key.

In other words, key chain keys are not pressed together but sequentially, one after the other.

Setup

My Fn key is XF86WakeUp.

The following below is part of my rc.lua

-- open edit ".vimrc"    awful.key({ "XF86WakeUp" }, "v", function ()    awful.util.spawn("termite -e 'nvim /home/Dropbox/.vimrc'") end,    {description = "Edit .vimrc", group = "Code"}),  

This snippet works just fine; I press Fn, release it, then press v and vim opens.

Just as intended.

Problem

After I have used this keychain, Awesome will not let go of the v key and every time after that when I press the v key, for whatever reason, vim opens.

This is less than ideal.

How to stop this behavior in Awesome?

gpg: keyserver receive failed: No data

Posted: 02 Aug 2021 09:07 AM PDT

I am getting this error when I am trying to install gauge framework.

sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys A04A6C4681484CF1  Executing: /tmp/apt-key-gpghome.cjtfKq6QwL/gpg.1.sh --keyserver hkp://keys.gnupg.net:80 --recv-keys A04A6C4681484CF1  gpg: keyserver receive failed: No data.  

Ubuntu: 18.04.3

'inf' in awk not working the way '-inf' does

Posted: 02 Aug 2021 07:23 AM PDT

Given a single column file of numbers, call it f, the following Awk code will return the maximum value

cat f | awk    '   BEGIN {max = -inf}                         {if ($1>max) max=$1}                      END { print max }                 '  

The same approach to get the minimum doesn't produce anything

cat f | awk '                 BEGIN  {min = inf}                    {if ($1<min) min=$1}                  END {print min}              '  

But if instead of using inf, I start off with min = [some large number], if the number is large enough, depending upon what's in the file, then the revised code works.

Why doesn't inf work, and is there some way to make the min case work like the max case, without having to know what's in the file?

Yum does not seem to recognize the $releasever variable in the Centos repos file

Posted: 02 Aug 2021 08:03 AM PDT

I was trying to use yum on a Centos 7 cluster to install a package, and I was getting the following error:

One of the configured repositories failed (Unknown),   and yum doesn't have enough cached data to continue. At this point the only   safe thing yum can do is fail. There are a few ways to work "fix" this: [...]  

I tried several suggested solutions online (yum clean all; deleting the cache; deleting the repo-databases and rebuilding, etc.) and nothing worked.

After hours of troubleshooting, I managed to find a workaround. On the /etc/yum.repos.d/CentOS-Base.repo file, I uncommented the baseurl line and replaced the $releasever variable with "7" (i.e. the version of the OS). For some reason, yum could not recognize $releasever and could not find the repo.

So instead of:

baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/  

I have:

baseurl=http://mirror.centos.org/centos/7/os/$basearch/  

after which both yum update and yum install seem to work fine. However, I don't know if this is a permanent solution to the issue.

Can someone tell me what's going on and if there's a more proper way to fix this problem?

Thanks.

Match touchpad properly in xorg.conf on Dell XPS 15

Posted: 02 Aug 2021 10:08 AM PDT

I'm trying to set nice options like tap and natural scroll to my Dell's touchpad. Booting X will detect 2 touchpads, one SynPS/2 Synaptics and one DLL touchpad. The SynPS/2 won't get any xevents, they all go to the DLL touchpad, so I disabled the SynPS/2 one and get the following device list:

% xinput -list  ⎡ Virtual core pointer                      id=2    [master pointer  (3)]  ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]  ⎜   ↳ Logitech Gaming Mouse G402                id=12   [slave  pointer  (2)]  ⎜   ↳ Logitech Gaming Mouse G402                id=13   [slave  pointer  (2)]  ⎜   ↳ HID 046a:0023                             id=15   [slave  pointer  (2)]  --- here the SynPS/2 Synaptics Touchpad .... was listed  ⎜   ↳ DLL06E4:01 06CB:7A13 Touchpad             id=16   [slave  pointer  (2)]  ⎣ Virtual core keyboard                     id=3    [master keyboard (2)]      ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]      ↳ Power Button                              id=6    [slave  keyboard (3)]      ↳ Video Bus                                 id=7    [slave  keyboard (3)]      ↳ Video Bus                                 id=8    [slave  keyboard (3)]      ↳ Power Button                              id=9    [slave  keyboard (3)]      ↳ Sleep Button                              id=10   [slave  keyboard (3)]      ↳ Integrated_Webcam_HD                      id=11   [slave  keyboard (3)]      ↳ HID 046a:0023                             id=14   [slave  keyboard (3)]      ↳ Intel HID events                          id=17   [slave  keyboard (3)]      ↳ AT Translated Set 2 keyboard              id=18   [slave  keyboard (3)]      ↳ Dell WMI hotkeys                          id=19   [slave  keyboard (3)]      ↳ Logitech Gaming Mouse G402                id=20   [slave  keyboard (3)]      ↳ HID 046a:0023                             id=21   [slave  keyboard (3)]  

My `/etc/X11/xorg.conf.d/50-touchpad.conf:

Section "InputClass"  Identifier "disable synaptics detection"  MatchVendor "SynPS/2"  Option "Ignore" "on"  EndSection    Section "InputClass"  Identifier "touchpad catchall"  Driver "libinput"  MatchIsTouchpad "on"  #   MatchVendor "DLL06E4:01"  #   MatchDevicePath "/dev/input/event'"  MatchProduct "06CB:7A13"  Option "TapButton1" "1"  Option "TapButton2" "3"  Option "EmulateTwoFingerMinZ" "35"  Option "EmulateTwoFingerMinW" "8"  Option "TapButton3" "2"  Option "VertTwoFingerScroll" "1"  Option "HorizTwoFingerScroll" "1"  Option "VertScrollDelta" "-111"  Option "HorizScrollDelta" "-111"  Option "CoastingSpeed" "8"  Option "CornerCoasting" "1"  Option "CircularScrolling" "1"  Option "CircScrollTrigger" "7"  EndSection  

When I matched the DevicePath to /dev/input/event5 (the path I figured out once I had started X), the touchpad would work as expected about 1/4 of all the times I started an X session. On the other sessions, the touchpad would get bound to different input events. So I tried to match its vendor/device strings, but now the touchpad doesn't get detected at all, although disabling the second touchpad via vendor strings works flawlessly. I also tried the matching patterns which are commented out in the config file.

I also switched the driver from synaptic to the newer libinput - could that cause any problems?

How to find the process with maximum file descriptors?

Posted: 02 Aug 2021 07:11 AM PDT

What is wrong with this for loop? I am trying to find which process has the maximum number of file descriptors. The first command in the for loop ps aux | awk '{print $2}' prints out only the process IDs. I know the first error lsof: illegal process ID: PID is there because the 1st line of the output is PID, but shouldn't the loop work fine for the rest of the lines?

[root@serv5 ~]# for i in `ps aux | awk '{print $2}'` ; do `lsof -p $i | wc -l` ; done  lsof: illegal process ID: PID  lsof 4.82   latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/   latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ   latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man   usage: [-?abhlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s]   [-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]  [+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]  Use the ``-h'' option to get more help information.  -bash: 0: command not found  -bash: 22: command not found  -bash: 4: command not found  -bash: 4: command not found  -bash: 4: command not found  -bash: 4: command not found  ^C  [root@serv5 ~]#  

Why is it executing the output of wc -l instead of going back to the loop?

Or is there another way I can find the process with maximum file descriptors?

Find where inodes are being used

Posted: 02 Aug 2021 09:50 AM PDT

So I received a warning from our monitoring system on one of our boxes that the number of free inodes on a filesystem was getting low.

df -i output shows this:

Filesystem       Inodes  IUsed    IFree IUse% Mounted on  /dev/xvda1       524288 422613   101675   81% /  

As you can see, the root partition has 81% of its inodes used.
I suspect they're all being used in a single directory. But how can I find where that is at?

No comments:

Post a Comment