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 9000Installing Nano Text Editor (Linux)
Debian/Ubuntu:
sudo apt-get install nanoRed Hat (Fedora, CentOS):
sudo dnf install nanoUpdate 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 -yHashing 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 SHA256Replace 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_hostExample:
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 unzipZipping a Folder Recursively
To zip a folder and all its contents recursively, use:
zip -r archive_name.zip folder_to_zipExample:
zip -r backup.zip data/Unzipping a File
To unzip a file to a specified directory, use:
unzip file.zip -d destination_folderExample:
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 -LListing Iptables Rules with Numeric Ports
To display port numbers instead of service names, use the -n argument:
sudo iptables -L -nSaving Iptables Rules
To save your current iptables rules to a file:
sudo iptables-save > iptables.v4.backupRestoring Iptables Rules
To restore iptables rules from a saved file:
sudo iptables-restore < iptables.v4You might also want to copy the backup file to a working file before restoring:
cp iptables.v4.backup iptables.v4
sudo iptables-restore < iptables.v4Hextra Theme Update
Update All Hugo Modules
To update all Hugo modules in your project to their latest versions, run:
hugo mod get -uUpdate Hextra Specifically
To update Hextra to the latest released version, execute:
hugo mod get -u github.com/imfing/hextraUpdate 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@mainPowerShell (Windows)
Check Laptop Battery Status
Retrieves detailed battery information using WMI (Windows Management Instrumentation):
gwmi -Class BatteryStatus -Namespace root\wmiCheck integrity of Windows
Scans and repairs system files:
sfc /scannowRepairs Windows image files:
DISM.exe /Online /Cleanup-image /RestorehealthAdd 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-envActivate the virtual environment:
source aws-env/bin/activateTo exit the virtual environment when finished:
deactivateMicrosoft 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:
- Open Microsoft Outlook
- Click on File in the top-left corner
- Select Options at the bottom of the left menu
- In the Outlook Options dialog box, click on Advanced in the left sidebar
- Scroll down to the Reminders section
- Find and check the box next to Automatically dismiss reminders for past calendar events
- Click OK to save your changes