Summary of Common WSL Commands

1.Install WSL with default Ubuntu:

wsl --install

and then reboot.

2.List Available Distributions for Installation:

wsl -l -o

output eg:

NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
Ubuntu-22.04 Ubuntu 22.04 LTS
Ubuntu-24.04 Ubuntu 24.04 LTS
OracleLinux_7_9 Oracle Linux 7.9
OracleLinux_8_7 Oracle Linux 8.7
OracleLinux_9_1 Oracle Linux 9.1
openSUSE-Leap-15.5 openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed openSUSE Tumbleweed

3. Install a certain distribution:

wsl --install -d Ubuntu-24.04

4. List Installed Linux Distributions and Their WSL Versions:

wsl -l -v

5. Set Default Version for New Linux Installations (WSL 1 or WSL 2):

wsl --set-default-version <Version#>

Replace with 1 or 2 to set the default WSL version for new Linux installations.

6. Set Default Linux Distribution:

wsl -s <DistributionName>

7. Run a Specific Linux Distribution:

wsl -d <DistributionName>

8. Upgrade or Downgrade a Specific Linux Distribution between WSL 1 and WSL 2:

wsl --set-version <distro name> <Version#>

9. Launch the Default Linux Distribution from Command Prompt or PowerShell:

wsl

10. Run Linux Commands without Switching Distributions:

wsl [command]

11. remove an installed Linux distribution in WSL:

wsl --unregister <DistributionName>

12. Default Storage Location:

C:\Users\<YourUsername>\AppData\Local\Packages\CanonicalGroupLimited...Ubuntu..._\LocalState\ext4.vhdx

13. Export an Existing Distribution:

wsl --export <DistributionName> <ExportFilePath>
# eg: wsl --export Ubuntu C:\backups\ubuntu.tar

14. Import to a Custom Location:

wsl --import <NewDistributionName> <TargetFolder> <ImportFilePath>
# eg: wsl --import UbuntuCustom C:\wsl\UbuntuCustom C:\backups\ubuntu.tar

WSL を使用して Windows に Linux をインストールする方法

15. sets up a port proxy from any network interface on a certain port to the local machine’s port. eg:

netsh interface portproxy add v4tov4 listenport=2358 listenaddress=0.0.0.0 connectport=2358 connectaddress=127.0.0.1

just edit /etc/wsl.conf:

[boot]
systemd=true
[user]
default=fsi
[interop]
enabled=true
appendWindowsPath=true

  • Enables systemd
  • Sets default user fsi
  • Lets WSL run Windows apps
  • Adds Windows paths to $PATH

Restart WSL to apply

WSL SSH Forwarding Note

The core command is:

netsh interface portproxy add v4tov4 listenaddress=<Windows_IP> listenport=22 connectaddress=<WSL_IP> connectport=22

But the correct process is not just add:

1. Check the current WSL IP

hostname -I

2. Delete the old rule

netsh interface portproxy delete v4tov4 listenaddress=10.71.100.29 listenport=22

3. Add the new rule

netsh interface portproxy add v4tov4 listenaddress=10.71.100.29 listenport=22 connectaddress=172.17.29.55 connectport=22

4. Verify

netsh interface portproxy show all

Prerequisites

sudo service ssh status
New-NetFirewallRule -DisplayName "WSL SSH 22" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 22

listenaddress = Windows IP

connectaddress = current WSL IP

Steps to Create Users and Assign Databases in PostgreSQL

Log in to PostgreSQL:

psql -U postgres

Create two new users (user1 and user2):

CREATE USER user1 WITH PASSWORD 'yourPassword';
CREATE USER user2 WITH PASSWORD 'yourPassword';

Create databases for each user:

CREATE DATABASE user1dbshare OWNER user1;
CREATE DATABASE user1dbprivate OWNER user1;
CREATE DATABASE user2dbshare OWNER user2;
CREATE DATABASE user2dbprivate OWNER user2;

Create a common_readonly role and configure it to access shared data for all users:

CREATE ROLE common_readonly NOLOGIN;
GRANT CONNECT ON DATABASE user1dbshare TO common_readonly;
GRANT CONNECT ON DATABASE user2dbshare TO common_readonly;

GRANT USAGE ON SCHEMA public TO common_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO common_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO common_readonly;

GRANT common_readonly TO user1;
GRANT common_readonly TO user2;

Log in to each database and create a table:

For user1dbshare:

\c user1dbshare user1
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user1dbprivate:

\c user1dbprivate user1
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user2dbshare:

\c user2dbshare user2
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

For user2dbprivate:

\c user2dbprivate user2
CREATE TABLE memo (
    id SERIAL PRIMARY KEY,
    key_words VARCHAR(255),
    content TEXT,
    english_content TEXT
);

Exit:

\q

Linux ACL Management

Assigning Permissions:

This command sets ACL (Access Control List) for the file yourFileName.csv.
-m option indicates modifying the ACL.
u:yourUserName:r assigns read (r) permission to the user yourUserName.

