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.
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.
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
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
Alt+. does the same thing and it is easier to press.
You can check out all key bindings for bash through
man readline
For the same functionality I use
!$
as parameter. For examplecat !$
.You've just changed my life. This alias just became that much easier to use.
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'scd
based on fuzzy fragment matching. Always navigating tosome/folder/giant-microwave-dish-project
? Just typez microwave
and save yourself the keystrokes.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
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 originalmail
MUA. There are frendlier ones available likemutt
or the decendants ofelm
likepine
oralpine
. 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 usingmailq
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.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.
For finding files: Fuzzy Finder (fzf)
For finding in files: ripgrep (rg)
Together: Unbeatable :-)
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.
Fish shell
history merge
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.history
!!
ps -ef | grep x (where X is part of a process name)
hwinfo
mediainfo
lspci / lscpu / etc
du -h
df -h
which x
I always alias my commands with '-h' unless there's a damn important reason not to.
MacOS
sort
sadly lacks the-h
optionIf 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:The GNU versions are installed with
g-
prefixes, but, as the caveats section says, if you add thegnubin
directory to yourPATH
ahead of/usr/bin/
, then you can access the GNU versions with their normal names (sort
,ls
,head
, ... instead ofgsort
,gls
,ghead
, ...).E.g., sorting sizes of files/subdirs in current directory:
I prefer including -i in my grep commands. I am terrible at remembering case for certain processes or things I am looking for!
Some simple sanity aliases for distros that lack them:
And some others I like:
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
I have some neat
bash
(and otherreadline
based tools) keybindings. These go in~/.inputrc
or/etc/inputrc
:These let you type the start of a command, then use the up and down arrows to scroll through history commands starting with that.
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.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.
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".
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
- basicallynetcat
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 thegconf
andkdeconfig
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
andbutane
- 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
andmycli
- basically nicer CLIs against Postgres and MySQL/MariaDBstern
- 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 namex
"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.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/TLSbtop
is another good system monitorI prefer
micro
overnano
(the default shortcuts are more natural)rg
(ripgrep
) is great for searching for text within filesfd
(fd-find
) is great for searching for files by nameranger
is a good file explorerautojump
can help you navigate quickly to folders you've been to beforezsh 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.
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:
Nvtop and btop, for nvidia graphics cards and just general system usage monitoring respectively.
zoxide, makes directory navigation really smooth.
Starting with the basics in the .{ba,z,…}shrc – safer and more verbose basic commands
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.
Next, the already mentioned
For when you’re stuck on some machine with next to nothing installed, but have a connection to the public web, there is
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:
bat of course being my next recommendation. The repo description really tells it all:
To use it everywhere in general, set it up next to your other variables:
In the same vain as cheat.sh, wttr.in:
Has some nice customization options for the response format, too:
?0
is the formatting option which means “small widget”, I usewttr.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\n
s 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.