Friday, July 23, 2021

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


sudo apt update sudo apt upgrade updated all but firefox

Posted: 23 Jul 2021 10:37 AM PDT

Looking at "similar questions", I did not find my issue. When running: sudo apt update sudo apt upgrade, it updated all BUT firefox. Any suggestions/corrections?

How to bind mount a directory on startup without sudo

Posted: 23 Jul 2021 10:19 AM PDT

NOTE: I'm working in WSL2, but my issues lies entirely within the Linux side of things. Please let me know if this is not the right place for this.

I am needing to mount --bind a directory during startup, I'm using the following in .bashrc:

if ! mountpoint -q -- "/mnt/wsl/$WSL_DISTRO_NAME"; then      mount --bind --make-private / "/mnt/wsl/$WSL_DISTRO_NAME"  fi  

I am getting an [expected] error: only root can use "--bind" option.

I have tried elevating my user privelege via /etc/sudoers:

[myusername] ALL=(ALL) NOPASSWD: /bin/mount  

I have also tried adding the following to /etc/fstab:

/       /mnt/wsl/Ubuntu-18.04   none    bind,user       0 0  

Yet nothing seems to work. I would like to accomplish this as responsibly as possible without giving my user permanent admin/root privilege... or any other similarly "lazy-ish" option.

A start job for unit sddm.service has failed

Posted: 23 Jul 2021 10:06 AM PDT

i made a clean installation of debian with kdeplasma on my laptop, but i havent desktop environmet install project bumblebee also try reinstall kde but nothing of this works for me, my journal say this

enter image description here

Meaning of the output from lsblk command

Posted: 23 Jul 2021 10:21 AM PDT

I have recently started using Linux and would love to know how to interpret the output from the lsblk -f command.

More specifically, I would like to know the different partitions and sizes.

  • For instance, I understand that ext4 and xfs are different file systems in unix. But the entire picture has a tree structure. So I was wondering if the total number of partitions is 4, i.e.,sda1, sda2, sda3 and sdb.
  • If so, then what are the sub-partitions (root, swap, home and var)?
  • Also, is lvm2_member a filesystem too?
NAME            FSTYPE      LABEL MOUNTPOINT   SIZE  sda                                            1.1T  ├─sda1                                           2M  ├─sda2          xfs               /boot          2G  └─sda3          LVM2_member                    1.1T    ├─centos-root ext4              /            200G    ├─centos-swap swap              [SWAP]       128G    ├─centos-var  ext4              /var          10G    └─centos-home ext4              /home        777G  sdb             ext4        data  /data       81.9T  loop1           squashfs                     487.5M  

ubuntu downgraded to 16.04 with a few issues

Posted: 23 Jul 2021 09:21 AM PDT

I have a laptop with Ubuntu 16.04 which has been used for countless things and is a mess of packages. A few weeks ago I further messed with it, as I needed to install ROS. I hammered it a little too much, and I found myself on 18.04. I was unaware that upgrading some packages to the version intended for a more recent release might have "unintended effects" and I also take the opportunity to warn everyone who might attempt the same thing. The scripts are strongly biased towards upgrading everything they can, and they don't ask for confirmation in an obvious manner (say "please confirm upgrade from 16.04 to 18.04")

It took a lot to downgrade and I dissuade everyone, like the official Ubuntu documentation does.

I would like to ask your help about a few issues.

  1. I am having some trouble with the graphic interfaces. I have xubuntu working, but it works correctly only if I login as root; gnome and the standard ubuntu do not work. I assume the upgrade scripts have made changes and I would have to revert, but I am rather clueless. I do not know if my graphic environment issues have to do with environmental variables, with having installed another graphic interface, or with some subtle preexisting problem. The whole mess came to be because I could not install the graphical interface of ROS; command line worked OK.

  2. now I am installing ROS again and some dependencies are incorrect; I realize that it is not straightforward to automatically decide which packages should be downgraded as the whole compiler toolchain was modified and backtracked, and I am willing to get my hands dirtier than they are already, but I would like to ask for some resources on correctly disentangling dependencies. The machine is old (latitude e6440 i7) and compiling from source would look like the most straightforward path, but is impractically slow.

Thank you a lot

How to find the escape sequence for `Shift + PageUp`/`Shift + PageDown`?

Posted: 23 Jul 2021 09:32 AM PDT

How can I find the escape sequence for Shift + PageUp/Shift + PageDown?

