Wednesday, July 14, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How do I prevent MacOS terminal from starting multiple shell processes

Posted: 14 Jul 2021 11:11 AM PDT

I've started using Z shell on MacOS Big Sur. I changed the default shell via chsh -s /bin/zsh. When I start the Terminal I see two processes running:

$ ps  CMD  -zsh  /bin/zsh  

I also see the following output when I start the Terminal program (from Applications):

Last login: xxxx  <USER>@macbook ~ % /bin/zsh  <USER>@macbook ~ %  

I've moved all of my ~/.*rc files to a backup directory and continue to observe this behavior. Furthermore, I changed my default shell back to bash via chsh -s /bin/bash and continue to see similar behavior:

Last login: xxxx    The default interactive shell is now zsh.  To update your account to use zsh, please run `chsh -s /bin/zsh`.  For more details, please visit https://support.apple.com/kb/HT208050.  macbook:~ <USER>$ /bin/zsh  <USER>@macbook ~ % ps  CMD  -bash  /bin/zsh  

At this point, I'm not sure what to try next. Any ideas?

find files with peculiar permissions set

Posted: 14 Jul 2021 10:49 AM PDT

I'm prepping for the LPIC1 exam, strongly relying on their online material here. Can someone pls help me clarify this doubt?

What is the difference among these:

  1. find ~ -perm 4000
  2. find ~ -perm -4000
  3. find ~ -perm /4000

Why is SSHFS so much less stable than SSH?

Posted: 14 Jul 2021 10:46 AM PDT

If I'm on a very slow and/or slightly hiccupy internet connection, and I ssh foo@bar.baz, the connection will mostly stay up. If there's particularly bad lag, output (and echoed input) will take forever to appear on the screen, and my terminal may appear to be hung . . . but then, unless the connection has dropped entirely, the output will show up and life will go on. If the connection has dropped entirely, I will usually get a "broken pipe" error message, after which, my original shell (on my own machine) continues working. Occasionally, it may hang instead, but this is not typical.

