echo
print textecho writes out whatever follows it. On its own that is trivial; with redirection it creates and appends to files, and with a dollar sign it shows what a variable holds.
> replaces a file’s contents; >> adds to the end. One character apart.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
$USER was replaced by its value before echo ran. The shell does the substituting; echo only prints.
Everything inside single quotes is taken literally, dollar sign included.
The output goes to the file instead of the screen. If the file existed, its old contents are gone.
The second line is added after the first. This is the usual way to add one line to a configuration file.
Switches
A switch changes how the command behaves. These are the ones used day to day; man echo lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-n- Do not add a new line at the end.
-e- Interpret escapes such as \n for a new line and \t for a tab.
-E- Do not interpret escapes. This is the default in bash.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
echo $PATHShows the value of a variable.
echo $?Shows the exit status of the last command: 0 means success.
echo -e "one\ttwo\nthree"Interprets \t as a tab and \n as a new line.
echo "text" | sudo tee -a /etc/hostsAppends to a root-owned file — sudo echo with >> does not work.
In cybersecurity
Whatever you echo is recorded in your shell history.
echo "password" | some-command leaves the password in ~/.bash_history. Read it with "read -s" instead, or from a file.
Typing > where >> was meant replaces the whole file with one line. Keep a copy before appending to anything that matters.
In "sudo echo x > /etc/file" the shell, running as you, opens the file — and is refused. Pipe to "sudo tee" instead.