Thursday, July 7, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


Can libvirt/qemu set the enoX number as if it were a physically numbered hardware port?

Posted: 07 Jul 2022 05:53 PM PDT

Recent Linux distributions use Predictable Network Interface Names (from udev) which states that "device names [like eno1] incorporate firmware or BIOS-provided index numbers for onboard devices."

Question:

Can the Libvirt XML be configured to specify the "BIOS-provided index number" so I can control the ethernet labeling inside the VM from libvirt for devices like enoX?

Completing Git branch names “from the middle”

Posted: 07 Jul 2022 05:48 PM PDT

At work we name our Git branches in a verbose way, like "feature/PROJ-123-frobnicate-blobs". In order to use the Zsh autocompletion with names like this, I end up typing the "feature/PROJ-" boilerplate over and over. I would love to be able to type

git switch 123Tab

and have "123" replaced with that entire branch name.

More generally, instead of autocompletion assuming that what I've typed is the beginning of the branch name, it should assume that I've merely given it a substring.

How can I configure Zsh to complete Git branch names in this way?

hostapd: I want wpa3 only..but enable WEP!

Posted: 07 Jul 2022 05:00 PM PDT

I start hostapd for wpa3 only auth.

interface=wlan0  bridge=br0  driver=nl80211  ssid=mysid  hw_mode=g  channel=6  wpa=2  wpa_passphrase=iforgotit  wpa_key_mgmt=SAE  rsn_pairwise=CCMP  

But when I do the scan

nmcli device wifi list it report...WEP!

nmcli device wifi list   IN-USE  BSSID              SSID         MODE   CHAN  RATE        SIGNAL  BARS  SECURITY            E****************  Mysid        Infra  6     65 Mbit/s   97      ▂▄▆█  WEP    

Why? How to disable wep?

edit1: i add this

auth_algs=1

but don't work, is still wep

How to grep on a single column using a list of words

Posted: 07 Jul 2022 05:56 PM PDT

I would like to extract some rows from a file based on their match on a single column with a list of words.

In awk, I could use something like this:

awk '$5 == "someword" {print}' file.txt  

I know that I can use grep like this:

grep -f listofwords.txt file.txt  

Could you please tell how I could grep a list of words based on a single column of my file?

Example

A   something  something2  B   something2 something3  C   something3 something4  D   something4 something5  G   something5 something6  

Vector of words that I want based on column 2:

something  something4  

Desired output:

A   something  something2  D   something4 something5  

i2c device node from device tree is not being probed

Posted: 07 Jul 2022 04:38 PM PDT

I am having trouble troubleshooting my problem where in my i2c pca9546 mux is not being probed by the corresponding driver, i2c-mux-pca954x.c. Here is my device tree node:

