Linux command

內網滲透

brew install ngrok #or snap install ngrok
ngrok config add-authtoken 2KQDERnnUjddPsWNMRhr3vsUeR1_3akBvNWQbgAMKNY8mH9ft
ngrok http <port>

Add iptable rule

sudo iptables -A INPUT -p tcp --dport 8888 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 8888:8890 -s 140.116.0.0/16 -j ACCEPT

start ssh

sudo apt install openssh-server
systemctl enable ssh.service
sudo systemctl start sshd.service

change website contents (Developer Mode)

document.designMode='on'

bits/stdc++.h path on mac

/Library/Developer/CommandLineTools/SDKs/MacOSX[MaxOS Version].sdk/usr/include/c++/v1/bits

or

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/bits
stdc++.h
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

share your terminal

curl -sSf https://sshx.io/get | sh && sshx

Enable SSH Service

sudo apt install openssh-server
sudo systemctl enable ssh
sudo ufw allow ssh

Execute one-time commands "at" a specified time

sudo at 14:50 2024-02-04
[command]
Ctrl+D

synchronize time to Taiwan time zone

sudo timedatectl set-timezone Asia/Taipei

Remove all python packages

pip freeze | xargs pip uninstall -y

change python version

ls /usr/bin/python3*


sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
sudo update-alternatives --remove python3 /usr/bin/python3.9
sudo update-alternatives --config python3

Using Pyenv to change python version

pyenv install 3.10.6  # install a specific Python version
pyenv local 3.10.6    # set a specific Python version in the current directory
pyenv versions        # show installed Python versions
pyenv install --list  # show all available Python versions for installation

Install speedtest

pip install speedtest-cli
pip install speedtest-cli --user

Trigger Github Action with no changes

git commit --allow-empty -m 'trigger new CI check'

get requirements.txt with current version

pipreqs . --force --savepath temp_requirements.txt
rm requirements.txt
while read line; do
  pkg=$(echo $line | cut -d'=' -f1)
  version=$(pip show $pkg 2>/dev/null | grep Version | head -1 | awk '{print $2}' )
  echo "found $pkg $version"
  if [ ! -z "$version" ]; then
    echo "$pkg==$version" >> requirements.txt
  fi
done < temp_requirements.txt 
rm temp_requirements.txt