5 ms·
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
by hiAndrewQuinn 3y ago
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.
- fsckboy 3y ago> 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.
- JohnMakin 3y agoI 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.
- galbar 3y agoOn top of that, I find it useful to know if a command should be run as a normal user ($) and root/administrator (#).
- bsilvereagle 3y ago“$” for non-root shells and “#” for root shells instead of writing out sudo/su.
- youainti 3y agoThis 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.
- jmcqk6 3y ago> 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.
- travisjungroth 3y agoEven when I understand, copypasting is often faster and skipping or removing the $ is slightly annoying.
- nottheengineer 3y agoI 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.
- dylan604 3y agoMy 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
- scubbo 3y ago> 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.
- eviks 3y agoExcept it doesn't, removing $ has no positive effect on your mind
- scubbo 3y agoI'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!
- eviks 3y agoif 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)
- eviks 3y agoBecause that's how it looks in their terminals, and it's a bit of a challenge to think through how users use something
- neilv 3y agoThis 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.)
- corndoge 3y agoDocker 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/ https://docs.docker.com/engine/install/ubuntu/
- jabroni_salad 3y agoAs 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.
- OrderlyTiamat 3y ago> 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‽
- hiAndrewQuinn 3y agoYeah, 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.
- chrisandchris 3y agoYes. $ means regular user, # means root user. Usually.