&i2c0 {  status = "ok";    pca9546@77 {      compatible = "nxp,pca9546";      #address-cells = <1>;      #size-cells = <0>;      reg = <0x77>;      status = "okay";      ....      ....  

I ran the command echo pca9546 0x77 > /sys/bus/i2c/devices/i2c-0/new_device resulting in the triggering the probe function and the device being created. I also went through the source code and realized that the driver is unable to find a matching device and that the device tree's nodes are not being recognized as the i2c bus probes for peripheral devices. Anyone know for what may be going on

Can a file that's being supplied by bind-mount support overwriting via `mv`?

Posted: 07 Jul 2022 04:49 PM PDT

Suppose I bind-mount file a atop file b...

$ echo 'line 1' > a  $ touch b  $ mount --bind a b  

The initial file contents will be mirrored at both paths, as expected:

$ cat a  line 1    $ cat b  line 1  

And if I concatenate to either path, the new contents will be mirrored both ways, as expected:

$ echo 'line 2' >> a    $ cat a  line 1  line 2    $ cat b  line 1  line 2    $ echo 'line 3' >> b    $ cat a  line 1  line 2  line 3    $ cat b  line 1  line 2  line 3  

However, I can't overwrite b via mv:

$ echo 'totally new contents' > temp  $ mv tmp b  mv: can't rename 'tmp': Device or resource busy  

Is there a way to get this to work so that the new contents are mirrored at a?


The reason I want to do this has to do with the way my system's filesystem is set up.

It's an embedded system, so most of the filesystem is mounted read-only. Certain 3rd-party services try to write to hard-coded files like /etc/machine-info or /etc/hostname, which doesn't work because they're read-only. Our normal way of working around this is to have a writable partition containing just the files that we expect to be modified, and then bind-mount those writable files onto the traditional Linux paths where the services can find them.

This works when the process opens the file for writing and modifies it in-place. But, as described above, it doesn't work when the process does the equivalent of mv.

Plasma button or command to show desktop grid

Posted: 07 Jul 2022 04:29 PM PDT

enter image description here

I find useful the desktop grid to drag & drop windows of applications between virtual desktops and I know that it can be displayed with a shortcut.

enter image description here

But sometimes I do it more often and when I am using a mouse so I am curious whether we can do it by clicking a button (or by a command that I can put in a launcher) in the way I do for activities

enter image description here

... or the way we can do (I realized it in the end!... but I don't do it) - with the pager widget, which allows dragging windows between the small buttons on the panel (too small for this purpose, too large to have them on the panel all the time as far as I concerned):

enter image description here

Also, I know an alternative is hot corners - but I still want a button (I always bump into hot corners by error- sorry that I'm so picky!)

Plasma 4 had an extension/widget for that purpose but I cannot find one for Plasma 5.

Convert unified diff hunk into text old or new

Posted: 07 Jul 2022 03:38 PM PDT

I'd love to be able to extract raw text from diffs. F.ex. the hunk:

--- a   2022-07-08 01:15:08.091318061 +0300  +++ b   2022-07-08 01:15:18.175389833 +0300  @@ -1,5 +1,5 @@   Common text    -Old text  +Changed text     Common text  

must be converted to text A:

Common text    Old text    Common text  

and B:

Common text    Changed text    Common text  

Quite strange I could not find this in standard tools, so I've always used some sed commands. Maybe I missed something and there is some standard way of doing this? Anyway, quite curious to know your shortest command-line implementation.

How to get the latest usb.ids when update-usbids no longer exists?

Posted: 07 Jul 2022 04:45 PM PDT

I had to move from Debian Jessie to Buster. The script that runs to create a small custom boot disc runs update-usbids to get the latest files to copy over to the build. However it now says update-usbids command not found. Looking around people say it was removed for systemd but the boot disk still uses init (moving it to systemd is not a reality and would bloat it too much).

So the question is, how do I update the usb.ids file so I can keep the boot disk up to date? If the file was some place could it just be downloaded using the wget command?

TIA!!

ssh publickey authentication failure: receive packet: type 51. sshd is not accepting publickey auth at all

Posted: 07 Jul 2022 03:12 PM PDT

I have read numerous solutions to this problem, but none seem to apply to what I'm seeing. Most focus on directory permissions, but those appear to be correct in this case. TL;DR: Two Centos7 servers with the same home directory; one's sshd is not allowing publickey authentication even though it is enabled.

I have two centos7 servers, let's call them centos-a and centos-b. Home directories are mounted via NFS, so the .ssh directories are identical between both (confirmation of this below). I can ssh from centos-a to centos-a, but not to centos-b. I can ssh from centos-b to centos-a and to centos-b.

ssh-ability centos-a centos-b
centos-a YES NO
centos-b YES YES
[myuser@centos-a ~]$ ls -la ~/.ssh  total 16  drwx------. 1 myuser domain users    0 Jul  6 11:45 .  drwx------. 1 myuser domain users    0 Jul  7 13:44 ..  -rw-------. 1 myuser domain users 1212 Jul  6 12:02 authorized_keys  -rw-------. 1 myuser domain users 1675 Jul  6 11:45 id_rsa  -rw-r--r--. 1 myuser domain users  402 Jul  6 11:45 id_rsa.pub  -rw-r--r--. 1 myuser domain users 1119 Jul  6 17:49 known_hosts    [myuser@centos-a ~]$ md5sum ~/.ssh/*  65b4fdf2d59cee3ae45b8480454453ec  /home/myuser/.ssh/authorized_keys  fa3e9fc5a8ff08787ff2ba8f979da24e  /home/myuser/.ssh/id_rsa  dca36ab3ec342423c5eca588f2ad5678  /home/myuser/.ssh/id_rsa.pub  f67bc94bc7a30b9876e3027b24f893d8  /home/myuser/.ssh/known_hosts    [myuser@centos-a ~]$ ssh centos-a hostname  centos-a    [myuser@centos-a ~]$ ssh centos-b hostname  myuser@centos-b's password:  
[myuser@centos-b ~]$ ls -la ~/.ssh  total 16  drwx------. 1 myser domain users    0 Jul  6 11:45 .  drwx------. 1 myser domain users    0 Jul  7 13:44 ..  -rw-------. 1 myser domain users 1212 Jul  6 12:02 authorized_keys  -rw-------. 1 myser domain users 1675 Jul  6 11:45 id_rsa  -rw-r--r--. 1 myser domain users  402 Jul  6 11:45 id_rsa.pub  -rw-r--r--. 1 myser domain users 1119 Jul  6 17:49 known_hosts    [myuser@centos-b ~]$ md5sum ~/.ssh/*  65b4fdf2d59cee3ae45b8480454453ec  /home/myuser/.ssh/authorized_keys  fa3e9fc5a8ff08787ff2ba8f979da24e  /home/myuser/.ssh/id_rsa  dca36ab3ec342423c5eca588f2ad5678  /home/myuser/.ssh/id_rsa.pub  f67bc94bc7a30b9876e3027b24f893d8  /home/myuser/.ssh/known_hosts    [myuser@centos-b ~]$ ssh centos-b hostname  centos-b    [myuser@centos-b ~]$ ssh centos-a hostname  centos-a  

As shown above, the permissions on the .ssh directory appears to be correct (and, regardless, is identical between both machines).

ssh -vvv on the failing ssh shows:

OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017  ...  debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4  debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000  ...  debug1: Host 'centos-b' is known and matches the ECDSA host key.  ...  debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password  debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password  debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password  debug3: authmethod_lookup gssapi-keyex  debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password  debug3: authmethod_is_enabled gssapi-keyex  debug1: Next authentication method: gssapi-keyex  debug1: No valid Key exchange context  debug2: we did not send a packet, disable method  debug3: authmethod_lookup gssapi-with-mic  debug3: remaining preferred: publickey,keyboard-interactive,password  debug3: authmethod_is_enabled gssapi-with-mic  debug1: Next authentication method: gssapi-with-mic  debug1: Unspecified GSS failure.  Minor code may provide more information  No Kerberos credentials available (default cache: KEYRING:persistent:1211402155)    debug1: Unspecified GSS failure.  Minor code may provide more information  No Kerberos credentials available (default cache: KEYRING:persistent:1211402155)    debug2: we did not send a packet, disable method  debug3: authmethod_lookup publickey  debug3: remaining preferred: keyboard-interactive,password  debug3: authmethod_is_enabled publickey  debug1: Next authentication method: publickey  debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa  debug3: send_pubkey_test  debug3: send packet: type 50  debug2: we sent a publickey packet, wait for reply  debug3: receive packet: type 51  debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password  debug1: Trying private key: /home/myuser/.ssh/id_dsa  debug3: no such identity: /home/myuser/.ssh/id_dsa: No such file or directory  debug1: Trying private key: /home/myuser/.ssh/id_ecdsa  debug3: no such identity: /home/myuser/.ssh/id_ecdsa: No such file or directory  debug1: Trying private key: /home/myuser/.ssh/id_ed25519  debug3: no such identity: /home/myuser/.ssh/id_ed25519: No such file or directory  debug2: we did not send a packet, disable method  debug3: authmethod_lookup password  debug3: remaining preferred: ,password  debug3: authmethod_is_enabled password  debug1: Next authentication method: password  myuser@centos-b's password:  

Contrast this to what I see going from centos-b to centos-a, which works:

...  debug1: Unspecified GSS failure.  Minor code may provide more information  Server not found in Kerberos database    debug3: send packet: type 50  debug2: we sent a gssapi-with-mic packet, wait for reply  debug3: receive packet: type 51  debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password  debug2: we did not send a packet, disable method  debug3: authmethod_lookup publickey  debug3: remaining preferred: keyboard-interactive,password  debug3: authmethod_is_enabled publickey  debug1: Next authentication method: publickey  debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa  debug3: send_pubkey_test  debug3: send packet: type 50  debug2: we sent a publickey packet, wait for reply  debug3: receive packet: type 60  debug1: Server accepts key: pkalg rsa-sha2-512 blen 279  debug2: input_userauth_pk_ok: fp SHA256:nAO5pVOzqUQzEUSEBN37WKp6ADs9Sk4rfTRGmk0FHEY  debug3: sign_and_send_pubkey: RSA SHA256:nAO5pVOzqUQzEUSEBN37WKp6ADs9Sk4rfTRGmk0FHEY  debug3: send packet: type 50  debug3: receive packet: type 52  debug1: Authentication succeeded (publickey).  

I've enabled sshd log messages in /etc/ssh/sshd_config and restarted the service

# Logging  SyslogFacility AUTH  SyslogFacility AUTHPRIV  LogLevel INFO  

But there are no additional useful messages in either /var/log/secure or /var/log/messages.

Interestingly the ssh from centos-b to centos-b is using gssapi authentication. If I force it to use publickey it fails:

[myuser@centos-b ~]$ ssh -vvv -o PreferredAuthentications=publickey centos-b hostname  ...  debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa  debug3: send_pubkey_test  debug3: send packet: type 50  debug2: we sent a publickey packet, wait for reply  debug3: receive packet: type 51  ...  Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).  

and I see in /var/log/messages:

Jul  7 13:52:10 centos-b sshd[23266]: Connection closed by 192.168.1.100 port 48064 [preauth]  

pubkey is enabled:

[root@centos-b ssh]# sshd -T | grep -i pub  pubkeyauthentication yes  pubkeyacceptedkeytypes ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha...  

Any suggestions for what I'm missing?

Do I have to mount new partitions in /mnt

Posted: 07 Jul 2022 05:10 PM PDT

I mounted a new SSD drive under /mnt/sdc1. I then symlinked various folders that have been taking up a lot of space in my /home directory to that partition, so I could free up some storage in /home, for example:

ln -s /mnt/sdc1/downloads ~/downloads

or

ln -s /mnt/sdc1/videos ~/videos

But that got me thinking. Would I be able to just make a folder for it in my /home directory and then mount it there? Is mounting drives in /mnt just convention or does mounting a new drive anywhere else actually have any consequences and cause trouble later down the line?

What is the difference between "find . -daystart -mtime" and "find . -mtime"?

Posted: 07 Jul 2022 02:45 PM PDT

What is the difference between the following -

find . -daystart -mtime +5  

and

find . -mtime +5  

It produced the same output when I tested it.

Is there any advantage of using -daystart? I am a beginner in this field so requesting to kindly advise.

"Unable to install GRUB in /dev/sda" fatal error when reinstall ubuntu

Posted: 07 Jul 2022 03:00 PM PDT

I have recently tried to reinstall Ubuntu to my Lenovo X1 Carbon but I'm getting the following issues (all my data is backed up):

  • I tried installing ubuntu from live disk. I selected "reinstall" and followed the default settings to the end where I got the following error:
unable to install GRUB in /dev/sda  Executing `grub-install /dev/sda` failed.  This is a fatal error.  
  • Since I had problems with my previous version I thought these may have transferred in the reinstall so I then tried Erase Ubuntu 14 and replace with Ubuntu 20. This gave me to same error. I tried following the suggestions on this post: https://askubuntu.com/questions/459620/unable-to-install-grub-in-dev-sda-when-installing-grub namely:
  • Manually deleting the previous partition and creating a new one. This gave the same error.
  • Installing grub via the boot terminal and via the terminal inside Try Ubuntu. Using sudo grub-install /dev/sdb and sudo grub-install /dev/sda In both instances I got
$ grub-install /dev/sda  grub-install: error: cannot find EFI directory.  

So following advice from here Cannot find EFI directory: issue with grub-install I mounted the efi system. Now when I use sudo grub-install /dev/sdb I get the error:

sudo grub-install /dev/sda  Install for x86_64-efi platform  grub-install: error: failed to get canonical path of `cow'.  
sudo grub-install --recheck --root-directory=/mnt /dev/sda  Install for x86_64-efi platform  grub-install: error: cannot find EFI directory.  
grub-install --efi-directory=/dev/sda7  Installing x86_64-efi platform  grub-install: error: failed to get canonical path of `udev`.  
sudo grub-install /dev/sda  Install for x86_64-efi platform  grub-install: error: failed to get canonical path of `cow'.  

Which is the same error I got before so it seems like I've gone round in circles.

I've tried running boot-repair both from within TryUbuntu and via a live disk. These executed successfully but then when I restarted and tried to access Ubuntu I got the same errors as before.

I know that each of these has their own forums but I feel like I'm going round in circles between them all. Can anyone piece together each of the errors to help me?

Some background- The reason I'm reinstalling is that a few years ago my laptop crashed in the middle of an update (I hadn't realised the battery cable had been switch off.). My friend kindly spent an afternoon manually fixing parts to get it to work again. Since then there have been a few things I've not been able to get working properly (printer drivers and calendar syncing for example). Since these weren't a problem for my research I continued without them until the end of my PhD. I recently had some errors trying to use Firedrake. Since I've now finished my PhD it seemed like a safe time to back up all my data and reinstall Ubuntu. Hoping that the reinstall would rectify the problems from the previous crash.

BASH recursive rename of js files to jsx

Posted: 07 Jul 2022 02:25 PM PDT

On a mac I'm migrating a create react app to vite and have a lot of *.js files that need changing to *.jsx. I done this manual once in my life and this is enough for one eternity.

I need a simple to understand script to do this preferably on a mac installation without needing to install anything.

I'v found lots of existing examples but none I've tried have worked completely.

edit ---

for bonus points, this only happens for files that contain import React as this makes the refactor quite quicker with less manual checking.

Why does `echo 'hi' | tee > a b c` create multiple files, whereas `echo 'hi' > a b c` doesn't?

Posted: 07 Jul 2022 02:24 PM PDT

My env: zsh, macOS


Command in concern:

  1. echo 'hi' | tee > a b c
  2. echo 'hi' > a b c

Command 1 creates files named a, b and c with content 'hi'. Command 2 creates a file named a with content 'hi b c'.

AFAIK, only the usage of Command 1 without > is documented in the manpage of tee:

echo 'hi' | tee a b c  

I want some help to understand why adding > the above code(i.e., Command 1) still creates multiple files, whereas Command 2 creates only one file.

Reverse engineer PCI drivers for device with none

Posted: 07 Jul 2022 03:35 PM PDT

Is it possible to reverse engineer PCI drivers for a device which has none?

The device in question was a PCI ESCON card that allowed you to connect a mainframe ESCON channel to a specialty unix computer. As far as I know, this device never had any drivers released publicly, but still uses a standard PCI bus.

Would it be possible to put together drivers without having an existing set to reverse engineer?

Any info would be appreciated.

Why does a 2-socket server show PCIe locations but the 4-socket server does not (how can I find the PCIe locations on the 4-socket server)?

Posted: 07 Jul 2022 03:27 PM PDT

I have two servers:

When I run hwloc-ls for the 2-socket server I see the PCIe topology with the HostBridges on each NUMANode, but the 4-socket server shows Packages instead of NUMANodes and all of the HostBridges are listed at the bottom. In addition, lscpu shows 2 NUMA nodes on the 2-socket but only 1 NUMA node on the 4-socket server.

How can I discern which PCIe device is attached to which socket on the 4-socket server?

When I run hwloc-ls on the 2-socket server I get the following:

Machine (63GB total)    NUMANode L#0 (P#0 31GB)      Package L#0 + L3 L#0 (20MB)        L2 L#0 (256KB) + L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0          PU L#0 (P#0)          PU L#1 (P#16)          ...      HostBridge L#0        PCIBridge          PCI 17d3:1880            Block(Disk) L#0 "sda"    NUMANode L#1 (P#1 31GB)      Package L#1 + L3 L#1 (20MB)        L2 L#8 (256KB) + L1d L#8 (32KB) + L1i L#8 (32KB) + Core L#8          PU L#16 (P#8)          PU L#17 (P#24)          ...      HostBridge L#6        PCIBridge          PCI 8086:10fb            Net L#8 "eth0"  

... and when I run it on the 4-socket server I get the following:

Machine (126GB)    Package L#0 + L3 L#0 (38MB)      L2 L#0 (256KB) + L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0        PU L#0 (P#0)        PU L#1 (P#60)        ...    Package L#1 + L3 L#1 (38MB)      L2 L#2 (256KB) + L1d L#2 (32KB) + L1i L#2 (32KB) + Core L#2        PU L#4 (P#15)        PU L#5 (P#75)        ...    Package L#2 + L3 L#2 (38MB)      L2 L#4 (256KB) + L1d L#4 (32KB) + L1i L#4 (32KB) + Core L#4        PU L#7 (P#30)        PU L#8 (P#90)        ...    Package L#3 + L3 L#3 (38MB)      L2 L#6 (256KB) + L1d L#6 (32KB) + L1i L#6 (32KB) + Core L#6        PU L#10 (P#45)        PU L#11 (P#105)        ...    Misc(MemoryModule)    ...    HostBridge L#5      PCIBridge        PCI 8086:10c9          Net L#6 "ens8f0"  

2-socket lscpu:

Architecture:          x86_64  CPU op-mode(s):        32-bit, 64-bit  Byte Order:            Little Endian  CPU(s):                32  On-line CPU(s) list:   0-31  Thread(s) per core:    2  Core(s) per socket:    8  Socket(s):             2  NUMA node(s):          2  Vendor ID:             GenuineIntel  CPU family:            6  Model:                 62  Model name:            Intel(R) Xeon(R) CPU E5-2450 v2 @ 2.50GHz  Stepping:              4  CPU MHz:               2804.841  CPU max MHz:           3300.0000  CPU min MHz:           1200.0000  BogoMIPS:              5000.25  Virtualization:        VT-x  L1d cache:             32K  L1i cache:             32K  L2 cache:              256K  L3 cache:              20480K  NUMA node0 CPU(s):     0-7,16-23  NUMA node1 CPU(s):     8-15,24-31  

4-socket lscpu:

Architecture:          x86_64  CPU op-mode(s):        32-bit, 64-bit  Byte Order:            Little Endian  CPU(s):                120  On-line CPU(s) list:   0-119  Thread(s) per core:    2  Core(s) per socket:    15  Socket(s):             4  NUMA node(s):          1  Vendor ID:             GenuineIntel  CPU family:            6  Model:                 62  Model name:            Intel(R) Xeon(R) CPU E7-4890 v2 @ 2.80GHz  Stepping:              7  CPU MHz:               1199.953  CPU max MHz:           3400.0000  CPU min MHz:           1200.0000  BogoMIPS:              5600.25  Virtualization:        VT-x  L1d cache:             32K  L1i cache:             32K  L2 cache:              256K  L3 cache:              38400K  NUMA node0 CPU(s):     0-119  

Setting domains in resolvectl results in timeouts

Posted: 07 Jul 2022 06:06 PM PDT

For some reason I can't manage to set domains for resolvectl. Either I don't understand what it does at all or something is weird for me.

Once I set a domain e.g. sudo resolvectl domain enp2s0 example.com, any query to example.com or any of its subdomains result in timeouts and NXDOMAIN for searched queries.

Why am I experiencing that? Also doesn't this feature actually work simply just like search in resolv.conf file but namespaced by network interface? i.e. If I query subdomain which is acutally nothing but subdomain.example.com and it has answers on that interface DNS servers I should resolve it successfully, am I right?

I want to download the latest 150 files from S3 Spaces

Posted: 07 Jul 2022 03:35 PM PDT

I want to download the latest 150 files from S3 Spaces. I used this command

s3cmd get s3://obs/site1/uploads/large/ /home/ankit -r | tail -n150  

but it does not do what I want; instead, it starts downloading all the files

For example: If I command: INPUT s3cmd ls s3://obs/site1/uploads/large/

OUTPUT

2020-04-30 20:04         0   s3://obs/site1/uploads/large/  2020-04-30 20:04   1401551   s3://obs/site1/uploads/large/501587671885rwk.jpg  2020-04-30 20:04    268417   s3://obs/site1/uploads/large/501587676002xe2.jpg  2020-04-30 20:04    268417   s3://obs/site1/uploads/large/501587677157ssj.jpg  2020-04-30 20:04    268417   s3://obs/site1/uploads/large/501587747245hea.jpg  2020-05-01 05:23    399636   s3://obs/site1/uploads/large/87429599_1412258992269430_5992557431891165184_o.jpg  

And I want to download the only the last file (it is latest) that is:

2020-05-01 05:23    399636   s3://obs/site1/uploads/large/87429599_1412258992269430_5992557431891165184_o.jpg  

I can list the latest file but cannot download the latest file: I listed through:

s3cmd ls s3://obs/site1/uploads/large/ | tail -n1  

OUTPUT: 2020-05-01 05:23 399636

s3://obs/site1/uploads/large/87429599_1412258992269430_5992557431891165184_o.jpg  

SO, please tell me the command to download this latest file only?

Why is my udev rule not working?

Posted: 07 Jul 2022 05:08 PM PDT

I need to automatically run my script /var/www/html/configWWW when any USB is plugged in to my Raspberry.

UDEV RULE - /etc/udev/rules.d/myRule.rules

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="****",  ATTR{idProduct}=="****", RUN+="/var/www/html/configWWW"  

MY SCRIPT - /var/www/html/configWWW

#!/bin/bash  file="/media/pi/USB/SymSif.xml"  if [ -f "$file" ]  then          (          echo "it works: $(date)" >> /home/pi/Desktop/test.txt          )  else          (          echo "it does not works: $(date)" >> /home/pi/Desktop/test.txt          )  fi  

On the other hand, if i run script from bash /var/www/html/configWWW, it works!

Why doesn't my udev rule work like my bash command?

Trying to install dual-boot Parrot OS 3.5 on Sony Vaio UEFI

Posted: 07 Jul 2022 03:00 PM PDT

I'm trying to install Parrot OS 3.5 on a Sony Vaio laptop, as a dual-boot alongside Windows 10. I have no trouble installing from my bootable USB, but Grub doesn't seem to be able to load it. I don't want to run it as a Live Disc, and I don't want to run it in VM, I want to be able to boot directly into it for use as a daily driver OS.

CUPS stops printing right after a while

Posted: 07 Jul 2022 04:00 PM PDT

I've converted an automatic printing system from Windows with Acrobat Reader to Ubuntu with CUPS. This took about 10 minutes using CUPS, but now I'm getting a strange issue with incomplete prints rolling out, or nothing being printed whatsoever after a while. CUPS reports seemingly arbitrary errors. Sometimes it doesn't even report an error, and most of the errors reported are "broken pipe" errors.

Usually after adding a printer to CUPS it will print fine for a while. When I come back a few hours later and try the exact same thing (even with the same file), the file might not print at all or come out of the printer with elements missing.

This might be an unrelated bug, but also after a while CUPS' web interface stops responding. All I can access after this happens is the HTTP version of the main page. A restart of CUPS fixes this.

I'm running a fresh installation of CUPS, with only remote administration enabled. The issue persists even after doing a sudo service cups restart.

I've added the printers in many different ways (socket, ldp, ipp), with both generic PCL6 drivers and the printers' official KPDL drivers. Directly after adding a printer the prints will usually come out as expected. I'm printing using the most basic command possible: lp -d [printer-name] [numbers].pdf.

I'm running Ubuntu Server 16.04. The printers I've configured are a Kyocera ECOSYS FS-1370DN, and a Kyocera ECOSYS P2135dn. The printers do not seem to be the issue though, as a HP printer I've used exhibits the same issue.

I've been trying to figure out what is going wrong for longer than I care to admit. And I'm starting to feel pretty stupid. Every time I think I've fixed it bad prints start rolling out soon after. Acrobat Reader/the Windows print spooler never has trouble printing, even while CUPS spits out garbage.

Other things I've tried without success: - Converting to PostScript (.ps) using pdf2ps before printing - Converting to PDF using GhostScript (fixing possible PDF errors) before printing - Printing web-downloaded test PDFs known to have printed well before.

This is the weird one that's defying all logic to me: Uploading the PDF files through ftp (the printers are capable of printing PDF) also only works sometimes. This completely circumvents CUPS, so it must be the printers right? But no, printing the same file through Acrobat Reader works fine.

As it stands the only option I see is to convert the Ubuntu server to a VM with an expensive Windows Server VM running alongside it, only used for printing... There must be a solution to this issue.

EDIT: I've set up CUPS on my Ubuntu Server 16.04 at home and configured a Canon MG8100 on it. The first few prints came out fine. The next morning, every job I added showed it completed, but actually nothing came out of the printer. This means it does not have anything to do with the printers. I added the MG8100 using LPD.

CUPS error log states the below errors. Keep in mind that all these errors occur for the exact same file on different times, and that the file was printed successfully in the same manner before.

E [26/Nov/2016:13:35:44 +0100] [Job 158] The printer is not responding.  

When this is logged no print is made and CUPS keeps retrying the job until it is abandoned. Other times it fails like this:

W [29/Nov/2016:11:45:01 +0100] [Job 169] /var/spool/cups/d00169-001: file is damaged  W [29/Nov/2016:11:45:01 +0100] [Job 169] /var/spool/cups/d00169-001 (file position 35596): xref not found  W [29/Nov/2016:11:45:01 +0100] [Job 169] /var/spool/cups/d00169-001: Attempting to reconstruct cross-reference table  

Which will result in a mangled print (Random parts being printed, and others being left out).

Use awk results as parameters to another command

Posted: 07 Jul 2022 03:06 PM PDT

I'm extracting rows from a set of text files with awk. The files look like this:

1000    1    75  1000    2    76  1001    1    76  1001    2    80  

I'm searching several directories of these with this command:

awk -F"\t" '$3 == "76" { print $1"\t"$2}' ../benchmark/*/labels.txt  

awk is giving me the correct output:

1000    2  1001    1  

Now for each found row I must execute a script passing these two numbers as parameters, like this:

./build.oct 1000    2  

What's the correct way to do that? I don't really care about script console output (it produces files).

How to save boot.log between reboots?

Posted: 07 Jul 2022 02:36 PM PDT

How do you save the /var/log/boot.log between reboots? Or, more specifically, how can you just have boots be appended to that file? I have an issue with a kernel that I am running and need to be able to preserve the boot.log when I boot up into a working kernel.

No comments:

Post a Comment