Notes - Useful Bash Commands

Follows are command lines that I often use (not necessarily the best approach) while interacting with Unix shell. Find files (including files in subdirectories) whose size is larger than x k bytes (replace k with M for mega bytes). sudo find . -type f -size + xk Re-run through some tasks periodically (e.g., every 10 minutes = 10 * 60s): while true; do ...; sleep 600; done Get size (disk usage) of a file/directory: [Read More]

Notes - Add OpenVPN and SSTP VPN Connections to NetworkManager in Ubuntu 18.04 Using CLI

This note originates from an effort to find ways to automate OpenVPN and SSTP VPN connections from an Ubuntu 18.04 machine using CLI. For setting VPN connection from GUI, NetworkManager GNOME has nice third-party packages for most VPN protocols. Only follow this note if you want to setup OpenVPN or SSTP VPN connection from CLI. OpenVPN has a nice CLI tool (i.e. openvpn). However, connecting to an SSTP VPN server using CLI (e. [Read More]

Notes - Connect to An SSTP VPN Server Using Command Line in Ubuntu

SSTP stands for Secure Socket Tunneling Protocol, developed by Microsoft. It is one of the most powerful and widely used VPN protocols. It has the ability to bypass most firewalls because it uses SSL over port 443, which is also used by the famous protocol – HTTPS. Together with OpenVPN protocol, SSTP is considered one of the “stealth-VPN” protocols. Since it is owned by Microsoft, most Windows operating systems has a built-in SSTP-client. [Read More]

Notes - Remove Broken Files (broken content, broken file name) in Ubuntu

I once wrote a python program to create text files, which only contain ASCII and UTF-8 Unicode text. Before being written to a file, every non-UTF-8 line of text is decoded to UTF-8 using this line of code: line = line.decode('utf-8', 'ignore').encode("utf-8") I noticed many suggestions on StackOverFlow to use python’s string.printable or bash’s strings command to sanitize the text. However, these functions will remove all non-ASCII characters, which includes many, many valid UTF-8 characters because ASCII is a subset of UTF-8 (reference). [Read More]

Notes - Useful Command in AWS's CLI

Follows are command lines that I often use (not necessarily the best approach) while interacting with AWS. Before starting, you will need to install the CLI. For macOS, use brew install awscli For Linux, use pip install awscli Commands list files from a public S3 bucket. If the bucket is not publicly accessible, you need to sign in and do not need the --no-sign-request flag: aws --no-sign-request s3 ls s3://<bucket>/<path> Download files from a S3 bucket: [Read More]

Notes - Docker Containers Command Lines

Follows are command lines that I often use (not necessarily the best approach) while interacting with Docker Container. Commands are correct up to Version 18.03.1. show all containers, including inactive ones: docker ps -a show images: docker images run a container from an image in interactive mode: docker run -d -it --name [nameOfContainer] [imageName:version or imageID] get into a container with a bash shell: docker exec -it [containerID] /bin/bash show images: [Read More]