{"id":31913577,"url":"https://github.com/zhibirc/cmd-wiki","last_synced_at":"2026-05-15T13:01:52.519Z","repository":{"id":37410325,"uuid":"149142542","full_name":"zhibirc/cmd-wiki","owner":"zhibirc","description":":books: The growing collection of solutions/tips/cheats/hacks/tricks for various system-wide and software specific purposes, which are sometimes hard to remember or which are quite difficult to reproduce in compare with just copy-paste. Most topics are related to GNU/Linux and macOS environment.","archived":false,"fork":false,"pushed_at":"2024-08-10T15:57:46.000Z","size":76,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T03:44:00.724Z","etag":null,"topics":["linux","macos","wiki"],"latest_commit_sha":null,"homepage":"","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/zhibirc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-09-17T14:58:23.000Z","updated_at":"2024-08-10T15:57:49.000Z","dependencies_parsed_at":"2024-08-10T17:07:09.206Z","dependency_job_id":null,"html_url":"https://github.com/zhibirc/cmd-wiki","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhibirc/cmd-wiki","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhibirc%2Fcmd-wiki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhibirc%2Fcmd-wiki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhibirc%2Fcmd-wiki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhibirc%2Fcmd-wiki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhibirc","download_url":"https://codeload.github.com/zhibirc/cmd-wiki/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhibirc%2Fcmd-wiki/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33067476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["linux","macos","wiki"],"created_at":"2025-10-13T18:49:54.152Z","updated_at":"2026-05-15T13:01:52.490Z","avatar_url":"https://github.com/zhibirc.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Wiki](https://img.shields.io/badge/wiki-knowledge--base-orange)]()\n[![Maintenance](https://img.shields.io/maintenance/yes/2024.svg?style=flat-square)]()\n[![Platform](https://img.shields.io/badge/OS-GNU%2FLinux-yellowgreen.svg?style=flat-square)]()\n[![Platform](https://img.shields.io/badge/macOS-yellowgreen.svg?style=flat-square)]()\n[![Spellcheck](https://github.com/zhibirc/wiki/actions/workflows/spellcheck.yml/badge.svg)](https://github.com/zhibirc/wiki/actions/workflows/spellcheck.yml)\n\n## Table of Contents\n\n1. [Git](#git)\n1. [NPM helpers](#npm-helpers)\n1. [Shell usefulness](#shell-usefulness)\n1. [Free Up Disk Space](#free-up-disk-space)\n1. [Samba setup](#samba-setup)\n1. [Samba share access (unrestricted)](#samba-share-access-unrestricted)\n1. [Samba share access (restricted)](#samba-share-access-restricted)\n1. [Network goodies](#network-goodies)\n1. [Diff between files/folders](#diff-between-filesfolders)\n1. [Protected archives](#protected-archives)\n1. [Pumping .bash_aliases](#pumping-bash_aliases)\n1. [Encrypt/decrypt a file](#encryptdecrypt-a-file)\n1. [Stress test via DoS attack](#stress-test-via-dos-attack)\n1. [cURL cheatsheet](#curl-cheatsheet)\n1. [Wget basics](#wget-basics)\n1. [Installing programs from sources](#installing-programs-from-sources)\n1. [Installing Oracle Java 8 / 9](#installing-oracle-java-8--9)\n1. [FFmpeg sweets](#ffmpeg-sweets)\n1. [Getting file info](#getting-file-info)\n1. [Getting hardware info](#getting-hardware-info)\n1. [Generate a random password](#generate-a-random-password)\n1. [Amazon Web Services (AWS)](#amazon-web-services-aws)\n1. [Docker](#docker)\n1. [Cool cheatsheets / tutorials / helper tools](#cool-cheatsheets--tutorials--helper-tools)\n1. [Bash-Snippets](#bash-snippets-)\n\n\n---\n\n\n### Git\n\n[**Documentation**](https://git-scm.com/doc)\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nCheck if merge conflicts will occur before actual merging:\n\n```shell\ngit merge \u003cbranch\u003e --no-ff --no-commit\ngit merge --abort\n```\n\nDiscard all unstaged changes:\n\n```shell\ngit checkout -- .\n```\n\nCreate branch from particular commit:\n\n```shell\ngit checkout -b \u003cbranch name\u003e \u003ccommit hash\u003e\n```\n\nCreate a local branch that tracks a remote branch:\n\n```shell\n# starting to work on an existing remote branch (e.g. upstream/develop)\ngit checkout --track \u003cremote branch name\u003e\n```\n\nAdd/stage (modified and deleted files only, new files are not affected) and commit in one command:\n\n```shell\ngit commit -am \"commit message\"\n```\n\nAutomate formation of release announcements:\n\n```shell\ngit shortlog -s | awk -F\\\\t '{print $2}' \u003e contributors.md\ngit shortlog --no-merges | awk -F '[[:alnum:] ]+ \\\\([0-9]' '{print $1}' | grep . \u003e changelog.md\n```\n\nGet a nice list of actual different commits not shared between the branches:\n\n```shell\ngit log --left-right --graph --cherry-pick --oneline master..develop\n```\n\nGenerate a \"top ten list\" of most commited files, the \"heat map\" of the code changes.\nIt could be used (along with other indicators, of course) to make informative decision about extracting\ncertaint components into separate services.\n\n```shell\ngit log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -10\n```\n\nHousekeeping tools:\n\n```shell\n# cleans up unreachable or \"orphaned\" Git objects\n\n# what is set to be pruned but not actually prune it\ngit prune --dry-run --verbose\n\n# prune and display output of all objects and actions taken by it\ngit prune --progress\n```\n\nIgnore changes to a file that's already tracked in the repository. \nIt's a common task and is very helpful in case of adding some local tokens, for example, to configuration file with boilerplate:\n\n```shell\ngit update-index --assume-unchanged \u003cfile\u003e\n# tracking changes again\ngit update-index --no-assume-unchanged \u003cfile\u003e\n```\n\u003c/details\u003e\n\n\n### NPM\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nGet debug info (useful for reports, GitHub issues, etc.):\n\n```shell\nnpx envinfo --binaries --languages --system --utilities\n```\n\u003c/details\u003e\n\n\n### Shell\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nCheck which init system your platform uses (**systemd** (`systemctl` command), or older **System V** (which uses the `service` command)):\n\n```shell\nps --no-headers -o comm 1\n```\n\nRemove multiple sub-folders:\n\n```shell\nfind . -type d -name node_modules -prune -exec rm -rf '{}' \\;\n```\n\nFind patterns:\n\n```shell\n# find files containing a given text\nfind . -type f -print0 | xargs -0 grep -l \"search string\"\n# \"l\" means that only the name of each input file with matched content will print\ngrep -rl \"search string\" /\n\n# handle multiple search patterns\ngrep -e hacker -e root -e admin /etc/passwd\n```\n\nSometimes process (Apache, for example) prevents to start service on the same port (nginx, for example):\n\n```shell\n# end the conflict process\nsudo fuser -k 80/tcp\n```\n\nAPT\n\n```shell\n# list all installed packages\napt list --installed | less\n\n# list all ready-to-upgrade packages\napt list --upgradeable | less\n\n# update list of available packages\nsudo apt update\n\n# upgrade the system by installing/upgrading packages\nsudo apt upgrade\n\n# search in package descriptions\napt search \u003cneedle_name\u003e\n\n# show package details\napt show \u003cpackage_name\u003e\n\n# remove automatically all unused packages\nsudo apt autoremove\n\n# all-in-one upgrade system command\nsudo apt update \u0026\u0026 sudo apt upgrade -y\n```\n\nChange/setup bash custom prompt (PS1) with Git branch displaying (if exists). Specify this in `~/.bashrc` and run `source ~/.bashrc` for applying changes:\n\n```shell\ngit_branch() {\n  git branch 2\u003e /dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/[\\1]/'\n}\n\nCOLOR_USER='\\[\\e[1;32m\\]'\nCOLOR_PATH='\\[\\e[00;36m\\]'\nCOLOR_RESET='\\[\\e[0m\\]'\n\nPS1=\"${COLOR_RESET}${COLOR_USER}\\u▶${COLOR_RESET} ${COLOR_PATH}\\w ${COLOR_USER}\\[\\033[00;32m\\]\\$(git_branch)\\[\\033[00m\\] $ ${COLOR_RESET}\"\n```\n\nResult of the above is something like:\n\n![PS1 example](assets/images/ps1.png)\n\nFast checking of PHP SSL support:\n\n```shell\necho '\u003c?php phpinfo(); ?\u003e' | php 2\u003e\u00261 |grep -i ssl\n```\n\nInstalling and basic setup of SSH Server:\n\n```shell\nsudo apt install openssh-server\n\n# check status\nservice --status-all | grep ssh\n# or\nsystemctl list-units | grep ssh\n\n# config in /etc/ssh/sshd_config\n\n# help\nman sshd_config\n\n# after making changes to the /etc/ssh/sshd_config file, save the file, and restart the sshd server to effect the changes using the following command:\nsudo systemctl restart sshd.service\n\n# in case of using SSH keys don't forget to copy the id_rsa.pub file to the remote host and append it to ~/.ssh/authorized_keys, then give it the right permissions:\nchmod 600 .ssh/authorized_keys\n```\n\u003c/details\u003e\n\n\n### Free Up Disk Space\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nYou can check the size of interested directory with `du -sh \u003cdirectory\u003e` preliminarily.\n\n```shell\n# clean the thumbnail cache\nrm -rf ~/.cache/thumbnails/*\n\n# remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed\nsudo apt autoremove\n\n# clean the apt cache\nsudo apt-get clean\n\n# remove old, unused kernels, except for the last two - the current and the previous\nsudo purge-old-kernels\n```\n\u003c/details\u003e\n\n\n### Samba setup\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\nsudo apt-get install -y samba samba-common python-glade2 system-config-samba\nsudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak\nsudo vi /etc/samba/smb.conf\n```\n\n```\n[global]\nworkgroup = WORKGROUP\nserver string = Samba Server %v\nnetbios name = srvr1\nsecurity = user\nmap to guest = bad user\nname resolve order = bcast host\nwins support = no\ndns proxy = no\n```\n\u003c/details\u003e\n\n\n### Samba share access (unrestricted)\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\nsudo mkdir -p /samba/share\ncd /samba\nsudo chmod -R 0755 share\nsudo chown -R nobody:nogroup share/\n```\n\n```\n[share]\npath = /samba/share\nbrowsable = yes\nwritable = yes\nguest ok = yes\nread only = no\n```\n\n```shell\nsudo service smbd restart\n```\n\u003c/details\u003e\n\n\n### Samba share access (restricted)\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\nsudo mkdir -p /samba/share/secured\nsudo addgroup securedgroup\ncd /samba/share\nsudo chown -R zhibirc:securedgroup secured\nsudo chmod -R 0770 secured/\nsudo usermod -a -G securedgroup zhibirc\nsudo smbpasswd -a zhibirc\n```\n\n```shell\nsudo vi /etc/samba/smb.conf\n```\n\n```\n[secured]\npath = /samba/share/secured\n# valid users = zhibirc\nvalid users = @securedgroup\nguest ok = no\nwritable = yes\nbrowsable = yes\n```\n\n```shell\nsudo service smbd restart\n```\n\u003c/details\u003e\n\n\n### Network goodies\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nRetrieve list of Samba master browser(s):\n\n```shell\nnmblookup -M -- -\n```\n\nShow NFS exports, like the ```showmount -e``` command:\n\n```shell\nnmap -sV --script=nfs-showmount 127.0.0.1\n```\n\nMapping processes to system ports they listen for:\n\n```shell\nsudo netstat -tpln\n```\n\nServe folder:\n\n```shell\npython -m SimpleHTTPServer 8080\n# or\npython3 -m http.server 8080\n# or\nsudo npm install http-server -g\nhttp-server\n```\n\nFind out MAC address by using IP address:\n\n```shell\narping -I eth0 -c 2 destination_ip\n```\n\nUsing `arp-scan` allows to discover all IP hosts on the local network, including those that block all IP traffic such as firewalls and systems with ingress filters.\nIt works on Ethernet and 802.11 wireless networks. Requires root privilege.\n\n```shell\n# \"eth0\" is used for example, in reality the network interface name depends on the OS, the network type and other factors\nsudo arp-scan --interface=eth0 --localnet\n# or\nsudo arp-scan --localnet\n```\n\u003c/details\u003e\n\n\n### Diff between files/folders\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\n# install \"Meld\", visual diff and merge tool for files, folders and VCS\nsudo apt install meld\n# diff between files\nmeld file1 file2\n# diff between folders\nmeld dir1 dir2\n```\n\nAlso it's possible and widely used to set **Meld** as a Git `difftool` and `mergetool`.\n\u003c/details\u003e\n\n\n### Protected archives\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nCreate encrypted ZIP archive (password as a plain text):\n\n```shell\nzip -P s0me_paSS -r protected.zip /home/sites/*/www/\n```\n\nCreate encrypted ZIP archive (request to enter password), different choices:\n\n```shell\nzip --encrypt protected.zip file_name\nzip --encrypt protected.zip file1 file2 file3\nzip --encrypt -r protected.zip /home/user/folder/\nzip --encrypt -r protected.zip /folder1/ /folder2/\n```\n\nZIP supports a simple password-based symmetric encryption system, which is documented in the ZIP specification, and known to be **seriously flawed**, \nso don't use it for data with limited access.\n\u003c/details\u003e\n\n\n### Pumping .bash_aliases\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nIt's possible to put a lot of useful shortcuts in `~/.bash_aliases` which can improve work effectiveness:\n\n```shell\n# General aliases\nalias df=\"df -h\"\nalias du=\"du -c -h\"\nalias mkdir=\"mkdir -pv\"\nalias ls=\"ls --color=auto --group-directories-first\"\nalias ll=\"ls -lA\"\nalias lx=\"ll -BX\"   # sort by extension\nalias lz=\"ll -rS\"   # sort by size\nalias lt=\"ll -rt\"   # sort by date\nalias l.=\"ll -d .*\" # show only hidden files\nalias ..=\"cd ..\"\nalias mnt=\"mount | column -t\"\nalias pwdgen=\"openssl rand -base64 30\"\nalias ports=\"netstat -tulanp\" # quickly list all TCP/UDP port on the server\nalias ping=\"ping -c 5\" # stop after sending count ECHO_REQUEST packets\nalias wget=\"wget -c\" # can resume downloads\nalias i=\"ifconfig\"\nalias net=\"netstat -tunlep\"\n\n# Git\nalias ga='git add'\nalias gp='git push'\nalias gl='git log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short'\nalias gs='git status'\nalias gd='git diff'\nalias gm='git commit'\nalias gb='git branch'\nalias gc='git checkout'\nalias gf='git reflog'\nalias gma='git commit -am'\nalias gra='git remote add'\nalias grr='git remote rm'\nalias gpu='git pull'\nalias gcl='git clone'\nalias gta='git tag -a -m'\n\n# Install NPM packages in Docker container to prevent security flaws\nalias dnpm='docker run -it --rm -u=$UID:$(id -g $USER) -v \"$PWD\":/npm -w /npm node npm'\nalias dnpx='docker run -it --rm -u=$UID:$(id -g $USER) -v \"$PWD\":/npm -w /npm node npx'\nalias dnode='docker run -it --rm -u=$UID:$(id -g $USER) -v \"$PWD\":/npm -w /npm node node'\nalias dyarn='docker run -it --rm -u=$UID:$(id -g $USER) -v \"$PWD\":/npm -w /npm node yarn'\n```\n\u003c/details\u003e\n\n\n### Encrypt/decrypt a file\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nUse the built-in **gpg** tool:\n\n```shell\n# encrypt\ngpg -c important.data.txt\n# decrypt\ngpg important.data.txt.gpg\n```\n\u003c/details\u003e\n\n\n### Stress test via DoS attack\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nUsing **ab** (Apache HTTP server benchmarking tool).\nOfficial docs: [link](https://httpd.apache.org/docs/2.4/programs/ab.html)\n\n```shell\nab -k -c 350 -n 20000 example.com\n```\n\nFor testing multiple URL's concurrently create a shell script with multiple `ab` calls:\n\n```shell\n#!/bin/sh\n\nab -n 100 -c 10 example.com/login \u003e test1.txt \u0026\nab -n 100 -c 10 example.com/news \u003e test2.txt \u0026\n```\n\nUsing **Siege**:\n\n```shell\nsiege -d10 -c50 example.com\n```\n\u003c/details\u003e\n\n\n### cURL\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nDebug options `--verbose` (`-v`), `--trace`, `--trace-ascii`, `--trace-time` allow to get more details as they show EVERYTHING **curl** sends and receives.\n\n```shell\n# use \"-\" as filename to have the output sent to stdout\ncurl --trace-ascii - http://www.example.com/\n```\n\nMake GET request, only print the response headers and display the time it took:\n\n```shell\ncurl -sIX GET -w \"Total time: %{time_total} s\\n\" www.example.com\n# or\ncurl -o /dev/null -D- www.example.com\n```\n\nTypical usage, send GET request with headers:\n\n```shell\ncurl -X GET 'http://www.example.com' -H 'Accept-Language: en' -H 'Authorization: Bearer A0v7mf98JJvWQTEbpEYNTt0uw2q0yl6P' -H 'Content-Type: application/json'\n```\n\nPOST request format depends on content type (`application/x-www-form-urlencoded` is the default):\n\n```shell\n# or simply -d\ncurl --data \"param1=value1\u0026param2=value2\" -X POST https://example.com/resource.cgi\ncurl -d '{\"key1\":\"value1\", \"key2\":\"value2\"}' -H \"Content-Type: application/json\" -X POST http://www.example.com\n```\n\nIdentify the HTTP options available on the target URL, including the various types of allowed HTTP methods:\n\n```shell\ncurl -v -X OPTIONS http://www.example.com/\n```\n\u003c/details\u003e\n\n\n### Wget\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nDownloading an entire Web Site:\n\n```shell\n# download the entire Web site\n# convert links so that they work locally, off-line\n# download all the files that are necessary to properly display a given HTML page\n# guarantee that only the files below a certain hierarchy will be downloaded\n# wait the specified number of seconds between the retrievals\n# cause the time between requests to vary between 0.5 and 1.5 * wait (see above) seconds\nwget --recursive --convert-links --page-requisites --no-parent --wait=5 --random-wait http://www.example.com/\n```\n\nYou may want to specify `--user-agent` option which allows you to change the \"**User-Agent**\" line.\nSpecifying empty user agent with `--user-agent=\"\"` instructs Wget not to send the \"**User-Agent**\" header in HTTP requests.\n\u003c/details\u003e\n\n\n### Installing programs from sources\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\ntar xzvf program.sources.tar.gz\ncd program.sources\n# configure and compile\n# if README is present, read it first\n./configure\nmake\nsudo make install\n# clean up any temp files, optional\nmake clean\n```\n\u003c/details\u003e\n\n\n### Installing Oracle Java 8 / 9\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\nsudo add-apt-repository ppa:webupd8team/java\nsudo apt update; sudo apt install oracle-java8-installer\n# or replace oracle-java8-installer with oracle-java9-installer to install Java 9\n# check the Java version\njavac -version\n# set Java environment variables\nsudo apt install oracle-java8-set-default\n```\n\u003c/details\u003e\n\n\n### FFmpeg\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nGet metadata information from media file:\n\n```shell\n# work on any file FFmpeg supports\nffmpeg -i video.mp4 -hide_banner\n# advanced method using FFprobe, multimedia stream analyzer\nffprobe -v error -show_format -show_streams video.mp4\n```\n\nConvert MP4 video to MP3 audio:\n\n```shell\nffmpeg -i video.mp4 audio.mp3\n# or, with additional options\nffmpeg -i video.mp4 -b:a 192k -vn audio.mp3\n```\n\nConvert RTSP stream to HLS:\n\n```shell\nffmpeg -i rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov -fflags flush_packets -max_delay 2 -flags -global_header -hls_time 2 -hls_list_size 3 -vcodec copy -y video.m3u8\n```\n\nSplit a video into images:\n\n```shell\nmkdir video; ffmpeg -i video.mp4 image%d.jpg\n```\n\nReduce the file size of MP4 file:\n\n```shell\n# get file information\nffmpeg -i video.mp4\n# 497 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)\n# reduce bitrate by approximately half\nffmpeg -i video.mp4 -b 248k video.out.mp4\n```\n\nCrop video file:\n\n```shell\nffmpeg -i video.mp4 -ss 00:00:03 -t 00:00:08 -async 1 fragment.mp4\n```\n\u003c/details\u003e\n\n\n### Getting file info\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\n```shell\n# display file or file system status\nstat file.name\n# get basic file info, recognize the type of data contained in\nfile file.name\n# or, for getting mime type\nfile -i file.name\n# read image metadata, ImageMagick is required\n# get format and characteristics of one or more image files\nidentify -verbose file.name \n```\n\nIn case of media file container used by a multimedia stream use information from [FFmpeg](#ffmpeg).\n\u003c/details\u003e\n\n\n### Getting hardware info\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nOverall:\n\n```shell\nuname -a\n\nsudo dmidecode | less\n\nsudo lshw | less\n\n# pretty print\nsudo lshw -html \u003e system_info.html\n```\n\nSpecific:\n\n```shell\n# list USB devices\nlsusb\n\n# list all PCI devices\nlspci\n\n# CPU\ncat /proc/cpuinfo\n# or more precise form\nlscpu\n\n# RAM\ncat /proc/meminfo\nfree\n\n# SSD/HDD\nsudo fdisk -l\n```\n\nOr, if you prefer some GUI tool, use `hardinfo` (`sudo apt install hardinfo`).\n\u003c/details\u003e\n\n\n### Generate a random password\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\u003c/details\u003e\n\n\n### Amazon Web Services (AWS)\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nSetup:\n\n```shell\nsudo apt install awscli\naws --version\n\n# configuring\naws configure\nAWS Access Key ID [None]: \u003cassociated with an IAM user\u003e\nAWS Secret Access Key [None]: \u003cassociated with an IAM user\u003e\nDefault region name [None]: \u003cany available region\u003e\nDefault output format [None]: \u003cjson|text|table\u003e\n\n# or configure the same for another user\naws configure --profile \u003cusername\u003e \n```\n\n```shell\n# enable command-completion feature\n\n# locate the AWS Completer script, use this path in command below\nwhich aws_completer\n\n# in ~/.bashrc\ncomplete -C '/usr/bin/aws_completer' aws\nsource ~/.bashrc \n```\n\u003c/details\u003e\n\n\n### Docker\n\n[**Documentation**](https://docs.docker.com/)\n\n\u003cdetails\u003e\n\u003csummary\u003eexpand section 🔻🔺\u003c/summary\u003e\n\u003cbr\u003e\n\nClean-up (containers, images, networks, cache):\n\n```shell\nalias d='docker' \u0026\u0026 d stop $(d ps -q) \u0026\u0026 d rm $(d ps -qa) \u0026\u0026 d rmi $(d images -q) \u0026\u0026 d network prune -f \u0026\u0026 d builder prune -f\n```\n\nRemove exited containers:\n\n```shell\ndocker rm $(docker ps -a -q -f status=exited)\n```\n\nBuild image in verbose mode (auto, plain, tty modes are available):\n\n```shell\ndocker build . --tag \u003ctag_name\u003e --no-cache --progress=plain\n```\n\u003c/details\u003e\n\n\n### Cool cheatsheets / tutorials / helper tools\n\n* [Bash-hackers wiki](http://wiki.bash-hackers.org/) _(bash-hackers.org)_\n* [Shell vars](http://wiki.bash-hackers.org/syntax/shellvars) _(bash-hackers.org)_\n* [Learn bash in y minutes](https://learnxinyminutes.com/docs/bash/) _(learnxinyminutes.com)_\n* [Bash Guide](http://mywiki.wooledge.org/BashGuide) _(mywiki.wooledge.org)_\n* [ShellCheck](https://www.shellcheck.net/) _(shellcheck.net)_\n\n\n### Bash-Snippets [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)]()\n\nA collection of small bash scripts for heavy terminal users with no dependencies: [link](https://github.com/alexanderepstein/Bash-Snippets)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhibirc%2Fcmd-wiki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhibirc%2Fcmd-wiki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhibirc%2Fcmd-wiki/lists"}