38 votes

What are some great time savers on CLI that you would recommend?

I use these right now on Debian:

ncdu

ncdu (NCurses Disk Usage): A disk usage analyzer with an ncurses interface, providing a fast and easy-to-use overview of disk space utilization. Ideal for identifying large directories and files in a user-friendly terminal interface.

duf

duf (Disk Usage/Free): A modern disk usage/free utility with a beautiful interface written in Go. It provides a quick and easy way to check disk usage across various file systems with color-coded output.

tldr

tldr (Too Long; Didn't Read): Simplified and community-driven man pages. Provides practical examples for commands, making it easier to understand and use without wading through lengthy and detailed man pages.

nala

nala (Next-Generation APT Frontend): A modern frontend for the APT package manager, designed to provide a more readable and user-friendly output for package management tasks.

Speedtest-cli

Speedtest-cli: A command-line interface for testing internet bandwidth using speedtest.net. Allows you to quickly check your upload and download speeds directly from the terminal.

htop

htop: An interactive process viewer for Unix systems. It provides a real-time, color-coded display of system processes, making it easier to monitor and manage system resources.

powertop

powertop: A tool for diagnosing issues with power consumption and power management on Linux systems. It provides detailed information on power usage by various system components and applications.

thinkfan

thinkfan: A simple fan control program for ThinkPads. It helps manage the system's fan speed to balance cooling and noise levels based on the temperature sensors.

tlp

tlp (Linux Advanced Power Management): A power management tool for Linux. It provides various configurations and options to optimize battery life on laptops without requiring manual tweaks.

flatpak

Flatpak: A system for building, distributing, and running sandboxed desktop applications on Linux. It provides a universal app distribution system that works across various Linux distributions.

neofetch

Neofetch: A command-line system information tool written in bash. It displays an aesthetically pleasing summary of system information alongside your terminal prompt.

iftop

iftop: A real-time console-based network bandwidth monitoring tool. It shows a list of network connections from/to your system and the bandwidth usage for each connection.

nano

nano: A simple, user-friendly text editor for the command line. Known for its straightforward and easy-to-use interface, making it a go-to for quick text editing tasks.

Edit
Oh wow! Thank you all for your suggestions!

I was looking around and found cheat; it's defined as a cheat that allows you to create and view interactive cheatsheets on the command line. Hopefully, someone else might find it helpful as well.

31 comments

  1. [2]
    unkz
    Link
    Nvim. Yeah, I didn’t say emacs, wanna fight about it? Also, lustyjuggler for the best buffer management, and copilot. Tmux, because it’s better than screen. Sed/awk/cut/perl/head/tail/cat — I’m...

    Nvim. Yeah, I didn’t say emacs, wanna fight about it? Also, lustyjuggler for the best buffer management, and copilot.

    Tmux, because it’s better than screen.

    Sed/awk/cut/perl/head/tail/cat — I’m always chopping up text with these.

    Bash/zsh — a healthy set of aliases and shell configuration can be a huge timesaver.

    16 votes
    1. Gopher
      Link Parent
      I used to be able to use vim proficient enough, but I havnt touched a computer in 2 years since I got a phone lol, I bet I couldn't even use vim at all now, I forget what all the keys do Same with...

      I used to be able to use vim proficient enough, but I havnt touched a computer in 2 years since I got a phone lol, I bet I couldn't even use vim at all now, I forget what all the keys do

      Same with I have suckless stuff on my computer, I forget all the keys, I probably couldn't do much more than open dmenu

      2 votes
  2. [4]
    underdog
    Link
    A bunch of good suggestions already in the thread so I'm just going to drop one that blew my mind when I first learned it: Escape+. (Press escape then full stop) This populates your command with...

    A bunch of good suggestions already in the thread so I'm just going to drop one that blew my mind when I first learned it:
    Escape+. (Press escape then full stop)

    This populates your command with the latest argument from the last command used. I find it extremely useful, for example:

    ll /tmp/mydir
    cat <hotkey>
    It then becomes: cat /tmp/mydir
    Then I just continue typing

    11 votes
    1. afrocat
      (edited )
      Link Parent
      Alt+. does the same thing and it is easier to press. You can check out all key bindings for bash through man readline

      Alt+. does the same thing and it is easier to press.
      You can check out all key bindings for bash through man readline

      8 votes
    2. gco
      Link Parent
      For the same functionality I use !$ as parameter. For example cat !$.

      For the same functionality I use !$ as parameter. For example cat !$.

      4 votes
    3. vord
      Link Parent
      You've just changed my life. This alias just became that much easier to use. alias set_workdir='export WORKDIR='

      You've just changed my life. This alias just became that much easier to use.

      alias set_workdir='export WORKDIR='
      
      3 votes
  3. [2]
    Macha
    Link
    zoxide - there's a bunch of similar implementations of this idea, so if you have your own favourite they're all pretty much interchangable but basically it's cd based on fuzzy fragment matching....

    zoxide - there's a bunch of similar implementations of this idea, so if you have your own favourite they're all pretty much interchangable but basically it's cd based on fuzzy fragment matching. Always navigating to some/folder/giant-microwave-dish-project? Just type z microwave and save yourself the keystrokes.

    9 votes
    1. nmn
      Link Parent
      that reminds me, some ~11 years ago I coded my own version of this. Never published it on GitHub because at the time I thought that no one would care

      that reminds me, some ~11 years ago I coded my own version of this. Never published it on GitHub because at the time I thought that no one would care

      2 votes
  4. [2]
    Akir
    Link
    I'm surprised that people think manpages are too verbose. If anything, I find them too sparse. Then again, there is always the occasional utility that uses their manpage as the only documentation,...

    I'm surprised that people think manpages are too verbose. If anything, I find them too sparse. Then again, there is always the occasional utility that uses their manpage as the only documentation, or where it's just a copy of their whole user manual, so I kinda get it. But on the other hand, it's usually easy enough to find what you need by pressing the backslash key to search.

    duf sounds really useful though; I never remember how to find out how much space is left on a storage volume, and I can never remember how to use dq.


    I have an entirely unwarranted fondness of CLI email programs. mailx is basically the definitive tool for it, as the enhansed version of the original mail MUA. There are frendlier ones available like mutt or the decendants of elm like pine or alpine. True CLI heads might be using one that attaches to vim or emacs. Now that I think about it the fondness is probably stockholm syndrome. I've spent many hours using mailq to figure out why emails are not being delivered. These days I pay people to maintain mail servers.

    find is an unsung hero that is massively more powerful than you'd think thanks to the -exec parameter. I find it particularly great to find the location of configuration files (I really don't get why so many software packages don't think to put that info in their documentation), or just stuff that I have forgotten where I had put them. The syntax is a little bit unintuitive but it's on pretty much every system by default.

    ppp is really handy for talking to a certain breed of retro computers, and can be used to connect them to the internet.

    6 votes
    1. vord
      Link Parent
      I like the tldr pages, not because the man pages are too verbose, but because 9/10 times, one of the examples in the tldr pages gets me where I need to be with substantially less skimming over 8...

      I like the tldr pages, not because the man pages are too verbose, but because 9/10 times, one of the examples in the tldr pages gets me where I need to be with substantially less skimming over 8 other flags I didn't care about.

      10 votes
  5. [3]
    Comment deleted by author
    Link
    1. tauon
      Link Parent
      For finding files: Fuzzy Finder (fzf) For finding in files: ripgrep (rg) Together: Unbeatable :-)

      For finding files: Fuzzy Finder (fzf)

      For finding in files: ripgrep (rg)

      Together: Unbeatable :-)

      4 votes
    2. yushir0
      Link Parent
      I had to go entirely too far into this thread to see fzf mentioned. The functionality that it adds just when you hit ctrl-r alone makes it a huge time saver. I also recommend tmux and the power...

      I had to go entirely too far into this thread to see fzf mentioned. The functionality that it adds just when you hit ctrl-r alone makes it a huge time saver.

      I also recommend tmux and the power line add-on for tmux.

      The airline plugin for vim adds a lot of improvements to the vim interface. That said, just in general, if you want to improve your life dramatically, learn some of the extensive functionality of vim. Most people never learn anything other than the basics. The "q" key for example hides functionality that will make people think you are a freaking magician.

      3 votes
  6. obtusegoose
    Link
    Fish shell Basically no config Suggests a command from history when you start writing out of the box (ctrl-f to complete is hardwired in my brain now so I accidentally use it elsewhere) Oh you...

    Fish shell

    • Basically no config
    • Suggests a command from history when you start writing out of the box (ctrl-f to complete is hardwired in my brain now so I accidentally use it elsewhere)
    • Oh you have history in another terminal session you want access to now? Just write history merge
    • Sane ad-hoc for-loops, <enter> won't execute if you haven't closed the loop block
    • abbr is what aliases should be, expands as you type so you can actually edit things before executing, and the history becomes readable. I can never switch to a shell without it again.
    6 votes
  7. [5]
    g33kphr33k
    Link
    history !! ps -ef | grep x (where X is part of a process name) hwinfo mediainfo lspci / lscpu / etc du -h df -h which x

    history

    !!

    ps -ef | grep x (where X is part of a process name)

    hwinfo

    mediainfo

    lspci / lscpu / etc

    du -h

    df -h

    which x

    5 votes
    1. [3]
      vord
      Link Parent
      I always alias my commands with '-h' unless there's a damn important reason not to.

      I always alias my commands with '-h' unless there's a damn important reason not to.

      2 votes
      1. [2]
        Macha
        Link Parent
        MacOS sort sadly lacks the -h option

        MacOS sort sadly lacks the -h option

        1 vote
        1. onyxleopard
          (edited )
          Link Parent
          If you want to have the flexibility to use both macOS/BSD default utilities and GNU versions of utilities on macOS, I recommend homebrew's coreutils package: $ brew info coreutils ==> coreutils:...

          If you want to have the flexibility to use both macOS/BSD default utilities and GNU versions of utilities on macOS, I recommend homebrew's coreutils package:

          $ brew info coreutils
          ==> coreutils: stable 9.5 (bottled), HEAD
          GNU File, Shell, and Text utilities
          https://www.gnu.org/software/coreutils
          Conflicts with:
            aardvark_shell_utils (because both install `realpath` binaries)
            b2sum (because both install `b2sum` binaries)
            ganglia (because both install `gstat` binaries)
            gfold (because both install `gfold` binaries)
            idutils (because both install `gid` and `gid.1`)
            md5sha1sum (because both install `md5sum` and `sha1sum` binaries)
            uutils-coreutils (because coreutils and uutils-coreutils install the same binaries)
          Installed
          /opt/homebrew/Cellar/coreutils/9.5 (476 files, 13.5MB) *
            Poured from bottle using the formulae.brew.sh API on 2024-03-31 at 17:53:44
          From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c/coreutils.rb
          License: GPL-3.0-or-later
          ==> Dependencies
          Required: gmp ✔
          ==> Options
          --HEAD
          	Install HEAD version
          ==> Caveats
          Commands also provided by macOS and the commands dir, dircolors, vdir have been installed with the prefix "g".
          If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH with:
            PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
          ==> Analytics
          install: 51,020 (30 days), 189,834 (90 days), 617,850 (365 days)
          install-on-request: 38,553 (30 days), 144,563 (90 days), 462,610 (365 days)
          build-error: 12 (30 days)
          

          The GNU versions are installed with g- prefixes, but, as the caveats section says, if you add the gnubin directory to your PATH ahead of /usr/bin/, then you can access the GNU versions with their normal names (sort, ls, head, ... instead of gsort, gls, ghead, ...).

          E.g., sorting sizes of files/subdirs in current directory:

          # macOS default utilities
          $ stat -f '%z' * | sort -nr | numfmt --to=iec | head
          1.8G
          97M
          2.8M
          1.5M
          1.5M
          825K
          697K
          438K
          281K
          249K
          # GNU utilities
          $ gstat -c '%s' * | gnumfmt --to=iec | gsort -rh | ghead
          1.8G
          97M
          2.8M
          1.5M
          1.5M
          825K
          697K
          438K
          281K
          249K
          
          1 vote
    2. mikey
      Link Parent
      I prefer including -i in my grep commands. I am terrible at remembering case for certain processes or things I am looking for!

      I prefer including -i in my grep commands. I am terrible at remembering case for certain processes or things I am looking for!

      1 vote
  8. [2]
    vord
    Link
    Some simple sanity aliases for distros that lack them: alias ls='ls -h' alias la='ls -lha' alias ll='ls -lh' alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' And some others I like:...

    Some simple sanity aliases for distros that lack them:

    alias ls='ls -h'
    alias la='ls -lha'
    alias ll='ls -lh'
    alias ..='cd ..'
    alias ...='cd ../..'
    alias ....='cd ../../..'
    

    And some others I like:

    alias du='du -h --max-depth=1'
    alias add_path='export PATH=$PWD:$PATH'
    
    4 votes
    1. jredd23
      Link Parent
      Yea, the disk usage command very useful command to find directory size. Between that and 'df' are my two commands to add to your alias list. #Get the top 5 directories du -hs * | sort -rh | head...

      Yea, the disk usage command very useful command to find directory size. Between that and 'df' are my two commands to add to your alias list.
      #Get the top 5 directories
      du -hs * | sort -rh | head -5

      #To display the amount of available disk space for file systems
      df -kH

      3 votes
  9. [3]
    em-dash
    Link
    I have some neat bash (and other readline based tools) keybindings. These go in ~/.inputrc or /etc/inputrc: "\C-[[A": history-search-backward "\C-[[B": history-search-forward These let you type...

    I have some neat bash (and other readline based tools) keybindings. These go in ~/.inputrc or /etc/inputrc:

    "\C-[[A": history-search-backward
    "\C-[[B": history-search-forward
    

    These let you type the start of a command, then use the up and down arrows to scroll through history commands starting with that.

    $if Bash
            Space: magic-space
    $endif
    

    This does history expansion when typing a space. Mostly I use this for previewing sudo !! before running it, but there's a lot of other neat stuff you can do with it.

    4 votes
    1. [2]
      vord
      Link Parent
      FWIW you can do this with default bash. Ctrl-R opens the history search, type your search query. Hit Ctrl-R again to move further back. Ctrl-S to go forward again.

      FWIW you can do this with default bash.

      Ctrl-R opens the history search, type your search query. Hit Ctrl-R again to move further back. Ctrl-S to go forward again.

      2 votes
      1. em-dash
        Link Parent
        Fancy. That appears to do something subtly different, though (searches in full commands, not just prefixes), and misses my main use case of "start typing a long command, realize halfway through...

        Fancy. That appears to do something subtly different, though (searches in full commands, not just prefixes), and misses my main use case of "start typing a long command, realize halfway through I've definitely run this exact command before, autocomplete it".

        1 vote
  10. [2]
    overbyte
    Link
    I work with containers a bit, so these tools are biased against those. openssl can generate random numbers without having to manually pull bits from the hardware devices, and it will likely exist...

    I work with containers a bit, so these tools are biased against those.

    openssl can generate random numbers without having to manually pull bits from the hardware devices, and it will likely exist even in a stripped-down container so it's my go-to tool for the one-off generation.

    socat - basically netcat on steroids. Relays bidirectional traffic from whatever to wherever. Files, pipes sockets, device descriptors, you name it. Invaluable for using a local tool against a remote instance or blindly shoving traffic to some other destination. We used this to work around region-specific limitations in Google Cloud before they introduced true global access, so it's robust enough for 24/7 production use.

    ansible - straightforward syntax and agentless. Not just for mass-provisioning servers, it's useful for templating out variations of config files with Jinja or reconfiguring laptops/desktops to a known state, with things like the gconf and kdeconfig modules to declaratively set settings for GNOME and KDE respectively. You can also run it imperatively, like grab hardware specs for a specific group of hosts. If you still have VMs on a cloud service, it's extremely powerful with dynamic inventory plugins.

    kind - the tool used to test Kubernetes itself during its development. Spins up a vanilla Kubernetes cluster using containers instead of VMs. As it was built for CI, it is extremely quick to start and teardown and you feed it a file to declaratively configure a cluster. I use it over the others specifically because it spins up a vanilla cluster without all the trimmings.

    ignition and butane - declarative, automated provisioning of immutable systems which is extremely powerful when combined with Terraform/OpenTofu. Basically halfway between a traditional VM and a container. Useful when I need to spin up a minimal single-purpose VM with CoreOS/Flatcar to run a lightweight tool, but where setting up all the infrastructure to run a container in a single VM is overkill.

    cfssl - Cloudflare's PKI toolbox. I always keep forgetting openssl's syntax to generate certs that aren't PEM encoded, and cfssl's JSON syntax makes it very straightforward to crank out a full chain to test things.

    pgcli and mycli - basically nicer CLIs against Postgres and MySQL/MariaDB

    stern - log tailing tool for Kubernetes clusters. Pods of containers are ephemeral, suffixed with randomly-generated strings and a badly built container would likely crash and wipe all the existing logs as they're attached to that container. This handles the ephemeralness for you so can focus on "show me the logs of all containers with the name x"

    ip-masq-agent - not quite an interactive CLI tool, but it saves massive amounts of hair-pulling frustrations when dealing with Kubernetes networking (both on their own are already complex enough). Basically makes it so pod traffic appears to be coming from the node IPs instead of the pod IP. It's a more intuitive concept to grasp and greatly simplifies access control across the board.

    3 votes
    1. vord
      (edited )
      Link Parent
      The s_client parameter is so immensely useful. Grabbing certificates from servers is my #1 use case. It serves as a good first-pass functional test to insure your server/process is using SSL/TLS

      openssl

      The s_client parameter is so immensely useful. Grabbing certificates from servers is my #1 use case. It serves as a good first-pass functional test to insure your server/process is using SSL/TLS

      2 votes
  11. DFGdanger
    Link
    btop is another good system monitor I prefer micro over nano (the default shortcuts are more natural) rg (ripgrep) is great for searching for text within files fd (fd-find) is great for searching...

    btop is another good system monitor

    I prefer micro over nano (the default shortcuts are more natural)

    rg (ripgrep) is great for searching for text within files

    fd (fd-find) is great for searching for files by name

    ranger is a good file explorer

    autojump can help you navigate quickly to folders you've been to before

    3 votes
  12. apolz
    Link
    zsh with oh-my-zsh is great. Lot's small improvements over your basic bash. zellij is a neat replacement for screen/tmux with saner default settings than tmux. fd (sometimes called fd-find) is a...

    zsh with oh-my-zsh is great. Lot's small improvements over your basic bash.

    zellij is a neat replacement for screen/tmux with saner default settings than tmux.

    fd (sometimes called fd-find) is a great replacement for find with more powerful and easier to remember options.

    sl - "steam locomotive" draws a silly train driving across your terminal anytime you misspelled an ls command. Never fails to bring a smile to my face.

    2 votes
  13. tanglisha
    Link
    The best thing I ever did to make cli usage easier was to start taking notes, especially when something was hard to figure out. Everyone organizes data differently. I have my cli and bash notes in...

    The best thing I ever did to make cli usage easier was to start taking notes, especially when something was hard to figure out.

    Everyone organizes data differently. I have my cli and bash notes in a directory in obsidian. Files are broken down by topic unless the program is self explanatory. Then I have header sections.

    It took me a while to set up, but now it's really easy to find what I need. When things are ambiguous I wrote the problem in trying to solve in different ways so search will also work.

    Here's an example of the headers in my bash/strings file:

    • substrings
    • replace
    • heredocs / multiple lines
      • multi line variables
      • piping
      • write to a file
      • assign to a variable
      • suppress indentation
      • multi line comments
    1 vote
  14. brogeroni
    Link
    Nvtop and btop, for nvidia graphics cards and just general system usage monitoring respectively.

    Nvtop and btop, for nvidia graphics cards and just general system usage monitoring respectively.

    1 vote
  15. Toric
    Link
    zoxide, makes directory navigation really smooth.

    zoxide, makes directory navigation really smooth.

    1 vote
  16. tauon
    Link
    Starting with the basics in the .{ba,z,…}shrc – safer and more verbose basic commands alias mv="mv -iv" # safer and verbose move alias cp="cp -riv" # safer, recursive and verbose copy alias...

    Starting with the basics in the .{ba,z,…}shrc – safer and more verbose basic commands

    alias mv="mv -iv" # safer and verbose move
    alias cp="cp -riv" # safer, recursive and verbose copy
    alias mkdir='mkdir -vp' # verbose mkdir that allows to pass a path
    alias ls="ls -F" # show trailing slash with folders
    alias ll="ls -la" # show detailed view of all files (including hidden)
    

    If you’re on macOS, a package manager is a must. Get Homebrew (or alternatives like MacPorts). Windows has Scoop and/or Chocolatey. Linux distros & the BSDs typically don’t tend to lack this feature by default. ;-)

    If you prepend your file or directory names with a date, do it in the ISO 8601 format, and live a happy life.

    mkdir "$(date -I) Birthday photos"
    

    Next, the already mentioned

    tldr

    For when you’re stuck on some machine with next to nothing installed, but have a connection to the public web, there is

    curl -s cheat.sh/topic
    

    cheat.sh uses (iirc) the tl;dr repos (and some others, shown by best availability per topic), but is available effectively everywhere. Fixed installation is available optionally, if I’m not mistaken.

    In addition, I run this in my shell .rc:

    function cheat()
    {
        curl -s cheat.sh/"$1"|bat
    }
    

    bat of course being my next recommendation. The repo description really tells it all:

    A cat(1) clone with wings.

    To use it everywhere in general, set it up next to your other variables:

    export EDITOR=hx
    export PAGER=bat
    

    In the same vain as cheat.sh, wttr.in:

    alias weather="curl -s wttr.in/$YOUR_TOWN?0"
    

    Has some nice customization options for the response format, too: ?0 is the formatting option which means “small widget”, I use wttr.in/location?format=Weather+in+%l:+%C+with+%t,+wind+at+%w,+H=%h&lang=$lang for a neat one-liner, but the format can include \ns as well.

    From the creator and maintainer of the previous two also comes qrenco.de, and yes, it works exactly the way you think it does.

    Browsh is a cool project, though I’m not sure how often it is really used, in a pinch and set up on a server, it looks amazing compared to the alternatives (w3m…), very promising.

    A related project is also mosh, probably best summarized as “better SSH” (mobile shell).

    Bitwarden, like most password managers, has an official CLI, but there are also arguably better third-party implementations (rbw).

    cb is a universal clipboard with several pasteboards and GUI integrations.

    libqalculate offers a full CLI calculator, including, conveniently, currency conversion.

    spotify_player – self-explanatory.

    Lastly, one that’s not strictly speaking an everyday CLI tool, but I want to mention it regardless. For the whole setup and “dotfile management” topic, chezmoi can be used to relieve some of the pain that tends to come from that process.

    I’m certain that the instant I press submit on this comment, I will think of half a dozen more cool/unique/quirky things, but I shall leave it at that for now.

    1 vote