I googled and tried a few suggestions, but what always happens is that the screen scrolls up/down when I press this, or nothing gets printed.

I'm trying to get the escape sequence, so that I can assign it to the PageUp/PageDown function in Tmux, when I'm in a TTY/virtual console. As you might know, recent Linux kernels have removed this functionality.

If it's relevant, some other Shift-related bindings I'm using in my terminal WezTerm:

{key='UpArrow', mods='SHIFT', action=wezterm.action{SendString='\x1b[a'}},  {key='DownArrow', mods='SHIFT', action=wezterm.action{SendString='\x1b[b'}},  {key='LeftArrow', mods='SHIFT', action=wezterm.action{SendString='\x1b[d'}},  {key='RightArrow', mods='SHIFT', action=wezterm.action{SendString='\x1b[c'}},  

Just giving an escape sequence that's in spirit with the above escape sequences is fine too.

How to copy entire directory as is (failed to preserve ownership)

Posted: 23 Jul 2021 10:06 AM PDT

I am trying to prepare Raspberry Pi image to be netbooted. I have downloaded IMG file of raspbian (for ex 2017-07-05-raspbian-jessie) and mounted it locally to linux box. I got two partitions. Now I wish to copy them to nfs server location.

If I do

cp -a * /home/dims/nfstest/root  

I get numerous errors like

cp: failed to preserve ownership for '/home/dims/nfstest/root/etc/lighttpd': Operation not permitted  

What does it mean and how to proceed?


It was because shared directory's owneship was nobody:nogroup. I don't know how it was affecting, so the answer is still interesting.

ExecCondition doesn't prevent start of service

Posted: 23 Jul 2021 09:29 AM PDT

I have a service file with an ExecCondition that, when exits with status=1/FAILURE, doesn't prevent the start of the daemon.

Which I believe, based on the documentation, should prevent the daemon from starting as well as prevent all other ExecStartPre commands from running.

when an ExecCondition= command exits with exit code 1 through 254 (inclusive), the remaining commands are skipped and the unit is not marked as failed.

systemd.service documentation

I put in a condition that should fail every time in an obvious way. ExecCondition=-sh -c 'exit(1)'

Here's the service file (with names changed to protect the innocent).

[Unit]  Description=Application  Wants=x-ray.service yankee.service zulu.service  Requires=alpha.service bravo.service  After=x-ray.service charlie.service bravo.service    [Service]  ExecCondition=-sh -c 'exit(1)'  ExecStartPre=-sh -c 'prestartShellScript.sh'  ExecStart=/opt/app/app argument1 argument2  WatchdogSec=10  Restart=always  RestartSec=10  WorkingDirectory=/opt/app  TimeoutSec=10    [Install]  WantedBy=multi-user.target  

But when I start the service, using systemctl status app I see this showing the app is running and the other processes also ran:

     Active: active (running) since Fri 2020-02-07 18:06:57 UTC; 6s ago      Process: 33783 ExecCondition=/bin/sh -c exit(1) (code=exited, status=1/FAILURE)      Process: 33796 ExecStartPre=/bin/sh -c prestartShellScript.sh (code=exited, status=0/SUCCESS)     Main PID: 33827 (app)        Tasks: 19 (limit: 4177)       Memory: 101.5M       CGroup: /system.slice/app.service               └─33827 /opt/app/app argument1 argument2  

I've also changed my ExecCondition to ExecStartPre but I see the same behavior.

How do I change my $EDITOR variable if it refuses to change?

Posted: 23 Jul 2021 08:24 AM PDT

I'm running Manjaro Linux in the KDE Plasma desktop environment. I'd like to be able to use the classic C-X C-E command to run Vim from a terminal emulator running Bash on the GUI desktop. However, when I try to change $EDITOR from /usr/bin/nano to /usr/bin/vim in my ~/.bash_profile, it fails to change in terminal emulators running on the GUI desktop. What could cause this, and how could I change it?

In the virtual consoles, it works fine. I execute $ echo $EDITOR and the expected /usr/bin/vim appears. Other environment variables changed and added in .bash_profile appear as expected in terminal emulators on the desktop and in the virtual consoles, e.g. $ echo SDL_SOUNDFONTS returns /path/to/foo.sf2.

