The small linux problem thread

Script to make a script to replace it. A bit inefficient, but gets the job done:
tscr.sh:

grep "^[0-9]" file > tmpfile
awk '{print "sed -i \x27s/^" $1 "/_" $1 "/\x27 file"}' tmpfile > sed-script.sh

[oddmin@bikypi4 tmp]$ cat file 
erraform
ansible
internal-product-name
123-internal-tool
536-something-or-other

[oddmin@bikypi4 tmp]$ sh tscr.sh 
[oddmin@bikypi4 tmp]$ cat sed-script.sh
sed -i 's/^123-internal-tool/_123-internal-tool/' file
sed -i 's/^536-something-or-other/_536-something-or-other/' file

[oddmin@bikypi4 tmp]$ sh sed-script.sh 
[oddmin@bikypi4 tmp]$ cat file 
erraform
ansible
internal-product-name
_123-internal-tool
_536-something-or-other

\d and (?:) are pcre, and GNU sed doesn’t do pcre. sed does [[:digit:]] or [0-9]. Maybe

sed 's/^[0-9]/_&/'
3 Likes

My brain was not functioning properly. I realized later in the night that I could have grepped the file and piped it into awk. Actually, I could make all that a one-liner that executes sed.

But my method is very brute-forced. Again, it could be way more efficient, but when you want something done once or twice on a small file, couple kilobytes, it should be fine. But given its very brute-force approach, it is almost guaranteed it won’t replace anything wrong.

In the meantime I realized such a complicated mess was not even needed, all you have to do is use sed to match the beginning of the line with a number, then replace the beginning with an _:

sed '/^[0-9]/s/^/_/' file

[oddmin@bikypi4 tmp]$ cat file
22_fog
erraform
ansible
internal-product-name
123-internal-tool
536-something-or-other
[oddmin@bikypi4 tmp]$ sed '/^[0-9]/s/^/_/' file
_22_fog
erraform
ansible
internal-product-name
_123-internal-tool
_536-something-or-other

Now, reading jlittle’s comment, it seems we thought of a similar thing in a slightly different way. I just search for the beginning of a line with a number and insert _ at the beginning, while he replaces anything that beginning with a number with _[the same line].

This isn’t really a Linux question, I know, but I don’t want to create an entirely new thread for it and it is related to Linux. I followed Lawrence System’s Wireguard tutorial for setting up Wireguard on my PFSense box, but I am not quite getting what I want. Does anyone know how or know of a good tutorial on how I can use Wireguard to access devices on my LAN remotely? Or perhaps I don’t use Wireguard, but some other technology.

3 Likes
1 Like

How did I miss this… Darned YouTube algorithm…

3 Likes

Has anyone ever configured PXE booting in uboot. I’m considering getting one of these, but I want to be able to provision it over the network.

https://shop.solid-run.com/product/SRS91-EVKCB-R01/

:facepalm:
Yes, that would do it.

Thank you!

1 Like

Edit: When I created the container, I had left the “unprivileged container” option checked. I recreated the container and have logged in with user: root and the password I created as expected.

I am sure that there is a simple solution, but I am currently beating my head against the wall.

On Proxmox (current and operational for months) I am attempting to install the Omada Controller software in an LXC container. (ubuntu-20.04-standard_20.04-1_amd64.tar.gz) It creates the container without any problems, but responds with “Login incorrect” no matter the credentials.

From the information that I have found, Proxmox LXC containers should have user: root and password: whatever you entered during the creation. I have tried root, Root, ubuntu, Ubuntu, admin, omada, Omada in endless combinations of the password I created, ubuntu, root, toor, blank, et cetera. I have even plugged in a generic usb keyboard because of a keyboard issue mentioned somewhere online.

Could someone end my suffering and tell me what I am missing?

I tend to reach for awk for these tasks. (No need for grep, and awk’s searching is more flexible, f.ex. awk '/search-string/ && $2 > 42'). In this case, it is helpful:

$ awk '/^\d/'
awk: cmd. line:1: warning: regexp escape sequence `\d' is not a known regexp operator
1 Like

Yeah, I usually use awk’s search too, just that I wasn’t thinking very straight at the time. I solved it all with just a sed later.

1 Like

I am running into an issue with the add-apt-repository command failing, it gives an error saying it timed out.

TimeoutError: [Errno 110] Connection timed out

A quick google found two other posts (source and source) with related issues, but none had a solution.

Does anyone know why this might be an issue? If not, how would I go about manually adding these PPAs to my system? If it matters, I am trying to add the ondrej/php ppa.

EDIT:

Figured it out. Was a problem with my computer trying to use IPv6, which isn’t set up. This fixed it:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
2 Likes

You can configure IPv4 to be the default path instead of killing IPv6

Also, to (officially) manually add apt sources:
https://help.ubuntu.com/stable/ubuntu-help/addremove-sources.html

1 Like

TBH, I don’t fully understand Wendell’s ramble post xD, but do you think this will accomplish what I am trying to do.

Not certain this will work, but I am trying to give Wireguard peers access to the LAN. If this isn’t what I am supposed to do using Wendel’s guide, what is? Also, the top rule is one Tom made on the Lawrence Systems video.

Update:
So it doesn’t seem to work. Also, there’s a lot of stuff in Wendel’s guide that thankfully doesn’t apply to me. I am a new Google Fiber subscriber (Hallelujah!), so I don’t have to worry about carrier-grade NAT or even Dynamic DNS because the IP address going to my fiber box / router is permanent! Everything else behind my LAN, though, doesn’t get a true public IP. I think this is called True NAT. There’s a lot of networking terms that are very jargony to me still.

I figured it out! Disregard my previous post.

1 Like

Actually, I have discovered that there is a problem on my laptop. When I said I figured it out, it is because I connected to my cellular data using my phone and tried to navigate to the pfsense web portal. That worked. Yet, now I have discovered that it doesn’t work on my Linux-powered laptop.

Follow-up on how I solved this problem (accidentally installing one os as EFI and one as legacy for dual boot).

We anyway decided to reinstall Windows 10 in UEFI mode, to make everything proper feng shui. After that we realized that Pop!_OS seemed to fit my wife’s workflow better than Ubuntu, so we ended up reinstalling Linux too (of course after turning off CSM in CMOS, to avoid any more non-EFI shenanigans).

Funnily however, when installing Pop after Windows, systemd-boot somehow wiped the EFI partition on the Windows drive. This is the kind of thing that the Windows installer used to do to Linux disks, I never expected it the other way around!

I had to reinstall the boot files for Windows afterwards, googling myself to the procedure. But now everything should be fine.

Understanding Flatpak?

Here I am again with not a technical problem, rather an “understanding” problem. I’m trying out Flatpak as a method to install those fringe programs that for various reasons refuse to live in the regular distro repositories. One of those is Signal-desktop on Debian-based distros.

On a fairly freshly installed Debian 11, I installed Flatpak from the apt repositories. Then I followed the instructions on Flathub to install Signal-Desktop. All look good, however it pulled in a bunch of dependencies:

root@host # flatpak install flathub org.signal.Signal
...
        ID                                            Branch Op Remote  Download
 1. [✓] org.freedesktop.Platform.GL.default           21.08  i  flathub 130.1 MB / 129.8 MB
 2. [✓] org.freedesktop.Platform.GL.nvidia-470-129-06 1.4    i  flathub 273.4 MB / 273.0 MB
 3. [✓] org.freedesktop.Platform.Locale               21.08  i  flathub  17.7 kB / 325.8 MB
 4. [✓] org.freedesktop.Platform.openh264             2.0    i  flathub   1.8 MB / 1.5 MB
 5. [✓] org.freedesktop.Platform                      21.08  i  flathub 224.5 MB / 200.4 MB
 6. [✓] org.signal.Signal                             stable i  flathub 154.2 MB / 156.3 MB

Warning: Not exporting file org.signal.Signal.appdata.xml of unsupported type.
Installation complete.

(the warning looks harmless according to a quick search, and the app works)

My question

Some of these deps look like things that could exist in the debian repositories too (though I haven’t verified this). Anyways they were taken as flatpaks. Is this simply because Flatpak needs to be a self-contained ecosystem in parallel with that based on the distro’s packaging system (in this case apt), or is there a way to integrate them and make Flatpak use deps from apt if possible?

I would prefer to have as much as possible in the distro’s preferred software catalog, and use things like Flatpak only for the out-of-the-ordinary stuff.

Essentially, yes.

No. Keep in mind that not only is it part of the ecosystem and concept, but the deps in the Flatpak repo are likely also a different version then what the distros repo provides (especially on Debian).

1 Like