Linux

NFS - Tutorial

Install and setup NFS server on Ubuntu 20.04 sudo su apt update apt upgrade -y apt install -y nfs-kernel-server Create export directory (NFS directory). sudo mkdir -p /mnt/nfs_dir chown {{ your_user }}:{{ your_user_group }} /mnt/nfs_dir chmod 777 /mnt/nfs_dir Configuring NFS server. vim /etc/exports # Add the line follows /mnt/nfs_dir 192.168.100.0/24(rw,sync,no_subtree_check) Open port for NFS (TCP 2049) ufw allow from 192.168.100/24 to any port nfs Apply the cofiguration and start NFS.

FFmpeg with Nvidia GPU on Ubuntu 20.04

Prep - Install Nvidia driver and cuda-toolkit I installed on Ubuntu 20.04. Install https://developer.nvidia.com/ffmpeg git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git cd nv-codec-headers && sudo make install && cd – git clone https://git.ffmpeg.org/ffmpeg.git cd ffmpeg #export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" sudo apt install -y pkg-config ./configure --enable-cuda-sdk --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 make -j 10 Error 1 /usr/local/cuda-10.2/bin/../targets/x86_64-linux/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported! 138 | #error -- unsupported GNU version!

Set up Ubuntu 20.04 server with Nvidia GPU (and spaCy)

After OS install - basical update Upgrade softwares sudo su apt update apt upgrade -y ssh hardening ssh user@newserver.com mkdir .ssh chmod 700 .ssh #copy id_ecdsa.pub in .ssh/authorized_keys chmod 600 .ssh/authorized_keys In /etc/ssh/sshd_config add the following configurations. PermitRootLogin no PubkeyAuthentication yes PasswordAuthentication no After configuration, restart sshd. sudo systemctl restart sshd sudo su passwd # Change root passwd Firewall - ufw https://ubuntu.com/engage/20.04-webinars This comes through the constant security patching process and new features like the Ubuntu Server Live installer, iptables to nftables migration, and more resilient boot loader.

iptables

Concept of iptables It is a realy rule table in which the IP communication rules are. There are groups of these rules, and it’s called “chain'. iptables configuration Configuration file You can see the configurations in the file /etc/iptables/rule.v4. Here is a sample line in the file. -A chain-outgoing-services -s 192.168.100.50/32 -d 1.2.3.4/32 -p tcp -m tcp --dport 22 -m comment --comment "This is a comment." -j ACCEPT http://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-en-4/s1-iptables-options.html -A chain-outgoing-services: Append the rule to chain chain-outgoing-services.

Kernel parameters for hardening

/etc/security/limits.conf Concept https://wiki.archlinux.org/index.php/Limits.conf /etc/security/limits.conf allows setting resource limits for users logged in via PAM. This is a useful way of preventing, for example, fork-bombs from using up all system resources. Note: The file does not affect system services. For systemd services the files /etc/systemd/system.conf, /etc/systemd/user.conf, and /etc/systemd/<systemd_unit>/override.conf control the limit. See the systemd-system.conf(5) man page for details. Config sample https://linux.die.net/man/5/limits.conf * soft nofile 160000 The syntax of the lines is as follows:

GPG

PGP and GPG PGP - Pretty Good Privacy GPG - GNU Privacy Guard oder GnuPG https://en.wikipedia.org/wiki/Pretty_Good_Privacy The Free Software Foundation has developed its own OpenPGP-compliant program called GNU Privacy Guard (abbreviated GnuPG or GPG). Install GPG on MacOS Installing homebrew first Refer to https://blog.ghostinthemachines.com/2015/03/01/how-to-use-gpg-command-line/ And install it. brew install gnupg Use GPG keygen Generate a key pair gpg --gen-key Real name: My Realname Email Address: foo@bar.com (Okay) (Enter the pass) As a default, the key type is RSA 2048.

rsync (Draft)

Why rsync not SCP It can restart download (fragmentation method?). Download a file from remote Download a folder from remote (@rsync_dir) rsync -avzhP remote_user@remote.com:/path/to/dir ./ -a: archive -h: human redable output -z: compress (like zip) data during the transfer -v: verbose -P: –partial + –progress Sync - upload a current structure under the remotedir In dir, rsync -ahzv ./* remote-user@remote.com:/path/to/dir/ It will overwrite the same name file!!` Skip (almost) same contents --size-only skips files that match in size.

Regular expressionexp - snippets

Regular expression Regular expression is a basic concept in theoretical computer science. Once you see the Wikipedia page of “Regular expression”, you can realize how important it is for understanding computer science. But for beninner of web engineer, the simple explanation of regular expression could be, it is just a “pattern” in a nut shell. Regular expression is often abbreviated to regex. Regex rules (To be updated…) Here is often used regex syntax.