{"id":20056162,"url":"https://github.com/marmelo/useful-commands","last_synced_at":"2026-02-18T20:32:34.400Z","repository":{"id":74377828,"uuid":"147604483","full_name":"marmelo/useful-commands","owner":"marmelo","description":"List of useful commands.","archived":false,"fork":false,"pushed_at":"2025-01-02T11:34:16.000Z","size":42,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-20T13:39:24.456Z","etag":null,"topics":["commands","docker","git","java","ssh","terminal"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marmelo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-09-06T02:11:24.000Z","updated_at":"2025-06-16T09:41:12.000Z","dependencies_parsed_at":"2023-12-06T14:27:30.524Z","dependency_job_id":"bd41163b-2964-448a-b2d1-45d8ded04236","html_url":"https://github.com/marmelo/useful-commands","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/marmelo/useful-commands","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelo%2Fuseful-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelo%2Fuseful-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelo%2Fuseful-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelo%2Fuseful-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marmelo","download_url":"https://codeload.github.com/marmelo/useful-commands/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marmelo%2Fuseful-commands/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29594259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T18:54:29.675Z","status":"ssl_error","status_checked_at":"2026-02-18T18:50:50.517Z","response_time":162,"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":["commands","docker","git","java","ssh","terminal"],"created_at":"2024-11-13T12:52:08.517Z","updated_at":"2026-02-18T20:32:34.367Z","avatar_url":"https://github.com/marmelo.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commands\n\n- [Bash](#bash)\n- [Docker](#docker)\n- [Git](#git)\n- [Java](#java)\n- [Mail](#mail)\n- [Nmap](#nmap)\n- [NVMe](#nvme)\n- [PostgreSQL](#postgresql)\n- [Sed](#sed)\n- [SSH](#ssh)\n- [Tmux](#tmux)\n- [Tor](#tor)\n- [YouTube](#youtube)\n\n\n## Bash\n\n```bash\n# forward port without iptables\nsocat TCP4-LISTEN:8080,fork TCP4:1.1.1.1:8080\n```\n\n```bash\n# create a RAM disk\nmount -t tmpfs -o size=512m tmpfs /mnt/tmpfs\n```\n\n## Docker\n\n```bash\n# save image image-name\nsudo docker save image-name | gzip \u003e /tmp/image-name.img.gz\n```\n\n```bash\n# load image image-name\ngunzip -c /tmp/image-name.img.gz | sudo docker load \n```\n\n\n## Git\n\n```bash\n# find which branches contain a commit\ngit branch --contains \u003ccommit\u003e\n```\n\n```bash\n# revert last commit and keep modified files\ngit reset --soft HEAD^\n```\n\n\n## HTTP\n\n``` bash\n# perform 1000 HTTP requests using 5 concurrent threads\nab -n 1000 -c 5 http://localhost:8080/api/version\n\n# this requires Apache HTTP server benchmarking tool which is available though\n# package httpd-tools in RHEL/CentOS and apache2-utils in Debian/Ubuntu\n```\n\n\n## Java\n\n```bash\n# get thread dump for PID 12345\njstack -l 12345 \u003e /tmp/thread.log\n```\n\n```bash\n# get heap summary for PID 12345\njmap -heap 12345 \u003e /tmp/heap.log\n```\n\n```bash\n# get heap histogram for PID 12345\njmap -histo 12345 \u003e /tmp/histogram.log\n```\n\n```bash\n# get heap dump for PID 12345\njmap -dump:format=b,file=/tmp/heap.bin 12345\n```\n\n```bash\n# force garbage collection for PID 12345\njcmd 12345 GC.run\n```\n\n```bash\n# enable JMX remote monitoring\njava\n  -Dcom.sun.management.jmxremote\n  -Dcom.sun.management.jmxremote.port=9010\n  -Dcom.sun.management.jmxremote.authenticate=false\n  -Dcom.sun.management.jmxremote.ssl=false\n  -Dcom.sun.management.jmxremote.local.only=false\n  -jar app.jar\n```\n\n## Mail\n\n```bash\n# test smtp server\nswaks -s server -f from -t to -au user -ap pass\n```\n\n## Nmap\n\n```bash\n# scan open ports\nnmap 192.168.1.1\n```\n\n```bash\n# scan open ports with service info\nnmap -sV 192.168.1.254\n```\n\n```bash\n# scan subnet for devices\nnmap -sn 192.168.1.1-255\nnmap -sn 192.168.1.1/24\n```\n\n```bash\n# scan subnet for ports\nnmap -p22,80,443 192.168.1.1/24\n```\n\n```bash\n# scan subnet for ports with service info\nnmap -sV -p22,80,443 192.168.1.1/24\n```\n\n```bash\n# reverse lookup subnet\nnmap --dns-servers 8.8.4.4,8.8.8.8 -sL 209.132.183.105/24\n```\n\n## NVMe\n\n```bash\n# get info\nnvme list\nnvme id-ctrl /dev/nvme0n1 -H\n```\n\n```bash\n# secure erase\n# (first check if \"Crypto Erase Supported as part of Secure Erase\" is available)\nnvme format /dev/nvme0n1 --ses 2\n```\n\n\n## PostgreSQL\n\n```sql\n# show running queries\nSELECT pid, age(clock_timestamp(), query_start), usename, query\nFROM pg_stat_activity \nWHERE query != '\u003cIDLE\u003e' AND query NOT ILIKE '%pg_stat_activity%' \nORDER BY query_start desc;\n```\n\n```sql\n# show table statistics\nSELECT relname, seq_scan, idx_scan, n_tup_ins, n_tup_upd, n_tup_hot_upd, n_tup_del, n_tup_newpage_upd, autovacuum_count, last_autovacuum\nFROM pg_stat_user_tables\nORDER BY n_tup_ins desc;\n```\n\n```sql\n# terminate connections\nSELECT pg_terminate_backend(pg_stat_activity.pid)\nFROM pg_stat_activity\nWHERE datname = '\u003cdatabase name\u003e';\n```\n\n```sql\n# copy database\nCREATE DATABASE \"new\" WITH TEMPLATE \"old\";\n```\n\n\n## Sed\n\n```bash\n# remove first line of file\nsed -i '1d' file.txt\n\n# remove second line of file\nsed -i '2d' file.txt\n\n# remove first and second line of file\nsed -i '1d;2d' file.txt\n\n# remove last line of file\nsed -i '$d' file.txt\n```\n\n\n## SSH\n\n```bash\n# copy file from local to remote without scp\ncat local.txt | ssh user@example.com \"cat \u003e /tmp/remote.txt\"\n```\n\n```bash\n# copy file from remote to local without scp\nssh user@example.com \"cat /tmp/remote.txt\" \u003e local.txt\n```\n\n```bash\n# SSH's X11 Forwarding (for instance xterm)\nssh -X user@example.com \"xterm\"\n\n# the remote machine must have:\n# 1. sshd X11 Forwarding enabled (\"X11Forwarding yes\" at /etc/ssh/sshd_config)\n# 2. xorg-x11-xauth package installed (yum install xorg-x11-xauth)\n```\n\n```bash\n# SSH socks5 proxy\nssh -D 9050 user@domain.com\n\ncurl --socks5 127.0.0.1:9050 ipinfo.io\nproxychains curl ipinfo.io\nproxychains firefox\n```\n\n```bash\nssh-agent | tee ~/.ssh/agent.env  # once\nsource ~/.ssh/agent.env           # multiple terminals\n```\n\n## Tmux\n\n```bash\n# create named session\ntmux new -s session-name\n```\n\n```bash\n# dettach session (inside tmux)\nCtrl+b d\n```\n\n```bash\n# list session\ntmux ls\n```\n\n```bash\n# attach session\ntmux attach -t session-name\ntmux attach -t 0\n```\n\n```bash\n# windows\nCtrl+b c Create a new window (with shell)\nCtrl+b w Choose window from a list\nCtrl+b 0 Switch to window 0 (by number )\nCtrl+b , Rename the current window\n```\n\n```bash\n# panes\nCtrl+b % Split current pane horizontally into two panes\nCtrl+b \" Split current pane vertically into two panes\nCtrl+b o Go to the next pane\nCtrl+b ; Toggle between the current and previous pane\nCtrl+b x Close the current pane\n```\n\n\n## Tor\n\n```bash\n# create Tor connection to explicit country exit node\necho -e \"ExitNodes {us}\\nStrictNodes 1\" | tor -f -\n```\n\n```bash\n# use curl\ncurl --socks5 127.0.0.1:9050 ipinfo.io\n```\n\n```bash\n# use torsocks\ntorsocks curl ipinfo.io\n```\n\n```bash\n# use proxychains\nproxychains curl ipinfo.io\n```\n\n```bash\n# use chromium\nchromium --user-data-dir=/tmp/x --proxy-server=\"socks5://127.0.0.1:9050\"\n```\n\n## YouTube\n\n```bash\n# download playlist to mp3\nyoutube-dl -x --audio-format=\"mp3\" --audio-quality=\"160k\" --add-metadata --continue \"https://www.youtube.com/playlist?list=PL7x1NEEwqJNvSGCXac6zGxERF9CDcsOK9\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarmelo%2Fuseful-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarmelo%2Fuseful-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarmelo%2Fuseful-commands/lists"}