Menu

linux/

Remote debugging with headless Chrome

Add the following arguments to chrome options:

options = webdriver.ChromeOptions()
options.add_argument("headless")
options.add_argument("remote-debugging-address=0.0.0.0")
options.add_argument("remote-debugging-port=9222")
wd = webdriver.Chrome(chrome_options=options)
  • start Chrome and navigate to chrome://inspect page
  • make sure Discover network targets is checked
  • click Configure button next to the previous option
  • add a new target, for example (must be an IP address): 10.214.36.58:9222
  • the remote browser should be automatically discovered and appear in Remote target list
  • click Inspect
· 23 Nov 2021

Setup lxd server as remote server

lxc config set core.https_address "[::]"
lxc config set core.trust_password new_password

After all clients are connected to the remote it is recommended to unset password:

lxc config unset core.trust_password
· 3 Sep 2021

Kernel panic after update

Traceback example: After update, kernel panic at boot with error: Unable to mount root fs on unknown-block(0,0)

Solution:
  1. Restart your server and on the boot screen select any other boot option with older kernel
  2. (optional, Leaseweb servers) Install missing dependency
sudo dnf install dracut-network
  1. Navigate to /boot and verify that initramfs-file doesn’t exist for the latest kernel version
  2. Generate it
# 4.18.0-338.el8.x86_64 is kernel version
dracut -f /boot/initramfs-4.18.0-338.el8.x86_64.img 4.18.0-338.el8.x86_64
  1. Regenerate grub files
grub2-mkconfig -o /boot/grub2/grub.cfg
  1. Restart
Sources:
· 1 Sep 2021

List all files installed by a package

List all files installed by a specific package:

sudo dnf repoquery -l golang-bin
· 13 Jul 2021

Show top 10 process with open files

lsof | awk '{print $1}' | sort | uniq -c | sort -r -n | head
· 13 Jul 2021

Increase default storage size of lxd container

lxc storage set default volume.size 20GB
· 13 Jul 2021

One liners to check open files limit

Check open files limit for the process named redis:

cat /proc/$(ps aux | grep redis | head -n 1 | kazy -x -r "\d+")/limits | kazy -i "open files" -i Limit

Check current number of open files for the process named redis:

sudo ls -l /proc/$(ps aux | grep redis | head -n 1 | kazy -x -r "\d+")/fd | wc -l
· 12 Jul 2021

Open file limits

Print system limits:

14:53 $ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 514130
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 514130
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Print just open files limit

16:52 $ ulimit -Sn
1024

Get number of open files for a specific process:

# Get process id

16:56 $ ps aux | grep wshub
cobro    3200102  2.0  0.0 3676920 86488 ?       Ssl  16:12   0:54 /opt/cobro/src/wshub/wshub -port 8015 -redis 127.0.0.1:6379 -auxport 8016
client   3212070  0.0  0.0  12132  1160 pts/0    S+   16:57   0:00 grep --color=auto wshub

# Check current limits for the process

16:57 $ cat /proc/3200102/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             514130               514130               processes
Max open files            1024                 262144               files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       514130               514130               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

# Print number of open files for the process

17:03 $ sudo ls -l /proc/3200102/fd | wc -l
157

Systemd needs this limit specified per service (otherwise it will be 1024):


[Service]
LimitNOFILE=2048
· 12 Jul 2021

Tune kernel parameters with sysctl

Lets say there is this error when using rootless containers with podman:

Error: rootlessport cannot expose privileged port 80, you can add 'net.ipv4.ip_unprivileged_port_start=80' to /etc/sysctl.conf (currently 1024), or choose a larger port number (>= 1024): listen tcp 0.0.0.0:80: bind: permission denied

To solve this problem, the value of net.ipv4.ip_unprivileged_port_start needs to be changed

Print current value:

sudo sysctl net.ipv4.ip_unprivileged_port_start

Print all configuration:

sudo sysctl -a

Temporarily change the value:

sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80

To permanently modify the value, create a new file in /etc/sysctl.d. To apply changes, either reboot or execute sudo sysctl -p /etc/sysctl.d/99-custom.conf

· 24 Jun 2021

Check DNS propagation worldwide

Service from Constellix: DNS Propagation

· 26 May 2021