Hacker News new | ask | show | jobs
by JohnMakin 1029 days ago
Reminds me of a large company I worked at, I had some documents for developers how to set up some local environment thing they had to do exactly 1 time and never again. It was just a handful of terminal commands, all starting with the traditional shell notation like:

$ (some command)

Over the course of a year I got periodic complaints that it "wasn't working" and I tried to find issues on my end and couldn't. One particularly vocal dev came to me directly and insisted it was broken, so I went on a shared session with him, it turns out they were pasting the "$" into the terminal causing it to say: "$: command not found."

That was the source of all the complaints, once I removed it, they stopped.

3 comments

Another trouble source I've had has been been fixed by some wikis. When I first ran into one that supported this about a dozen years ago it made my life a lot easier.

And that is having a function that injects the current user's username into the wiki page. Any instructions that require you to log in as you can then be blindly cut and pasted, without people coming and telling me "it doesn't work" when they try to log in as me. Yeah of course that doesn't work, mate.

People reading runbooks aren't fully engaged. They may actually be in a war room. The moral of this story is that you are not entitled to carve out a chunk of your coworker's attention. Those periods should be brief, and tied to an active initiative/epic. After that 'work' is done, everything you wrote should be something that they can operate at 2:00 am.

Because sooner or later, they well.

Is there a reason websites put that $ in front of commands you are fully expected to mindlessly copy and paste? I've seen it happen more and more and it simply baffles me.
I think it is to separate command line input from output -

$ echo "Hello!"

Hello!

The $ denotes that this is a terminal command, and anything that is not preceded by $ will usually be some kind of output. That's certainly how/why I was using it.

On top of that, I find it useful to know if a command should be run as a normal user ($) and root/administrator (#).
Docker does this properly; they show the character but it's nonselectable so you can still copy paste directly without spending time removing the $. eg https://docs.docker.com/engine/install/ubuntu/
> you are fully expected to mindlessly copy and paste

I think this is the disconnect. Don't mindlessly copy and paste things. Take the time to understand what's going on.

Even when I understand, copypasting is often faster and skipping or removing the $ is slightly annoying.
My favorite are the ones where the command is in a width limited element that needs to scroll so you can't see the full command to evaluate if you want to copy it or not. If the overflow has been properly set to scroll, it's doable, but I've seen the odd site where the overflow was hidden and you had to copy&paste it somewhere else just to see if you wanted to paste it in an actual terminal
I try to do that, but there are a lot of times where I find myself thinking "I don't care, I just want this to work" and blindly copy anything that's not super fishy. Especially after nvidia updates.
“$” for non-root shells and “#” for root shells instead of writing out sudo/su.
This is exactly why. If you are doing linux maintenance, this is really helpful because you can tell if you should be running a specific command as root or user. If you are just giving instructions on what to do for a normal user, omitting it is probably fine. If you are doing something that will require both, it might be good to explain it at the beginning of your instructions.
This goes back to pre-Web, originally to distinguish normal user (`$`) from `root` user (`#`), and sometimes from C-shell or some non-shell interactive line-oriented program.

I used to think it was dumb and annoying.

I partly changed my mind recently, when I found myself copy&pasting lots of quick wiki-like documentation into Markdown fenced code blocks that involved multiple hosts.

Just having the hostname in the prompt reduces the text I have to type in addition to the copy&past, to explain where this command is happening, such as on the workstation vs. one of the servers.

(But it didn't quite help the other day, when I was documenting some self-hosted LLM procedures, and needed to be copy&pasting examples from multiple Screen terminals on the same host, where the prompt didn't distinguish them.)

> Is there a reason websites put that $ in front of commands you are fully expected to mindlessly copy and paste?

As well as the answers you've already been given (distinguishes input from output, distinguishes root from non-), one answer is contained in your own question - it prevents mindless copy-pasting.

Except it doesn't, removing $ has no positive effect on your mind
I'd claim that I'm technically correct - you _cannot_ mindlessly copy-paste `$-prefixed` code into a terminal and have it execute, because the `$` will result in a syntax error - but you are, indeed, correct to say that it is possible the _then_ mindlessly delete the `$` without thinking about the rest of the content. But it's another prompt, at least!
if you want to be that technical, than start with the fact that you can easily mindlessly copy&paste, it just won't execute, which is technically a separate thing

(another prompt is just an annoyance for no benefit)

As a generalist with many operating systems in use, I like that this tells you what OS the command is for. Especially now that powershell with its many unix-like aliases is getting popular, this isn't always evident.
> powershell with its many unix-like aliases

This choice simply baffles me. If I could just use those aliases and have it under the hood be PS calls- that's great! But that's not what's happening, instead it's a totally different command with different a different syntax and different flags. Why make it an alias at all‽

Yeah, alright. As the former "PowerShell guy" for an office of 200+ people when I still preferred WSL and bash, I can definitely accept this answer.
> Is there a reason websites put that $ in front of commands

back in the mid-early days of computers, I'm pretty sure the unix prompt was a $ (and as has been pointed out, a # for the root user). Thus custom of using it in documentation started because it's literally what people would see.

Because that's how it looks in their terminals, and it's a bit of a challenge to think through how users use something
Yes. $ means regular user, # means root user. Usually.
For a long time I had my prompt some version of:

:$! $CWD $HOSTNAME $;

: (exit status, current directory, hostname, $ or # and a ;

the idea being -- you could just cut and paste and it'd mostly just work (except megabozos who like to make directories named ; or whatnot)