Less Commonly Used Unix Commands
danielmiessler.com
danielmiessler.com
Considering the number of API's that return json data these days, it's simplified my life a great deal. It's proven especially useful for automation shell scripts, when working with things like the aws command line client that return all results as json. Usually I'm looking to extract something like a single field to use as input for a following command, and jq makes it really easy. No more inline python or awkward sed regex's. :)
It's available using apt-get on debian/ubuntu, but that version is out of date with the online docs. It's rather trivial to build from source though (it has no external deps).
ls /usr/bin/|sort -R|head
In my opinion it was a poorly named article with just as poor content. Many of the descriptions of the commands were not good ("lsof: godlike"). Better descriptions could generally even be found automatically: man lsof|grep NAME -A1 -m1|tail -n1 whatis lsof
apropos lsofEvery time someone mentions here how POSIX and C are portable across UNIXes, I have recolletions of maintaining code full of #ifdefs to make it work across such "portable" systems.
Not to mention how nice the Makefiles used to be.
It rather implies that Mac OS X supports what UNIX certification requires, plus whatever extensions Apple does on top.
This was always the main issue with POSIX compatibility fragmentation across UNIX platforms.
It's just as common to see linux only commands in posts like this.
curl -C - -o "some_file"
It will basically get the size of "some_file" and use it as an offset when making the HTTP request, similar to wget --continue.
Very useful to download a file from a unreliable network and when you need all those security cookies. To get the cookies I use "Copy cURL" from Network pane of Chrome's "Developer tools".
In this case, "Copy cURL" of a request from Chrome's Developer Tools is priceless.
I'd add the following to the list : printf , bc
Also, "ddate" is fun. I had no idea and just spent an enjoyable 10 minutes looking it up.
Thanks for posting this.
My thoughts exactly. Time, df, du, iostat, watch, htop, wget, tmux, ....
Really?
And I don't even know why you'd think iostat, watch, htop, or tmux would be well-known amongst anyone other than sysadmins and long-time nix power users. And tmux didn't even exist five years ago.
Emacs user?
> Emacs user?
As holyjaw mentions (https://news.ycombinator.com/item?id=7253126), this appears to be a vimmer's self mockery, rather than an Emacsy attack:
http://fc04.deviantart.net/fs71/i/2011/029/8/3/emacs_user_at...
I never have to press more than two keys at a time, which is also true for vim..
But seriously: How do you do common things such as `query-replace{-regex}` or `indent-region`? Have you rebound them all?
However.. point taken. The default bindings for those two functions are terrible (at least with a german keyboard layout).
ido-mode is essential. :)
Well that's not very useful. Maybe change it to actually say what it does. List open files.
The majority in the list seem pretty common, but I guess with more and more gui dependents some people just never spent days wading through man pages or info coreutils, so still useful.
pv - progress bars for pipes
iostat - hopefully common by now. best way to peek at disk IO
wget: get w’s
Ok, if I didn't know what wget did already that wasn't too useful. But then it gets worse vim: attack yourself
man units: interesting
ddate: wtf watch: execute something on a schedule *in realtime*
printf: change the format of output
apropos: info on commands
dd: disk writing
ss: socket statistics (show apps *using the Internet*)
Almost but not quite. $ man ddate
No manual entry for ddateAlso, xmlstarlet is cool.
Very nice for finding differences between files (like config files, or results of some tool) where diff won't help you (too big a diff, or files are too different)
I'll vote for "yes" which at least seems intuitively useful in a "yes | rm -i something" kind of way. Well that specific example is useless... Also over two decades ago if you obtained access to someones account it was considered highly amusing to end their .profile with a call to /bin/yes. Oh and before the newfangled /dev/urandom (or /dev/zero) we used to redirect "yes" out to media to wipe them or test overall system thruput.
Now for one thats truly obscure and ripe for abuse because no one ever runs it anymore, try RMT the remote magtape manipulator.
I use it when I want to compile a LaTeX document and ignore errors:
$ yes ^M | pdflatex document
(useful because TeX tools hate accepting command-line options). column: create columns from text input
tr: translate/substitute/delete input
join: like a database join but for text
comm: file comparison like a db join
paste: put lines in a file next to each other
rs: reshape arrays
jot: generate data
expand: replace spaces and/or tabs
time: track how long a task takes to run
watch: execute something on a schedule in realtime
xargs: execute something on all inputs
iftop: visually show network traffic
htop: show system stats more powerfully
xxd: manipulate files in hex
mtr: powerful traceroute replacement
mdfind: osx find replacement that uses spotlight
brew: osx package manager
df: disk usage
du: disk usage
dig: dns queries
host: dns queries
man ascii: lookup your ascii
sshfs: mount a directory through ssh
wget: get w’s
tmux: a better screen
pushd: push your pwd to a stack
popd: pop pwd off your stack
lsof: godlike
ncat: use this instead of nc
fuser: kills locking processes
vim: attack yourself
tac: cat in reverse
rename: change spaces to underscores in names
open .: in osx, open finder in the current dir
lsmod: show kernel modules
printf: change the format of output
timeout: execute something and kill it soon after
disown: protect a job from disconnect
fc: edit your last command in your editor and execute it
sudo !!: repeat last command with sudo
tee: send output to stdout as well
pgrep: greps through processes
pkill: kills processes based on search
fmt: text formatter
bc: an interactive calculator language
apropos: info on commands
strace: the uber debug tool
man units: interesting
pstree: shows processes in a…well…tree
ddate: wtf
zgrep: grep within compressed files
zless: look at compressed files
readlink: read values of links
atop: another top
split: break a file into pieces
dd: disk writing
ndiff: show differences in mmap scans
ss: show apps using the internetI use it primarly to see the used bandwidth in real-time. It's better than ifstat for that job.
So really it just depends on what you're trying to do as to the practicality of sshfs. But then I guess you could argue that is the case for nearly all the commands that many sysadmins have flamewars over.
fetch is also useful to get w's.
Turns out, not so much. :|
EDIT:
'watch mtr' is handy for keeping an eye on your network connection, and finding slowdowns.
It has an uncanny knack for getting me to where I want to go with very little in the way of input.
http://unix.stackexchange.com/questions/4290/aliasing-cd-to-...
That's definitely useful.