Thursday, October 14, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Making Bash send this error to std error

Posted: 14 Oct 2021 10:46 AM PDT

While writing some Lua as a backend for my LuaTeX code I noticed the following. For background, here is the Lua code. This version is standard Lua. But you don't really need to understand Lua to understand what the function is doing.

I needed a function that would return both standard output and error to Lua, and hence to TeX.

Since Lua doesn't have a library function that does this, I had to roll one myself.

This version writes standard output to a file, and redirects standard error to standard output. Then it reads them both and returns them. This isn't particularly pretty, but better alternatives are not obvious.

local function exec_cmd(command, stdout_message, stderr_message)     local filename=os.tmpname()     local cmd = string.format(command .. " 2>&1 1> %s", filename)     local pipe = io.popen(cmd)     local stderr = pipe:read("*all")     pipe:close()     local f = assert(io.open(filename, "r"))     local stdout = f:read("*all")     f:close()     os.remove (filename)     if stdout ~= nil and stdout ~= '' then        print(string.format(stdout_message, stdout))     end     if stderr ~= nil and stderr ~= '' then        error(string.format(stderr_message, stderr))     end  end  

Today, while in a state of momentary confusion, I wrote the following code as the argument command to the function above.

"wkhtmltopdf searchpath(foo.html) foo.pdf"  

So this command gets passed to the shell:

wkhtmltopdf searchpath(foo.html) foo.pdf 2>&1 1> /tmp/lua_vyOiay  

for some suitable temporary file.

This gives the error, if typed directly on the shell (and forgetting about the Lua, which has served its explanatory purpose)

