Category Archives: Linux

Get the Output of a Program in a Variable in Bash

Do you need to get the output of a program in a variable in Bash? There are two simple ways to achieve that: var=`./ params`var=`./ params` Or alternatively you can use $(), i.e: var=$(./ params)var=$(./ params) Remember to not put spaces before or after the = operator. If you need to capture also error messages […]

Capture Multiple Line Output Into a Bash Variable

Lets say you have a bash script “” that outputs multiple lines, i.e: line1 line2 line3line1 line2 line3 You capture the script output in a bash variable like this: OUTPUT=$(/root/$(/root/ Now pay attention on how you echo the output: Echo Variable Without Double-Quotes If you echo the variable without the double-quotes: echo $OUTPUTecho $OUTPUT It […]

How to Extract Domain from URL in Bash

Using awk you can extract a domain name from an URL: echo | awk -F[/:] ‘{print $4}’echo | awk -F[/:] ‘{print $4}’ The output is:

Get Local File Permissions from Command-Line on Linux

Using stat command you can get local file permissions: stat -c "%a %n" /path/to/file/or/folderstat -c "%a %n" /path/to/file/or/folder Here is an example output: $ stat -c "%a %n" ./Documents/Testing.html 664 ./Documents/Testing.html$ stat -c "%a %n" ./Documents/Testing.html 664 ./Documents/Testing.html Details about the stat parameters: %a Access rights in octal %n File name%a Access rights in octal […]

Automatically Renew Let’s Encrypt Certificates (Nginx)

Here I made a simple bash script that automatically renew all Let’s Encrypt certificates and reload Nginx only once, if at least one certificate was renewed successfully: #!/bin/sh   # ===DESCRIPTION # This script is used to renew Let’s Encrypt certificates via certbot # And reload Nginx web server only once if at least one […] cannot open shared object file: No such file or directory

While I was installing Node.js Puppeteer I got this error: /usr/lib/node_modules/puppeteer/.local-chromium/linux-672088/chrome-linux/chrome: error while loading shared libraries: cannot open shared object file: No such file or directory/usr/lib/node_modules/puppeteer/.local-chromium/linux-672088/chrome-linux/chrome: error while loading shared libraries: cannot open shared object file: No such file or directory To fix this issue just install the required libraries: apt install -y […]] No usable sandbox

If you get this error when you run Chrome on Linux Debian:] No usable sandbox! Update your] No usable sandbox! Update your kernel Then you need to type the following commands to fix it: echo kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/00-local-userns.conf service procps restartecho kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/00-local-userns.conf service procps restart

Route All Internet Traffic Through Tor on Linux Debian

You can route all Internet traffic throguth Tor, here is how: *** Please note, I am using Debian 10 Buster *** Add this on /etc/apt/sources.list: deb buster maindeb buster main Run this to install Tor Project public keys: gpg –keyserver –recv-key 74A941BA219EC810 gpg -a –export 74A941BA219EC810 | apt-key add – apt-get updategpg […]

Configure a New IP Address on Server

First you need to buy an additional IP address. Then you can drag & drop it inside your server via the web interface. Now you need to edit /etc/network/interfaces by adding this: # Your new IP address (1) auto enp1s0f0:0 iface enp1s0f0:0 inet static address YOUR_FAILOVER_IP_HERE netmask   # Your new IP address (2) […]

Add Shared Folder on VirtualBox VM via Command-Line on Debian

Lets say you have created a shared folder in your Linux Debian host, i.e: /vms/shared_folder/vms/shared_folder Now you want to add that shared folder on VM named “Win7-64-bit-VM1”: VBoxManage sharedfolder add Win7-64bit-VM1 –name srv –hostpath "/vms/shared_folder" –transientVBoxManage sharedfolder add Win7-64bit-VM1 –name srv –hostpath "/vms/shared_folder" –transient The “–transient” makes sure the mapping will not persist over the […]