If, on the other hand, I sshfs foo@bar.baz:. ./qux, even the slightest internet hiccup will leave the remote directory unreachable, and this, in turn, will hang almost any command or program that tries to read from or write to it. Not only that, but the programs in question will usually be impossible to get rid of with kill -9. I've even had the following happen, more than once:

  • In a shell on one (virtual) terminal: ssh foo@bar.baz -- prompts for password, drops me into a shell in foo's home directory
  • In a shell on a second (virtual) terminal: sshfs foo@bar.baz:. ./qux -- prompts me for password, appears to work
  • On that same terminal, less than a minute later: ls qux -- hangs
  • Back to the first shell: No error message, ls displays promptly the contents of foo's home directory, as expected
  • Checking back to the second terminal -- ls is still hung, and proves to be unkillable, except by kill the shell I ran it in (and therefore any other long-running commands that I may foolishly have failed to nohup

Why is this? Why is mounting done with sshfs disrupted by hiccups that don't disrupt a remote shell accessed with ssh? And why do commands that are trying to read from a remote directory mounted with sshfs -- not even to write to it, which if interrupted, could leave a file in an incoherent state, but merely to read from it -- hang unkillably?

Is there a way to tell if a daemon user is chrooted?

Posted: 14 Jul 2021 10:31 AM PDT

I am still new to understanding chroot. Some packages install their own users (_packagedaemon) and create their own directories (/var/package/).

I can see in /etc/passwd:

_packagedaemon:*:860:860:Package Daemon:/var/package:/sbin/nologin  

But I don't know if the user is chrooted, and I'm not sure where else to check.

Why is Vim sometimes starting on random lines and other times only showing first lines of a file?

Posted: 14 Jul 2021 10:22 AM PDT

Vim sometimes only shows me some middle section of a file and other times only the beginning of the file (the first 30 or so lines). How do I change this to show all lines of the file? I read here to use a resize command but that didn't work.

Replace filename by its content

Posted: 14 Jul 2021 09:54 AM PDT

My aim: replace filenames by their contents in a json file with a command sed or awk or other...

An example:

file.json

...        "value": "{{<test/myData.txt>}}"  ...  

test/myData.txt

blabla  blabla  

After a unix command, I want this content in the file.

result.json

...        "value": "blabla\nblabla"  ...  

My problem: I try with Sed: sed -E "s/\{\{<([^>]+)>\}\}/{r \1}/" file.json > result.json

But the file is not read, I have this result:

...    "value": "{r test/myData.txt}"  ...  

An idea to resolve my problem with sed ? or a better idea ?

Thanks

Cannot string together multiple "-c" options using vim from the terminal

Posted: 14 Jul 2021 09:46 AM PDT

I execute a set of handy commands I need to do often on a standard type of file using the -c (or equivalently, the +) option from command line using vim. However, after an update to the remote system's OS, commands beyond the first one are interpreted as different file names and results in the first command being executed and multiple buffers being opened rather than multiple commands being executed on one file.

The command I use is vim -c ':11' -c ':norm wllv,dZZ' myfile (go to line 11, move over a few characters, select the current position, and replace using a leader command, and then save and exit). With the change on the remote system, this now results in two buffers being opened, one is wllv,dZZ and the other is myfile

Vim also throws this error:

Error detected while processing command line:  E471: Argument required: :norm  

Furthermore, if I try vim -c ":11" -c ":21" myfile, both commands work and no extra buffer is opened, which indicates the error is perhaps somewhere with :norm, but I'm not sure why as this was working just fine very recently.

Current version of vim is 7.4, in case that helps.

Any help restoring the old behavior or understanding where the issue is coming from would be greatly appreciated, thanks!

Using sed to change all contents of a file except a particular line number (the header)?

Posted: 14 Jul 2021 10:00 AM PDT

I want to use sed on Linux to change all the second fields in a CSV file for all rows except the first row (which is the header). I'm aware that I can just loop this and go line by line using sed -i '{$LINE_NUMBER ....' and not using this on that line, but I'm wondering if there is a way to do this without a loop which is slower.

I guess I could also just change all contents. Then in the next line change it back for this one particular line.

| Q1 | Q2 | Q3 |  | Name    | Resource_ID | Key |  | Joseph | 343433| AGFD |  | Mary | 242355 | AREW |  

Route to external network with multiple NICs connected to one Linux bridge?

Posted: 14 Jul 2021 09:25 AM PDT

Assume a machine has 2 physical NICs (eth0 and eth1), and both of them can access external network. Then a bridge br0 is created with both eth0 and eth1 added to it (IP addresses are removed on eth0 and eth1, and one of the removed IP address is configured to br0).

The question is, for other subnets from virtual ethernet interface connected to br0, they have their default gateway set to the IP address of br0, but then how does the br0 choose the NIC (eth0 or eth1) to forward the packets from subnets to external network?

Are gpg keyservers always unreliable?

Posted: 14 Jul 2021 09:46 AM PDT

I've used gpg for minimal things for years now (pass, yadm, etc.) and one thing I consistently have noticed is slow response times from the keyservers (mit, ubuntu, etc) when accessed through the web portals (searching takes absolutely forever).

Recently yay seems to have been having trouble importing keys with a No Name error that people seem to frequently encounter and the solution is always to just manually import the key. This has happened twice in the past week for me, with 1password and spotify. I tried researching long term solutions instead of the manual import shortcut and one suggestion was set the keyserver manually in /etc/pacman.d/gnupg/gpg.conf but that didn't resolve the problem. I ran pacman-key --refresh-keys and it worked, but it seemed incredibly error prone. Here's a snapshot of the output toward the end:

==> ERROR: Could not update key: B9113D1ED21E1A55  gpg: error retrieving 'pete@muddygoat.org' via WKD: General error  gpg: error reading key: General error  gpg: error retrieving 'p.r.lewis@cs.bham.ac.uk' via WKD: General error  gpg: error reading key: General error  gpg: error retrieving 'prlewis@letterboxes.org' via WKD: General error  gpg: error reading key: General error  gpg: error retrieving 'plewis@aur.archlinux.org' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 6D1A9E70E19DAA50  gpg: error retrieving 'roman@archlinux.org' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 3A726C6170E80477  gpg: error retrieving 'schiv@archlinux.org' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 81AF739EC0711BF1  gpg: error retrieving 'speps@aur.archlinux.org' via WKD: No data  gpg: error reading key: No data  gpg: WARNING: unacceptable HTTP redirect from server was cleaned up  gpg: error retrieving 'speps@gmx.com' via WKD: No data  gpg: error reading key: No data  gpg: WARNING: unacceptable HTTP redirect from server was cleaned up  gpg: error retrieving 'speps@gmx.com' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: CF7037A4F27FB7DA  gpg: error retrieving 'l.jirkovsky@gmail.com' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 73B8ED52F1D357C1  gpg: error retrieving 'stephane@archlinux.org' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: EA6836E1AB441196  gpg: error retrieving 'gostrc@gmail.com' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 7FB1A3800C84C0A5  gpg: error retrieving 'danielmicay@gmail.com' via WKD: No data  gpg: error reading key: No data  gpg: error retrieving 'security@grapheneos.org' via WKD: No data  gpg: error reading key: No data  gpg: error retrieving 'security@attestation.app' via WKD: No data  gpg: error reading key: No data  gpg: WARNING: unacceptable HTTP redirect from server was cleaned up  gpg: error retrieving 'security@seamlessupdate.app' via WKD: No data  gpg: error reading key: No data  gpg: error retrieving 'daniel.micay@grapheneos.org' via WKD: No data  gpg: error reading key: No data  gpg: error retrieving 'daniel.micay@attestation.app' via WKD: No data  gpg: error reading key: No data  gpg: WARNING: unacceptable HTTP redirect from server was cleaned up  gpg: error retrieving 'daniel.micay@seamlessupdate.app' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: F9E712E59AF5F22A  gpg: error retrieving 'teg@jklm.no' via WKD: Connection refused  gpg: error reading key: Connection refused  gpg: error retrieving 'teg@pps.jussieu.fr' via WKD: No name  gpg: error reading key: No name  gpg: error retrieving 'tomegun@archlinux.org' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: C8880A6406361833  gpg: error retrieving 'timothy.redaelli@gmail.com' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: E711306E3C4F88BC  gpg: error retrieving 'atsutane@freethoughts.de' via WKD: General error  gpg: error reading key: General error  gpg: error retrieving 't.toepper@gmx.de' via WKD: No data  gpg: error reading key: No data  gpg: error retrieving 'atsutane@freethoughts.de' via WKD: General error  gpg: error reading key: General error  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 39E4F17F295AFBF4  gpg: WARNING: unacceptable HTTP redirect from server was cleaned up  gpg: error retrieving 'vegai@iki.fi' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 097D629E437520BD  gpg: error retrieving 'xyne@archlinux.ca' via WKD: No data  gpg: error reading key: No data  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 5CED81B7C2E5C0D2  gpg: error retrieving 'baptiste@bitsofnetworks.org' via WKD: No data  gpg: error reading key: No data  gpg: error retrieving 'baptiste@jonglez.org' via WKD: General error  gpg: error reading key: General error  gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net  gpg: keyserver refresh failed: No name  ==> ERROR: Could not update key: 1F0CD4921ECAA030  gpg: key 4DC95B6D7BE9892E: "David Runge (Arch Linux Master Key) <dvzrv@master-key.archlinux.org>" not changed  gpg: Total number processed: 1  gpg:              unchanged: 1  pub   ed25519 2021-04-26 [SC]        2AC0A42EFB0B5CBC7A0402ED4DC95B6D7BE9892E  uid           [  full  ] David Runge (Arch Linux Master Key) <dvzrv@master-key.archlinux.org>  sub   cv25519 2021-04-26 [E]    gpg: key 25EA6900D9EA5EBC: "George Rawlinson <george@rawlinson.net.nz>" 1 new signature  gpg: Total number processed: 1  gpg:         new signatures: 1  pub   ed25519 2016-11-03 [C]        034D823DA2055BEE6A6BF0BB25EA6900D9EA5EBC  uid           [ unknown] George Rawlinson <george@rawlinson.net.nz>  uid           [  full  ] George Rawlinson <grawlinson@archlinux.org>  sub   ed25519 2016-11-03 [S]  sub   ed25519 2016-11-04 [A]  sub   cv25519 2016-11-04 [E]  

Is this always the case with gpg and keyservers? Are manual imports just a part of life? Why are these keyservers so unstable?

Please note: the Arch wiki suggests the following possible problems:

  • An outdated archlinux-keyring package.
  • Incorrect date.
  • Your ISP blocked the port used to import PGP keys.
  • Your pacman cache contains copies of unsigned packages from previous attempts.
  • dirmngr is not correctly configured
  • you have not upgraded in a long time and gpg/pacman does not handle that well

But I upgrade daily, my ISP has not blocked any ports (I can manually import), and my date is correct. I'm pretty sure I even recently cleared my pacman and yay caches (which seems like people actually recommend against). It seems like it's a problem with the spottiness of the keyservers themselves.

Am I wrong that it's the keyservers? If not, why are they so spotty? If I am wrong, what can I do to improve my pacman/yay experience to make this smoother and eliminate these pain points.

send udp broadcast via bash

Posted: 14 Jul 2021 08:47 AM PDT

I try to send a udp broadcast with 2 (FF 01) bytes over bash, but in my network sniffer I notice it's 3 bytes. FF 01 0A where does the line break come from and how can i prevent it?

echo -e '\xFF\x01' | socat - udp-datagram:255.255.255.255:1500,bind=:6666,broadcast,reuseaddr  

how can I check/test 2 conditions then execute a specific list of commands I tried case, I tried if, I tried for not working

Posted: 14 Jul 2021 10:01 AM PDT

sorry if it was confusing.

here is what the script needs to be doing

I input 2 values.

DB Server name= 192.168.1.1

DB schema = My_DB_schema

Then I need a method to execute some command when those 2 values are there

sample would be:

if the DB server name and DB schema are

192.168.1.1
My_DB_schema

execute

command 1

command 2

I tried with a case statement but i think it will only test for one condition.

Thank you

Passing a variable value to a second call to awk

Posted: 14 Jul 2021 08:40 AM PDT

I want to pass the variable var to the next awk statement in the below command

cat scr1|awk '{val=substr($0,10,10)} 1'|awk '/           /{print $0}'  

This statement is for finding a string of 10 blank spaces in a file ONLY at positions 10 through 19 and returning that row only. If anyone has a better way please let me know.

Loop through MAC addresses, how to handle both numbers (0-9) and letters (a-f) in a "for" loop

Posted: 14 Jul 2021 08:33 AM PDT

I've a script with this code

for i in {2..9}          do           grep "Node${i}\|01, source address = 00:00:00:00:00:0${i}" t1.txt > t2.txt          done  

Is it possible to expand the loop from "9" to the "f" character of the exadecimal MAC address, in order to handle the "a" to "f" cases too?

Showing line numbers by default in ed

Posted: 14 Jul 2021 08:58 AM PDT

In the ex editor, one can show line numbers by default by adding this line to a .exrc file:

set number  

Is there a way to have ed start with line numbers showing by default, when lines are invoked?

Running an ed script from within ed

Posted: 14 Jul 2021 10:58 AM PDT

I have created a script file called "cleanup" which contains a series of regular expressions that clean up an ed file(s) of blank spaces, trailing white-space, blank lines etc. I run it as follows:

ed [name-of-file] < [name-of-script]  

I sometimes want to run the script on the file I am currently editing from within ed. I am unsure of the syntax I would need to do that.

Here is an example script:

g/^  */s///  # Remove blank spaces at the beginning of a line  g/  *$/s///  # Remove trailing whitespace at end of line  g/   */s// /g  # Remove additional spaces between words  g/^$/d  # delete blank lines  g/\(''\|''\)/s//"/g  # Remove curly braces  g/\("\|"\)/s//"/g  g/\('\|'\)/s//'/g  # idem  ,p  Q  

How to change two alternative file extension with a specific extension?

Posted: 14 Jul 2021 09:59 AM PDT

I have two different file extensions abc.fq.gz and abc.fastq.gz and I need to change these to abc.sam.

I tried this:

#!/bin/bash  refdir="Homo_sapiens.GRCh38.dna_sm.primary_assembly"  forward=(*_1.{fq,fastq}.gz)  reverse=(*_2.{fq,fastq}.gz)    for i in "${!forward[@]}"  do    echo ${forward[i]//_1.{fq,fastq}.gz/.sam}>> a.txt  done  

but this {fq,fastq} part doesn't work. As you can see above I need to replace either _1.fq.gz or _2.fastq.gz with .sam, so

  • the input is either abc_1.fq.gz or abc_1.fastq.gz
  • and the expected output is abc.sam

How can I do this?

Systemd service deactivates itself when USB device is pulled out

Posted: 14 Jul 2021 10:48 AM PDT

I have a task manager that communicates to an arduino over serial port, the arduino has an OLED display that shows the system's CPU, memory, swap, net download/upload, disk read/write usages.

The service is written in Ruby, and it never exits. If the arduino is pulled out and replugged, the service detects that.

To enable the Ruby script at boot, I have the following systemd service:

[Unit]  Description=Arduino OLED as a Ultra Light-Weight System Monitor     [Service]  ExecStart=/bin/ruby /root/.local/share/gem/ruby/3.0.0/bin/blink-tm  Restart=on-failure  User=root  Group=root    [Install]  WantedBy=multi-user.target  

When I start it, it works just fine. But when I pull out the arduino, even though the code should work, the unit still deactivates itself! I also tried adding Type=oneshot, Type=simple, and Type=forking, but no luck

Here's the status of the service when the arduino is pulled out from the PC:

○ blink-tm.service - Arduino OLED as a Ultra Light-Weight System Monitor       Loaded: loaded (/usr/lib/systemd/system/blink-tm.service; enabled; vendor preset: disabled)       Active: inactive (dead) since Wed 2021-07-14 13:02:33 IST; 3min 30s ago      Process: 3502 ExecStart=/bin/ruby /root/.local/share/gem/ruby/3.0.0/bin/blink-tm (code=exited, statu>     Main PID: 3502 (code=exited, status=0/SUCCESS)          CPU: 115ms    Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.41: A potential device discovered: 1a86:7523  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.41: Changing baudrate to 57600...  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.41: Successfully Changed baudrate to 57600...  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.41: No device found. Retrying 2  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.91: A potential device discovered: 1a86:7523  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.91: Changing baudrate to 57600...  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:32.91: Successfully Changed baudrate to 57600...  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:33.41: Device discovered successfully. Path: /dev/ttyUSB0  Jul 14 13:02:33 archlinux ruby[3502]: :: 13:02:33.66: Device ready!  Jul 14 13:02:33 archlinux systemd[1]: blink-tm.service: Deactivated successfully.  

As said, the Ruby script never fails, it prints some standard output. One example is running /bin/ruby /root/.local/share/gem/ruby/3.0.0/bin/blink-tm from the terminal never exits when I pull out the arduino and re-plug it in.

So what could be the reason behind auto-deactivating service? I want to run the service as long as the ruby script runs.

Installing pgadmin4 from source code in debian. It has no .configure

Posted: 14 Jul 2021 10:47 AM PDT

I downloaded source code with .tar.gz extension. I extracted it

   tar -xzf pgamdin4-5-6.tar.gz  

However, inside pgadmin4-5-6 directory there is no configure file. I think we run ./configure to create a Makefile, so Makefile already exist. This is what I get when I run ls

DEPENDENCIES  Dockerfile  docs  LICENSE  Make.bat  Makefile  pkg  README.md  requirements.txt  runtime  tools  web  

I tried

 $ make  

this gives me error:

file "build_code_snippet.py", line 4, in <module>      import builtins  ImportError: No module named builtins  make[1]: [Makefile.sphinx:22: code_snippet] Error 1 (ignored)  sphinx-build -W -b html -d _build/doctrees   . _build/html  make[1]: sphinx-build: No such file or directory  make[1]: *** [Makefile.sphinx:47: html] Error 127  make[1]: Leaving directory '/home/tesla/Downloads/pgadmin4-5.4/docs/en_US'  make: *** [Makefile:128: docs] Error 2  

When I tried make install I get this error:

   make: *** No rule to make target 'install'.  Stop.  

I already installed with python. However, I want to know how I can install from the source code. What am I doing? I already tried from source code last year on a different machine and I have tried recently on my new machine, I wonder how can I install it

Logical Device Name assigned to Physical NIC mapping

Posted: 14 Jul 2021 09:31 AM PDT

I'm looking for a scripted solution that will show which logical network interfaces are mapped to which physical NICs.

That is, if a server has 2+ interfaces and 2+ NICs, how do I know which NIC contains which interface? i.e., the ethX interface is mapped to the underlying ______ NIC hardware.

The closest I can get right now involves using two commands and then comparing the results. I'm striving for the most generic *nix commands as I want these to work across a broad swath of Linux installations without relying on any additional installed tools/packages. ( Typically, I have no rights or permission to install anything)

Command 1 returns the interface name and the MAC address. MAC addresses are typically immutable, so they provide a solid reference point. The interface name is a label, and is gathered for reference

> ip link show  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000          link/ether 14:18:77:27:c1:32 brd ff:ff:ff:ff:ff:ff  3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000          link/ether 14:18:77:27:c1:33 brd ff:ff:ff:ff:ff:ff  4: sci0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000          link/ether 14:18:77:27:c1:34 brd ff:ff:ff:ff:ff:ff  5: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000          link/ether 14:18:77:27:c1:35 brd ff:ff:ff:ff:ff:ff  

Command 2:

>lspci -vd ::0200        01:00.0 Ethernet controller: Broadcom Limited NetXtreme BCM5720 Gigabit Ethernet PCIe          Subsystem: Dell Device 1f5b          Flags: bus master, fast devsel, latency 0, IRQ 55, NUMA node 0          Memory at 91b30000 (64-bit, prefetchable) [size=64K]          Memory at 91b40000 (64-bit, prefetchable) [size=64K]          Memory at 91b50000 (64-bit, prefetchable) [size=64K]          Expansion ROM at 92700000 [disabled] [size=256K]          Capabilities: [48] Power Management version 3          Capabilities: [50] Vital Product Data          Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+          Capabilities: [a0] MSI-X: Enable+ Count=17 Masked-          Capabilities: [ac] Express Endpoint, MSI 00          Capabilities: [100] Advanced Error Reporting          Capabilities: [13c] Device Serial Number 00-00-14-18-77-27-c1-32          Capabilities: [150] Power Budgeting <?>          Capabilities: [160] Virtual Channel          Kernel driver in use: tg3          Kernel modules: tg    01:00.1 Ethernet controller: Broadcom Limited NetXtreme BCM5720 Gigabit Ethernet PCIe          Subsystem: Dell Device 1f5b          Flags: bus master, fast devsel, latency 0, IRQ 57, NUMA node 0          Memory at 91b00000 (64-bit, prefetchable) [size=64K]          Memory at 91b10000 (64-bit, prefetchable) [size=64K]          Memory at 91b20000 (64-bit, prefetchable) [size=64K]          Expansion ROM at 92740000 [disabled] [size=256K]          Capabilities: [48] Power Management version 3          Capabilities: [50] Vital Product Data          Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+          Capabilities: [a0] MSI-X: Enable+ Count=17 Masked-          Capabilities: [ac] Express Endpoint, MSI 00          Capabilities: [100] Advanced Error Reporting          Capabilities: [13c] Device Serial Number 00-00-14-18-77-27-c1-33      ...  

From these two outputs I can map the interface on eth0 to the physical NIC, using the interface MAC Address and the Device Serial Number.

Is there a more direct method to see this?

We need a scripting method to handle this as a remote discovery.

Due to some limitations, the command cannot use any piping of output. So no grep, awk, etc. We can truncate and compare the results in code.

Thank you.

Wifi 6 ax2201 with kali linux live usb

Posted: 14 Jul 2021 09:12 AM PDT

I have an hp laptop with the intel wifi 6 ax201 wifi card.
The wifi does not function when live booting kali linux. However, wifi will function, if I boot kali linux as persistant from the usb, than reboot (back to persistancy), so I assume the drivers are there, they just requiere a reboot. The problem is, since I ran it live for testing purposes, there is no reboot for me, and persistancy is just so slow,freezes every couple of mins and so on, so I don't want to use that.
I tries downloading and installing the drivers from intel (installed according to the readme file that comes with it), but that did not work, though I am not sure if I did that correctly, since I am a newbie.
Basically, is there a way that wifi 6 ax201 from intel could function with kali live boot without peristance?

Xterm / Aterm takes ages to redraw the screen when changing workspace

Posted: 14 Jul 2021 11:05 AM PDT

This is a weird problem that i'm having, so i love xterm i've been using it for over a decade, and I've never had any problems with it. I was using it xterm fine under debian / gentoo / solaris / hp ux, i recently upgraded this system, with a AMD Ryzen 5 board, and removed the old Intel board. I completely reinstalled the operating system, the graphics card, window manager and operating system version are the same (i.e. still debian)

But whenever i switch workspaces (I'm using windowmaker) Xterm takes several seconds to redraw the xterm contents, and i use dozens of xterm windows, so it can take about 5-6 seconds to redraw all the xterm contents on the screen. I've never had this problem before, it must be some setting.

Is there some way to force it to remember the xterm contents so it doesn't redraw the entire thing unnecessarily each time you change workspaces?

I've tried other terminals too, and those also redraw the entire terminal contents from start to finish. Very slowly. So I don't think this is an xterm problem, think it's some linux xorg setting. Has anyone else come across this?

Just to add something to this, i notice the screen refresh goes really slow for the top half of the screen, then instant for the bottom half. It's almost as though it's forgotten than the terminal is maximised. When I press ALT+ENTER to full screen the window, the screen redraws instantly.

Wireless Ralink USB Adapter doesn't work properly in Kali Linux 2021

Posted: 14 Jul 2021 10:08 AM PDT

I want to make it as simple as possible. So I have downloaded Kali Linux 2021 latest version on my VirtualBox and my host machine runs Windows 10.

I bought a USB wireless adapter which has a Ralink RT5370 chipset (supports monitor mode). I just completed my Kali virtual setup and it is completely fresh.

Yet, my USB wireless adapter doesn't work in VirtualBox Kali but works in my host machine (Windows 10).

In Kali, I can see wlan0 in ifconfig and iwconfig (which means Kali can see the adapter). I can execute ifconfig wlan0 down/up but it doesn't scan any networks. It doesn't show any network in wireless settings and sudo iwlist wlan0 scan returns no results.

And there are 5-6 networks around me (I can see them in host machine). So what should I do to make my adapter work in fresh Kali Linux setup? I can provide any command output information (like lsusb) you can just ask for them. Thanks in advance.

How can I receive an xmodem file using command line?

Posted: 14 Jul 2021 11:01 AM PDT

I'm using Putty or Picocom to talk directly to a Mobile Modem using AT commands, while doing some experiments that require up/downloading some files on the mobile module's EFS partition. The protocol used to do this is Xmodem and it seem that most terminal utilities no longer include/support this. Picocom does as a 3rd party dependence:

Picocom can send and receive files over the serial port   using external programs that implement the respective protocols.   In Linux typical programs for this purpose are:    • rx(1) - receive using the X-MODEM protocol        *  • rb(1) - receive using the Y-MODEM protocol  • rz(1) - receive using the Z-MODEM protocol  • sx(1) - send using the X-MODEM protocol           *  • sb(1) - send using the Y-MODEM protocol  • sz(1) - send using the Z-MODEM protocol  

However, none of these are available for Win/Cygwin and I'm not able to find the sources to compile these. (Where are these hosted these days?)

Q: What would be the easiest way to receive Xmodem data using command line?
(What other simple alternatives are there?)

I have already looked at the following Unix SE questions:

Central user management with multiple servers with SSH keys, LDAP?

Posted: 14 Jul 2021 10:02 AM PDT

the number of my servers and users is growing and I would like to adopt a central database to manage users accounts. I'm thinking about OpenLDAP, but I have a question.

Is it possible in LDAP to somehow restrict specific users to access only certain servers? For example, I have servers A, B, C, D and E and users 1 to 20. Let us say that users 1-5 can access servers B and D, users 6-10 servers A, B and E, users 11-20 to all of the servers. Can I enforce this somehow in LDAP or any other central database?

Is there a better solution than LDAP? I would also like to centrally manage SSH keys for my users. I know that there is a schema to do this in LDAP, but is there an alternative better soultion to this situation?

Best Regards
Kamil

How to make tr aware of non-ascii(unicode) characters?

Posted: 14 Jul 2021 10:44 AM PDT

I'm trying to remove some characters from file(UTF-8). I'm using tr for this purpose:

tr -cs '[[:alpha:][:space:]]' ' ' <testdata.dat   

File contains some foreign characters (like "Латвийская" or "àé"). tr doesn't seem to understand them: it treats them as non-alpha and removes too.

I've tried changing some of my locale settings:

LC_CTYPE=C LC_COLLATE=C tr -cs '[[:alpha:][:space:]]' ' ' <testdata.dat  LC_CTYPE=ru_RU.UTF-8 LC_COLLATE=C tr -cs '[[:alpha:][:space:]]' ' ' <testdata.dat  LC_CTYPE=ru_RU.UTF-8 LC_COLLATE=ru_RU.UTF-8 tr -cs '[[:alpha:][:space:]]' ' ' <testdata.dat  

Unfortunately, none of these worked.

How can I make tr understand Unicode?

check the current backlog queue size

Posted: 14 Jul 2021 09:02 AM PDT

The sysctl netdev_max_backlog sets a limit to the maximum number of packets allowed in the kernel's backlog queue.

Is there a way to check the current queue size (i.e., how many packets are currently in the queue at a given time)?

Literally, the value of queue->input_pkt_queue.qlen from net/core/dev.c:netif_rx():

  queue = &__get_cpu_var(softnet_data);      __get_cpu_var(netdev_rx_stat).total++;    if (queue->input_pkt_queue.qlen <= netdev_max_backlog) {      if (queue->input_pkt_queue.qlen) {  enqueue:        __skb_queue_tail(&queue->input_pkt_queue, skb);        local_irq_restore(flags);        return NET_RX_SUCCESS;      }  

Root access denied in LiveUSB of Porteus

Posted: 14 Jul 2021 09:15 AM PDT

I am on Live Linux USB of Porteus linux and I copied it to RAM.

I want to access root folder for making changes so that settings gets saved.

but this is showing upRoot Access denied

How to remove multiple newlines at EOF?

Posted: 14 Jul 2021 10:58 AM PDT

I have files that end in one or more newlines and should end in only one newline. How can I do that with Bash/Unix/GNU tools?

Example bad file:

1\n  \n  2\n  \n  \n  3\n  \n  \n  \n  

Example corrected file:

1\n  \n  2\n  \n  \n  3\n  

In other words: There should be exactly one newline between the EOF and the last non-newline character of the file.

Reference Implementation

Read file contents, chop off a single newline till there no further two newlines at the end, write it back:

#! /bin/python    import sys    with open(sys.argv[1]) as infile:      lines = infile.read()    while lines.endswith("\n\n"):      lines = lines[:-1]    with open(sys.argv[2], 'w') as outfile:      for line in lines:          outfile.write(line)  

Clarification: Of course, piping is allowed, if that is more elegant.

Dashes in printf

Posted: 14 Jul 2021 09:05 AM PDT

I'm trying to use printf to format some pretty output in a bash script

e.g.:

-----------------------    | This is some output |   -----------------------  

But I've stumbled over some behavior I don't understand.

$ printf "--"  

gives me the error:

printf: usage: printf [-v var] format [arguments]

and

$ printf "-stuff"  

results in

-bash: printf: -s: invalid option

So apparently printf thinks I'm trying to pass some arguments while I'm not.

Meanwhile, completely by accident, I've found this workaround:

$ printf -- "--- this works now ----\n"  

gives me

--- this works now ----  

Can anyone explain this behavior?

No comments:

Post a Comment