When I execute $ export EDITOR=/usr/bin/vim or $ EDITOR=/usr/bin/vim; export EDITOR in a terminal emulator on the GUI desktop, the environment variable changes as expected to /usr/bin/vim. Likewise, if I add export EDITOR=/usr/bin/vim or EDITOR=/usr/bin/vim; export EDITOR to my .bashrc, then $ echo EDITOR returns /usr/bin/vim as expected in terminal emulators on the GUI desktop.

However, I've seen it said that environment variables should be modified in ~/.bash_profile or ~/.profile, or even in /etc for variables set globally, but not in ~/.bashrc, which is why I've focused on ~/.bash_profile.

At this point, I just want to satisfy my curiosity: What in the desktop environment could be changing $EDITOR to /usr/bin/nano over the instructions in my ~/.bash_profile? As far as I can tell, my .bashrc isn't the culprit, but I'm a new user and could easily have missed something important.

Quickly check if file is a text (non-binary) file

Posted: 23 Jul 2021 08:21 AM PDT

I have a list of files where I want to filter out all non-text (binary) files. I know that I can use file to check the filetype, but this is abysmally slow for huge numbers of files (I have omitted the grep text | cut -d':' -f1 for brevity):

❯ find -type f | wc -l  3719  ❯ find -type f | time ( while read file; do file $file; done ) >/dev/null  ( while read file; do; file $file; done; ) > /dev/null  10,08s user 4,92s system 99% cpu 15,019 total  ❯ find -type f | time parallel file >/dev/null  parallel file > /dev/null  21,49s user 12,36s system 468% cpu 7,229 total  ❯ find -type f | time xargs file >/dev/null  xargs file > /dev/null  4,39s user 0,04s system 99% cpu 4,444 total  ❯ find -type f | time ( while read file; do case "$(head -c2 $file)" in ([[:print:]][[:print:]]) echo $file;; esac; done ) >/dev/null  ( while read file; do; case "$(head -c2 $file)" in ([[:print:]][[:print:]])    1,96s user 1,13s system 105% cpu 2,942 total  

The last example above is the idea I pursued so far - read in the first few characters of a file and check whether they are printable. This will have to be adjusted to allow newlines though, and it isn't faster by a sufficient margin.

I only need a heuristic that filters out most of the binary files, it does not have to be completely accurate.

linux 2 interfaces 2 gateway routing problem

Posted: 23 Jul 2021 08:30 AM PDT

I have a server, running Oracle Linux 8.4 with 2 IP addresses on 2 nics:

    link/ether 34:48:ed:f6:d3:5c brd ff:ff:ff:ff:ff:ff      inet 10.154.224.252/24 brd 10.154.224.255 scope global noprefixroute eno1         valid_lft forever preferred_lft forever      inet6 fe80::3648:edff:fef6:d35c/64 scope link         valid_lft forever preferred_lft forever  3: ens2f0np0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether bc:97:e1:7a:41:e0 brd ff:ff:ff:ff:ff:ff      inet 10.154.226.252/24 brd 10.154.226.255 scope global noprefixroute ens2f0np0         valid_lft forever preferred_lft forever      inet6 fe80::be97:e1ff:fe7a:41e0/64 scope link         valid_lft forever preferred_lft forever  

So I created 2 table routing in /etc/iproute2/rt_tables db and app and script

#!/bin/sh  ip route add 10.154.226.0/24 dev ens2f0np0 src 10.154.226.252 table db  ip route add default via 10.154.226.1 dev ens2f0np0 table db  ip rule add from 10.154.226.252/24 table db  ip rule add to 10.154.226.252/24 table db    ip route add 10.154.224.0/24 dev eno1 src 10.154.224.252 table app  ip route add default via 10.154.224.1 dev eno1 table app  ip rule add from 10.154.224.252/24 table app  ip rule add to 10.154.224.252/24 table app     ip r command show:     10.154.224.0/24 dev eno1 proto kernel scope link src 10.154.224.252 metric 100  10.154.226.0/24 dev ens2f0np0 proto kernel scope link src 10.154.226.252 metric 100  192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown  

i can connect to machine in any interface via ssh, but i cannot go out from server to internet, other subnets.

Kernel IP routing table  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface  10.154.224.0    0.0.0.0         255.255.255.0   U     100    0        0 eno1  10.154.226.0    0.0.0.0         255.255.255.0   U     100    0        0 ens2f0np0  192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0  

Something I miss? How can i fix that?

Count the number of ssh connections made from and to a solaris host per minute

Posted: 23 Jul 2021 07:44 AM PDT

The purpose of this exercise is to know the count of ssh connection that my ansible automation creates when it runs.

/etc/centrifydc/ssh/sshd_config is the ssh utility that my automation uses.

My ansible on my localhost (linux) which connects to oracle@remotehost7 (solaris) and makes several ssh connections.

I need a count of the number of such ssh connections made in the last 1 minute.

I know how to list ssh connections using command ss | grep -i ssh

Can someone please guide how to record the count of ssh connections made to remotehost7 in the last 1 minute?

Pulseaudio can't capture audio on headphone

Posted: 23 Jul 2021 07:44 AM PDT

I was trying to install cava on Manjaro. I've configured the source correctly, but it gave an error. I've tried other sound visualizers (like vis) and same thing happened.

It can't be a configuration problem, because the same thing happens on the KDE audio preview (when you play an audio and it shows how high is the volume of the audio playing).

I've created a virtual microphone that monitors a virtual audio device (null sink). When i play audio in that device (and configure the music visualizer to use it), it works with no problem, on all programs (cava, vis and kde).

My conclusion is that it must be a problem with pulseaudio, though i don't have the technical knowledge to be sure.

This is the output of the pacmd list-sinks:

2 sink(s) available.      index: 1          name: <Source>          driver: <module-null-sink.c>          flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY          state: IDLE          suspend cause: (none)          priority: 1000          volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB                  balance 0,00          base volume: 65536 / 100% / 0,00 dB          volume steps: 65537          muted: no          current latency: 1252,57 ms          max request: 344 KiB          max rewind: 344 KiB          monitor source: 1          sample spec: s16le 2ch 44100Hz          channel map: front-left,front-right                       Estéreo          used by: 0          linked by: 1          configured latency: 2000,00 ms; range is 0,50 .. 2000,00 ms          module: 25          properties:                  device.description = "Saída nula"                  device.class = "abstract"                  device.icon_name = "audio-card"    * index: 20          name: <alsa_output.pci-0000_07_00.6.analog-stereo>          driver: <module-alsa-card.c>          flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY          state: RUNNING          suspend cause: (none)          priority: 9039          volume: front-left: 32768 /  50% / -18,06 dB,   front-right: 32768 /  50% / -18,06 dB                  balance 0,00          base volume: 65536 / 100% / 0,00 dB          volume steps: 65537          muted: no          current latency: 18,46 ms          max request: 3 KiB          max rewind: 3 KiB          monitor source: 24          sample spec: s16le 2ch 44100Hz          channel map: front-left,front-right                       Estéreo          used by: 1          linked by: 1          configured latency: 18,75 ms; range is 0,50 .. 1999,82 ms          card: 1 <alsa_card.pci-0000_07_00.6>          module: 7          properties:                  alsa.resolution_bits = "16"                  device.api = "alsa"                  device.class = "sound"                  alsa.class = "generic"                  alsa.subclass = "generic-mix"                  alsa.name = "ALC887-VD Analog"                  alsa.id = "ALC887-VD Analog"                  alsa.subdevice = "0"                  alsa.subdevice_name = "subdevice #0"                  alsa.device = "0"                  alsa.card = "1"                  alsa.card_name = "HD-Audio Generic"                  alsa.long_card_name = "HD-Audio Generic at 0xfe680000 irq 60"                  alsa.driver_name = "snd_hda_intel"                  device.bus_path = "pci-0000:07:00.6"                  sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:07:00.6/sound/card1"                  device.bus = "pci"                  device.vendor.id = "1022"                  device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"                  device.product.id = "15e3"                  device.product.name = "Family 17h (Models 10h-1fh) HD Audio Controller (PRIME B450M-A Motherboard)"                  device.string = "front:1"                  device.buffering.buffer_size = "352768"                  device.buffering.fragment_size = "176384"                  device.access_mode = "mmap+timer"                  device.profile.name = "analog-stereo"                  device.profile.description = "Estéreo analógico"                  device.description = "Family 17h (Models 10h-1fh) HD Audio Controller (PRIME B450M-A Motherboard) Estéreo analógico"                  module-udev-detect.discovered = "1"                  device.icon_name = "audio-card-pci"          ports:                  analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: no)                          properties:                    analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes)                          properties:                                  device.icon_name = "audio-headphones"          active port: <analog-output-headphones>    

