What are your most commonly used helpful command line tools that might be lesser known?
Posted by PMMePicsOfDogs141@reddit | linux | View on Reddit | 89 comments
Here are some I use: tldr - usually has the info I'm looking for quickly available instead of reading through the whole man page bat - cat with syntax highlighting fuck - I suck at typing
Idk if these are super unheard of but I never really see anyone talk about them. Y'all got any more you'd like to add? I'm interested to see what other people have found useful
restorationcompanion@reddit
I just made a set of command line tools for development that does port kill commands, wol, shutdown, and ollama enhanced pentesting. https://github.com/skosari/killport
Prestigious_BMG1212@reddit
kill
Green-Arm2086@reddit
The 'yes' command outputs y until it's stopped. It's super useful if you need to say yes to a bunch of options in an installation.
FractalFaro@reddit
I use the "paste" command frequently to convert a vertical list to a CSV list. For example
I'm sure there are lots of way to do this with sed, awk, etc., but this is easy to remember.
BarryTownCouncil@reddit
I'd use tr
ipaqmaster@reddit
What tr args would you use?
I tried with some basic tr:
But it puts a comma after the last element
BarryTownCouncil@reddit
tr '\n' ,
ipaqmaster@reddit
That would still result in the problem I've highlighted no?
ASIC_SP@reddit
Similar to
paste -s, you can also useseq -s, 5. Of course, that's helpful only for number generation andpasteis handy for generic use cases.itsSatyam_kr@reddit
seq 5 | tr ‘\n’ ‘,’
cathexis08@reddit
Sum all instances of a pattern across many files:
grep -c 'some pattern' * | cut -d : -f 2 | paste -sd+ | bcOnlyEntrepreneur4760@reddit
comm
Dashing_McHandsome@reddit
sl - steam locomotive, a typo for the ls command
ipaqmaster@reddit
I remember installing that in Ubuntu in like 2009 or something when I was quite young and oh man the amount of times my fingers race-conditioned
slinstead ofls. And it wouldn't close when interrupted either if I remember correctly.A worthy punishment.
beaumad@reddit
Exactly my experience. Equal parts funny and annoying.
LinuxGamerLife@reddit
Here's mine. Only been on linux for a couple of months, and absolutely loving being able to do this!
bin2iso - Converts bin and cue files to iso and moves them to relevant folder based on input
makeiso - Make an iso from a cd/dvdrom using dd
mic - Extracts track 1 from a video file using ffmpeg
mntiso - Mounts an iso file
mp3-extract - Extracts audio from video into mp3 using ffmpeg
number - Picks a random number from a text file with numbers in it
random-name - Picks a random name from a text file with names in it
unmntiso - Unmounts iso
upgrade - I am too lazy to type "sudo dnf upgrade"
whisper - Transcribes voice from mp3 file into text. Using openai's whisper
on_a_quest_for_glory@reddit
wabassoap@reddit
I use this all the time:
du -h -d 1 | sort -h
Helps me target which folders are the largest. Then once I jump into one, I can run it again there.
cathexis08@reddit
du -hxd1will do the same thing as what you have but won't hop across filesystems which is nice to avoid having your du end up in a virtual file system like proc or sys.wabassoap@reddit
Nice thanks!
So what’s considered another filesystem, anything that’s mounted to that point, even if it’s some weird nested bind mount?
And what if it’s a symlink to another filesystem?
cathexis08@reddit
I don't know about self-referential bind mounts (where some part of the file system is bind mounted elsewhere on the same file system) but other than that it will limit itself to only the filesystem containing the initial du target.
wabassoap@reddit
“ the filesystem containing the initial du target”
That makes sense, thank you!
on_a_quest_for_glory@reddit
use dust, it'll tell you which files take up the most space in one single command
International_Bus597@reddit
Exa is better than lsd in my opinion
on_a_quest_for_glory@reddit
can you explain why? i haven't found a reason to switch from lsd
International_Bus597@reddit
lsd need extras configs. With exa you just throw some arguments and with work
MintAlone@reddit
Try yelp, e.g.
yelp man:ls.henrytsai20@reddit
pgrep/pkill can directly find the process without complete name as well.
sz4bo@reddit
ranger (file manager)
with setup to open text files with
micro (text editor)
krysztal@reddit
Not exactly a tool, but I believe this is a function of bash?
!!repeats last command you ran. If you try to use something requiring root without realizing it/forgetting, you can justsudo !!to quickly rerun itMangy_Karl@reddit
To add to this, if you run history and want to run a command again, all you need to do is ! and it will execute the command that is present in your history tbere
FerorRaptor@reddit
You can also do !executable to repeat the last usage of that executable, I use it all day with gcc/make
moopet@reddit
There are loads of these little shortcuts for previous lines, but the one I use most often is $ for "last thing on the previous command" - so If I do, say, vim long/path/to/file.sh, then I can do chmod +x $ immediately afterwards.
ccppurcell@reddit
I feel like I could use that all the time! But how am I supposed to remember all the little things like that.
cathexis08@reddit
tigterminal gitk equivalentsyklemil@reddit
numbat. You can write little unit calculation programs in it, or just use it similarly to
units. So you can do stuff likenumbat -e '1 mile -> km'and get back out10 km(in case anyone doesn't know what a mile is).0tus@reddit
column is one I didn't notice mentioned here yet. For nicer outputs when listing things in the terminal or checking info from CSV style files.
Just for fun try.
column /etc/passwd -t -s ":"and compare that
cat /etc/passwdI've also seen a video where some lady does some crazy arcane incantation with the colum commands and turns that thing into a proper a functional json file.
alerikaisattera@reddit
fortune, cowsay, lolcat
Hegemonikon138@reddit
And you can unleash the holy trinity by running fortune | cowsay | lolcat
TSG-AYAN@reddit
I use pik a lot (process manager tui)
bat is amazing like you said, I pipe most command's --help to `bat -lhelp` (aliased to bh, so I just add |bh to any command) to get nice highlights on any command.
eza as replacement for ls.
httpie for nicer api calling.
sgpt with ZLE function to quickly get the command from natural language (for when I know what I want, but don't remember exactly), works great with self-hosted Mistral Small 3.2. only use if you can read and understand the command you want to run.
gitui for a fast git tui that works for 99% things I do with git.
Atuin for shell history, fzf is a strong contender but it breaks for multi-line insertions, so atuin it is.
Finally, delta for quick friendly diffs.
The majority of the shell experience however is zinit config, aliases and functions I amassed throughout my year on linux.
The main things here are powerlevel10k, history-substring-search, zsh-completions, fast-syntax-highlighting, fzf and fzf-completions for everything. I started with Blackvoid zsh's config as guide and made the whole config in \~4 hours.
fzf completions is a must have imo.
PolyhedralZydeco@reddit
Zsh-completions 🖤
TSG-AYAN@reddit
zsh completions and fzf-tab is a match made in heaven
Connect-Employ-4708@reddit
It copies the output of your command to your clipboard, so you don't have to ctrl-c
Jean_Luc_Lesmouches@reddit
To write files :
ipaqmaster@reddit
I recommend avoiding the muscle memory of
>and instead either using a pipe into| tee -a foo.txtor at the very least using>>to append instead of obliterate a potentially existing file.If you live live using only a single
>you will inevitably some day truncate something you care or would be inconvenienced by having to restore.moopet@reddit
That's what noclobber is for. Then use >| to force it if you need to.
WhatSgone_@reddit
wtf - tells me the acronyms meanings because people use them widely
Ytrog@reddit
truncatecan be very helpful.I made the following alias to clear a file:
I use it for things like shopping lists on my phone (in Termux), so I have an empty file again to fill.
One_Egg_4400@reddit
Recoll for file indexng. Basically let you Google your own machine. Remember that function your wrote 3 years ago, but can't remember in what script? Just search for it with recoll and you'll have it.
linuxjohn1982@reddit
This is where simply knowing all the linux tools might just be better. Using a for-loop and grep can do the same thing, and with so much more nuance and understanding that comes with knowing how to do it.
hackerdude97@reddit
You can't beat pre indexing though. I haven't used the tool yet but I assume it's instant. Meanwhile, a for loop going through my 1TB drive would be fairly slower
linuxjohn1982@reddit
True. And it would take time to even put the one-liner together.
But it would just work anywhere that has sh or bash installed, and you can fine-tune the output to show only what you are looking for.
One_Egg_4400@reddit
Sure, but as per my answer above, you'll index compressed files as well. And word documents, pdfs, etc. When you have all your files indexed, simply writhing the function name in the search query, without writing a long for loop or specifying files/directories, is super quick, and the results are returned instantly.
So although I agree on learning the basic tools is well and good, this tool does really bring something more to the table
ipaqmaster@reddit
I kind of already do that by grepping through my scripts collection directory. I wonder how different the experience would be with this. Would it really be easier to find those snippets without putting in as much regex effort? Seems too good to be true
One_Egg_4400@reddit
Yeah, you can get far beyond text files with recoll, including compressed files, pdfs, emails... And although the initial indexing might take some time, returning results from queries are basically instantly. You also get the option to preview or open the resulting files within the gui.
ipaqmaster@reddit
But the "function I wrote 3 years ago" is always going to be plaintext.. :\
One_Egg_4400@reddit
Might be compressed, might be documented within a pdf. But yes, I get your point, most of the time that specific use case is typically plaintext and grep may suffice.
It's all about use case. Being able to search any file for anything is really useful nevertheless.
JockstrapCummies@reddit
I'm actually considering setting up a Recoll (+its webui) instance at work, to index the shared documents drive, and expose it on the intranet.
So many colleagues are depending on the abysmal Windows built-in search that just can't find files. Recoll in comparison can even do OCR (calling Tesseract) on scanned PDFs. To me it sounds perfect for stuff like ancient minutes that only exist as some decaying piece of paper in the archives downstairs.
Does anyone have any similar experience on this? I'm hesitant to go full-on EDMS (Paperless, Mayan, OpenKM...) because that'll change staff workflow so much. So I'm just thinking of bolting on a Recoll search instance onto their big network drive.
GameKing505@reddit
This sounds awesome - thanks for sharing
TheWaffleKingg@reddit
Oh that sounds wonderful
vim_deezel@reddit
ncdu
ripgrep (rg)
tree
mc
micro
fzf
on_a_quest_for_glory@reddit
thanks for ncdu, just installed it and it's amazing
rscmcl@reddit
man
ipaqmaster@reddit
Training yourself to check manpages before searching the web is a gateway to almost never searching the web for shell stuff ever again.
owl_cassette@reddit
My problem is usually that
manlacks examples. So it's slower overall if I need to experiment versus getting a SO post with my exact issue solved.Also the
manpages tend to be more technical. I find lots of people, including myself, can't make heads or tails of it.Catenane@reddit
Funny enough, if you make a
tails of the manpage, you often find a usage/examples section. :)Agreed though. ffmpeg manpages are a great example of "wow this is so amazingly thorough....I can't do anything with this."
BizNameTaken@reddit
nix-comma. Requires having nix (the tool, not the OS) installed. You can basically run any binary that exists on nixpkgs without installing it by just typing
, <binary>. Great for running things you don't often need and don't want to install globallycoding_guy_@reddit
nix-shell -p is such a nice command
BarryTownCouncil@reddit
zoxide is a fantastic cd replacement that remembers previous locations and let's you just use partial directory names etc.
/ $ z bob
/one/two/threebobfour $
johnzzon@reddit
Zoxide is so great. I work on many different projects (agency) so jumping from one project to another is a breeze.
epikoolbeer@reddit
ls -lth
ncdu htop
ktoks@reddit
"\e[A": history-search-backward "\e[B": history-search-forward
rfc2549-withQOS@reddit
Apropos and perl ;)
also grep with the --color flag
maru0812@reddit
curl wettr.in/YourCity Weather forecast in the shell
curl cheat.sh/CommandYouSearch The cheat sheet you always wanted
dennycraine@reddit
tac - cat in reverse.
linuxjohn1982@reddit
also,
yesdennycraine@reddit
Definitely
QliXeD@reddit
So nobody is going to mention lnav? Really?
Careless_Bank_7891@reddit
Superfine?
I prefer it over something like nautilus or thunar or dolphin
Weekly-Math@reddit
xargs
ben2talk@reddit
Given that this is reddit, it's hard to judge... I'd be laughed out of the forum for suggesting bat, or tldr...
Also for not first including zoxide and fzf, along with yazi and Kitty terminal on a Plasma desktop with Dolphin it's an incredibly synergetic relationship.
I should add my zcd function in fish shell... and if I'm browsing files with Dolphin, I hit F4 to pull up Konsole/fish and can jump and search from right there.
Bat is cool, but moar is an amazing pager that suits some things better.
Oh, and 'thefuck' that is so popular (only on reddit) sucks, and ends up messing up in so many ways - not least needing to install non-repo versions of python just to get it running unless you're already on an outdated (or should we say 'stable') linux version.
So if I do 'zi show' I get a fuzzy list of 3 TV Shows folders on separate drives to jump to, if I just go 'z fish' it takes me to my ~/.config/fish; 'scrip` takes me to a (long path) scripts folder.
But if I want something new, I go 'zcd` and get a fuzzy list of folders with that to select from...
IonTichy@reddit
at: one off timed tasks, very hand for setting up oneshot commands that should run sometime later
Good_gooner6942@reddit
rename.ul
An excellent bulk file renamer.
xte2@reddit
Well... Many, actually... Ripgrep-all/ripgrep is probably the one I use most frequently, it's not unknown but still many do not know it exists. fd is less flexible than find (you do not execute commands directly on results) but it's often quicker than find. choose is another modern unix tool for when cat+awk are not that needed.
jj (Jujutsu) it's an SCM over git, much saner than git, fully compatible (so you can develop with people using git on the same repos) yes not so widespread. Not exactly CLI (a WebUI meant to be launched via CLI) to quick offer much more than simple files exchange between hosts https://github.com/9001/copyparty to cite the first that came to mind.
SpaceDetective@reddit
That bat sounds handy - I've had to make do with view (vim read-only).
Btw two spaces to make end of line.
Is "fuck" a tool or a comment you were making?
PMMePicsOfDogs141@reddit (OP)
Yeah like others have said thefuck (made an edit to clarify) is a tool for when you make an error when typing in a command
Also thanks, didn't realize it was all 1 big block. Fixed the formatting
TSG-AYAN@reddit
thefuck is a tool, basically guesses what the last command was supposed to be
SealProgrammer@reddit
https://github.com/nvbn/thefuck
doc_willis@reddit
pydf