{"id":16138820,"url":"https://github.com/tungbq/cmd","last_synced_at":"2026-01-20T11:02:30.029Z","repository":{"id":252953153,"uuid":"841995213","full_name":"tungbq/cmd","owner":"tungbq","description":"A bookmark of essential commands for a software engineer's daily tasks :bookmark:","archived":false,"fork":false,"pushed_at":"2025-07-26T10:02:12.000Z","size":155,"stargazers_count":30,"open_issues_count":6,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-25T17:45:54.545Z","etag":null,"topics":["bookmark","cheatsheet","cli","cmd","command-line","commands","note"],"latest_commit_sha":null,"homepage":"https://tungbq.github.io/cmd/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tungbq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-13T13:11:48.000Z","updated_at":"2025-10-06T12:29:44.000Z","dependencies_parsed_at":"2024-11-01T15:42:26.554Z","dependency_job_id":"ff00fb6e-bc39-420c-af82-90ed9df55351","html_url":"https://github.com/tungbq/cmd","commit_stats":{"total_commits":58,"total_committers":1,"mean_commits":58.0,"dds":0.0,"last_synced_commit":"9598c695c531512cc88e1a66d8207bd40b42c278"},"previous_names":["tungbq/cmds"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tungbq/cmd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungbq%2Fcmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungbq%2Fcmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungbq%2Fcmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungbq%2Fcmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tungbq","download_url":"https://codeload.github.com/tungbq/cmd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tungbq%2Fcmd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28602175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T10:46:13.255Z","status":"ssl_error","status_checked_at":"2026-01-20T10:42:51.865Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bookmark","cheatsheet","cli","cmd","command-line","commands","note"],"created_at":"2024-10-09T23:45:43.775Z","updated_at":"2026-01-20T11:02:30.023Z","avatar_url":"https://github.com/tungbq.png","language":null,"readme":"# CLI Commands Reference\nA bookmark of essential command-line commands for a software engineer's daily tasks 📑\n- Source code: [**tungbq/cmd**](https://github.com/tungbq/cmd) ⭐\n- Website: [**https://tungbq.github.io/cmd**](https://tungbq.github.io/cmd)\n- Contributing guideline: [**here**](https://github.com/tungbq/cmd/blob/main/CONTRIBUTING.md) 📖\n\n## Table of Contents\n- [Linux Commands](#linux-commands)\n- [SSH Commands](#ssh-commands)\n- [JQ Commands](#jq-commands)\n- [Git Commands](#git-commands)\n- [Docker Commands](#docker-commands)\n- [Kubernetes Commands](#kubernetes-commands)\n- [Helm Commands](#helm-commands)\n- [Ansible Commands](#ansible-commands)\n- [Terraform Commands](#terraform-commands)\n- [PostgreSQL Commands](#postgresql-commands)\n- [Python Commands](#python-commands)\n- [Azure CLI Commands](#azure-cli-commands)\n- [Powershell Commands](#powershell-commands)\n- [Bash Scripting](#bash-scripting)\n- [Vim Shortcuts](#vim-shortcuts)\n\n---\n\n## Linux Commands\n\n```bash\n# TIPS: Press `Ctrl + R` to find your previous commands.\n\n# Clear terminal output\nclear\n\n# List files in the current directory with details\nls -la\n\n# Check system stats\ndf -h\ncat /etc/os-release\ncat /proc/meminfo\nnproc\n\n# Working with linux service\nsystemctl status target_service\nsystemctl start target_service\nsystemctl stop target_service\njournalctl -u target_service\n\n# Reload config without restarting the service\nsystemctl reload target_service\n\n# Change file mode\nchmod +x some_file.sh\nchmod 0600 /path/to/directory\n\n# Change directory owner\nsudo chown -R user:user folder\n\n# Create new directory\nmkdir -p /path/to/directory\n\n# Change directory\ncd /path/to/directory\n\n# Copy a file or directory\ncp source destination\n\n# Move or rename a file or directory\nmv old-name new-name\n\n# Remove a file\nrm file-name\n\n# Show disk usage of directories and files\ndu -h --max-depth=1\n\n# Search for a pattern in files\ngrep -r \"pattern\" /path/to/search\n\n# Display the current directory's path\npwd\n\n# History\nhistory\n\n# CURL, add '-k' to ignore certificate verification\ncurl https://abc.example.com\n\n# wget - Download a file from a URL\nwget http://example.com/file.zip\n\n# wget - Download a file and save it with a different name\nwget -O newfile.zip http://example.com/file.zip\n\n# Check network\nnetstat -anpt\nping google.com\nnslookup google.com\ntracepath google.com\n\n# Check system metric (CPU/RAM/...)\ntop\n\n# Tar\n## Compress\ntar -cvf sampleArchive.tar /home/sampleArchive\n\n## Extract\ntar -xvf sampleArchive.tar\ntar -xvf sampleArchive.tar.gz -C /home/ExtractedFiles/\n\n# Unzip\nunzip your_file.zip\n## Specify the output location\nunzip your_file.zip -d target_location\n\n# Control file content\necho \"first line\" \u003e file.txt\necho \"second line\" \u003e\u003e file.txt\n\n# SCP commands\n## Download file from remote to local machine\nscp -r username@IP:/path/on/remote /path/on/local\nscp -r -i /path/to/key.pem username@IP:/path/on/remote /path/on/local\nscp -r -P 12345 -i /path/to/key.pem username@IP:/path/on/remote /path/on/local\n\n## Send file from local to remote machine\nscp -r /path/on/local username@IP:/path/on/remote\n\n# DNS check\ndig domain.com\n\n# Working with logs content\ncat /var/log/syslog\n## Show last 100 lines.\ntail -n 100 /var/log/syslog\n## Show first 100 lines.\nhead -n 100 /var/log/syslog\n# Monitor logs live (Ctrl+C to exit).\ntail -f /var/log/syslog\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## SSH Commands\n\n```bash\n# Generate SSH keys\nssh-keygen -t rsa\n\n# SSH to a server using username/password\nssh user@1.2.3.4\n\n# SSH to a server using key\nssh -i user_key.pem user@1.2.3.4\n\n# Use locally available keys to authorise logins on a remote machine\n## Copy default key\nssh-copy-id user@1.2.3.4\n\n## Copy specific key\nssh-copy-id -i ~/.ssh/mykey user@host\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## JQ Commands\n\n```bash\n# Pretty-print JSON data\njq '.'\n\n# Extract a specific field from a JSON object\njq '.fieldName' file.json\n\n# Filter JSON data by a specific condition\njq 'select(.fieldName == \"value\")' file.json\n\n# Parse JSON from an API response\ncurl -s http://api.example.com/data | jq '.'\n\n# Flatten a nested JSON structure\njq '.[].nestedField' file.json\n\n# Format JSON output into a more readable structure\njq '.' file.json | less\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Git Commands\n\n```bash\n# Configure git info\ngit config --global user.name \"Your Name\"\ngit config --global user.email \"your.email@example.com\"\n\n# Remove '--global' flag if you want to config for project only\ngit config user.name \"Your Name\"\ngit config user.email \"your.email@example.com\"\n\n# Verify\ngit config -l\n\n# Clone repo via HTTPS\ngit clone https://github.com/REPO_OWNER/repo.git\n\n# Clone with username\ngit clone https://username@github.com/REPO_OWNER/repo.git\n\n# Clone repo via SSH\ngit clone git@github.com:REPO_OWNER/repo.git\n\n# Create a new branch\ngit checkout -b new-branch\n\n# Pull the latest changes from the remote repository\ngit pull origin main\n\n# Check the status of your working directory\ngit status\n\n# Add changes to the staging area\ngit add .\ngit add file_name1 file_name2 folder_name1\n\n# Commit changes with a message\ngit commit -m \"Your commit message\"\n\n# View log\ngit log\n\n# Push to remote feature branch\ngit push origin new-branch\n\n# Reset staging area to match the lastest origin commit\ngit reset origin/main\n\n# Checkout content of folder or file from other branch\ngit checkout your_branch\ngit fetch\ngit checkout origin/\u003cother-branch\u003e -- \u003cpath_to_folder\u003e/\ngit checkout origin/\u003cother-branch\u003e -- \u003cpath_to_file\u003e\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Docker Commands\n\n```bash\n# List all running containers\ndocker ps\n\n# List all containers (including stopped ones)\ndocker ps -a\n\n# Build an image from a Dockerfile\ndocker build -t your-image-name .\n\n# Run a container from an image\ndocker run --name container-name your-image-name\n\n# Stop a running container\ndocker stop container-name\n\n# Remove a stopped container\ndocker rm container-name\n\n# Remove an image\ndocker rmi image-name\n\n# Show container logs\ndocker logs container-name\n\n# List all Docker images\ndocker images\n\n# Enter a running container's shell\ndocker exec -it container-name /bin/bash\n\n# Cleanup docker (add `-f` flag to force cleanup)\ndocker system prune\n\n## Docker Compose\n# Start up containers as defined in the Docker Compose file\ndocker compose up\n\n# Start up containers in detached mode\ndocker compose up -d\n\n# Stop running containers\ndocker compose down\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Kubernetes Commands\n\n```bash\n# Linux Export KUBECONFIG to access the cluster\nexport KUBECONFIG=/path/to/kubeconfig.conf\n\n# Window Export KUBECONFIG to access the cluster\n $env:KUBECONFIG = \"\\path\\to\\kubeconfig.conf\"\n\n# Check nodes\nkubectl get nodes\n\n# Get all pods in the target namespace\nkubectl get pods -n your_namespace\n\n# Get all services in the current namespace\nkubectl get svc -n your_namespace\n\n# Get all resources in all namespace\nkubectl get all -A\n\n# Describe a pod\nkubectl describe pod pod-name\n\n# Apply a configuration to a resource by filename or stdin\nkubectl apply -f config-file.yaml\n\n# Delete resources by filenames, stdin, resources, and names\nkubectl delete -f config-file.yaml\n\n# Get logs from a pod\nkubectl logs pod-name\n\n# Execute a command in a container\nkubectl exec -it pod-name -- /bin/bash\n\n# Forward a port from a pod to the local machine\nkubectl port-forward pod-name 8080:80\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Helm Commands\n\n```bash\n# Add a Helm repository\nhelm repo add repo-name https://example.com/repo\n\n# Update all Helm repositories\nhelm repo update\n\n# Search for charts in a Helm repository\nhelm search repo repo-name\n\n# Install a Helm chart\nhelm install release-name repo-name/chart-name\n\n# List all Helm releases across all namespaces\nhelm list --all-namespaces\n\n# Uninstall a Helm release\nhelm uninstall release-name\n\n# Upgrade an existing Helm release\nhelm upgrade release-name repo-name/chart-name\n\n# Get the status of a Helm release\nhelm status release-name\n\n# Show the history of a Helm release\nhelm history release-name\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Ansible Commands\n\n```bash\n# Run an Ansible playbook\nansible-playbook playbook.yml -i inventory.ini\n\n# Run a single Ansible ad-hoc command\nansible all -m ping\n\n# List all available Ansible roles\nansible-galaxy list\n\n# Install a role from Ansible Galaxy\nansible-galaxy install role-name\n\n# Test an Ansible inventory file\nansible-inventory --list -i inventory.ini\n\n# Run an Ansible playbook with increased verbosity\nansible-playbook playbook.yml -vvv\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Terraform Commands\n\n```bash\n# Initialize a Terraform configuration directory\nterraform init\n\n# Init and migrate TF state files to another location\nterraform init -migrate-state\n\n# Plan the changes required by the Terraform configuration\nterraform plan\n\n# Apply the changes required by the Terraform configuration\nterraform apply\n\n# Create a Terraform execution plan and save it to a file (recommended)\nterraform plan -out=\"tfplan.out\"\n\n# Apply the changes from saved plan\nterraform apply \"tfplan.out\"\n\n# Apply the changes automatically (use with your own risk, suitable for automation tasks)\nterraform apply --auto-aprove\n\n# Apply with secret var\nterraform apply -var-file=\"secret.tfvars\"\n\n# Destroy all the resources managed by Terraform\nterraform destroy\n\n# Validate the Terraform configuration files\nterraform validate\n\n# Format Terraform configuration files\nterraform fmt\n\n# Show the current state of Terraform-managed infrastructure\nterraform show\n\n# Refresh the state file with the real infrastructure\nterraform refresh\n\n# List the available Terraform providers\nterraform providers\n\n# Unlock Terraform\nterraform force-unlock \u003cLOCK_ID\u003e\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## PostgreSQL Commands\n\n```bash\n# Connect to a PostgreSQL database\npsql -h hostname -U username -d database_name\n\n# List all databases\npsql -c \"\\l\"\n\n# List all tables in the current database\npsql -c \"\\dt\"\n\n# Show the structure of a specific table\npsql -c \"\\d table_name\"\n\n# Create a new database\ncreatedb new_database_name\n\n# Drop an existing database\ndropdb database_name\n\n# Create a new user\ncreateuser new_user_name\n\n# Drop an existing user\ndropuser user_name\n\n# Grant all privileges on a database to a user\npsql -c \"GRANT ALL PRIVILEGES ON DATABASE database_name TO user_name\"\n\n# Revoke all privileges on a database from a user\npsql -c \"REVOKE ALL PRIVILEGES ON DATABASE database_name FROM user_name\"\n\n# Backup a PostgreSQL database to a file\npg_dump database_name \u003e backup_file.sql\n\n# Restore a PostgreSQL database from a backup file\npsql database_name \u003c backup_file.sql\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Python Commands\n\n```bash\n# Run a python script\npython python_script.py\n\n# Install a package using pip\npip install package-name\n\n# Install a specific version of a package\npip install package-name==1.2.3\n\n# Uninstall a package\npip uninstall package-name\n\n# List all installed packages\npip list\n\n# Freeze installed packages into a requirements file\npip freeze \u003e requirements.txt\n\n# Install packages from a requirements file\npip install -r requirements.txt\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## Azure CLI Commands\n\n```bash\n# Login to Azure\naz login\n\n# Login with device code\naz login --use-device-code\n\n# Get the details of a subscription\naz account show\n\n# Get subscription ID\naz account show --query id --output tsv\n\n# List all subscriptions associated with your account\naz account list --output table\n\n# Set a specific subscription as default\naz account set --subscription \"SUBSCRIPTION_ID\"\n\n# List all resource groups\naz group list --output table\n\n# List location\naz account list-locations\n```\n\n[Back to top 🔝](#cli-commands-reference)\n\n## PowerShell Commands\n```powershell\n# Get the current directory\nGet-Location\n\n# List files in the current directory with details\nGet-ChildItem -Force\n\n# Create a new directory\nNew-Item -Path \"C:\\path\\to\\directory\" -ItemType Directory\n\n# Remove a file\nRemove-Item -Path \"C:\\path\\to\\file.txt\"\n\n# Display a message in the console\nWrite-Host \"This is a message displayed in the console.\"\n\n# Copy a file\nCopy-Item -Path \"C:\\source\\file.txt\" -Destination \"C:\\destination\\file.txt\"\n\n# Move or rename a file\nMove-Item -Path \"C:\\path\\to\\oldname.txt\" -Destination \"C:\\path\\to\\newname.txt\"\n\n# Check the content of a file\nGet-Content -Path \"C:\\path\\to\\file.txt\"\n\n# Write a line to a file (overwrites existing content)\nSet-Content -Path \"C:\\path\\to\\file.txt\" -Value \"This is the first line.\"\n\n# Append a line to a file\nAdd-Content -Path \"C:\\path\\to\\file.txt\" -Value \"This is an appended line.\"\n\n# Search for a string in a file\nSelect-String -Path \"C:\\path\\to\\file.txt\" -Pattern \"search-string\"\n\n# Run a script with elevated privileges\nStart-Process powershell -Verb runAs -ArgumentList \"-File C:\\path\\to\\script.ps1\"\n\n# Test network connection (ping)\nTest-Connection google.com\n\n# Download a file from a URL\nInvoke-WebRequest -Uri \"https://example.com/file.zip\" -OutFile \"C:\\path\\to\\file.zip\"\n\n# Compress files into a ZIP archive\nCompress-Archive -Path \"C:\\path\\to\\folder\\*\" -DestinationPath \"C:\\path\\to\\archive.zip\"\n\n# Extract files from a ZIP archive\nExpand-Archive -Path \"C:\\path\\to\\archive.zip\" -DestinationPath \"C:\\path\\to\\extract\"\n\n# Get system information\nGet-ComputerInfo\n\n# Check the status of a service\nGet-Service -Name \"ServiceName\"\n\n# Start a service\nStart-Service -Name \"ServiceName\"\n\n# Stop a service\nStop-Service -Name \"ServiceName\"\n\n# Restart a service\nRestart-Service -Name \"ServiceName\"\n\n# List installed software\nGet-WmiObject -Class Win32_Product | Select-Object -Property Name, Version\n```\n \n[Back to top 🔝](#cli-commands-reference)\n\n## Bash Scripting\n```bash\n# Basic if statement\nif [ \"$VAR\" = \"value\" ]; then\n  echo \"Match\"\nfi\n\n# For loop\nfor i in {1..5}; do\n  echo \"Number $i\"\ndone\n\n# While loop\nwhile true; do\n  echo \"Running...\"\n  sleep 1\ndone\n\n# Script arguments\necho \"Script name: $0\"\necho \"First argument: $1\"\n\n# Functions\nmy_func() {\n  echo \"Hello from function\"\n}\n\nmy_func\n\n# Reading input\nread -p \"Enter your name: \" name\necho \"Hello, $name\"\n\n# Exit with code\nexit 0\n```\n[Back to top 🔝](#cli-commands-reference)\n\n## Vim Shortcuts\n```\n# Enter insert mode\ni\n\n# Save and exit\n:wq\n:x!\n\n# Exit without saving\n:q!\n\n# Search in file\n/term\n\n# Delete line\ndd\n\n# Delete all content of file\n# (Not in insert mode) Press ggdG\n\n# Copy (yank) line\nyy\n\n# Paste\np\n\n# Undo\nu\n\n# Redo\nCtrl + r\n```\n[Back to top 🔝](#cli-commands-reference)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungbq%2Fcmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftungbq%2Fcmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftungbq%2Fcmd/lists"}