Can not stop nohup process

Posted: 23 Jul 2021 08:00 AM PDT

I am trying to run a very complex statistical model that I expected to take a very long time, so I used nohup to run the process. However, I underestimated the length and it would take like 260+ days to complete so I want to cancel the process.

I attempted using ps aux |grep nohup to get the PID, I get the following output:

 \<username> 4920  0.0  0.0  14224   972 pts/15   S+   01:53   0:00 grep nohup  

When I use kill -9 14224 I am told there is no process. So I used ps -ef | grep beast-2 as I do not remember the entire command I entered. Pulls up the following:

144039      1  0 Jul22 pts/12   00:00:00 /bin/sh /opt/anaconda3/bin/beast-2 -seed 777 -working -overwrite -instances 3 -threads 3 -beagle_SSE /home/<username>/XML/ST736_MTBD1.xml  

I use kill -9 144039 and check again but the process is still running underneath a new PID.

What can I do?

Handling Optional Arguments in bash

Posted: 23 Jul 2021 08:23 AM PDT

I have the following function that is supposed to write strings in new lines. There is a warning option, so that when -w is set by the user, some lines get coloured in red. -w allows an optional numeric argument -wNUM. If NUM is not provided, warn is set to 1 so that only the first line is coloured red.

I am encountering a problem with calling the command

