Friday, January 28, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Excel - Highlight selected/active cell keeping old color

Posted: 28 Jan 2022 12:45 AM PST

there is here (https://stackoverflow.com/questions/365125/how-do-i-set-the-background-color-of-excel-cells-using-vba#365131) some information about highlighting an active/selected cell in excel, but I cannot manage to restore the old background color of the cell that was set prior to the selection. Does anyone have a suggestion how to solve this issue? Thanks!!!

What is the difference between a systemd scope and a systemd slice?

Posted: 28 Jan 2022 12:05 AM PST

What is the difference between a systemd scope and a systemd slice?

Both are for resource management. But what can you do only with a slice and what only with a scope?

How to copy multiple files to different locations through package() in PKGBUILD

Posted: 27 Jan 2022 11:23 PM PST

I am new to PKGBUILD. I created an AUR installer tool and for that I am creating PKGBUILD file. After so much reading and video tutorials, I have come up with this so far. Basically, I have a .desktop file that I need to move to /usr/share/applications. In addition there are some scripts and icons that I want to copy to $HOME/.aurin.

# Maintainer: Suleman Elahi <suleman@ilfrs.ga>  pkgname=aurin  pkgver=0.1  pkgrel=1  pkgdesc="Aurin is AUR packages installer."  arch=("any")  url="https://github.com/suleman-elahi/aurin"  license=('MIT')  depends=('libnotify' 'tk')  source=("git://github.com/suleman-elahi/${pkgname}/")  sha1sums=('SKIP')    package() {      mkdir -p $pkgdir/$HOME/.aurin/      install -D -m755 ./data/aurin.desktop $pkgdir/usr/share/applications/aurin.desktop      xdg-mime default aurin.desktop x-scheme-handler/aurin      install -D -m755 ./data/askpass $pkgdir/$HOME/.aurin/askpass      install -D -m755 ./data/aurin.png $pkgdir/$HOME/.aurin/aurin.png      install -D -m755 ./data/aurin48.png $pkgdir/$HOME/.aurin/aurin48.png      install -D -m755 ./data/install $pkgdir/$HOME/.aurin/install      install -D -m755 ./data/installpkg.sh $pkgdir/$HOME/.aurin/installpkg.sh      install -D -m755 ./data/passprompt $pkgdir/$HOME/.aurin/passprompt      install -D -m755 ./data/runner $pkgdir/$HOME/.aurin/runner      make DESTDIR="$pkgdir/" install  }  

Basically, I am copying files to different locations. But when I install through it, I get:

==> Starting package()...  install: cannot stat './data/aurin.desktop': No such file or directory  ==> ERROR: A failure occurred in package().      Aborting...  [archlabs@archlabs Aurin]$  

I know I am making a mistake it's just I don't know what it is. Need help with this. Thanks.

Failure while connecting external harddrive

Posted: 27 Jan 2022 11:08 PM PST

I am trying to connect a seagate external drive to my PC that runs Manjaro 5.15.16-1. However, it is not detected by the system. It is not listed in /dev/, I can't view it with fdisk -l. But, I can see it through lsusb.

Here is my dmesg output when I plug my drive in.

[ 1298.309372] usb 1-4: new high-speed USB device number 21 using xhci_hcd  [ 1298.464162] usb 1-4: New USB device found, idVendor=0bc2, idProduct=ab44, bcdDevice=48.85  [ 1298.464179] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3  [ 1298.464185] usb 1-4: Product: Backup+ Hub  [ 1298.464190] usb 1-4: Manufacturer: Seagate  [ 1298.464194] usb 1-4: SerialNumber: 01CB0037B432  [ 1298.465693] hub 1-4:1.0: USB hub found  [ 1298.466048] hub 1-4:1.0: 3 ports detected  [ 1298.582970] usb 2-4: new SuperSpeed USB device number 23 using xhci_hcd  [ 1298.602988] usb 2-4: New USB device found, idVendor=0bc2, idProduct=ab45, bcdDevice=48.85  [ 1298.603011] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3  [ 1298.603014] usb 2-4: Product: Backup+ Hub  [ 1298.603020] usb 2-4: Manufacturer: Seagate  [ 1298.603022] usb 2-4: SerialNumber: 01CB0037B432  [ 1298.605760] hub 2-4:1.0: USB hub found  [ 1298.606064] hub 2-4:1.0: 3 ports detected  [ 1299.539488] usb 1-4-port2: Cannot enable. Maybe the USB cable is bad?  [ 1301.095960] usb 2-4.1: new SuperSpeed USB device number 24 using xhci_hcd  [ 1301.113319] usb 2-4.1: New USB device found, idVendor=0bc2, idProduct=ab38, bcdDevice= 1.00  [ 1301.113338] usb 2-4.1: New USB device strings: Mfr=2, Product=3, SerialNumber=1  [ 1301.113346] usb 2-4.1: Product: Backup+ Hub BK  [ 1301.113352] usb 2-4.1: Manufacturer: Seagate  [ 1301.113357] usb 2-4.1: SerialNumber: NA9QY9SY  [ 1301.120343] scsi host2: uas  [ 1301.121106] scsi 2:0:0:0: Direct-Access     Seagate  Backup+ Hub BK   D781 PQ: 0 ANSI: 6  [ 1301.122043] sd 2:0:0:0: Attached scsi generic sg0 type 0  [ 1301.122365] sd 2:0:0:0: [sda] Spinning up disk...  [ 1302.149335] .......................ready  [ 1324.443771] sd 2:0:0:0: [sda] 11721045167 512-byte logical blocks: (6.00 TB/5.46 TiB)  

Any kind of help would be appreciated! edit: I think it should be worth mentioning that the drive is not partitioned.

users command does not show recently added users

Posted: 27 Jan 2022 10:42 PM PST

I have created few users:

sudo useradd bart  sudo useradd marge  sudo useradd lisa  sudo useradd maggie  

These users now exist

$ awk -F: '{ print $1}' /etc/passwd  blueray  bart  marge  lisa  maggie  

However these users does not show up on users command output

$ users  blueray  

What might be the reason?

How to use all disk space available on Linux Mint?

Posted: 27 Jan 2022 09:39 PM PST

I'm new to Linux and Linux Mint - but I recently flashed Linux Mint on my 16 GB USB drive (dual-boot), and for some reason Linux Mint is giving me warnings that there's no space left.

When I go to check how much disk space is available, it's saying that there's only 8.3 GB of space available in total, where there should be 16 GB.

enter image description here

enter image description here

How do I get Linux to use all of the space on my USB?

Am I doing something wrong, or am I just misunderstanding something?

Cheers,

Tom

Can I run both Wine and Wine Staging on the same OS without any interference between both?

Posted: 27 Jan 2022 09:38 PM PST

I'm asking before trying because I already have a few things set up in Wine Stable, so I don't want to mess things up by installing something else over it.

Basically, I want to install Staging because I have an app which is said to require the former to function properly under Linux (it's a music player.)

Will installing Staging affect the way Wine Stable behaves? If so, how? Can I configure Wine Stable and Wine Staging separately?

I'm running Debian Bullseye Stable.

Thank you.

How to get the full console log of my tmux session on Linux?

Posted: 27 Jan 2022 09:26 PM PST

I have a Linux VM on Google Cloud and it has a tmux session which is running a .py file and I am trying to get the console log, but I can't scroll up or anything.

Any idea?

Here's my console

Why wait in this script is not executed after all subshells?

Posted: 28 Jan 2022 12:10 AM PST

In this script, that pulls all git repositories:

#!/bin/bash    find / -type d -name .git 2>/dev/null |   while read gitFolder; do      if [[ $gitFolder == *"/Temp/"* ]]; then          continue;      fi      if [[ $gitFolder == *"/Trash/"* ]]; then          continue;      fi      if [[ $gitFolder == *"/opt/"* ]]; then          continue;      fi      parent=$(dirname $gitFolder);      echo "";      echo $parent;      (git -C $parent pull && echo "Got $parent") &  done   wait  echo "Got all"  

the wait does not wait for all git pull subshells.

Why is it so and how can I fix it?

top command and + and * symbols

Posted: 28 Jan 2022 12:30 AM PST

I am trying to fetch memory usage with below top command.

KiB Mem :  8009480 total,  1438848 free,  1964392 used, 4606240 buff/cache   KiB Swap:  7340028 total,  5302364 free,  2037664 used. 5202692 avail Mem  
top -p $PID -n 1 -b | grep 'KiB Mem :' | awk -F, '{print $3}'  1963780 used  

Strangely sometimes I receive the output as

*"15108960+used"*  

I am not able to understand why are the +,* symbol coming in between sometimes.

I couldn't find anything in man page about it.

What does that mean? How do I make top command print without * and + in the output.

Note : Running in CentOs Machine.

How to programmatically maintain umask in /etc/profile and /etc/bashrc

Posted: 27 Jan 2022 11:31 PM PST

I am looking for a way to programmatically maintain a consistent umask in the files /etc/profile and /etc/bashrc. They have an entry such as follows:

if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then    umask 002  else    umask 022  fi  

So I would like to programmatically check for the first if statement above. If found, check to verify the next line is a umask (and not a comment) and if so, set it back to my standard umask if it has deviated from it. I realize I could just copy the entire file but would rather not disturb other changes that may have been made. I'm sure someone has done with with sed/awk/grep and can share or perhaps have thoughts on how to achieve this? I am required to maintain a umask for the login shell and for the non-login shell. It references this at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_basic_system_settings/assembly_managing-the-umask_configuring-basic-system-settings. Thank you.

Why can't I install an almost indentical kernel on brand new debian 11?

Posted: 27 Jan 2022 10:44 PM PST

My overall objective is to build an RT_PREEMPT kernel that I can modify. As an intermediate step, I'm trying to build and install (and run as a grub entry) a generic, non-RT_PREEMPT kernel. But I think the question below is valid, even without mentioning RT_PREEMPT.

Here's the scenario:

  1. brand new install of Debian 11 from the .iso
  2. download what I believe is as close to the same kernel source from kernel.org.
  3. build,
  4. boot fails with:
Loading initial ramdisk ...  error: out of memory.  Press any key to continue ...  

If I press a key, the process continues briefly before the kernel panics because it can't mount root. I'm new to Linux, but this seems like such a basic thing that it should work. So I'm doing something wrong, but don't know what it is. The out of memory error seems not that common, so here I am asking for help. Here are more details of my process:

  1. download the .iso from debian.org (debian-11.2.0-amd64-netinst.iso) and install. The install is totally generic, and they only thing I add is KDE and SSH.
  2. log in and run uname -a. The output looks like:
Linux sdcc13 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 GNU/Linux  

This part is a little confusing, but I think this means that this is a version 5 kernel, patch level 10 and sublevel 92. On kernel.org, I think the closest version is:

longterm:   5.10.93   

So, these are the commands I'm using:

wget https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.10.93.tar.xz  xz -cd linux*.tar.xz | tar xvf   cd linux-5.10.93/  cp /boot/config-$(uname -r) .config  sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison  make -j11  sudo make modules_install  sudo make install  sudo reboot  

And then the reboot fails as described above. I do have to edit the .config to fix the CERT issue, but I don't change anything else. This seems incredibly generic, and it seems like it should work, so any help is appreciated. I've also tried make menuconfig, and make oldconfig as part of this process, but the result is the same. What am I missing?

I finally got the Debian instructions to work (with a few added lines). So, to build the same kernel that's on a stock debian 11 system, here is what I did. The scariest part is that you have to remove the stock kernel, so better to have at least one different kernel before doing this:

sudo apt-get install build-essential fakeroot

sudo apt-get build-dep linux

apt-get source linux

cd linux-5.10.92/

fakeroot make -j10 -f debian/rules.gen binary-arch_amd64

sudo apt remove --purge linux-image-5.10.0-11-amd64-unsigned

sudo dpkg -i linux-image-5.10.0-11-amd64-unsigned_5.10.92-1_amd64.deb

sudo reboot

Thanks for the help.

Kubuntu 21.10: All ports (open or closed) return ICMP admin-prohibited, even with no firewall enabled. How to fix?

Posted: 27 Jan 2022 11:16 PM PST

Running an up-to-date installation of Kubuntu 21.10.

If I run any network service on the machine, I'm unable to reach it from anywhere else on my network. The error is always "Host unreachable". A tcpdump scan reveals the SYN packet does reach the host, but an ICMP "admin-prohibited" packet is immediately sent back. The packet never even reaches iptables (verified by adding a rule that would match a connection, and it's counter never increases)

nmap is also unable to detect the port as open, however its scan does show up in the counter. nmap interprets the port as filtered because the prohibited packet is ICMP; no response to the SYN packet is sent.

Here is the tcpdump output, on the host machine with a service actively listening on port 8000, that appears when another machine tries to connect:

04:43:09.154362 IP 192.168.1.3.56608 > 192.168.1.183.8000: Flags [S], seq 3664350430, win 64240, options [mss 1460,sackOK,TS val 2819866111 ecr 0,nop,wscale 7], length 0  04:43:09.154417 IP 192.168.1.183 > 192.168.1.3: ICMP host 192.168.1.183 unreachable - admin prohibited filter, length 68  

Here is what happens when nmap scans:

04:44:49.060156 ARP, Request who-has 192.168.1.183 tell 192.168.1.3, length 46  04:44:49.060177 ARP, Reply 192.168.1.183 is-at 74:e6:e2:da:19:0f, length 28  04:44:49.156156 IP 192.168.1.3.33094 > 192.168.1.183.8000: Flags [S], seq 4114316293, win 1024, options [mss 1460], length 0  04:44:49.156260 IP 192.168.1.183 > 192.168.1.3: ICMP host 192.168.1.183 unreachable - admin prohibited filter, length 52  

iptables is completely clear, ACCEPT policy on all default chains, no rules whatsoever on filter, nat and mangle.

Services can be accessed locally using localhost or the machine's IP on the machine itself. The only issue is trying to access from the network.

I do have Docker on the machine, but for trying to figure this out, I disabled Docker and removed all of its iptables rules and chains. If services are started as Docker containers, they are able to be reached from the network. But I am trying to run a service outside of a container.

The machine also has VirtualBox installed, if that's relevant, but at the time of testing no VirtualBox machines were running.

Also of important note is that the SSH server running on the host can be reached successfully - this is the only service that is reachable, regardless of what else is running:

Starting Nmap 7.91 ( https://nmap.org ) at 2022-01-26 11:00 UTC  Nmap scan report for 192.168.1.183  Host is up (0.00035s latency).  Not shown: 65534 filtered ports  PORT      STATE SERVICE  22/tcp    open  ssh  MAC Address: *redacted*  Too many fingerprints match this host to give specific OS details    Nmap done: 1 IP address (1 host up) scanned in 78.45 seconds  

Is there perhaps a kernel setting somewhere that is causing this to occur?

Edit: As requested here is iptables-save output, but it's totally empty...

# Generated by iptables-save v1.8.7 on Wed Jan 26 06:17:24 2022  *filter  :INPUT ACCEPT [0:0]  :FORWARD ACCEPT [0:0]  :OUTPUT ACCEPT [0:0]  COMMIT  # Completed on Wed Jan 26 06:17:24 2022  # Generated by iptables-save v1.8.7 on Wed Jan 26 06:17:24 2022  *nat  :PREROUTING ACCEPT [0:0]  :INPUT ACCEPT [0:0]  :OUTPUT ACCEPT [0:0]  :POSTROUTING ACCEPT [0:0]  COMMIT  # Completed on Wed Jan 26 06:17:24 2022  

clock_gettime error logging into VSFTP on Amazon Linux 2 from certain clients only

Posted: 28 Jan 2022 12:24 AM PST

We have an FTP server VSFTPD running on AWS Linux 2; users are chrooted. Some users can log on fine, others are getting connection failed in WinSCP and an error in Filezilla. On investigation, the error is:

Relink /lib64/libnss_myhostname.so.2 with /lib64/librt.so.1 for IFUNC symbol clock_gettime

Oddly, the exact same configuration which works for some clients fails for the others.

This doesn't seems to be a common error and I would value ideas about how to fix it, either in the VSFTPD configuration or the clients.

Using two variables to form a single text file

Posted: 28 Jan 2022 12:24 AM PST

I am trying to create a text file with below content

user name is ${name}  and his mobile number is ${number}  

I have 10 users and 10 mobile numbers as well. User names are saved in user.txt and the contact number is saved in contact.txt.

user.txt looks like below.

apple  cat  tom  

contact.txt looks like below,

1234  3456  5678  

my output should look like below.

user name is apple  and his mobile number is 1234    user name is cat  and his mobile number is 3456    user name is tom  and his mobile number is 5678  

I want this output in single file. Could someone please help me with the shell and python script?

Make OS-dependent Requires section in an RPM spec file

Posted: 28 Jan 2022 12:51 AM PST

Situation

I have an RPM that uses semanage (SELinux policy management tool) and restorecon (SELinux context configuration tool) in the post-installation and pre-uninstallation stages.

Unfortunately, between RHEL 6/7 and 8, the package containing these tools was renamed from policycoreutils-python to policycoreutils-python-utils.

A working spec file for the RHEL8 RPM contains:

Requires(post): policycoreutils-python-utils  Requires(preun): policycoreutils-python-utils  

And a working spec file for the RHEL6/7 RPM contains:

Requires(post): policycoreutils-python  Requires(preun): policycoreutils-python  

What I try to achieve

I could live with the two spec files/two RPMs, one for every OS type, but I'm lazy and I want one spec that serves all.

What I tried

I read about the OS conditional %{rhel}, containing the OS version. The following should work, according to the RPM manual:

%if %{rhel} < 8  Requires(post): policycoreutils-python  Requires(preun): policycoreutils-python  %endif     %if %{rhel} == 8  Requires(post): policycoreutils-python-utils  Requires(preun): policycoreutils-python-utils  %endif  

If I check the value of the %{rhel} variable on my target systems, I get what I expect:

centos7-system» rpm --eval '%{rhel}'  7    centos8-system» rpm --eval '%{rhel}'  8  

Installation of this RPM on a CentOS 6/7 instance works fine. However, upon installation of the OS-independent RPM on an CentOS 8 instance, I get:

centos8-system» dnf install my-1.26-0.x86_64.rpm  <...>  Error:   Problem: conflicting requests    - nothing provides policycoreutils-python needed by my-1.26-0.x86_64  

Debug output:

centos8-system» rpm -ivvvh my-1.26-0.x86_64.rpm 2>&1 | grep Requires  D:  Requires: /bin/bash                                     YES (db files)  D:  Requires: /bin/sh                                       YES (db files)  D:  Requires: /bin/sh                                       YES (cached)  D:  Requires: /bin/sh                                       YES (cached)  D:  Requires: /usr/bin/env                                  YES (db files)  D:  Requires: /usr/bin/perl                                 YES (db files)  D:  Requires: /usr/bin/php                                  YES (db files)  D:  Requires: nagios-plugins                                NO  D:  Requires: perl(Getopt::Long)                            YES (db provides)  D:  Requires: perl(strict)                                  YES (db provides)  D:  Requires: policycoreutils-python                        NO  D:  Requires: policycoreutils-python                        NO  (cached)  D:  Requires: policycoreutils-python                        NO  D:  Requires: rpmlib(CompressedFileNames) <= 3.0.4-1        YES (rpmlib provides)  D:  Requires: rpmlib(FileDigests) <= 4.6.0-1                YES (rpmlib provides)  D:  Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1       YES (rpmlib provides)  D:  Requires: rpmlib(PayloadIsXz) <= 5.2-1                  YES (rpmlib provides)  

It would seem that the Requires for the CentOS 6/7 scenario are used, and not those from the CentOS 8 scenario.

What am I not seeing here? Is there anything I can do to debug this?

Related and sources

Storage encryption on Linux desktop: LVM on LUKS or ZFS

Posted: 27 Jan 2022 10:50 PM PST

I choose solution for storage encryption on Linux desktop. For years LVM on LUKS was a best option with superior performance and reliability. But ZFS on Linux actively develops new functions and now we have options.

I compared LVM on LUKS and ZFS with various fio tests with default encryption settings, provided by developers and mantainers: aes-xts-512b at LUKS, aes-256-gcm at ZFS. Here are average bandwidth and latency metrics at RAM block device for each volume type:

BandwidthLatency

At the first comparsion on the charts looks controversional. XTS obviously faster than GTC on random small blocks. But on sequentional reads and writes ZFS shows comparable latency with a noticeable increase in bandwidth!

Which of these solutions is best suited for desktop tasks in terms of performance? Now I find it difficult to choose and I will be grateful for the advices.

UPD1:

For example, my typical storage tasks are:

  • Web browser loads: mixed reads & writes files near 100-1000 KB in local cache;
  • Starting applications: random reads system binaries near 100-1000 KB;
  • Compiling software: reads & writes hudge amount of small files;
  • Storing archive like photos: mostly writes files up to 10 MB, rare reads;
  • Serving huge files like UHD videos for home media: up to 100 GB sequetial writes or reads;
  • And more.

It is easy to optimize system for each individual task. But which of the solutions best fit all of them?

UPD2:

And here is some real life measurements with files: Tar operations time

How to write a script that accepts input from stdin or a file?

Posted: 27 Jan 2022 11:07 PM PST

I have a bash driver for a awk script that should accept input as cat text.txt | driver.sh or ./driver.sh file1.txt file2.txt ... [filen.txt] for however many files. I have tried using

   read var     gawk -f awk_prac.awk $var  

This works for piping only. I also tried using a for loop to read all the file names, but that doesn't work for piped text. Any input is appreciated.

sum rows and columns in a table of numbers

Posted: 27 Jan 2022 11:43 PM PST

I have large and many tables of numbers. Below is just a sample:

A 25 27 50   B 35 37 75   C 75 78 80   D 99 88 76   

I want to sum the rows and the columns in each table for further processing so the output look like this:

A 25 27 50 102  B 35 37 75 147  C 75 78 80 233  D 99 88 76 263  234 230 281  

How can I do it? I tried awk but did not work.

Can I use scp to copy files to the home directory without having to specify it?

Posted: 27 Jan 2022 10:13 PM PST

I've followed this tutorial to see how to use scp to transfer files to my server. And all is well. So I'm using commands like this:

scp examplefile yourusername@yourserver:/home/yourusername/  

But I'm wondering if there's a way for me to not have to specify the destination with the prepended /home/yourusername/. I'm already using the username in the address, is there a way to make the home directory on the remote user the "base" of the file transfer destination?

Or, to clarify, I want to be able to send files to the home directory of the user on the remote computer (yourusername@yourserver:/home/yourusername/) with a command like this:

scp examplefile yourusername@yourserver  

Is it possible? Feasible?

Trying to connect bose quietcomfort 35 headset over bluetooth on arch linux

Posted: 27 Jan 2022 10:05 PM PST

There is another question here, but i followed those instructions and it still didn't work.

Here is the systemctl status

Oct 06 10:02:38 TRAYUSH bluetoothd[376]: Bluetooth daemon 5.42  Oct 06 10:02:38 TRAYUSH systemd[1]: Started Bluetooth service.  Oct 06 10:02:38 TRAYUSH bluetoothd[376]: Starting SDP server  Oct 06 10:02:38 TRAYUSH bluetoothd[376]: Bluetooth management interface 1.12 initialized  Oct 06 10:02:38 TRAYUSH bluetoothd[376]: Failed to obtain handles for "Service Changed" characteristic  Oct 06 10:02:38 TRAYUSH bluetoothd[376]: Sap driver initialization failed.  Oct 06 10:02:38 TRAYUSH bluetoothd[376]: sap-server: Operation not permitted (1)  Oct 06 10:02:38 TRAYUSH bluetoothd[376]: Failed to set mode: Not Supported (0x0c)  Oct 06 10:03:00 TRAYUSH bluetoothd[376]: a2dp-sink profile connect failed for 04:52:C7:0E:7F:12: Protocol not available  Oct 06 10:06:20 TRAYUSH bluetoothd[376]: a2dp-sink profile connect failed for 04:52:C7:0E:7F:12: Protocol not available  

Here are the contents of /etc/bluetooth/main.conf

[General]  ControllerMode=bredr  

And the contents of /etc/bluetooth/audio.conf

[General]  Enable=Source,Sink,Headset,Gateway,Control,Socket,Media  

Here is what happens when I try to connect via bluetoothctl

[trash@TRAYUSH ~]$ bluetoothctl  [NEW] Controller 98:58:8A:07:14:FC TRAYUSH [default]  [NEW] Device 04:52:C7:0E:7F:12 QC35  [bluetooth]# power on  Changing power on succeeded  [bluetooth]# agent on  Agent registered  [bluetooth]# connect 04:52:C7:0E:7F:12   

Here is the relevant information from /etc/pulse/default.pa

### Automatically load driver modules for Bluetooth hardware  .ifexists module-bluetooth-policy.so  load-module module-bluetooth-policy  .endif    .ifexists module-bluetooth-discover.so  load-module module-bluetooth-discover  .endif  

Any help is appreciated, thanks.

Ninja Edit: Pulseaudio-bluetooth IS installed.

find and replace with the value in another file

Posted: 28 Jan 2022 12:08 AM PST

I have two files with different formats with columns tab spaced. I have to compare the columns column1, column2 of file1 with file2. If they matches, I need to replace the value in column6 of file1 with the value in column3 of file2. I have tried using awk but I am not able to replace the value. Could you please advise on the below snippet ?

awk 'FILENAME == ARGV[1] {      m[$1,$2] = $6;      next;  }  {      if (($1,$2) in m) {          m[$6]= $3; print m[$6];      }  }' file1 file2      top few lines of file1  1201 12011 1 0 0 0 1  1202 12021 1 0 0 0 1  1203 12031 1 0 0 0 1  1204 12041 1 0 0 0 2  1207 12071 1 0 0 0 2  1209 12091 1 0 0 0 1  1210 12101 1 0 0 0 1  1212 12121 1 0 0 0 1  1213 12131 1 0 0 0 1  1214 12141 1 0 0 0 2    top few lines of file2  1201    12011   1  1202    12021   1  1203    12031   1  1204    12041   1  1206    NA  1  1207    12071   2  1208    NA  1  1209    12091   2  1210    12101   2  

I want to assign the values from file2 to file1 column as I would like to write the updated content into another file out.txt

edit

Tried the below code as per the comments

awk '{      if (FNR==NR) {          a[FNR]=$1;b[FNR]=$2;c[FNR]=$3}      else {                       if (a[FNR] == $1 && b[FNR] ==$2) {              $6=c[FNR]} else {$6=$6};             print $0;          }      }' file2 file1  

Got this output

1201 12011 1 0 0 1 1  1202 12021 1 0 0 1 1  1203 12031 1 0 0 1 1  1204 12041 1 0 0 1 2  1207 12071 1 0 0 0 2  1209 12091 1 0 0 0 1  1210 12101 1 0 0 0 1  1212 12121 1 0 0 0 1  1213 12131 1 0 0 0 1  1214 12141 1 0 0 0 2  

Use here-document in a one-liner?

Posted: 27 Jan 2022 09:05 PM PST

I have a simple script that executes commands on remote host using ssh and a here-document.

I was trying to do it with a one-liner at command line but I couldn't figure out how to do the here-document outside of a script. Is it possible? I spent some time googling and reading documentation about here-documents, but it wasn't coming to me.

This script works fine - I needed the here-document section in order to run awk remotely via ssh but I usually like to do one-liners for simple stuff:

#!/bin/bash  # it looks up all my hosts with 'db' in the name  # then gets the PID of any rsyncs running as user 'research'  # and pumps them into xargs    getHosts=(`curl --silent "http://assetts.lab/all_hosts" | grep -v ^# | awk -F" " '{print$1}'|grep db`)  for BOX in ${getHosts[@]};do      echo "$BOX: "      ssh -T sshUser@$BOX <<"EOF"  ps -ef | egrep "rsync|iasync" | awk -F" " '{if ($1 ~ "research") print $2}'|sudo xargs -i ps -fp '{}'  #ps -ef | egrep "rsync|iasync" | awk -F" " '{if ($1 ~ "research") print $2}'|sudo xargs -i kill '{}'  EOF      echo  done  

I'm probably missing something simple... Anyway thanks for any suggestions :)

Get a progress indicator when importing MySQL databases

Posted: 28 Jan 2022 12:17 AM PST

I often import MySQL databases, and this can take a while. There is no progress indicator whatsoever. Can one be shown, somehow? Either records imported, MB imported, or tables imported... anything is better than just waiting. Anybody any idea?

I use this command:

mysql -uuser -p -hhost database < largefile.sql

Files are between 40-300 MB, and the host is within the local network.

No comments:

Post a Comment