sudo setfacl -m u:yourUserName:r yourFileName.csv

Revoking Permissions

This command removes the ACL entry for the user yourUserName from the file yourFileName.csv.
-x option indicates removing a specified ACL entry.

sudo setfacl -x u:yourUserName yourFileName.csv

Setting Default Permissions (Mask)

This command sets the mask permission for the file yourFileName.csv to read, write, and execute (rwx).
The mask defines the maximum permissions allowed for users other than the owner and the group. Here, setting the mask to rwx allows users to have up to read, write, and execute permissions.

sudo setfacl -m m::rwx yourFileName.csv

Removing All ACL Entries

This command removes all ACL entries from the file yourFileName.csv, resetting it to its default permission state. -b option indicates deleting all ACL entries.

sudo setfacl -b yourFileName.csv

Viewing ACL Settings

This command displays the current ACL settings for the file yourFileName.csv.

getfacl yourFileName.csv

Enable RDP by remote pwsh

# Enable Remote Desktop by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0

# Check if there is any existing firewall rule for port 3389 (RDP)
$ExistingRule = Get-NetFirewallRule -Direction Inbound | Where-Object { $_.LocalPort -eq 3389 }

# Enable the rule if it exists
if ($ExistingRule) {
    $ExistingRule | Enable-NetFirewallRule
    "Existing Remote Desktop firewall rules have been enabled."
} else {
    # Create a new firewall rule if no existing rule is found
    New-NetFirewallRule -DisplayName "Allow RDP" -Direction Inbound -LocalPort 3389 -Protocol TCP -Action Allow
    "No existing rule found, a new Remote Desktop firewall rule has been created and enabled."
}

# Enable Network Level Authentication (NLA) by modifying the registry
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -value 1

# Check if Remote Desktop service has been enabled
$RDPStatus = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server').fDenyTSConnections
if ($RDPStatus -eq 0) {
    "Remote Desktop is enabled"
} else {
    "Remote Desktop is not enabled"
}

Setting a Static IP in Linux with nmcli

  1. If it uses NetworkManager:
    cat /etc/netplan/01-network-manager-all.yaml :
    # Let NetworkManager manage all devices on this system
    network:
     version: 2
     renderer: NetworkManager
  2. Determine the Default Gateway:
    Use the ip route command to find out the default gateway of your network, which is essential for configuring your static IP.
    ip route | grep default | awk '{print $3}'
  3. Setting a Static IP Address:
    Replace "WifiName" with your actual connection name. Here’s how you can set a static IP address, gateway, DNS, and switch the method to manual:
    nmcli con mod "WifiName" ipv4.addresses 192.168.1.10/24
    nmcli con mod "WifiName" ipv4.gateway 192.168.1.1
    nmcli con mod "WifiName" ipv4.dns "8.8.8.8"
    nmcli con mod "WifiName" ipv4.method manual
  4. Applying the Changes:
    After setting the static IP, you need to restart the network connection to apply these changes:
    nmcli con down "WifiName"
    nmcli con up "WifiName"
  5. Reverting to DHCP (Dynamic IP):
    If you encounter any issues or decide to return to using DHCP, you can reset the configuration as follows:
    nmcli con mod "WifiName" ipv4.method auto
    nmcli con down "WifiName"
    nmcli con up "WifiName"

Configure Nginx as a Reverse Proxy

Modify the Nginx configuration to act as a reverse proxy. Edit the Nginx site configuration file:

sudo vi /etc/nginx/sites-available/default

Update the following server block at the bottom (replace [yourDomain.com] and adjust the [YOUR_APP_PORT] to match your application):

server {
        listen 443 ssl;
#       listen [::]:80;

        server_name [yourDomain.com];
        ssl_certificate /etc/letsencrypt/live/[yourDomain.com]/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/[yourDomain.com]/privkey.pem;
#       root /var/www/example.com;
#        index index.html;

        location / {
#               try_files $uri $uri/ =404;
                proxy_pass http://localhost:[YOUR_APP_PORT];
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
        }
}

restart it to apply your changes:

sudo systemctl restart nginx

You should be able to access your web application over HTTPS by visiting https://[yourDomain.com]

Setting a New Static IP Address

Open the dhcpcd configuration file:

sudo vi /etc/dhcpcd.conf

Set the static IP address: At the end of the file, add the following lines, replacing the example network information with your own:

interface eth0
static ip_address=192.168.1.XX/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

Here, 192.168.1.XX is the new IP address you wish to assign to your server. Ensure this IP address is not already in use within your local network.

sudo sync;sudo /sbin/shutdown -r now

Quick Fixes for WiFi Disconnection on Ubuntu

Method 1: Disable WiFi Power Management

Ubuntu might automatically turn off WiFi to save power. Here’s how to stop that:

  1. Check Your Network Interface Name: Use
    iwconfig
    to find your network interface name (it’s wlan0 for many but can differ).
  2. Turn Off Power Management: Execute
    sudo iwconfig wlan0 power off
    , replacing wlan0 with your actual interface name.