printfm -w -- "First line" "second line").

I have included local warn="1" before the case statement.

  ("-w"|"--warning")       local warn="1"       case "$2" in  

The function is listed here

printfm ()  {    # Process command line options    shortopts="hVw::"    longopts="help,version,warning::"      opts=$(getopt -o "$shortopts" -l "$longopts" -n "${0##*/}" -- "$@")      if [ $? -ne 0 ]; then      local shorthelp=1  # getopt returned (and reported) an error.      return    fi      local f=0        if [ $? -eq 0 ]; then      eval "set -- ${opts}"      while [ $# -gt 0 ]; do        case "$1" in          ("-V"|"--version")            printf "%s\n" "V01 Jul 2021 Wk27"            declare -i f=0            shift            break            ;;          ("-h"|-\?|"--help")            printf "%s\n" "Print strings."            declare -i f=0            shift            break            ;;          # ------------------------------------          ("-w"|"--warning")            case "$2" in              (+([[:digit:]]))                 local -r warn="$2"                shift 2                ;;              (*)                 local -r warn="1"                shift 2                ;;              esac              declare -i local f=1              ;;            # ----------------------------------------            (--)              declare -i local f=1              shift              break              ;;          esac        done      fi        red=$(tput setaf 9)        rgl=$(tput sgr0)          # Print normal text or warnings          if [[ -v $f ]] && (( f != 0 )); then          # print normal multi-line text        [[ ! -v $warn ]] && printf '%s\n' "$@"          # print multi-line warnings          rge='^[0-9]+$'        if [[ -v $warn && "$warn" == "1" ]]; then          printf '%s\n' ${red}"$1"${rgl}  # first line red          printf '%s\n' "${@:2}"          # remaining, uncoloured        elif [[ -v $warn && "$warn" =~ $rge ]]; then          printf '%s\n' ${red}"$@"${rgl}  # all lines red        fi        fi      return 0    }  

A few basics with AND or OR I need some help with

Posted: 23 Jul 2021 07:26 AM PDT

I have a few problems that I seem to be stumped with. It seems to be with the logic of Bash.

if [ "$argument" = "Y" -o "$argument" = "YES" ];    then    …  fi  

Is there a way to create this statement without using "$argument" twice? and how could I expand this to add maybe 3 or 4 answers e.g. Yup, OK

Secondly,

while [ "$argument" != "Y" ] || [ "$argument" != "YES" ] || [ "$argument" != "N" ] || [ "$argument" != "NO" ]; do     echo "Not a valid selection"  done  

I'm not sure what I'm doing wrong here but no matter the entered statement into $argument, I always get Not a valid selection it won't accept Y, YES, N, or NO

Is there an emulator or a compatibility layer to run Linux binary on macOS?

Posted: 23 Jul 2021 08:06 AM PDT

There exists a compatibility layer called Wine to run Windows binary on Linux. Is there something similar on macOS to run Linux binary?

How to remove spaces at the end of folder names?

Posted: 23 Jul 2021 08:23 AM PDT

I would like to delete the spaces at the end of my folder names.

I have a folder called "Project1 " in which I have another folder called "Exercise1 ".

I want to use a script to delete the spaces at the end and only at the end.
I don't know if I have expressed myself correctly.

Thank you in advance, have a nice evening.

I typed the command /bin/ls -l | od -c

root@debian:~$ /bin/ls -l | od -c  0000000   t   o   t   a   l       3   2  \n   d   r   w   x   r   -   x  0000020   r   -   x       2       k   a   b   i   a       k   a   b   i  0000040   a       4   0   9   6       j   u   i   l   .       2   0      0000060   1   0   :   2   6       B   u   r   e   a   u  \n   d   r   w  0000100   x   r   -   x   r   -   x       7       k   a   b   i   a      0000120   k   a   b   i   a       4   0   9   6       j   u   i   l   .  0000140       2   2       1   7   :   4   6       D   o   c   u   m   e  0000160   n   t   s  \n   d   r   w   x   r   -   x   r   -   x       2  0000200       k   a   b   i   a       k   a   b   i   a       4   0   9  0000220   6       j   u   i   l   .       2   2       1   9   :   2   6  0000240       I   m   a   g   e   s  \n   d   r   w   x   r   -   x   r  0000260   -   x       2       k   a   b   i   a       k   a   b   i   a  0000300       4   0   9   6       j   u   i   l   .       2   0       1  0000320   0   :   2   6       M   o   d 303 250   l   e   s  \n   d   r  0000340   w   x   r   -   x   r   -   x       2       k   a   b   i   a  0000360       k   a   b   i   a       4   0   9   6       j   u   i   l  0000400   .       2   0       1   0   :   2   6       M   u   s   i   q  0000420   u   e  \n   d   r   w   x   r   -   x   r   -   x       2      0000440   k   a   b   i   a       k   a   b   i   a       4   0   9   6  0000460       j   u   i   l   .       2   0       1   0   :   2   6      0000500   P   u   b   l   i   c  \n   d   r   w   x   r   -   x   r   -  0000520   x       2       k   a   b   i   a       k   a   b   i   a      0000540   4   0   9   6       j   u   i   l   .       2   0       1   0  0000560   :   2   6       T 303 251   l 303 251   c   h   a   r   g   e  0000600   m   e   n   t   s  \n   d   r   w   x   r   -   x   r   -   x  0000620       2       k   a   b   i   a       k   a   b   i   a       4  0000640   0   9   6       j   u   i   l   .       2   0       1   0   :  0000660   2   6       V   i   d 303 251   o   s  \n  0000673  

systemd networking is ignoring network configuration file on boot

Posted: 23 Jul 2021 08:40 AM PDT

I have an embedded linux system compiled with Yocto, using systemd. I have a network configuration file at /etc/systemd/network/20-wired.network. The contents of that file are:

[Match]  Name=eth0    [Network]  Address=192.168.5.40/24  Gateway=192.168.5.1  DNS=192.168.5.1  

However, when I reboot my machine, the eth0 interface is successfully configured using DHCP instead of assigning the static IP address. The ip a command shows:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether f8:dc:7a:3c:27:82 brd ff:ff:ff:ff:ff:ff      inet 10.1.1.223/16 brd 10.1.255.255 scope global dynamic noprefixroute eth0         valid_lft 85898sec preferred_lft 85898sec      inet6 fe80::43ec:fd39:e1c0:3c05/64 scope link noprefixroute         valid_lft forever preferred_lft forever  

However, if I then wait 5 seconds or so after boot, and do a systemctl restart systemd-networkd the system will usually be configured correctly like so:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether f8:dc:7a:3c:27:82 brd ff:ff:ff:ff:ff:ff      inet 192.168.5.40/24 brd 192.168.5.255 scope global eth0         valid_lft forever preferred_lft forever      inet6 fe80::43ec:fd39:e1c0:3c05/64 scope link noprefixroute         valid_lft forever preferred_lft forever  

Lastly, with the right timing on the restart of the network service, I can seemingly even get this result (both the intended static address and the unwanted DHCP address):

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000      link/ether f8:dc:7a:3c:27:82 brd ff:ff:ff:ff:ff:ff      inet 192.168.5.40/24 brd 192.168.5.255 scope global eth0         valid_lft forever preferred_lft forever      inet 10.1.1.223/16 brd 10.1.255.255 scope global dynamic noprefixroute eth0         valid_lft 86246sec preferred_lft 86246sec      inet6 fe80::43ec:fd39:e1c0:3c05/64 scope link noprefixroute         valid_lft forever preferred_lft forever  

Does anyone know what is going on here or how to debug this? Is there something obvious wrong with my configuration?

systemctl status systemd-networkd shows the following immediately after boot (specifically after network-online.target):

* systemd-networkd.service - Network Service       Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)       Active: activating (start) since Tue 2021-07-20 12:58:52 UTC; 65ms ago  TriggeredBy: * systemd-networkd.socket         Docs: man:systemd-networkd.service(8)     Main PID: 282 ((networkd))        Tasks: 1 (limit: 3576)       Memory: 416.0K       CGroup: /system.slice/systemd-networkd.service               `-282 (networkd)  

Some number of seconds later it looks like this:

* systemd-networkd.service - Network Service       Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)       Active: active (running) since Tue 2021-07-20 12:58:52 UTC; 3min 20s ago  TriggeredBy: * systemd-networkd.socket         Docs: man:systemd-networkd.service(8)     Main PID: 282 (systemd-network)       Status: "Processing requests..."        Tasks: 1 (limit: 3576)       Memory: 2.0M       CGroup: /system.slice/systemd-networkd.service               `-282 /lib/systemd/systemd-networkd  

