Skip to content
General

General

CheatSheet General Commands

Starting a Simple Python HTTP Webserver (Windows / Linux)

To quickly serve files over HTTP, you can use Python’s built-in http.server module. Here’s how to start a simple HTTP server on port 9000:

python3 -m http.server 9000

Installing Nano Text Editor (Linux)

Debian/Ubuntu:

sudo apt-get install nano

Red Hat (Fedora, CentOS):

sudo dnf install nano

Update and Clean System (Linux)

Update your system’s package list, upgrade installed packages, and remove unnecessary packages to keep your system clean.

sudo apt update && sudo apt upgrade -y && sudo apt autoclean -y && sudo apt autoremove -y

Hashing Files with Certutil (Windows)

If you need to verify the integrity of a file on Windows, you can use certutil.exe to generate a SHA256 hash. Here’s how:

certutil.exe -hashfile .\file.txt SHA256

Replace file.txt with the path to your file.

SSH Connect Commands with a Private Key (Windows / Linux)

To connect to a remote server using SSH and a specific private key, use:

ssh -i path/to/your/private_key username@remote_host

Example:

ssh -i .\ssh-key.key [email protected]

Ensure that your public key is added to the remote user’s ~/.ssh/authorized_keys file to allow authentication.

SCP Commands (Windows / Linux)

Copying from Remote Linux to Local Windows

To copy a file from a remote server to your local machine, use:

scp -i path/to/your/private_key username@remote_host:/path/to/remote/file .

Example:

scp -i .\ssh-key.key [email protected]:/etc/linkding/data/backup.zip .

Copying from Local Windows to Remote Linux

To copy a file from your local machine to a remote server, use:

scp -i path/to/your/private_key local_file.ext username@remote_host:/path/on/remote/server/

Example:

scp -i .\ssh-key.key backup.zip [email protected]:/home/ubuntu/

Zip and Unzip Files (Linux)

Installing Zip/Unzip

If unzip is not installed on your Linux system, you can install it using:

sudo apt-get install zip unzip

Zipping a Folder Recursively

To zip a folder and all its contents recursively, use:

zip -r archive_name.zip folder_to_zip

Example:

zip -r backup.zip data/

Unzipping a File

To unzip a file to a specified directory, use:

unzip file.zip -d destination_folder

Example:

unzip backup.zip -d data/

Iptables (Linux)

Iptables is a command-line firewall utility that uses policy chains to allow or block traffic.

Listing Iptables Rules

To list the current iptables rules:

sudo iptables -L

Listing Iptables Rules with Numeric Ports

To display port numbers instead of service names, use the -n argument:

sudo iptables -L -n

Saving Iptables Rules

To save your current iptables rules to a file:

sudo iptables-save > iptables.v4.backup

Restoring Iptables Rules

To restore iptables rules from a saved file:

sudo iptables-restore < iptables.v4

You might also want to copy the backup file to a working file before restoring:

cp iptables.v4.backup iptables.v4
sudo iptables-restore < iptables.v4

Hextra Theme Update

Update All Hugo Modules

To update all Hugo modules in your project to their latest versions, run:

hugo mod get -u

Update Hextra Specifically

To update Hextra to the latest released version, execute:

hugo mod get -u github.com/imfing/hextra

Update Hextra to development branch

To update Hextra to try the most recent changes before the next release, execute:

hugo mod get -u github.com/imfing/hextra@main

PowerShell (Windows)

Check Laptop Battery Status

Retrieves detailed battery information using WMI (Windows Management Instrumentation):

gwmi -Class BatteryStatus -Namespace root\wmi

Check integrity of Windows

Scans and repairs system files:

sfc /scannow

Repairs Windows image files:

DISM.exe /Online /Cleanup-image /Restorehealth

Add RSAT Active Directory Tools

Adds the Remote Server Administration Tools (RSAT) for Active Directory Domain Services and Lightweight Directory Services:

Add-WindowsCapability -Online -Name "Rsat.ActiveDirectory.DS-LDS.Tools"

Python Virtual Environment (Linux)

Creating and Activating a Virtual Environment

Create a new Python virtual environment in your current directory:

python3 -m venv aws-env

Activate the virtual environment:

source aws-env/bin/activate

To exit the virtual environment when finished:

deactivate

Microsoft Outlook

How to Automatically Dismiss Past Meeting Notifications

Meeting notifications can quickly clutter your screen if they’re not dismissed after the event has passed. Here’s a clear step-by-step guide to enable automatic dismissal of past meeting reminders in Microsoft Outlook:

  1. Open Microsoft Outlook
  2. Click on File in the top-left corner
  3. Select Options at the bottom of the left menu
  4. In the Outlook Options dialog box, click on Advanced in the left sidebar
  5. Scroll down to the Reminders section
  6. Find and check the box next to Automatically dismiss reminders for past calendar events
  7. Click OK to save your changes
Last updated on