Some commands I often use

SQL

Create user to login to mysql without using sudo

Run this command to get the username

whoami

Run mysql with sudo to run next command

sudo mysql

Create user as same as unix user to login to mysql

CREATE USER 'your_username'@'localhost' IDENTIFIED VIA unix_socket;
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

### Change root password and authentication method

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘your_password_here’; FLUSH PRIVILEGES; EXIT;


### Test you can connect from regular user with root password

mysql -u root -p


## Qemu

qemu-img.exe create -f qcow2 kali.qcow2 60G

qemu-system-x86_64.exe -m 4G -smp 2 -hda C:\Users\chch\Downloads\vm_qemu\kali.qcow2 -boot d -cdrom .\kali-linux-2026.1-installer-amd64.iso -vga virtio


### Using pandoc to convert docx to md file for github

Extract images from docx files:
```pandoc input.doc -t gfm --extract-media=./images -o index.md```

Convert docx to md
```pandoc -f docx -t markdown -o input.md input.docx```

### Check listening ports
```netstat -ant```

### Nmap scan - general
``` nmap -sS <target IP>```

### Docker

Quick install script (Linux)

curl -fsSL https://get.docker.com | sh

Add yourself to docker group (avoids sudo)

sudo usermod -aG docker $USER ```

Write ISO to usb

sudo dd bs=4M if=./ubuntu-26.04-live-server-amd64.iso of=/dev/sdb1 status=progress oflag=sync

Check mailbox report

Get-mailboxStatistics -server SERVER01 | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)"; expression = {$_.TotalItemSize.Value.ToMB() }}, ItemCount

Get-MailboxStatistics -server SERVER01 | Sort-Object TotalItemSize - Descending | ft DisplayName,@{label="TotalItemSize(KB)"; expression={$_.TotalItemSize.Value.toKB()}},ItemCount > c:\mailboxsizes.txt

Check mailbox size

You run the following command to get the report mailbox size from Exchange. The command will generate the file mailboxsizes.txt which is saved in C:\

Get-mailboxStatistics -server YOURSERVER| Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)"; expression = {$_.TotalItemSize.Value.ToMB() }}, ItemCount > c:\mailboxsizes.txt