So it looks like the service is still "activating" when the network-online.target services run. I'm not sure what that means, though, or if it's a problem.

Can I enable auto-sleep at the tty login prompt?

Posted: 23 Jul 2021 08:28 AM PDT

I recently turned on my computer and accidentally left it sitting at the login prompt for hours, needlessly sucking power. A display manager would automatically suspend in that case, but I don't want one.

So can I configure the computer to go to sleep (I guess using systemctl suspend) after idling a few minutes at the login prompt (and ideally also in a logged in tty)?

How does `awk 'NF {p=1} p'` remove blank lines from the beginning and end of a file?

Posted: 23 Jul 2021 08:47 AM PDT

Searching for a way to remove blank lines from the beginning and the end (using tac) of a file, I've stumbled across this one:

awk 'NF {p=1} p'  

How / why does this work?

I understand NF is only true if there are any fields (if the line is not a blank line).

how to install a webmin module by command line (bash)?

Posted: 23 Jul 2021 08:07 AM PDT

I want to install a module in webmin by command line (bash). How do you do this?

Example:

wget https://download.webmin.com/download/modules/text-editor.wbm.gz  

inside this .gz: text-editor.wbm

sudo tar -xf text-editor.wbm.gz  

enter image description here

The module (in this case text-editor) when installed via GUI:

