Thursday, July 27, 2023

Delete iptables rule using line number

To easiest way to delete iptables rules, is by listing the rule with line number like below

$ sudo iptables -L OUTPUT --line-number

In this example, we are listing all the rules inside OUTPUT chain, with line number

To delete that rule, use this command
$ sudo iptables -D OUTPUT 1

like below

We can run the first command to verify that the rule has been deleted
$ sudo iptables -L OUTPUT --line-number

like below

To delete multiple rules, just repeat the same steps over and over again.

Saturday, July 22, 2023

Brave browser failed to load in Linux Mint due to a locked profile

The issue is, whenever we click on the brave browser logo, it will show a loading animation, and it won't start after a few seconds.

To troubleshoot this, I launch brave using terminal by running below command:
$ brave-browser

And I can see an error, which is
"[3056:3056:1217/] The profile appears to be in use by another Brave process (2300) on another computer (hisham-workmachine). Brave has locked the profile so that it doesn't get corrupted. If you are sure no other processes are using this profile, you can unlock the profile and relaunch Brave."
I just found out that the error happened when I changed my hostname.

To recover brave, we just need to unlock the profile, by removing in ~/.config/BraveSoftware/Brave-Browser/SingletonLock. I usually will just rename it, and not deleting it, just in case.
$ cd ~/.config/BraveSoftware/Brave-Browser/
$ mv SingletonLock SingletonLock.0

We should be able to launch brave now 😁

Tuesday, July 18, 2023

Transferring podman image to another machine via network without registry

Unlike docker, podman comes with a useful tool to transfer image over network, without the need of any registry, which is podman image scp. This tool will take advantage of ssh connection between machines to transfer images.

To transfer an image to another machine, just use below command
$ podman image scp imagename:tag user@anothermachine::

We can also use this command to transfer the image between different users in one machine
$ podman image scp userA@localhost::imagename:tag userB@localhost::

Or to transfer from root storage to a rootless storage
$ sudo podman image scp root@localhost::imagename:tag nonroot@localhost::

Or vice versa
$ podman image scp imagename:tag root@localhost::

If no destination user is specified, podman transfer to the current user
$ podman image scp userB@localhost::imagename:tag 

We can also run the command from remote machine (machineC), to transfer image from machineA to machineB
$ podman image scp user@machineA::imagename:tag user@machineB::

To get more information about this command, use man
$ man podman-image-scp

Wednesday, July 12, 2023

Transferring docker image to another machine via network without a registry

We can use "docker save" and "docker load" commands to achieve this, combined with ssh.

These are the steps:

Save your image to a file

$ docker save -o filename imagename:tag

To get a smaller filesize, we can use xz, bzip2 or gz compression

$ docker save imagename:tag | xz > filename.xz

$ docker save imagename:tag | bzip2 > filename.bz2

$ docker save imagename:tag | gzip > filename.gz 

Then, transfer the file over ssh to another machine

$ scp filename.xz user@anothermachine

Load back the image in the other machine. "Docker load" will automatically decompress the file if it is compressed with xz, bzip2 or gz.

$ docker load -i filename.xz

We can also use redirection, instead of the -i option

$ docker load < filename.xz

All that can also be done in one liner

$ docker save imagename:tag | xz | ssh user@anothermachine docker load

Wednesday, July 5, 2023

Using wireguard vpn client on ubuntu

Wireguard is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN.

To use wireguard as a client, first, we need to get the wireguard configuration file from the provider. It will come with .conf naming convention.

Once we have that, we need to install wireguard package together with resolvconf
$ sudo apt install wireguard resolvconf -y

Then, put the wireguard configuration file into /etc/wireguard
$ sudo mv mywireguard.conf /etc/wireguard

We are now able to use wireguard and connect to the wireguard server. Use below command to setup wireguard  interface using the above configuration
$ sudo wg-quick up mywireguard

An interface will be created with the same name
$ sudo ip link dev show mywireguard
8: mywireguard: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000

We should now be able to connect to any host inside the wireguard server's network.

To turn off wireguard, simply use below command
$ sudo wg-quick down mywireguard

Monday, July 3, 2023

Install zapzap, a desktop whatsapp client on ubuntu linux

zapzap is a desktop whatsapp client built for linux, and available to be installed via flathub. To install zapzap in ubuntu and its derivatives:

Install flatpak
$ sudo apt update && sudo apt install flatpak -y

Add flathub repo
$ flatpak remote-add --if-not-exists flathub

Install zapzap using flatpak
$ sudo flatpak install flathub com.rtosta.zapzap

Once installed, launch zapzap. You will be presented with something like below

Follow the steps in the above picture, which are

You should now be able to use your whatsapp in zapzap