Tuesday, November 9, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


dnf update not working in CentOS

Posted: 09 Nov 2021 09:22 AM PST

Unable to run dnf update command in CentOS8. Below error occurred while,

Failed to open log file: /var/log/hawkey.log.

tracker-miners-fs-3 process eats RAM in Feodra 35

Posted: 09 Nov 2021 09:14 AM PST

I noticed recently that my computer suddenly freezed with some frequency. I saw that it was because swap memory was being used a lot, and I found tracker-miners-fs-3 was the process that was demanding a lot of memory. Once I left my computer working and when I returned, that process was using like 10GB of RAM and there were like 2GB of swap being used.

This started happening recently, I imagine after some update, and is very anoying because I have to check constantly how much RAM it's using and kill it if necessary. And if I forget, my computer freezes.

These are the specs of my computer

             .',;::::;,'.                adrian@fedora            .';:cccccccccccc:;,.            -------------         .;cccccccccccccccccccccc;.         OS: Fedora release 35 (Thirty Five) x8       .:cccccccccccccccccccccccccc:.       Host: Aspire A515-51 V2.02     .;ccccccccccccc;.:dddl:.;ccccccc;.     Kernel: 5.14.16-301.fc35.x86_64    .:ccccccccccccc;OWMKOOXMWd;ccccccc:.    Uptime: 1 hour, 3 mins   .:ccccccccccccc;KMMc;cc;xMMc:ccccccc:.   Packages: 2560 (rpm), 3 (flatpak)   ,cccccccccccccc;MMM.;cc;;WW::cccccccc,   Shell: zsh 5.8   :cccccccccccccc;MMM.;cccccccccccccccc:   Resolution: 1920x1080   :ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:   DE: GNOME 41.1   cccccc:0MMKxdd:;MMMkddc.;cccccccccccc;   WM: Mutter   ccccc:XM0';cccc;MMM.;cccccccccccccccc'   WM Theme: Adwaita   ccccc;MMo;ccccc;MMW.;ccccccccccccccc;    Theme: Adwaita-dark [GTK2/3]   ccccc;0MNc.ccc.xMMd:ccccccccccccccc;     Icons: Adwaita [GTK2/3]   cccccc;dNMWXXXWM0::cccccccccccccc:,      Terminal: gnome-terminal   cccccccc;.:odl:.;cccccccccccccc:,.       CPU: Intel i7-8550U (8) @ 4.000GHz   :cccccccccccccccccccccccccccc:'.         GPU: Intel UHD Graphics 620   .:cccccccccccccccccccccc:;,..            Memory: 7309MiB / 19873MiB     '::cccccccccccccc::;,.  

Is there a way to fix this?

How to combine and apply multiple commands to each line read from a file, pass the output to create multiple bigquery tables from files in gcs

Posted: 09 Nov 2021 08:51 AM PST

I have multiple .parquet files in each of the subfolders inside a folder in cloud storage. Each of the sub folders are table names and all the files inside a subfolder has to be loaded in that table. I need to create a script that can create multiple tables (each for a subfolder) and load the files inside that subfolder into the respective table created.

parent_folder/table1/*.parquet (contains multiple parquet files along with some other data)

parent_folder/table2/*.parquet

parent_folder/table3/*.parquet

each subfolder table(n) has abc.parquet,def.parquet,..... along with a metadata folder and a schema file ( I need to consider only .parquet files for loading and skip others).

I need to create table1, table2, table3 in bigquery and load all parquet files in folders table1,2 and 3 into respective tables.

I found something like this one below, where the names of all the files with full path are written to a txt file and do a while loop to read each line (file path) and pass them to bq create command.

gsutil ls "gs://bucket/foldername/*.csv" > tableslist.txt    while read p ; do bq load --autodetect --replace=true --source_format=parquet dataset.tableName $p ; done < tableslist.txt  

In my case I have multiple subfolders, so I am writing subfolders path to the txt file and then want to pass each line as argument to above command where dataset.tablename will have name of each subfolder, but the problem is I need to again append names of all parquet files (/*.parquet) to the argument $p.

Basically I need to combine these scripts.

bq load \  --source_format=PARQUET \  dataset.table1 \  "gs://mybucket/parent_folder/table1/*.parquet"  
bq load \  --source_format=PARQUET \  dataset.table2 \  "gs://mybucket/parent_folder/table2/*.parquet"  

and so on. Say I have 100 tables with table1,table2,.. and need to create 100 tables by looping with the above script.

Kindly help with this or suggest on any alternate ways to do this. Thanks.

Installing new GPU with drivers

Posted: 09 Nov 2021 08:04 AM PST

I am currently upgrading my PC from an AMD 5700XT to an RTX 3070 which use different drivers (duh).

The drivers i currently have installed are the xf86-video-amdgpu Packages from arch as well as openCL and some other amd related Packages:

libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau libva-vdpau-driver lib32-libva-vdpau-driver amdvlk lib32-amdvlk

Should i uninstall those packages BEFORE or AFTER installing my new gpu? Any other precautions I should take?

Unstable WiFi Connection/Ping in Manjaro

Posted: 09 Nov 2021 07:48 AM PST

I have this issue to where my ping will be very unstable, this has been an ongoing problem for quite a while now, and I'm not sure if it is a hardware or software problem, because I had this issue when I used Linux mint in the past, and now I'm on Manjaro and still have the same issue. I monitor this by pinging my public IP in the terminal, and what will happen is that it will often go from a normal ping to a very high ping, and sometimes it will just disconnect entirely. I run sudo systemctl restart NetworkManager as a temporary fix to this when the connection drops.

Here are some examples of what I see:

Fluctuating ping:

64 bytes from 68.110.153.215: icmp_seq=1058 ttl=64 time=2.78 ms  64 bytes from 68.110.153.215: icmp_seq=1059 ttl=64 time=74.7 ms  64 bytes from 68.110.153.215: icmp_seq=1060 ttl=64 time=45.9 ms  64 bytes from 68.110.153.215: icmp_seq=1061 ttl=64 time=177 ms  64 bytes from 68.110.153.215: icmp_seq=1062 ttl=64 time=2448 ms  64 bytes from 68.110.153.215: icmp_seq=1063 ttl=64 time=6074 ms  64 bytes from 68.110.153.215: icmp_seq=1064 ttl=64 time=5164 ms  64 bytes from 68.110.153.215: icmp_seq=1066 ttl=64 time=5419 ms  64 bytes from 68.110.153.215: icmp_seq=1067 ttl=64 time=7070 ms  64 bytes from 68.110.153.215: icmp_seq=1068 ttl=64 time=6071 ms  64 bytes from 68.110.153.215: icmp_seq=1069 ttl=64 time=6120 ms  64 bytes from 68.110.153.215: icmp_seq=1070 ttl=64 time=6055 ms  64 bytes from 68.110.153.215: icmp_seq=1071 ttl=64 time=5052 ms  64 bytes from 68.110.153.215: icmp_seq=1072 ttl=64 time=4051 ms  64 bytes from 68.110.153.215: icmp_seq=1073 ttl=64 time=3027 ms  64 bytes from 68.110.153.215: icmp_seq=1074 ttl=64 time=2022 ms  64 bytes from 68.110.153.215: icmp_seq=1075 ttl=64 time=1021 ms  64 bytes from 68.110.153.215: icmp_seq=1076 ttl=64 time=19.3 ms  64 bytes from 68.110.153.215: icmp_seq=1077 ttl=64 time=88.4 ms  64 bytes from 68.110.153.215: icmp_seq=1078 ttl=64 time=4.23 ms  64 bytes from 68.110.153.215: icmp_seq=1079 ttl=64 time=3.19 ms  64 bytes from 68.110.153.215: icmp_seq=1080 ttl=64 time=3.43 ms  64 bytes from 68.110.153.215: icmp_seq=1081 ttl=64 time=7.42 ms  64 bytes from 68.110.153.215: icmp_seq=1082 ttl=64 time=3.89 ms  64 bytes from 68.110.153.215: icmp_seq=1083 ttl=64 time=825 ms  64 bytes from 68.110.153.215: icmp_seq=1084 ttl=64 time=1086 ms  64 bytes from 68.110.153.215: icmp_seq=1085 ttl=64 time=2146 ms  64 bytes from 68.110.153.215: icmp_seq=1086 ttl=64 time=1163 ms  64 bytes from 68.110.153.215: icmp_seq=1087 ttl=64 time=142 ms  64 bytes from 68.110.153.215: icmp_seq=1088 ttl=64 time=4.26 ms  64 bytes from 68.110.153.215: icmp_seq=1089 ttl=64 time=3.54 ms  64 bytes from 68.110.153.215: icmp_seq=1090 ttl=64 time=313 ms  64 bytes from 68.110.153.215: icmp_seq=1091 ttl=64 time=3.07 ms    

Sometimes cutting out entirely:

64 bytes from 68.110.153.215: icmp_seq=2583 ttl=64 time=2.63 ms  64 bytes from 68.110.153.215: icmp_seq=2584 ttl=64 time=2.88 ms  64 bytes from 68.110.153.215: icmp_seq=2585 ttl=64 time=3.10 ms  64 bytes from 68.110.153.215: icmp_seq=2586 ttl=64 time=8.05 ms  64 bytes from 68.110.153.215: icmp_seq=2591 ttl=64 time=3.33 ms  64 bytes from 68.110.153.215: icmp_seq=2592 ttl=64 time=279 ms  64 bytes from 68.110.153.215: icmp_seq=2593 ttl=64 time=1950 ms  64 bytes from 68.110.153.215: icmp_seq=2594 ttl=64 time=957 ms  64 bytes from 68.110.153.215: icmp_seq=2595 ttl=64 time=2.09 ms  From 192.168.0.44 icmp_seq=2622 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2623 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2624 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2625 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2626 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2627 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2628 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2629 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2630 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2631 Destination Host Unreachable  From 192.168.0.44 icmp_seq=2632 Destination Host Unreachable    

Here are some outputs I've seen people post that you might find useful. I'm not sure exactly what information you'll need though.

Output of networkctl -a:

[linkio@linkio ~]$ networkctl -a  WARNING: systemd-networkd is not running, output will be incomplete.    IDX LINK   TYPE     OPERATIONAL SETUP    1 lo     loopback n/a         unmanaged    2 enp8s0 ether    n/a         unmanaged    3 wlo1   wlan     n/a         unmanaged    4 anbox0 bridge   n/a         unmanaged    4 links listed.  

Output of lsusb:

[linkio@linkio ~]$ lsusb  Bus 001 Device 003: ID 05c8:036e Cheng Uei Precision Industry Co., Ltd (Foxlink) Webcam  Bus 001 Device 002: ID 8087:8000 Intel Corp. Integrated Rate Matching Hub  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub  Bus 002 Device 002: ID 062a:4101 MosArt Semiconductor Corp. Wireless Keyboard/Mouse  Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  

Output of lspci:

[linkio@linkio ~]$ lspci  00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 09)  00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09)  00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 09)  00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04)  00:16.0 Communication controller: Intel Corporation 8 Series HECI #0 (rev 04)  00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)  00:1c.0 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 1 (rev e4)  00:1c.1 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 2 (rev e4)  00:1c.2 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 3 (rev e4)  00:1c.5 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 6 (rev e4)  00:1d.0 USB controller: Intel Corporation 8 Series USB EHCI #1 (rev 04)  00:1f.0 ISA bridge: Intel Corporation 8 Series LPC Controller (rev 04)  00:1f.2 SATA controller: Intel Corporation 8 Series SATA Controller 1 [AHCI mode] (rev 04)  00:1f.3 SMBus: Intel Corporation 8 Series SMBus Controller (rev 04)  08:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL810xE PCI Express Fast Ethernet controller (rev 07)  09:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8188EE Wireless Network Adapter (rev 01)  

If you need anymore information, I'll edit the question with said information.

Display grep output whith line breaks inside a if statement in a bash script

Posted: 09 Nov 2021 09:55 AM PST

I want to validate a text file with a script.

The file to validate is:

FDFHDK JKL  1545665 152  HDKFHDK UHG  YRYRUBH DFG  867HDKE WER  

Valid lines must match the regex '[A-Z]{7}+[[:space:]]+[A-Z]{3}'.

If all the lines are valid, the script shows a message saying that the file is OK.

If at least there is one line that don't match with the regex, the script show a message and display the lines that don't match the regex.

The script is:

#!/usr/bin/env bash  result=""  output=$(grep -vE '[A-Z]{7}+[[:space:]]+[A-Z]{3}' "$1" |wc -l)  if [[ $output > 0 ]]  then    echo "These lines don't match:"    result="${resultado} $(grep -vE '[A-Z]{7}+[[:space:]]+[A-Z]{3}' "$1") \n"    echo -e $result  else    echo "The text file is valid"  fi    

The expected output is

These lines don't match  FDFHDK JKL  1545665 152  867HDKE WER  

But I'm getting

These lines don't match:  FDFHDK JKL 1545665 152 867HDKE WER  

So the actual script is not taking the line break into account.

How can I install "sudo" without root access in termux?

Posted: 09 Nov 2021 07:56 AM PST

I am using termux Linux emulator. I tried most of the Linux commands and most of it worked but when I tried sudo it shows

No superuser binary detected.  Are you rooted?  

I think it needs the device rooted. How can I run sudo without root in termux Android Linux emulator?

Udev: Auto-Configuring webcam rule fires but doesn't work when plugging in. But works when calling "udevadm trigger"

Posted: 09 Nov 2021 07:29 AM PST

Okay, I'm at a complete loss: I'm trying to auto-configure my webcam.

When running "udevadm trigger" while the device is already plugged in everything works and the cam is configured. But when I just plug the device in, the rule fires, the script runs but the camera isn't configured. I'm using the following udev rule+script:

/etc/udev/rules.d/99-local-webcam.rules:

SUBSYSTEM=="video4linux", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="636b", RUN+="/bin/sh -c '/etc/webcam_config.sh'"  

/etc/webcam_config.sh

#!/bin/sh  echo " I'm running" >> /tmp/webcamlog  sleep 3  v4l2-ctl --set-ctrl=white_balance_temperature_auto=0 >/tmp/webcamout 2>&1  sleep 1  v4l2-ctl \  --set-ctrl=contrast=32 \  --set-ctrl=saturation=61 \  --set-ctrl=hue=-5 \  --set-ctrl=gamma=100 \  --set-ctrl=gain=0 \  --set-ctrl=sharpness=3 \  --set-ctrl=backlight_compensation=80 \  --set-ctrl=exposure_auto=1 \  --set-ctrl=exposure_absolute=178 \  --set-ctrl=exposure_auto_priority=0 \  --set-ctrl=focus_auto=0 \  --set-ctrl=focus_absolute=280 \  --set-ctrl=white_balance_temperature=3794 \  --set-ctrl=brightness=0 >/tmp/webcamout 2>&1  

Stuff I've already figured out

  1. According to journalctl the rule is run in both instances
  2. My script also runs, because both testfiles in /tmp/ are created
  3. There is no error or any other message in /tmp/webcamout
  4. If I increase the value of the "sleep" commands the camera doesn't come available before that time is up, so maybe the device isn't available when the script runs? But I would expect some kind of error?!
  5. It doesn't make any difference if I'm using PROGRAM= instead of RUN+=

Could anybody point me in the right direction, where the problem might be? It's a noname camera (Logilink LL1) and I'm runing Kubuntu 20.04 LTS.

Binary who use library

Posted: 09 Nov 2021 07:28 AM PST

is it possible to know from which binary a particular library is used?

I would like to delete a file.so but i don't know if it's used by a program?!

limits.conf priorities

Posted: 09 Nov 2021 07:31 AM PST

Does a wildcard have priority over an individual limit? In the example below, will the limit for * be applied to all users including bar or all users except bar?

bar             -       nofile          65536    *               -       nofile          16384  root            -       nofile          16384  

Thanks in advance for the help

Trying to remotely change Windows 10 user account properties from Linux with "net sam" command - getting an error

Posted: 09 Nov 2021 07:04 AM PST

I have a desktop computer on the LAN running Windows 10 Pro with two users - the priviledged "w10_admin" and restricted "w10_user" and 192.168.1.100 local IP address. I need to change w10_user's account credentials (namely switch "Account is disabled" property) from a Linux machine on the same LAN running Arch with samba installed.

I can get the proper user list from W10 machine with: $ net -S 192.168.1.100 -U w10_admin%pass rpc user

w10_admin  w10_user  Administrator  Guest  

I can remotely shutdown W10 machine with $ net -S 192.168.1.100 -U w10_admin%pass rpc shutdown -t 0 -f

Yet if I try to use net sam command (as per the samba's manual) to change the "Account is disabled" property of the w10_user

# net -S 192.168.1.100 -U w10_admin%pass sam set disabled w10_user yes

I keep getting Could not find name w10_user message.

# net -S 192.168.1.100 -U w10_admin%pass sam list users gives zero output, so I may suppose sam and rpc modes work differently, with sam not being enabled on the W10 machine.

So, how do I properly change Windows 10 user account properties from Linux CLI remotely?

Parse comma separated string ignoring commas between quotes

Posted: 09 Nov 2021 09:35 AM PST

I have a comma separated string that could contain quoted elements with commas. For example:

issuer=C = US, O = "DigiCert, Inc.", CN = DigiCert High Assurance TLS Hybrid ECC SHA256 2020 CA1  

I would like to extract the different elements ignoring the quoted comma (DigiCert, Inc.).

The script should be POSIX compliant and run on non GNU systems.

How to troubleshoot audio problem in Fedora?

Posted: 09 Nov 2021 06:56 AM PST

How to troubleshoot my audio problem so i can fix it ? i don't know where to start and what causing it. Here's some information i can give, and will gladly provide more if anyone can help / guide me :( , i don't add my dmesg yet, because i don't know what should i provide from it

the symptomps to provide this error is random. Deleting ~/.config/pulse folder can temporary fix the problem, but in the future it can back to error again

i'm using asus-g751 because mine was G752VY. It's the same card

sudo cat /etc/modprobe.d/alsa-base.conf  options snd_hda_intel model=asus-g751  
aplay -l  **** List of PLAYBACK Hardware Devices ****  card 0: PCH [HDA Intel PCH], device 0: ALC668 Analog [ALC668 Analog]    Subdevices: 1/1    Subdevice #0: subdevice #0  card 0: PCH [HDA Intel PCH], device 1: ALC668 Digital [ALC668 Digital]    Subdevices: 1/1    Subdevice #0: subdevice #0  
pactl info  Server String: /run/user/1000/pulse/native  Library Protocol Version: 35  Server Protocol Version: 35  Is Local: yes  Client Index: 45  Tile Size: 65472  User Name: jeremykenn  Host Name: asus-pc  Server Name: pulseaudio  Server Version: 15.0  Default Sample Specification: s16le 2ch 44100Hz  Default Channel Map: front-left,front-right  Default Sink: alsa_output.pci-0000_00_1f.3.analog-stereo  Default Source: alsa_input.pci-0000_00_1f.3.analog-stereo  

enter image description here

building a json from jq

Posted: 09 Nov 2021 07:32 AM PST

I want to generate a json file in jq like this below :

{    "cpe": "dabb8fbd-d7be-4175-abb4-c628bb8cf1b5",    "ps": [ "Obev" ],    "ets": 5,    "pMap": {        "aik": ["1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-1", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-2", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-3", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-4", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-5"]      }  

Here is what I am trying in jq -

inner2=$(jq -n --arg aik "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-1", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-2", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-3", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-4", "1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-5" \                '$ARGS.named')    res=$(jq -n   --arg cpe "App" \                --arg ps "["Obev"]" \                --arg ets 5 \                --argjson pMap "$inner2" \                '$ARGS.named')  

but it doesn't returns the JSON format as expected. ets value if 5 which is int hence no quotes expected but it generates one pMap value generates like this "aik": {"1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-1, 1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-2, 1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-3, 1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-4, 1~4-b7-4c-bb-b~od1.y.1..aiq~s-an-6~-a-5"}

here as per desired op the format is not getting generated

ps value is also not getting generated as per desired op

Any help would be great

Wi-Fi search does not occur Debian 10

Posted: 09 Nov 2021 07:09 AM PST

I'm new to working with Linux, before that I had onу Linux Mint.

I installed Debian 11 from a bootable USB stick. I tried to install from the netinst version of iso, but I could not connect to the hidden network, so I installed the main system without a graphical shell.

After that, I decided to install from the image of the base system (4.7GB) with the GNOME shell. The installer required an ap for the network card, I added this file to iso and booted the system without access to the Internet.

I expected to be able to connect to the hidden network without problems, but in the system settings under Wi-Fi there was an inscription "Missing firmware".

  • My network card is Realtek.
  • And USB Wi-Fi Modem.

I downloaded a lot of non-free deb packages to a USB flash drive - realtek-firmware, Linux-firmware-non-free, but nothing changed.

I noticed that when the system starts, when the components are loaded, the last gray inscription says the absence of rt28070.bin. I found it and uploaded it to the /etc/firmware folder.

After that, the inscription "Missing firmware" disappeared. But no network was detected, it also did not work to connect directly.

Please tell me how to fix this error?

Need the exit code of condition function when a Bash "while" loop terminates

Posted: 09 Nov 2021 08:48 AM PST

I'm trying to get the exit code of the function that I'm repeatedly calling in the "condition" part of a Bash while loop:

while <function>; do       <stuff>   done   

When this loop terminates due to an error, I need the exit code of <function>. Any thoughts on how I can get that?

Count and return how many replacements were done with sed in a file

Posted: 09 Nov 2021 08:08 AM PST

I have a large JSON file in which I want to replace one string with another. It should not, but it might happen that this string would be used in a context where I do not want to replace it.

I know how many times it is in the file in the right context so I would like to also print how many occurrences of the string were replaced with sed. How can I do that?

For finding and replacing the string I use:

sed -i "" "s/my_string/new_string/g" my_file.json  

Note that I'm on mac but I would need it for Linux too, like:

sed -i "s/my_string/new_string/g" my_file.json  

I know I could just run a grep to find the string in the file and return the count like this:

grep -o my_string my_file.json | wc -l  

but that's not what I'm asking. I am asking if there is a way how to do the same as any text editor (word, notepad, geany, ...) does -- if I give a string, it tells me how many times it saw this string and replaced it with another.

More information -- it will run in a Bash script so if there would be another better way, I am open to that.

Want bash script to get txt file all possible combinations

Posted: 09 Nov 2021 08:41 AM PST

I have following characters, numbers and special characters:

012345789  !@#$%  ABCDEFGHIJKLMNOPQRSTUVWXYZ  abcdefghijklmnopqrstuvwxyz  

I want a bash script that create a txt file that have all the possible 8 digit combination of above for example:

aK@05B!8 and so on. Can you please suggest me a script?

What does the output of `ll /proc/self/fd/` (from `ll /dev/fd`) mean?

Posted: 09 Nov 2021 09:12 AM PST

Related, but not duplicates:

  1. /dev/fd inconsistency
  2. How does /dev/fd relate to /proc/self/fd/?
  3. Why does process substitution result in a file called /dev/fd/63 which is a pipe?

On Ubuntu 18.04 and 20.04, where Ubuntu has alias ll='ls -alF' defined in ~/.bashrc, I see the following outputs for the "floppy drive" /dev/fd devices:

For ls:

$ ls /dev/fd  0  1  2  3  

For ll:

$ ll /dev/fd  lrwxrwxrwx 1 root root 13 Nov  5 11:46 /dev/fd -> /proc/self/fd/  

I can see /dev/fd is a symbolic link to /proc/self/fd/, so I ll that and see:

$ ll /proc/self/fd/  total 0  dr-x------ 2 username username  0 Nov  8 19:01 ./  dr-xr-xr-x 9 username username  0 Nov  8 19:01 ../  lrwx------ 1 username username 64 Nov  8 19:01 0 -> /dev/pts/6  lrwx------ 1 username username 64 Nov  8 19:01 1 -> /dev/pts/6  lrwx------ 1 username username 64 Nov  8 19:01 2 -> /dev/pts/6  lrwx------ 1 username username 64 Nov  8 19:01 3 -> 'socket:[8239772]'  lr-x------ 1 username username 64 Nov  8 19:01 4 -> /proc/29512/fd/  
  1. What does all this stuff mean?
  2. How do floppy disks work here?
  3. What is /dev/pts/6, and why do 0, 1, and 2 all point to it?
  4. What is 'socket:[8239772]'?
  5. What is /proc/29512/fd/?
  6. What is the historical use of and description for /dev/fd?

Related:

  1. my previous question which inspired me to ask this question: '-sh: syntax error: unexpected "("' when attempting process substitution on an embedded Linux device with `bash`

Replacing counter in a filename for all files in a directory

Posted: 09 Nov 2021 09:08 AM PST

After importing several 1000 Files from a camera onto a hard drive I realized, that the counter, used in the process of renaming the file - does not start from 0. This leads to file structure like this:

My vacation 2018-05-03 2345.jpg  My vacation 2018-05-03 2346.jpg  My vacation 2018-05-04 2347.jpg  

I would like to batch rename all those files in a wax, that the index starts with 0

My vacation 2018-05-03 0001.jpg  My vacation 2018-05-03 0002.jpg  My vacation 2018-05-04 0003.jpg  

I went already through some topics dealing with batch renaming files and adding an counter/index (bash loop) or usig rename/prename but I was not able to get a working solution for my case.

Basically, I would like to match the part of the filename with the description and the date using the regular expression .*(\d\d\d\d\-\d\d\-\d\d){1} and add a suffix counter on the end.

Connecting to Bluetooth but Connection Failed: No audio endpoints registered

Posted: 09 Nov 2021 08:07 AM PST

I do dual boot Kali-Linux with Windows11. So the problem is I want to connect with my Bluetooth speaker (JBL GO), but unfortunately I cannot connect. I use both GUI and CLI to connect to my speaker. It was working perfectly before. I can connect in Windows, but not in my Kali.

Here is the message using GUI: GUI

And here is the message using CLI:

$ bluetoothctl                                                                                    Agent registered  [bluetooth]# agent KeyboardOnly  Agent is already registered  [bluetooth]# default-agent   Default agent request successful  [bluetooth]# power on  Changing power on succeeded  [bluetooth]# scan on  Discovery started  [CHG] Controller 00:1A:7D:DA:71:15 Discovering: yes  [CHG] Device 30:C0:1B:95:1D:C3 RSSI: -51  [CHG] Device 30:C0:1B:95:1D:C3 TxPower: 0  [bluetooth]# remove 30:C0:1B:95:1D:C3  [DEL] Device 30:C0:1B:95:1D:C3 JBL GO  Device has been removed  [NEW] Device 30:C0:1B:95:1D:C3 JBL GO  [CHG] Device 30:C0:1B:95:1D:C3 TxPower: 0  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 00001108-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000110d-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb  [bluetooth]# trust 30:C0:1B:95:1D:C3  [CHG] Device 30:C0:1B:95:1D:C3 Trusted: yes  Changing 30:C0:1B:95:1D:C3 trust succeeded  [bluetooth]# pair 30:C0:1B:95:1D:C3  Attempting to pair with 30:C0:1B:95:1D:C3  [CHG] Device 30:C0:1B:95:1D:C3 Connected: yes  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 00001101-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 00001108-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb  [CHG] Device 30:C0:1B:95:1D:C3 ServicesResolved: yes  [CHG] Device 30:C0:1B:95:1D:C3 Paired: yes  Pairing successful  [CHG] Device 30:C0:1B:95:1D:C3 ServicesResolved: no  [CHG] Device 30:C0:1B:95:1D:C3 Connected: no  [bluetooth]# connect 30:C0:1B:95:1D:C3  Attempting to connect to 30:C0:1B:95:1D:C3  Failed to connect: org.bluez.Error.Failed  [bluetooth]# exit  

I check the bluetooth.service:

$ sudo systemctl status bluetooth  ● bluetooth.service - Bluetooth service       Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled; vendor preset: disabled)       Active: active (running) since Sat 2021-11-06 08:32:21 WIB; 47min ago         Docs: man:bluetoothd(8)     Main PID: 3844 (bluetoothd)       Status: "Running"        Tasks: 1 (limit: 38347)       Memory: 2.0M          CPU: 439ms       CGroup: /system.slice/bluetooth.service               └─3844 /usr/libexec/bluetooth/bluetoothd    Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSink/sbc  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSource/sbc  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSink/sbc_xq_453  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSource/sbc_xq_453  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSink/sbc_xq_512  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSource/sbc_xq_512  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSink/sbc_xq_552  Nov 06 09:12:21 [hostname] bluetoothd[3844]: Endpoint registered: sender=:1.87 path=/MediaEndpoint/A2DPSource/sbc_xq_552  Nov 06 09:12:30 [hostname] bluetoothd[3844]: /org/bluez/hci0/dev_30_C0_1B_95_1D_C3/sep1/fd0: fd(42) ready  Nov 06 09:12:30 [hostname] bluetoothd[3844]: profiles/audio/avctp.c:avctp_connect_browsing_cb() Browsing: connect to 30:C0:1B:95:1D:C3: Connection refused (111)  

I already try rfkill, alsa but no result. But when I try these command:

$ pulseaudio -k  $ pulseaudio -D  $ pulseaudio --start  

, it works. But I cannot find my device in pavucontrol. Now I'm stuck :| GUI Connected

Here is my version of Kali:

$ uname -a  Linux [my_hostname] 5.14.0-kali2-amd64 #1 SMP Debian 5.14.9-2kali1 (2021-10-04) x86_64 GNU/Linux  

Bluetoothctl version: bluetoothctl: 5.61

Blueman version: 2.2.2-1

EHOSTUNREACH error creating a TCP connection between instances on the same EC2 subnet

Posted: 09 Nov 2021 07:31 AM PST

I have a client EC2 instance and a server EC2 instance, both residing in the same EC2 subnet. The subnet routing table is configured so that this is a "local" route.

When I run EC2 networking insights for a TCP path from the client instance to the server instance at port 22, it finds a path successfully. To me, that suggests that security groups and ACLs are configured in a way that permits this traffic.

When I run telnet <server-ip> 22 from the client, I get "No route to host." In strace, I see that connect(2) is failing with errno=EHOSTUNREACH.

To me, that kinda suggests security groups / ACLs / issues with intermediate routing?
 But when I run telnet from the server to the client with random ports, which I know nothing's listening on, I get the expected "Connection refused."

Especially weird is that I can see the communication fine in the VPC flow log. The action is "ACCEPT", and the log-status is "OK." So that kinda suggests that security groups / ACLs are fine?

When I run route(8) from the client instance, I see that the gateway for the server instance is 0.0.0.0, which suggests it's just available on the local broadcast domain. So it doesn't seem like there are any intermediate routers.

Does anyone have any idea of what's going on here, or what I could do to debug further? Ideally, I'd have other ways of getting on the instance, or at least accessing its logs.

It kinda seems like the server instance might be rejecting the traffic at the level of IP, without getting to TCP? But that seems strange, because the server's IP layer shouldn't even know about the TCP port.

I believe that sshd is running on the server instance, so if I can resolve this networking issue, then presumably I can access my instance.

The "Pro Audio" profile in PipeWire for audio devices / sound cards

Posted: 09 Nov 2021 09:00 AM PST

After upgrading from PulseAudio to PipeWire my sound devices now feature the "Pro Audio" profile however I've Googled for it and haven't found anything interesting. You can find it by running PulseAudio Volume Control and see it under the Configuration tab for your devices.

Would be nice if someone could, I don't know, glance over PipeWire sources (I'm not a C programmer per se and I don't really understand digital audio aside from the very basics) and explain what it is and why the user may want to use it instead of e.g. something which is offered by default.

tar fails on symlinks when called as python subprocess

Posted: 09 Nov 2021 08:20 AM PST

After upgrading my debian from buster to bullseye, my yocto build process fails in do_package: Function failed: perform_packagecopy with hundereds of messages like

tar: ./dir/linkfile: Cannot change mode to rwxrwxrwx: No such file or directory  

(linkfile is any symbolic link in the directory). The actual copy action has been executed, the files and their symlinks are present with the expected mode settings. It looks like the symlink is copied before the file it points to and tar believes it needs to adapt the mode of the symlink, but gets an error, because the file the symlink is pointing to does not exist (but this is just an assumption).

Unfortunally, I can't reproduce the error executing

tar -cf - -C /full/path/image -p -S . | tar -xf - -C /full/path/package  

directly. This does not give any error. Just when executed as a python subprocess from out the yocto scripting hell, I get these errors. Just in case, the tar is

$ tar --version  tar (GNU tar) 1.34  

How to Grep nmap output?

Posted: 09 Nov 2021 06:53 AM PST

I have a massive scan.gnmap file:

Host: 1.1.1.1 ()    Status: Up  Host: 1.1.1.1 ()    Ports: 80/open/tcp//http//nginx/, 443/open/tcp//ssl|http//nginx/    Ignored State: filtered (4998)  Host: 2.2.2.2 (foo.com) Status: Up  Host: 2.2.2.2 (foo.com) Ports: 80/open/tcp//http//awselb|2.0/, 443/open/tcp//ssl|http//Apache httpd 2.4.41 (() PHP|5.3.29)/ Ignored State: filtered (4998)  Host: 3.3.3.3 (bar.com) Status: Up  Host: 3.3.3.3 (bar.com) Ports: 25/open/tcp//smtp?///    Ignored State: filtered (4999)  Host: 4.4.4.4 ()    Status: Up  Host: 4.4.4.4 ()    Ports: 80/open/tcp//http//Microsoft-Azure-Application-Gateway|v2/, 443/open/tcp//ssl|https//Microsoft-Azure-Application-Gateway|v2/ Ignored State: filtered (4998)  Host: 5.5.5.5 (foobar.com)  Status: Up  Host: 5.5.5.5 (foobar.com)  Ports: 80/open/tcp//http?///, 443/open/tcp//ssl|https?///   Ignored State: filtered (4998)  Host: 6.6.6.6 ()    Status: Up  Host: 6.6.6.6 ()    Ports: 80/open/tcp//http//Microsoft IIS httpd 10.0/, 443/open/tcp//ssl|http//Microsoft IIS httpd 10.0/, 454/open/tcp//ssl|upnp//Microsoft IIS httpd/, 1221/open/tcp//http//Microsoft HTTPAPI httpd 2.0 (SSDP|UPnP)/, 4022/open/tcp//dnox?///, 4024/open/tcp//tnp1-port?///, 7654/open/tcp//unknown///   Ignored State: filtered (4993)  

I'm trying to pull out all of the HTTP services while appending the port number (including services on port 1221, 454, and 443), but my attempts have failed:

$ awk '/open/{print $2" "$5}' scan.gnmap | sed -e 's/\// /g' | awk '/http/{print $1":"$2}'    1.1.1.1:80  2.2.2.2:80  4.4.4.4:80  5.5.5.5:80  6.6.6.6:80  

What is the simplest method for pulling out all of the HTTP host:port combinations?

How to capture WOL packets?

Posted: 09 Nov 2021 08:33 AM PST

I used

sudo tcpdump -v -i eth0 ether proto 0x0842 or udp port 9  

but didn't see anything when WakeMeOnLan from NirSoft wakes the computer.


The same with Wireshark

enter image description here

Working acpi kernel options for Asus FX503VD?

Posted: 09 Nov 2021 09:07 AM PST

On kernel version 4.15.0-sabayon, the only way to load X is with the kernel options:

acpi_osi=! acpi_osi='Windows 2009'  

(and acpi=off but that's radical and leaves me with no sensors). Otherwise I get unresponsive black screen and no obvious error in the X.org log.

The problem with this option is that it turns off the Elan 1200 touchpad (not only for me, other people complain about it as well).

So I'm looking for other (if possible tested) kernel options which might work on my laptop (or similar). I've tested already many permutations of different windows versions and modeset and acpi_rev_override=5 and pcie_port_pm=off, but obviously I can't cover them all so if anyone had success with this, please share.

Add .ucode driver in Debian installer

Posted: 09 Nov 2021 08:07 AM PST

When I install Debian, installer request network connection. But Debian can't found my Ethernet card (Intel(R) Dual Band Wireless-AC 8260).

I use non-free installer and try put .ucode file in /firmware/ folder on USB (from here), but it not work!

I also try renamed iwlwifi-8000 in iwlwifi-8260, but it also not work.

Big thanks for your response!

Mouse click integration with SSH client, on command line, not just vim?

Posted: 09 Nov 2021 09:24 AM PST

In vim, you can use the option :set mouse=a, and then (if your SSH client supports it) you will be able to simply click and the cursor will move, rather than having to use the arrow keys or whatnot.

I realize that vim switches to the 'alternate screen'. I'm just wondering if there's a way to use such integration on the 'main' screen also. If so, are there any shell script interpreters that handle this?

Right now I'm using bash, and sometimes I type a quite long command, and have to correct something mid-way through. If there was an alternative to bash which was reasonable, or an extension to bash which handles mouse interaction I would be pleased. Do you know what I need to make this work?

Further I'm interested in mysql but let's start with the main command line.

Display result of a command right aligned in terminal

Posted: 09 Nov 2021 07:05 AM PST

I have a script that goes through many different checks and I use the success, failure functions defined in /etc/init.d/functions to clearly show the action result on the terminal.

That works great, except in some cases where I print a bit more text, I then get the result box displayed over my text:

/usr/share/app/lib/lib_mylib.so lib[ OK ]o matches as expected

Where I'd like it to be displayed:

/usr/share/app/lib/lib_mylib.so lib_mylib.so matches as expected [ OK ]

Looking around I saw that /etc/init.d/functions is using a variable RES_COL to position where to print the result field. If /etc/sysconfig/init exists then RES_COL is taken from there, set by default to 60 chars.

I've tried export RES_COL=100 after sourcing /etc/init.d/functions to no avail. Furthermore I'd like the result field to be right-aligned with the terminal window and not having to hard-code any value for that. Any idea?

No comments:

Post a Comment