bash: syntax error near unexpected token `('

But the interesting thing about this is that this error doesn't appear to go to standard output. At least, the above command does not collect it, and I wasn't able to collect it any other way.

So, in the interests of bullet-proofing my Lua function, here are my questions.

  1. What is going on above with that nonsense command, and why isn't the error being sent to stderr? This is just for my information.
  2. What can I do (if anything) to make sure that I collect the stderr string, and interrupt my TeX program as it should be interrupted?

Bash: command substitution with background job

Posted: 14 Oct 2021 10:43 AM PDT

I'm trying to fire and forget a process within a function in bash. I'd this function to return a status corresponding to the fact the process has indeed been fired and retrieve output of the function to get the PID of the sub-process. So I wrote that:

my_ping() {      # ... param check which potentially return 1        ping "$1" &      local pid      pid="$!"      echo "$pid"      return 0  }  

When calling it with command substitution, the function blocks and never returns (it does not block outside of command substitution)

main() {        # my_ping www.google.com # does not block and print PID      # Blocks waiting for ping to terminate    local mp_pid    mp_pid=$(my_ping www.google.com)  }    main "$@"  

I don't get why the function blocks in that situation, I tried various approach (setsid, disown etc...) unsuccessfully but I just don't quite grasp what is happening. Any pointer to understand this situation?

Packages with broken dependencies

Posted: 14 Oct 2021 09:37 AM PDT

I am unable to install any debian packages because gdebi complains about packages with broken dependencies. Then I ran pkexec synaptic and found the culprits. Packages libicu_dev, libicu60 and libicu60:386 have broken dependencies.

How can I fix it?

dpkg doesn't even recognize they are installed.

How to fix these broken dependencies? Any clues?

apt-get update error in termux

Posted: 14 Oct 2021 09:27 AM PDT

Get:1 https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease [4009 B] Err:1 https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF Get:2 http://ftp.harukasan.org/kali kali-rolling InRelease [30.6 kB] Err:2 http://ftp.harukasan.org/kali kali-rolling InRelease The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository devel@kali.org Reading package lists... Done W: GPG error: https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF E: The repository 'https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: GPG error: http://ftp.harukasan.org/kali kali-rolling InRelease: The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository devel@kali.org E: The repository 'http://http.kali.org/kali kali-rolling InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.

mount: /: mount point not mounted or bad option (fresh Gentoo installation)

Posted: 14 Oct 2021 09:17 AM PDT

Just rebooted gentoo install from livecd, and it seems like nothing is writable. On boot I get this error as it tries to remount the root filesystem read/write:

mount: /: mount point not mounted or bad option  Root filesystem could not be mounted read/write  

My wifi interface also failed to start, but I think I know how to fix it... If the root filesystem worked.

Also here is my /etc/fstab:

dev/nvme0n1p1     /boot     vfat     defaults     2 0  dev/nvme0n1p5     none      swap     sw           0 0  dev/nvme0n1p6     /         ext4     noatime      0 0  

So far I've tried to unmount dev/nvme0n1p6 and remount it as write, but it always gives me /dev/nvme0n1p6 already mounted to /. Any help is appreciated.

Xilinx onload | SFC (Failed to allocate EVQ DMA buffer)

Posted: 14 Oct 2021 09:16 AM PDT

I am trying to use the Xilinx onload high performance user-level network stack however I am running into issues.

04:00.0 Ethernet controller: Solarflare Communications XtremeScale SFC9250 10/25/40/50/100G Ethernet Controller (rev 01)  04:00.1 Ethernet controller: Solarflare Communications XtremeScale SFC9250 10/25/40/50/100G Ethernet Controller (rev 01)  

The onload SFC driver is loaded:

# modinfo sfc|head  filename:       /lib/modules/4.19.0-18-amd64/extra/sfc.ko  version:        5.3.11.1000  license:        GPL  description:    Solarflare network driver  author:         Solarflare Communications and Michael Brown <mbrown@fensystems.co.uk>  srcversion:     A6B4EAB63B29F43716D99FA  

Running sfnt-pingpong within onload wrapper results in failure to allocate EVQ DMA buffer

# onload --profile=latency-best taskset -c 1 sfnt-pingpong tcp xxx.xxx.xxx.xxx  

Message printed to term on execution:

oo:sfnt-pingpong[20328]: netif_tcp_helper_alloc_u: ERROR: Failed to allocate stack (rc=-100)  See kernel messages in dmesg or /var/log/syslog for more details of this failure  

Messages in syslog/dmesg:

[146259.642318] [sfc efrm] efrm_vi_q_alloc: Failed to allocate EVQ DMA buffer  [146259.642432] [sfc efrm] efrm_vi_q_alloc: Failed to allocate EVQ DMA buffer  [146259.642501] [sfc efrm] efrm_vi_q_alloc: Failed to allocate EVQ DMA buffer  [146259.745166] [sfc efrm] efrm_vi_q_alloc: Failed to allocate EVQ DMA buffer  

Internal display gets bypassed when X is started, startx

Posted: 14 Oct 2021 10:55 AM PDT

I'm running CentOS Linux release 8.4.2105, kernel: 4.18.0-305.19.1.el8_4.x86_64. The Dell I'm using has built in Intel graphics, and an NVIDIA Quadro M1000M GPU, running with kmod-nvidia-470.74-1.el8_4.elrepo.x86_64. Machine is a Dell precision 7510 with Xeon E3-1505M I recently ran dnf update....[smile vanishes]

It would appear that the Intel graphics controller is just...gone. So a separate issue, but necessary for explanation, X never started automatically after I installed the Nvidia driver. I would boot up and drop into a terminal, log in, and have to manually execute: startx to get the desktop environment to come up; slight inconvenience but I really didn't care. Anyway, same procedure, on boot I drop into a terminal as usual and this comes up on my laptop's internal display; the LCD, but when I: startx, I only get video on the external display, e.g., HDMI.

output from lspci:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers (rev 07)  00:01.0 PCI bridge: Intel Corporation 6th-10th Gen Core Processor PCIe Controller (x16) (rev 07)  00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 07)  00:14.0 USB controller: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller (rev 31)  00:14.2 Signal processing controller: Intel Corporation 100 Series/C230 Series Chipset Family Thermal Subsystem (rev 31)  00:16.0 Communication controller: Intel Corporation 100 Series/C230 Series Chipset Family MEI Controller #1 (rev 31)  00:17.0 SATA controller: Intel Corporation Q170/Q150/B150/H170/H110/Z170/CM236 Chipset SATA Controller [AHCI Mode] (rev 31)  00:1c.0 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #2 (rev f1)  00:1c.2 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #3 (rev f1)  00:1c.4 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #5 (rev f1)  00:1d.0 PCI bridge: Intel Corporation 100 Series/C230 Series Chipset Family PCI Express Root Port #9 (rev f1)  00:1f.0 ISA bridge: Intel Corporation CM236 Chipset LPC/eSPI Controller (rev 31)  00:1f.2 Memory controller: Intel Corporation 100 Series/C230 Series Chipset Family Power Management Controller (rev 31)  00:1f.3 Audio device: Intel Corporation 100 Series/C230 Series Chipset Family HD Audio Controller (rev 31)  00:1f.4 SMBus: Intel Corporation 100 Series/C230 Series Chipset Family SMBus (rev 31)  00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (2) I219-LM (rev 31)  01:00.0 VGA compatible controller: NVIDIA Corporation GM107GLM [Quadro M1000M] (rev a2)  01:00.1 Audio device: NVIDIA Corporation GM107 High Definition Audio Controller [GeForce 940MX] (rev a1)  02:00.0 Network controller: Intel Corporation Wireless 8260 (rev 3a)  03:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader (rev 01)  3d:00.0 Non-Volatile memory controller: SK hynix PC300 NVMe Solid State Drive 512GB  

Where is Intel VGA controller? Even more troubling in the BIOS, under system information, I see:

Video Controller    Error!  Video BIOS Version  Error!  Video Memory        Error!  Panel Type          Error!  Native Resolution   Error!  

I have my Xorg.0.log and dmesg, but am not positive at the moment on how to attach these (first post here...), will figure this out and up load soon.

Things I have tried to restore the internal monitor:

sudo dnf history undo transaction_num # really wished that would have worked; errored with unable to locate packages  sudo dnf reinstall xorg-x11-drv-intel.x86_64 # reinstall the intel driver  sudo dnf -y reinstall `rpm -qa | egrep -i "xorg|mesa"` # reinstall all of X  sudo dnf reinstall $(rpm -qa | grep mesa) # reinstall mesa  reinstall nvidia driver  removed/renamed /etc/X11/xorg.conf to xorg.conf.BAK  

so far nothing has worked and I am out of ideas.

UPDATE:

# xrandr --listproviders  Providers: number : 1  Provider 0: id: 0x218 cap: 0x1, Source Output crtcs: 4 outputs: 8 associated providers: 0 name:NVIDIA-0  
sudo lsmod | grep -i nv | grep -vw nvme  nvidia_drm             65536  7  nvidia_modeset       1196032  20 nvidia_drm  nvidia              35278848  1212 nvidia_modeset  drm_kms_helper        233472  1 nvidia_drm  drm                   569344  11 drm_kms_helper,nvidia,nvidia_drm  t10_pi                 16384  2 sd_mod,nvme_core  

NetworkManager not handling connections

Posted: 14 Oct 2021 08:50 AM PDT

I am facing a problem where although I am connected to the network I cannot find any connections on my NM applet. I added a VPN configuration also there and whenever I try to log into it i get a prompt that says

Could not find source connection.

My /etc/network/interfaces contents are:

# interfaces(5) file used by ifup(8) and ifdown(8)  # Include files from /etc/network/interfaces.d:  #source-directory /etc/network/interfaces.d    #auto eno1  #iface eno1 inet dhcp    #gateway my_gateway_address    iface eno1 inet static          address my_ip_address          gateway my_gateway_addres  

I have tried re-installing all the network manager packages and I had no luck with making my connections appear...

Here is the output of the nmcli -p -f general device show eno:

===============================================================================                               Device details (eno1)  ===============================================================================  GENERAL.DEVICE:                         eno1  GENERAL.TYPE:                           ethernet  GENERAL.NM-TYPE:                        NMDeviceEthernet  GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/Devices/2  GENERAL.VENDOR:                         Intel Corporation  GENERAL.PRODUCT:                        Ethernet Connection (7) I219-LM  GENERAL.DRIVER:                         e1000e  GENERAL.DRIVER-VERSION:                 3.2.6-k  GENERAL.FIRMWARE-VERSION:               0.5-4  GENERAL.HWADDR:                         E4:54:E8:D6:3A:68  GENERAL.MTU:                            1500  GENERAL.STATE:                          10 (unmanaged)  GENERAL.REASON:                         0 (No reason given)  GENERAL.IP4-CONNECTIVITY:               3 (limited)  GENERAL.IP6-CONNECTIVITY:               3 (limited)  GENERAL.UDI:                            /sys/devices/pci0000:00/0000:00:1f.6/net/eno1  GENERAL.IP-IFACE:                       eno1  GENERAL.IS-SOFTWARE:                    no  GENERAL.NM-MANAGED:                     no  GENERAL.AUTOCONNECT:                    yes  GENERAL.FIRMWARE-MISSING:               no  GENERAL.NM-PLUGIN-MISSING:              no  GENERAL.PHYS-PORT-ID:                   --  GENERAL.CONNECTION:                     --  GENERAL.CON-UUID:                       --  GENERAL.CON-PATH:                       --  GENERAL.METERED:                        unknown  -------------------------------------------------------------------------------  

Here is the output of the nmcli device status:

DEVICE   TYPE      STATE      CONNECTION   docker0  bridge    connected  docker0      eno1     ethernet  unmanaged  --           lo       loopback  unmanaged  --        

I tried managing the device by: sudo nmcli dev set enp8s0 managed yes but without success.

Lastly, here are the contents of /etc/NetworkManager/NetworkManager.conf file:

[main]  plugins=ifupdown,keyfile    [ifupdown]  managed=true    [device]  wifi.scan-rand-mac-address=no  

How do I write a script that creates symbolic links of files found inside folders in source directory to another directory

Posted: 14 Oct 2021 09:56 AM PDT

I'm fairly new to Linux and I have used batch files to do batch tasks easily. I have this script that scans the folders found inside the source folder and then creates a symbolic link off each compressed ZIP archive found inside to the destination folder.

What the script does is that it goes out of the current directory twice, enters a folder called projects, then another folder called example inside and finally into a folder called release.

Within the release folder are a bunch of other folders (i.e version 1, version 2, version 3, etc.) and inside these folders is a .zip file.

The next part of the script is that it goes through the folders version 1, version 2, version 3, etc. and then creates a symbolic file of the .zip file found inside to the destination folder.

This for loop continues on until there are no remaining .zip files to create a symbolic link of.

The script looks like this, there are comments left as a guideline:

@echo off    REM Sets the location of directories to be used in the script    REM The source folder has more folders inside with compressed ZIP archives  set source=%~dp0..\..\projects\example\release    REM The destination folder is where all the compressed ZIP archives will go to  set destination=%~dp0destination    REM A for-loop in-charge of searching for all compressed ZIP archives inside the folders in the source directory  for /D %%i in ("%source%\*") do (      REM A for-loop that grabs every compressed ZIP archives found inside the folders in the source directory      for %%j in ("%%~fi\*.zip") do (          del "%destination%\%%~ni_%%~nj.zip" >nul 2>nul          REM Creates a symbolic link for each compressed ZIP archive found to the destination directory          mklink "%destination%\%%~ni_%%~nj.zip" "%%j" 2>nul      )  )    REM This creates a new line  echo.    REM Displays an error message that the script is not run as an administrator, and a guide for potential troubleshooting if the script is already run as an administrator  if %errorlevel% NEQ 0 echo *** ERROR! You have to run this file as administrator! ***  if %errorlevel% NEQ 0 echo *** If you are getting this error even on administrator, please create the 'destination' folder ***    REM Prompts the user for any key as an input to end the script  pause  

The directory structure and contents looks about like this:

.  └── Example      └── Release          ├── Version 1          │   └── version1.zip          ├── Version 2          │   └── version2.zip          ├── Version 3          │   └── version3.zip          └── Version 4              └── version4.zip    

How would I go about to converting this to a Shell script? I know not every feature in a Windows batch script isn't available in BASH and that's okay because I can omit some parts of the script. Thank you in advance.

export variables in for loop

Posted: 14 Oct 2021 08:31 AM PDT

I have a terraform project with a terraform.tfvars file where I use these variables:

customer_id    = 20  customer_name  = "sd"  alpega_api_url = "efs"  token_url      = "fesf"  oauth_username = "ds"  oauth_password = "dd"  

In some other parts of the project, I use environment variables like this:

API_URL = os.environ["api_url"]  

Hence, when I have to export these variables if I change them. After exporting, I do terraform init and terraform apply to run the project.

I want to automate running this project such that I can run it for more than one customer credentials by automatically changing & exporting the variables and then running the terraform commands. Is it possible via a shell script or something similar?

Modify a string literal in ELF x86_64 file

Posted: 14 Oct 2021 10:06 AM PDT

I have a ELF x86_64 (basically an executable file) and I'd like to replace a string literal within the file (without corrupting the executable file however)... and I should do that programmatically using a Linux bash/sh script...

Which is the simplest approach?

I've read somewhere that sed could be used (like on a regular text file) but there is the limitation that the new string must not be longer than the old one and must be zero-terminated... what if I'd like to replace with a longer string?

Thanks.

Install MDTAP on Rhel8 but it failed

Posted: 14 Oct 2021 08:05 AM PDT


I have a machine with RHEL8 operating system. I have to install Defender Endpoint for Linux, by following the guide: Deploy Microsoft Defender for Endpoint on Linux manually

I came to the passage: yum install mdatp
but I get this error

[root@rhel8]#yum install mdatp  Updating Subscription Management repositories.  Unable to read consumer identity    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.    Kubernetes                                                                                                                                                   0.0  B/s |   0  B     02:00  Errors during downloading metadata for repository 'kubernetes':    - Curl error (28): Timeout was reached for https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml [Connection timed out after 30001 milliseconds]  Error: Failed to download metadata for repo 'kubernetes': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried  

I tried to disable the repository of kubernetes on /etc/yum.repos.d/kubernetes.repo. Relaunched the command "yum install mdatp" and I get this:

[root@rhel8]# yum install mdatp  Updating Subscription Management repositories.  Unable to read consumer identity    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.    packages-microsoft-com-prod                                                                                                                                  9.7 MB/s | 7.9 MB     00:00  Last metadata expiration check: 0:00:15 ago on Thu 14 Oct 2021 10:54:14 AM CEST.  Dependencies resolved.  =============================================================================================================================================================================================   Package                                     Architecture                         Version                                    Repository                                                 Size  =============================================================================================================================================================================================  Installing:   mdatp                                       x86_64                               101.45.00-1                                packages-microsoft-com-prod                                44 M  Installing dependencies:   libatomic                                   x86_64                               8.4.1-1.el8                                InstallMedia                                               23 k   mde-netfilter                               x86_64                               100.69.32-1                                packages-microsoft-com-prod                                36 k    Transaction Summary  =============================================================================================================================================================================================  Install  3 Packages    Total download size: 44 M  Installed size: 157 M  Is this ok [y/N]: y  Downloading Packages:  Error opening file for checksum: /run/media/root/RHEL-8-4-0-BaseOS-x86_64/BaseOS/Packages/libatomic-8.4.1-1.el8.x86_64.rpm  Package "libatomic-8.4.1-1.el8.x86_64" from local repository "InstallMedia" has incorrect checksum  Error: Some packages from local repository have incorrect checksum  

With the command:

[root@rhel8]# dnf repolist  Updating Subscription Management repositories.  Unable to read consumer identity    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.    repo id                                                                                      repo name  InstallMedia                                                                                 Red Hat Enterprise Linux 8.4.0  docker-ce-stable                                                                             Docker CE Stable - x86_64  kubernetes                                                                                   Kubernetes  packages-microsoft-com-prod                                                                  packages-microsoft-com-prod  

If I install the package libatomic from this link libatomic and the package mdatp from this link mdatp, do I destroy the machine?? 😱 How can I manage to install the mdtap command?

Thanks and good evening!

gpg2 -- get fingerprint using script

Posted: 14 Oct 2021 08:12 AM PDT

I am attempting to extract the fingerprint from a GPG2 key. The fingerprint will then be passed to pass init $GPG2_FINGERPRINT for initialization

In the example below I want the fingerprint value 0126E6FFD15E33B8BCE7B748E79142F98581FC60.

$ gpg2 --list-signatures  pub   rsa2048 2021-10-14 [SCEA]        0126E6FFD15E33B8BCE7B748E79142F98581FC60  uid           [ unknown] User 1 (User 1) <user@1.com>  sig 3        E79142F98581FC60 2021-10-14  User 1 (User 1) <user@1.com>  sub   rsa2048 2021-10-14 [SEA]  sig          E79142F98581FC60 2021-10-14  User 1 (User 1) <user@1.com>  

When using --with-colons the subkey fingerprint is also returned. How can I get a clean output without the subkey info?

if I omit --list-keys and use --with-fingerprint instead I get pretty close... expect the warning is displayed: gpg: WARNING: no command supplied. Trying to guess what you mean. I can redirect the warning to get a clean output but I would rather use the correct command

Is there another way I can accomplish this? The end goal is to setup pass with a GPG key via scripting (no user interaction).

$ gpg2 --with-fingerprint --with-colons ./pubring.kbx  gpg: WARNING: no command supplied.  Trying to guess what you mean ...  pub:-:2048:1:E79142F98581FC60:1634220843:::-:  fpr:::::::::0126E6FFD15E33B8BCE7B748E79142F98581FC60:  uid:::::::::User 1 (User 1) <user@1.com>:  sub:-:2048:1:213A9C4C15D3AAA9:1634220843::::  

join two text file in bash that is separated by comma

Posted: 14 Oct 2021 10:14 AM PDT

file 1:

Doe, John, phone123  Dane, Jane, phone124  

file 2

phone123, longdistance, 10mins  phone124, local, 5mins  phone124, longdistance, 6mins  

output

Doe, John phone123 longdistance 10mins  Dane, Jane phone124 local 5mins  Dane, Jane phone124 longdistance 6mins  

So far, I have

join -1 1 -2 3 -o 2.1,2.2,1.1,1.2,1.3 file2.txt file1.txt > output.txt  

it works if file 1 and 2 is separated by only space without "," but when I put the comma in the file it outputs blanks.

Is there really no way to set socks or proxy in Xfce as simply as in Gnome?

Posted: 14 Oct 2021 07:45 AM PDT

I've been reading some articles on how to set an HTTP proxy or a socks server with Xfce, and one of the solutions was to add some lines to /etc/environment and then logout and log back in. Not very nice. Moreover, my browser somehow didn't understand the seemingly plain and clear setup with the variables ALL_PROXY and NO_PROXY (both in upper and lower case), and thus stopped working altogether. Another solution was to use dconf-editor or the Gnome network tool, which did the trick, but only for Firefox. Somehow Firefox saw the system settings, while Vivaldi or Brave didn't (not to mention they don't have any proxy settings, but worked as needed in Gnome when I used these tools).

I was surprised that up until now there seemingly is no tool for easy global proxy/socks server setting without using either Gnome or KDE. Is this really true?

Rename file by removing repetitive substrings contained in filenames

Posted: 14 Oct 2021 09:18 AM PDT

I need to rename a bunch of files with the following pattern:

sub-2795479_ses-V1_task-rest_acq-REST1_dir-AP_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_run-01_bold.json  

to

  sub-2795479_ses-V1_task-rest_acq-REST1_dir-AP_run-01_bold.json  

Each filename only contains one type of substring out of 4 possibilities - run-01_ (or run-02_, run-03_, run-04)

Note that the substring run-0[1-4]_ can repeat itself random amount of times in a given file.

I am out of my wits and the closest thing I can find is this question on Stack Overflow. However, based on my limited knowledge in string manipulation, I would love to have more help!!!

Finding specific PNG images and renaming them

Posted: 14 Oct 2021 08:00 AM PDT

I have to find multiple files named logo.png in different subdirectories, and change their names to oldlogo.png, how do I do that?

I already have the beginning, finding the file (each logo.png file is 56431 bytes), but I don't know how to move them to another file, within the same subdirectory.

This is what I have for finding the files:

find -name logo.png -size 56431c  

Crazy clock drift on ancient VM

Posted: 14 Oct 2021 09:12 AM PDT

I am stuck with a Centos 5.3 VM (running on Proxmox) which exhibits huge clock drift. It was configured to run ntpdate every 5 minutes but the clock was still getting out of sync by up to 20 seconds between executions. I've tried running ntpd (and stopping the cron job) but its not reporting any errors / I can't see an ntp.drift file getting created anywhere and the clock is continuing to drift.

I'm running approximately 30 VMs and the same number of containers on the cluster - nothing else exhibits the same issue. Apart from the server address there is not other configuration in /etc/ntp.conf

Need to enable gd for an older version of PHP

Posted: 14 Oct 2021 09:46 AM PDT

The PHP version is 5.6, so quite old. Using apt-get install php5.6-gd won't work any more.

I can locate these gd.so:

/usr/lib/php/20151012/gd.so  /usr/lib/x86_64-linux-gnu/libgd.so.3 -- links to 3.0.0 below  /usr/lib/x86_64-linux-gnu/libgd.so.3.0.0  

To enable gd, I think I have to set up one of these in mods_available, mods_enabled, etc.

I'm guessing I'll need an alias gd.so in a common place which links to one of the above, but where to put it, and which one to link to?

Is there a step-by-step guide on manually setting this up?

Automate locale changes on Linux

Posted: 14 Oct 2021 08:42 AM PDT

I'm finding it quite tricky to programmatically change locales on Ubuntu and CentOS. I find many guides on using the console interface like here, manually stepping through things, but I want to automate my configuration on a new system. What command do I run so that all output from locale will show en_GB.UTF-8 on all of the following so that I can automate this on any new install?

$ locale  LANG=C.UTF-8  LANGUAGE=  LC_CTYPE="C.UTF-8"  LC_NUMERIC="C.UTF-8"  LC_TIME="C.UTF-8"  LC_COLLATE="C.UTF-8"  LC_MONETARY="C.UTF-8"  LC_MESSAGES="C.UTF-8"  LC_PAPER="C.UTF-8"  LC_NAME="C.UTF-8"  LC_ADDRESS="C.UTF-8"  LC_TELEPHONE="C.UTF-8"  LC_MEASUREMENT="C.UTF-8"  LC_IDENTIFICATION="C.UTF-8"  LC_ALL=  

Linux, add to sudoers file programmatically

Posted: 14 Oct 2021 10:41 AM PDT

What is the correct way to update the sudoers file programmatically? Specifically:

  • How can I add ,timestamp_timeout=600 to the end of the Defaults env_reset line in my sudoers files (to increase the sudo nag time to 10 hours), and doing this programmatically and without destroying the system (I tried this once and made my Linux system unbootable and had to reinstall). I have read that chmod 440 might be important for this.
  • I understand that this is dangerous, I understand why it is protected, but these are my home systems where I have a script that runs through dozens of simple configuration changes (and I rebuild those systems fairly regularly also, so it would be useful to me to be able to automate this).
  • I am most interested in how to do with this with standard Linux tools that I can put into a bash script, but I would be very interested to also see how this exact operation is done in Ansible so that I could roll out simple changes like this to all sudoers files on my home network.
  • On this page there is a discussion on the sudoers file, but I don't quite understand the references to visudo -c -f; I think what is being suggested there is: copy the sudoers file, then make changes to that copy, then visudo -c -f to check that the new file is valid, then overwrite sudoers, then chmod 440 on that new file, is that it? I'm not sure of the steps to implement this.

"gpg: error reading key: No public key" when updating manjaro-keyring

Posted: 14 Oct 2021 10:46 AM PDT

I have a super weird issue which has almost been preventing me from installing/updating anything. Anytime pacman tries to update the manjaro-keyring package, I get the error in the title of this post. I have had to temporarily disable GPG checking in my pacman.conf, and I know this is not really an ideal security situation. Are there any known issues with the formatting on the GPG keys?

I'm running gnupg 2.2.29-1 and I've made sure to stay on the stable branch while the issue persists. I was on unstable but force downgraded everything. Rebooted and reregistered keys many times in multiple orders. I'm totally at a loss.

I've visited Manjaro's help site and every Manjaro forum page that even mentions GPG. Suggestions from there unfortunately did nothing to help.

To be specific, on step 4: sudo pacman-key --populate archlinux manjaro

When it tries to append manjaro.gpg keys, I get the "No public key" error twice in a row, then the rest seems to continue normally. I tried continuing anyway, but when I re-enable key checking and run sudo pacman -Syu I get the following:

error: GPGME error: No data  error: GPGME error: No data  error: GPGME error: No data  error: GPGME error: No data  :: Synchronizing package databases...   core                 171.2 KiB  32.2 KiB/s 00:05 [#####################################################################] 100%   extra               1900.0 KiB  6.27 MiB/s 00:00 [#####################################################################] 100%   community              6.7 MiB  8.44 MiB/s 00:01 [#####################################################################] 100%   multilib             175.7 KiB  2.86 MiB/s 00:00 [#####################################################################] 100%  error: GPGME error: No data  error: GPGME error: No data  error: GPGME error: No data  error: GPGME error: No data  error: failed to synchronize all databases (invalid or corrupted database (PGP signature))  

Sorting ls output respecting locale but not ignoring nonalphanumeric characters

Posted: 14 Oct 2021 10:52 AM PDT

Let's say I have a directory with the files _b, a, c, č, d. I would like to sort the files according to the cs_CZ.UTF8 locale but without ignoring the underscore, ie like this: _b a c č d.

Currently, ls (and ls | sort as well) sorts the files like this: a _b c č d. All answers I have found suggest using LC_COLLATE=C, but that changes the ordering to this: _b a c d č (notice that č is now at the end, not between c and d as it is supposed to be).

Is there any way to achieve this goal?

Note that I also care about other characters than underscore, ie I would like a-n.pdf a-p.pdf a.pdf c č d sort in this order and not a-n.pdf a.pdf a-p.pdf c č d. (EDIT: Actually, a.pdf a-n.pdf a-p.pdf c č d is also fine, as long as the non-alphanumeric characters are not ignored.)

The following are not the answers I am looking for:

  • using LC_COLLATE=C as explained above,
  • using shell expansion such as ls _*; ls [^_]* because the question is not only about underscores.

Shift of dates in a CSV file via bash script

Posted: 14 Oct 2021 09:32 AM PDT

Currently I have a file with records like this :

D20211011,S0519,306668,1  D20211004,S1600,306668,1  D20211009,S1604,306668,1  D20211010,S1605,306668,1  D20211006,S1610,306668,1  D20211011,S1611,306668,1  

Assuming that the current date is 20211011, I need to apply a transformation on the rows only where date is less than the current date and that row with date in the past should be updated to current date.

In the example shared above, transformation should be done on rows 2 to 5.

D20211004,S1600,306668,1 -> D20211011,S1600,306668,1  D20211009,S1604,306668,1 -> D20211011,S1604,306668,1  D20211010,S1605,306668,1 -> D20211011,S1605,306668,1  D20211006,S1610,306668,1 -> D20211011,S1610,306668,1  

Is there a method to indicate the last occurrence a loop over lines of an input file?

Posted: 14 Oct 2021 08:05 AM PDT

Suppose I have a file direction with the lines

east  north  south  west  south-west  

and using a loop and echo in a shell script I want to generate this output:

Direction: east  Direction: north  Direction: south  Direction: west  Last direction: south-west  

So in other words I want to do something different with the last line in the script.

Cannot Schedule Audio Volume Change with Cron (tried direct in cron, python, etc...)

Posted: 14 Oct 2021 08:37 AM PDT

I posted this in Raspberry Pi, but was told that it was better suited in a general linux or programming area. So I figured I'd ask here now...

I am putting together a kiosk that should play video. I'm using a NUC with Raspberry Pi Desktop. Everything works but automating the audio with Cron. I work in a school and blasting sound during the day would kind of suck, so I want it to change based on the time of the day.

When run from terminal the following code works:

/usr/bin/amixer set Master 16384  

and

amixer sset 'Master' 16384  

So, I put it into Cron:

15 09 * * * /usr/bin/amixer set Master 16384  

and

43 09 * * * amixer sset 'Master' 16384  

Nothing. Fine. So I make a really simple python script to run (yes, I realize I put it in a system folder, I was planning on moving it, it just kind of ended up there.)

#!/usr/bin/env python3    from subprocess import call  call(["/usr/bin/amixer", "set", "Master", "65536"])  

I make it executable:

chmod +x /etc/python/sound100.py  

Then I call it from the terminal with both:

/etc/python/sound100.py  

and

/usr/bin/python3 /etc/python/sound100.py  

Again, it works. Yay. Into Cron it goes. Neither:

11 10 * * * python3 /etc/python/sound100.py  

nor

11 10 * * * /usr/bin/python3 /etc/python/sound100.py  

Not even

11 10 * * * /etc/python/sound100.py  

Nothing works.

So begins the actual troubleshooting. I check the syslog. Everything runs, but I learn that when I run it as a sudo command it says that the maximum volume is 83 when run as a sudoer. So that means I can't run it as from sudo crontab -e, but I start running it from the user's cron.

Still nothing. So I try running it as a sudoer but with the user beforehand. Nothing again.

Please help me. I just want to adjust the volume automatically without logging into ssh for every NUC we're putting up three times a day until I quit or retire.

Thank you!

Is there anyway to see my REAL DNS server

Posted: 14 Oct 2021 10:36 AM PDT

Is there anyway to see my REAL DNS server?

and I'm not referring to 127.0.0.53 or the router (192.168.0.1), but the real external server in bash?

I'm talking about the ISP DNS, or VPN DNS servers...

Changing default desktop environment

Posted: 14 Oct 2021 09:05 AM PDT

I'm on Fedora 20 and I want to change the default desktop environment from Gnome3 to Gnome classic. I want to do this with the terminal because I can't access the dropdown menu on the login screen (Once I select a user it logs straight in).

I already installed it, all I have need to do now is switch from Gnome3 to Gnome Classic.

How to install glibc version that corresponds to GCC 4.4 on RHEL5

Posted: 14 Oct 2021 10:07 AM PDT

We have a program with executables built on RHEL6 using GCC4.4 and we need to run it on RHEL5.5. But RHEL5.5, by default does not have the necessary version of glibc.

Has anyone faced such an issue and possibly recommend how to install their libraries in this particular case?

No comments:

Post a Comment