enter image description here

It sends the files to several places. Example:

To /usr/share/webmin/text-editor

enter image description here

To : /etc/webmin/text-editor

enter image description here

To: /var/webmin/modules/text-editor (empty):

enter image description here

Important:

Webmin installation methods used in my test:

Method 1:

sudo sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list'  wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add -  sudo apt -y install webmin  

Method 2:

wget https://prdownloads.sourceforge.net/webadmin/webmin_1.910_all.deb  sudo dpkg --install webmin_1.910_all.deb  

I asked the author (Jamie Cameron) no response to the date, because he is the author of webmin and the author of the module that I try to install

Text Editor 1.4  Description Provides a simple interface for editing text files, with a history of recently-edited files.  Download    text-editor.wbm.gz  Author  Jamie Cameron  Last updated    2007-04-18 11:27:19  

Update:

I have managed to make a script that installs the text-editor module. It is not very "elegant", but it works:

sudo chmod +x text-editor.sh && sudo ./text-editor.sh

#!/bin/bash    fshare=/usr/share/webmin/text-editor  fetc=/etc/webmin/text-editor  fvar=/var/webmin/modules/text-editor    if [ ! -d $fshare ]; then mkdir -p $fshare; fi  if [ ! -d $fetc ]; then mkdir -p $fetc; fi  if [ ! -d $fvar ]; then mkdir -p $fvar; fi  touch $fetc/files  wget -c https://download.webmin.com/download/modules/text-editor.wbm.gz  tar -xf text-editor.wbm.gz  cp -f -R text-editor/* $fshare  cp text-editor/config $fetc  sed -i '$ s/$/ text-editor/' /etc/webmin/webmin.acl  sh -c 'echo "text-editor=1" >> /etc/webmin/installed.cache'  /etc/init.d/webmin restart  

However, there should be a better method to install any webmin module by command line

