Files
cheat_sheet/data/commands.json
T

163 lines
4.8 KiB
JSON

{
"linux": [
{
"command": "du -sh --block-size=1M /path/to/directory",
"desc": "Show size of directory in MB (Change M to G for GB)"
},
{
"command": "df -h /path/to/mount",
"desc": "Show statistics about a drive (remove path for all)"
},
{
"command": "find /path/to/directory -type f | wc -l",
"desc": "Show amount of files in directory and its sub-directories"
},
{
"command": "find /path/to/directory -type f -exec grep -n 'search' {} +",
"desc": "Print all rows together with the filenames and rows a string is found in"
},
{
"command": "ss -tuln",
"desc": "Show open ports on current host (linux)"
},
{
"command": "echo Hostname: $(hostname); echo Local_IP: $(hostname -i | awk '{print $1}'); echo Default_Gateway: $(ip route | awk '/default/ {print $3}')",
"desc": "Print IP Address, Hostname, Default Route"
}
{
"command": "find . -type f -iname 'myfile.txt'",
"desc": "Search for a specific file in folder (recursive, case-insensitive (use -name for case sensitive))"
},
{
"command": "zip -r folder_name.zip folder_name",
"desc": "Zip a folder and all of its contents into a archive"
}
],
"python": [
{
"command": "python3 -m venv .venv && source .venv/bin/activate",
"desc": "Initialise a (simple) .venv and activate it"
},
{
"command": "pip install jupyterlab ipykernel && python3 -m ipykernel install --user --name=project-name",
"desc": "Install and initialise the kernel to use in jupyter"
},
{
"command": "jupyter lab",
"desc": "Start Jupyiter Lab"
}
],
"go": [
{
"command": "go mod init github.com/username/projectname",
"desc": "Initialise a go project and create a mod file"
},
{
"command": "go get github.com/some/package@latest",
"desc": "Add dependencies"
},
{
"command": "go mod tidy",
"desc": "Tidy up unused dependencies"
},
{
"command": "go mod verify",
"desc": "Verify Integrity"
},
{
"command": "go run <target_file_or_folder>",
"desc": "Run a main.go file"
},
{
"command": "go build -o bin/<bin_name> <target_file_or_folder>",
"desc": "Build an executable"
},
{
"command": "GOOS=linux GOARCH=amd64 go build -o bin/myprogram.exe main.go",
"desc": "Cross-compile for Linux (alt. windows, darwin (arm64 / amd64))"
}
],
"git": [
{
"command": "git checkout -b branch_name",
"desc": "Create and checkout a new branch"
},
{
"command": "git rebase <target_branch>",
"desc": "Rebase commits from source branch to target branch"
},
{
"command": "git stash",
"desc": "Stash changes without commiting"
},
{
"command": "git reflog",
"desc": "Show history of all changes"
},
{
"command": "git remote set-url origin git@github.com:username/repo.git",
"desc": "Change origin url (example from https to ssh)"
}
],
"gpg": [
{
"command": "gpg --list-keys",
"desc": "List all imported keys"
},
{
"command": "gpg --import pubkey.asc",
"desc": "Import a downloaded key"
},
{
"command": "gpg --encrypt --sign --recipient RECIPIENT_KEY_ID message.txt",
"desc": "Encrypts message.txt with the recipients key into message.txt.gpg"
},
{
"command": "gpg --decrypt message.asc",
"desc": "Decrypt a file with a encrypted message"
},
{
"command": "gpg --export -a KEY_ID > publickey.asc",
"desc": "Export a existing (public) key into a file"
},
{
"command": "gpg --fingerprint KEY_ID",
"desc": "Check fingerprint of key"
},
{
"command": "gpg --sign-key RECIPIENT_KEY_ID",
"desc": "Sign a key"
},
{
"command": "gpg --keyserver hkps://keys.openpgp.org --send-keys RECIPIENT_KEY_ID",
"desc": "Send a signed key to a keyserver"
}
],
"security": [
{
"command": "firejail --private --net=none <application>",
"desc": "Run a command in a sandbox with no access to the home dir or the network"
},
{
"command": "nmap -p- -A <ip-address>",
"desc": "Scan a IP Address for open ports and os information"
},
{
"command": "nmap -p <port-num> -sV <ip-address>",
"desc": "Scan a specific port to see more information about service running"
},
{
"command": "nmap -p <port-num> --script ssh* <ip-address>",
"desc": "Scan a ssh port for all ssh relavant info"
},
{
"command": "chkrootkit / rkhunter --check / lynis audit system",
"desc": "System checking tools for malware and auditing on linux"
},
{
"command": "arch-audit",
"desc": "Audit installed packages for known vulnerabilities (pacman)"
}
]
}