Wednesday, 24 May 2023

[Python] pip over proxy (e.g. behind a firewall)

pip install --proxy http://[<usr_name>[:<password>]@]<proxyserver_name>:<port#> <pkg_name>
You might want to upgrade pip while you are at it.
python[.exe] -m pip install --proxy http://[<usr_name>[:<password>]@]<proxyserver_name>:<port#> --upgrade pip

Sunday, 21 May 2023

[ubuntu] Activate the hibernate button/option

Problem

A fresh install of Ubuntu does not sport the hibernate option/button.

Solution not working for me

Presumtion is that you use a swap partition and no swap file (alone, not sure a combination works). Make sure, your swap is at least as big as your memory. You can check with

free -h
In /etc/systemd/logind.conf the hibernate key must be handled by the uncommented line:
HandleHibernateKey=handle-hibernate-key
Activate the setting with
update-initramfs -u
Make sure in /etc/default/grubthere is an entry for your resume partition like
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/dm-0"
You then need to update the grub configuration.
update-grub
Then reboot.

[ubuntu] DNS gone after reboot

Problem

After a fresh installation of kubuntu 22.04 LTS, DNS does not work any longer after a reboot (or shotdown and start).

Solution

Most robust

Edit (possibly create) a file within /etc/systemd/network/. It might be called like 10-dhcp.network, however, it should contain:

[Match]
# Naming scheme: en* -> ethernet, wlan* -> wlan
Name=*

[Network]
DHCP=yes

If you want, you can create for each technology one file. Then you need to restart your network by:

sudo systemctl restart systemd-networkd

Less robust because of static

Make sure that in /etc/systemd/resolved.conf the is an uncommented line
DNS=192.168.2.1 208.67.222.222 208.67.220.220 192.168.1.1
where the ip addresses are the ones of the DNS servers you want to use.

Alternatively

You can configure the DNS servers in each of your network configuration with the network manager of your system or your choice.

Holzhammermethode

sudo ln -sf "/run/systemd/resolve/stub-resolv.conf" "/etc/resolv.conf"

Tuesday, 16 May 2023

[ubuntu] (Fresh install) boot into grub command line

Problem

grub>

Solution

# please note that grub commandline supports some command expansion using tab key
$ # find the root partition
$ ls
$ # set root partition, e.g.
$ root=(lvm/vg-root)
$ # load existing config file, e.g.
$ configfile /boot/grub/grub.cfg
You now should see the selection dialogue of your grub and can boot. To permanently fix the problem, install a tool and run it. Unfortunately, it is not (yet) part of the distribution. Very sadly, you have to add a personal repository. Either sudo the following commands or execute them as root.
$ sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt update
$ sudo apt install -y boot-repair
$ sudo boot-repair

Thursday, 11 May 2023

[git] Undo pushed but unmerged git commit

Problem

You were a bit hasty and committed and pushed something you should not have, e.g., as it has happened to me, into the wrong branch. Now, you want to undo the commit also in the remote repository, but not loose the changes you made.

Solution

Technically, you want, to my understanding

  1. Make HEAD point to the previous commit.
  2. Clean the index from the wrong commit.
  3. Push to the remote repository.
So, you would want to
  • $ git reset --mixed HEAD~
    where ~ stands for the parent commit, to go back more than commit, issue multiple times. The mixed option is the standard and therewith optional.
  • git push
    And this is the rather tricky part, because git might to refuse. In that case, you have two potentially dangerous options and you might want to double check with
    git help push
    I presume if you are on your own branch and nobody is working on it (as it should be?), you are safe with any of the options. Please don't sue me.
    • --force-with-lease
      This will overwrite the changes others are pushing while you are pushing (at least that is what I have understood).
    • --force
      This will overwrite ALL changes others might have pushed inbetween your wrong commit and this fixing.

[git] Create a local branch from another branch

From the active branch git checkout -b <LOCAL_BRANCH> From a donator branch git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH...