My Command Book
Table of Contents
Git
Clear Local Branches
Clear all local branches except for the current branche
git branch | grep -v "$(git symbolic-ref --short HEAD)" | xargs git branch -D
Clear Local Tags
git tag -d $(git tag -l)
Git Fast-Forward Merge
git merge --no-ff feature-branch
SSH
Generate SSH Key
ssh-keygen -t ed25519 -C "your_email@example.com"
Windows Powershell & CMD
Windows Creating a Symbolic Link (Like ln -s) in PowerShell
Syntax (PowerShell 5+ / Windows 10+)
New-Item -ItemType SymbolicLink -Path "C:\link\myshortcut" -Target "C:\original\myfolder"
Example: Link a folder Suppose you want to create a symbolic link from:
Target: C:\Projects\RealFolder
Link: C:\Links\ShortcutToProject
New-Item -ItemType SymbolicLink -Path "C:\Links\ShortcutToProject" -Target "C:\Projects\RealFolder"
Linux
Mount External SSD
This paragraph is generated by Google Gemini 3 Pro
To mount an external SSD with your current user’s ownership, the exact steps depend on the filesystem formatted on the drive. Native Linux filesystems (like ext4) handle permissions differently than Windows/cross-platform filesystems (like NTFS or exFAT).
Assumption explicitly marked: This guide assumes your SSD is already partitioned and formatted.
Here is how to identify your drive and mount it correctly based on its filesystem.
Step 1: Identify the SSD Partition
First, you need to find the device identifier for your SSD.
Run the following command:
lsblk
Look at the output to find your external SSD based on its size. The partition will look something like sdb1, sdc1, or nvme1n1p1.
Note: In the following steps, replace /dev/sdX1 with your actual partition identifier.
Step 2: Create a Mount Point
A mount point is the directory where you will access the files on your SSD. A standard location is inside the /media or /mnt directory.
Create the directory:
sudo mkdir -p /media/$USER/external_ssd
Step 3: Mount the SSD (Choose your filesystem)
Option A: For exFAT, NTFS, or FAT32 filesystems
These filesystems do not natively support Linux file permissions. Because of this, you must explicitly tell the mount command to assign ownership to your user at the time of mounting. You can use $(id -u) and $(id -g) to automatically pass your current user’s ID and group ID.
Run this command:
sudo mount -o uid=$(id -u),gid=$(id -g) /dev/sdX1 /media/$USER/external_ssd
Option B: For ext4 or other native Linux filesystems
Linux native filesystems track file permissions internally. The uid and gid flags in the mount command will not work here. Instead, you mount the drive normally and then change the directory ownership.
- Mount the drive:
sudo mount /dev/sdX1 /media/$USER/external_ssd
- Change the ownership of the mount point to your current user:
sudo chown -R $USER:$USER /media/$USER/external_ssd
Step 4: Verify the Mount
To confirm the drive is mounted and owned by you, check the directory permissions:
ls -ld /media/$USER/external_ssd
Your username should appear as both the owner and the group.
SMB
- Install Samba
sudo apt update
sudo apt install samba -y
- chmod
sudo chmod 777 /path/to/shared_folder
- Edit config file
sudo vim /etc/samba/smb.conf
Add the following content:
[MyShare]
comment = Ubuntu File Share
path = /path/to/shared_folder
read only = no
browsable = yes
guest ok = no
- Set Password for Samba
sudo smbpasswd -a username
- Allow UFW
sudo ufw allow samba
- Start Samba
sudo systemctl restart smbd