Method 2: Edit NetworkManager Configuration

Prevent automatic disconnections by tweaking NetworkManager:

  1. Open Configuration File: Run
    sudo vi /etc/NetworkManager/NetworkManager.conf.
  2. Add Power Save Setting: Insert the following lines:
    [connection]
    wifi.powersave = 2
  3. Restart NetworkManager: Apply changes with
    sudo systemctl restart NetworkManager.

Encountered “Operation not supported”? If disabling power management directly doesn’t work, try this alternative:

Alternative Method: Use TLP for Advanced Power Management

TLP offers granular control over power settings, including WiFi:

  1. Install TLP: Update your system and install TLP with
    sudo apt update
    followed by
    sudo apt install tlp tlp-rdw.
  2. Start TLP: Activate TLP using
    sudo tlp start.
  3. Edit TLP Configuration: Modify
    /etc/tlp.conf
    to disable WiFi power management. Uncomment (or add) the lines:
    WIFI_PWR_ON_AC=off
    WIFI_PWR_ON_BAT=off
  4. Restart TLP: Make your changes effective with
    sudo tlp start

Spotfire Server 12.0.8とOpenID Connect連携の設定方法

Microsoftのアイデンティティプラットフォームには、IDトークンのv1.0版とv2.0版の2種類があります。これらのバージョンは、トークンに含まれるクレームを決定します。v1.0とv2.0のIDトークンは、それぞれが持つ情報に違いがあります。トークンのバージョンは、それが要求されたエンドポイントに基づいています。新しいアプリケーションはv2.0を使用するべきです。

v1.0の認証エンドポイント: https://login.microsoftonline.com/common/oauth2/authorize
v2.0の認証エンドポイント: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

上記の2種類のトークン、v1.0とv2.0は登録時に両方使用可能ですが、v2.0が推奨されています。登録プロセスについては、以下の手順を参照してください:

1) https://portal.azure.com にログインし、「Microsoft Entra ID」セクションでアプリケーションを登録します。

2) 「アプリ登録」->「新規アプリケーション登録」をクリックします。別のページが表示され、フィールド名、アプリケーションタイプ(Webapp/API)、および「リダイレクトURL」を入力する必要があります。

3) TIBCO Spotfireサーバー設定でカスタムのパブリックアドレスを有効にします。

4) UIConfigの「OpenID Connect」タブを選択し、OpenID Connectを有効にします。

5) Azureで、登録済みのアプリケーションをクリックします。Spotfireサーバー設定ツールからのリターンエンドポイントURL、アプリケーションID、テナントID、オブジェクトIDが表示されます。

6) 「クライアントシークレット」の取得方法:「証明書&シークレット」をクリックし、「新規クライアントシークレット」をクリックし、説明と期間を入力して保存します。フィールドにキーが生成されるので、クリップボードにコピーします。

7) UIConfig->設定->「Web認証(例:OpenID Connect)」を選択します。

8) UIConfig->「OpenID Connect」->「新規プロバイダー追加」をクリックします。プロバイダー名、ディスカバリードキュメントURL、クライアントID、クライアントシークレットを指定します。

a) UIConfig >> Discovery document URL: https://login.microsoftonline.com/{tenant}/.well-known/openid-configuration
「Azure Active Directory」>>「アプリ登録」>> アプリ選択 >> 「テナントID」を参照します。
例:https://login.microsoftonline.com/55e98fdf-9ac4-42f6-a35d-6bcb4d9b4bc7/.well-known/openid-configuration
b) UIConfig >> クライアントIDは「アプリケーションID」です。
c) UIConfig >> クライアントシークレットは、アプリからAzureによって生成された「シークレットキー」です。

さらに詳細な情報は以下のリンクで確認できます:

例:

番号項目名
 1.Configuration Start -> AuthenticationWeb Authentication(e.g. OpenID Connect)
 2.Configuration Start -> User directoryDatabase
 3.OpenID Connect -> Enable OpenID ConnectYes
 4.OpenID Connect -> Enable Third Party Login InitiationYes
 5.OpenID Connect -> Enable RP-Initiated LogoutNo
 6.OpenID Connect -> Enable Back-Channel LogoutNo
 7.OpenID Connect -> Enable Front-Channel LogoutNo
 8.OpenID Connect -> Return Endpointhttps://[FQDN]/spotfire/auth/oidc/authenticate
 9.OpenID Connect -> Third Party Login Initiation Endpointhttps://[FQDN]/spotfire/auth/oidc/v1/initiate
 10.OpenID Connect -> EnabledYes
 11.OpenID Connect -> Provider nameAzure
 12.OpenID Connect -> Discovery document URLhttps://login.microsoftonline.com/[tenantID]/.well-known/openid-configuration
 13.OpenID Connect -> Client ID「アプリケーションID」
 14.OpenID Connect -> Client secret「シークレットキー」

通过 WordPress.com 设计一个这样的站点
从这里开始