Since they are specific command lines, I prefix the commandline with the actual default linux prompt. I use the $(dollar sign) to prompt Ubuntu's encouragement logging in as a normal user for and using the
sudo elevated for systemwide or other specific intentions.
When I first started using Unix/Linux, I always logged in as Root to save time. For years there was confusion on my various machines of my files and space and the systemwide files and space. I had to log in as root just to access many of my personal files.
When I eventually moved to Ubuntu, I started using many defaults and following the convention. So the prompt I almost always have is the $(dollar sign) prompt.
There are some commands and work that can be done without
sudo, then there is the commands to make the changes system wide. Without specifying the commandline is at the normal user's prompt, there can be some confusion as to why the
sudo command when many people are already at an elevated level after having issues a
sudo su - command. If I had a reason to do that in one of my answers, I would change the prompt to the
# symbol... so far I haven't had a reason to do that.
Then, it's not like I'm giving a script to copy and paste. It's one command line at a time (when I use the
$ symbol). So I expect for the user to select the text following the dollar sign, copy and paste it one line at a time.
There are occasions where there might be many commands of which I would make a convenient script and not use the
Script to copy and paste
On occasions I might give a script to copy and paste. I consider that different. If there are lots of lines indented to be executed exactly, I'll use the bash scripting language facility to put the lines one by one. I'll also include a description of what the lines are intended to do in case the user might one to customize it in a text editor before saving it to execute the lines.
While there there is a little learning curb when it comes to the terminal commandline. I wouldn't consider the small element of a user recognizing pasting the prompt as part of the commandline will give an error a bigger inconvenience over the visual provision of actually seeing the prompt with the provided answer. At a glance (in no time) the user will recognize this is a terminal command. Outside of having the
$ prompt, at a glance it might be an entry to add to a file and not a command.
I still make that mistake from time to time. I see a couple of text lines to fix a problem, and try to execute them, but find they are lines to append to a configuration file.
On the few occasions where the
$ prompt has been edited from my answers, it appears to take away clarity.