Update:

Jamie Cameron replied.

enter image description here

So, In my case it would be:

sudo /usr/share/webmin/install-module.pl text-editor.wbm  

I hope this answer serves all interested parties

The theme is closed. You can vote for the closing of the question

iptables dhcp snooping

Posted: 23 Jul 2021 08:36 AM PDT

I have ubuntu with isc-dhcp-server (DHCP rfc2131) as "authoritative" in my local eth, and some user of my local network has activated another dhcp (rogue) that generates conflict

I don't have any Cisco or HP switch with "dhcp snooping" to block dhcp rogue with rules (like a "ip dhcp snooping"). And these rules do not work:

localeth=enp2s0  iptables -I INPUT -i $localeth -p udp -m multiport -sports 67,68 -j DROP  iptables -I FORWARD -i $localeth -p udp -m multiport -dports 67,68 -j DROP  iptables -t mangle -A PREROUTING -i $localeth -p udp -m multiport --dports 67,68 -j DROP  

How to block this dhcp rogue with iptables rules?. Thanks

Duplicating xfce panel across multiple monitors

Posted: 23 Jul 2021 10:21 AM PDT

I have multiple monitors on my desktop using XFCE for a DE and I'd like to have the panel on the bottom to be duplicated across all of my screens and show the same open applications on both. Currently the panel is only displayed on my right screen.

How would I go about setting this up with XFCE?

Downloading a .epub from a .acsm

Posted: 23 Jul 2021 09:23 AM PDT

I want to transfer books I buy on Google Play (downloads a .acsm) to my Kobo reader device. Everything I can find on internet about it:

  • has you running Adobe Digital Editions
  • aims at removing the DRM

I want to avoid both: I'm fine with the DRM as long as I can read the book on my device, and I don't want to run ADE through wine or otherwise (already lost hours trying that).

I guess acsm -> epub "conversion" is mostly a download, but are there conversions/encryptions along the way ? There is an url in the <src> tag in the .acsm, but also a lot of other parameters. Is there a way to download "manually" (without ADE) ?

Viewing (monitoring) line status of a serial port

Posted: 23 Jul 2021 10:06 AM PDT

Is there a utility software (or an easy method to do it from shell script) to display a serial port's status — i. e. blinking "RXD", "TXD", "DCD", "DTR", "DSR", "RTS", "CTS"? Particularly, I need to monitor whether "DCD" line is set most of the time and momentarily cleared on some interval. The port doesn't need to be sniffed, it's okay to open it exclusively.

In DOS and Windows world, it's usual for terminal emulator and other modem-related software to display pin status, either in GUI or in console applications. However, I couldn't find an alternative even for Linux (although some say it may be possible to examine /proc/tty/driver/serial by hand, if it exists), not to mention FreeBSD, which is my actual target. Common tools like cu and minicom only display port settings at most, not the status.

Use the same file link for both Linux and Windows

Posted: 23 Jul 2021 09:02 AM PDT

Is it even possible to do so? I mean, can I create a link on Linux and than make this link valid also on Windows?

Use-case

I have the folder /media/Data/DownloadedMusic on a NTFS partition. I also have the folder /media/Data/Music on the same partition. How can I create a link to DownloadedMusic inside Music so that the link can be accessible both from a Linux system and a Windows system?

How to automatically accept epel gpg key

Posted: 23 Jul 2021 07:40 AM PDT

The very first time that I install a package from epel, I am prompted if I want to import a GPG key.

Notice how there are 2 'Is this ok' prompts when installing redis?

[root@us-devops-build02 yum.repos.d]# yum install redis  Loaded plugins: fastestmirror  Loading mirror speeds from cached hostfile  .. truncated for readability    Total download size: 213 k  Installed size: 668 k  Is this ok [y/N]: y  Downloading Packages:  redis-2.4.10-1.el6.x86_64.rpm                                                                                                                                                                                                                                                                          | 213 kB     00:00       warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY  Retrieving key from http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6  Importing GPG key 0x0608B895:   Userid: "EPEL (6) <epel@fedoraproject.org>"   From  : http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6  Is this ok [y/N]: y  

This causes puppet to fail on freshly-provisioned machines, unless I ssh in to the machine first and manually accept the installation of this key.

  1. Why does epel need a key to be downloaded on the first installation of a package?
  2. How can I automatically install this key on my images so puppet won't fail?

No comments:

Post a Comment