All commands (14,233)

  • Detects true graphical applications (Qt, GTK, SDL, FLTK, wxWidgets) by parsing ELF dynamic tags with readelf -d instead of relying on .desktop files or executing binaries. It ignores protocol-only CLI utilities (like xset or xrandr) by targeting widget toolkits directly rather than base display server libraries (like libX11 or libwayland-client).


    1
    for b in /usr/bin/*; do [[ -f "$b" && -x "$b" ]] && readelf -d "$b" 2>/dev/null | grep -qE 'libQt[0-9]?(Gui|Widgets)|libgtk-|libgdk-|libSDL|libforms|libfltk|libwx_' && echo "GUI: $b"; done
    wuseman1 · 2026-08-19 20:11:11 0
  • Display a compact, columnized reference of printable ASCII characters and their shell-compatible octal escape sequences. Show Sample Output


    1
    for i in {1..256};do printf '%3d %b\n' $i \\0$((i/64*100+i%64/8*10+i%8));done|cat -t|column -c$((${COLUMNS:-80}/2))
    AskApache · 2026-08-13 07:42:31 0
  • The xorshift32 PRNG written by George Marsaglia in Bash, code golfed. Bash already has the $RANDOM and $SRANDOM environment variables, so this isn't all that useful. The seed "s" must be non-zero. Show Sample Output


    0
    n(){ s=$[s^s<<13];s=$[s^s>>17];s=$[s^s<<5];echo $[s&2**32-1]; }
    atoponce · 2026-07-31 03:42:35 0
  • https://djmag.com/top100djs Show Sample Output


    0
    elinks -dump https://djmag.com/top100djs | awk '/^[0-9]+$/ { rank=$0; next } rank && /^\[[0-9]+\]/ { gsub(/^\[[0-9]+\]/, ""); gsub(/^[ \t]+|[ \t]+$/, ""); print rank ". " $0; rank="" }'|sort -u
    wuseman1 · 2026-07-17 16:30:19 0
  • A lightweight and dependency-minimal way to record a selected region of your Wayland screen. By using `slurp`'s custom formatting directly (`%wx%h+%x+%y`), we eliminate the need for piping through helper tools like `sed` or `awk` to construct the geometry argument for `gpu-screen-recorder`. Requirements: slurp, gpu-screen-recorder


    1
    gpu-screen-recorder -w "$(slurp -f "%wx%h+%x+%y")" -f 60 -o "$HOME/rec_$(date +%Y%m%d_%H%M%S).mp4"
    wuseman1 · 2026-07-15 04:44:42 0
  • Ignores deleted files since main. dos2unix already skips binary files. Safely NUL-delimited. Add -i for a dry run.


    -2
    git diff --diff-filter=ACMRTUX --name-only main -z | grep -zvE '(.meta)' | xargs -0 dos2unix --add-eol
    Hype · 2026-06-23 03:50:58 0
  • Downloads BlackArch tool pages and prints only GitHub links using pure awk filtering.


    1
    curl -sL blackarch.org/{tools,recon}.html | awk -F'"' '$4 ~ /^https:\/\/github\.com\// { print $4 }'
    wuseman1 · 2026-02-12 08:38:04 0

  • 0
    nmcli connection import type wireguard file wireguard_config.conf
    wuseman1 · 2026-02-11 20:31:36 0
  • This is good when the other option on this site not includes ´tput´ like on minimal shell


    4
    printf '%*s\n' "${COLUMNS:-80}" '' | tr ' ' "${1-_}"
    wuseman1 · 2026-02-11 18:27:03 0

  • 2
    kdeconnect-cli -d $(kdeconnect-cli -a --id-only) --share kdeconnect-cli-send-file.sh
    wuseman1 · 2026-02-03 03:10:30 0

  • 0
    cat /dev/urandom | play -q -t raw -r 8000 -e unsigned-integer -b 8 -c 1 -t alsa default
    wuseman1 · 2026-01-27 13:25:49 0

  • 0
    udevadm monitor --udev --subsystem-match=usb | gawk '/add/ { system("espeak \"USB device attached\"") }'
    wuseman1 · 2026-01-27 12:24:27 0

  • 1
    lsmod | awk 'NR>1 && $4!="-" {print $1; split($4,a,","); for(i in a) print " -> used by:", a[i]; print ""}'
    wuseman1 · 2026-01-26 19:00:04 0

  • 4
    awk 'NR==13' /etc/services
    atoponce · 2025-11-25 18:40:02 0

  • -1
    awk '{sum += $0} END {print sum}' file
    atoponce · 2025-11-25 18:21:44 0

  • 5
    netstat -ntu | tail -n +3 | awk '{print $5}' | sed 's/:[0-9]*$//' | sort | uniq -c | sort -rn
    atoponce · 2025-11-25 18:15:39 0
  • Do not use this in production! This is a true hardware random number generator using your system as the entropy source. It models flipping a coin by pitting a fast clock (the CPU) against a slow clock (the RTC). The CPU models the coin flipping head over tails during flight and the RTC models the duration of the coin's flight in the air. A timer is set 1 millisecond into the future and a bit is flipped as fast as possible before the timer expires. 256 bits are collected then hashed with SHA-256 to whiten the data and ensure uniformity. This makes some assumptions however. It assumes that your system is not compromised. It assumes your system is generating enough interrupts for the kernel scheduler to be unpredictable on what gets CPU priority. It assumes that your installed sha256sum(1) command is correctly implemented. Just because you can, doesn't mean you should. Use your system's RNG (EG, /dev/urandom) instead. Show Sample Output


    1
    trng() { zmodload zsh/datetime; local flips=""; while ((${#flips}<256)); do local coin=0; local t=$((EPOCHREALTIME+0.001)); while (($EPOCHREALTIME<$t)); do ((coin^=1)); done; flips+=$coin; done; local h=($(print "$flips"|sha256sum));
    atoponce · 2025-11-24 18:13:40 0
  • Calculates the ceiling of the log2 of a given argument. Show Sample Output


    1
    log2() { local n=0; for ((i=$1-1; i>0; i>>=1)); do ((n+=1)); done; echo $n; }
    atoponce · 2025-11-24 17:17:14 0
  • Issues & improvements Race conditions: the check for writability then mv is not fully atomic — another process could create/remove/change the target between the test and mv. Permissions and ownership: mv will preserve contents but the resulting file may have the temp file's permissions/ownership (mktemp default). Signal safety: if interrupted (SIGINT, SIGTERM) the temp file may remain. Portability: uses bash-compatible constructs but relies on mktemp and -a (POSIX [ -a ] is obsolete; better to use -e). Better error messages and exit status handling. Allow optional mode to write to stdout when no filename given. Support setting desired file mode (umask or chmod) and preserve atomic replace semantics. Enhanced version Uses safer existence test ([ -e ] not deprecated -a). Installs traps to clean up temp file on exit/signals. Preserves mode of the existing file (if it exists) or allows a chmod option. Attempts a safer atomic replace: write to temp in same directory as target when a filename is supplied (reduces window for cross-filesystem mv failure and preserves atomicity). If no filename given, writes temp contents to stdout. Returns non-zero on failure and prints concise errors to stderr.


    -5
    buffer(){ tty -s&&return; d=${1:-/tmp}; tmp=$(mktemp "$d/.b.XXXXXX")||return; trap 'rm -f "$tmp"' EXIT; cat>"$tmp"||{ rm -f "$tmp"; return 1; }; [ -z "$1" ]&&{ cat "$tmp"; rm -f "$tmp"; return 0; }; mv -f "$tmp" "$1"; }
    cryptology_codes · 2025-09-14 21:19:55 0

  • 0
    adb shell input keyevent KEYCODE_VOLUME_DOWN
    alikhalil · 2025-08-13 13:22:00 0
  • This fetches ipfs v0.36.0 for GNU/LInux and puts it in ~/bin without a tmp file or anything else. This works if you already have ~/bin. The `--strip-components=1` flag removes the "kubo" directory in this case. If you have a tar with an even deeper directory structure, say: `some/other/directory/file`, you can just use `--strip-components=3` and it will only extract `file` for you. `-C ~/bin` puts the file in the designated path. In this case, `~/bin`. Show Sample Output


    1
    tar --strip-components=1 -C ~/bin/ -xzf <( curl -L https://dist.ipfs.tech/kubo/v0.36.0/kubo_v0.36.0_linux-amd64.tar.gz ) kubo/ipfs
    renich · 2025-08-12 03:38:07 0
  • Show top 10 users by memory combined consumption in percentage. Show Sample Output


    -1
    ps aux | awk '{arr[$1]+=$4}; END {for (i in arr) {print i,arr[i]}}' | sort -hk2 | tail -10
    Raboo · 2025-08-01 07:06:55 0
  • If you need to see a list of the reboots of your system with date and time stamps then on a Linux with systemd you can use (as non-root) the command: journalctl --list-boots This could be useful if you are trying to track when a power outage occurred. An alternative is: /bin/sudo grep "^-" /var/log/boot.log ^ This only shows the boot start date/times while the journalctl command shows a "LAST ENTRY" associated with each "BOOT ID". Show Sample Output


    1
    $ journalctl --list-boots # display tabular history of reboots
    mpb · 2025-07-22 14:52:34 0

  • 1
    while true; do input tap $(wm size | awk -F 'x' '{print $1/2 " " $2/2}'); done
    wuseman1 · 2025-05-27 13:32:54 0

  • 0
    mount -t cifs -o username=administrator,password=xxx,vers=1.0,sec=ntlmv2 //192.168.0.30/nas_share /mnt/win_share
    swarzynski · 2025-03-20 08:16:19 0
  •  1 2 3 >  Last ›

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Backup all starred repositories from Github

execute your commands hiding secret bits from history records
$ wget --user=username --password="$password" http://example.org/ Instead of hiding commands entirely from history, I prefer to use "read" to put the password into a variable, and then use that variable in the commands instead of the password. Without the "-e" and "-s" it should work in any bourne-type shell, but the -s is what makes sure the password doesn't get echoed to the screen at all. (-e makes editing work a bit better)

Get the beats per minute from an audio track
Requires bpm-tools https://www.pogo.org.uk/~mark/bpm-tools/

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Set Time Zone in Ubuntu
Reconfigures time zone in Ubuntu, which I cannot figure out how to do through the GUI. Worked like a charm to set my time zone to CEST from EDT.

Mount a VMware virtual disk (.vmdk) file on a Linux box
Assumes XP/2000/2003. For Server 2008+ try offset=105,906,176 You can find this number in the System Information utility under Partition Starting Offset. UEFI based boxes you want partition 2 since the first is just the boot files (and FAT). This works with (storage side) snapshots which is handy for single file restores on NFS mounted VMware systems

Use "most" as your man pager
you should have the "most" package installed. I like it because it is colorful and easier to read. alternatively you can use "less" instead of "most". you can also add this to your ~/.bashrc to make it permanent.

Substitute audio track of video file using mencoder
Creates a new video file with video stream copied from input file and a different audio stream

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Print lines in a text file with numbers in first column higher or equal than a value
A text file contains thousands of numbers. This command prints lines were the number is greater or equal than a specified value (134000000).


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: