Synthird's blog

Using the echo command in Linux

The echo command displays any parameters you give to it in the terminal.

For example:

echo Hello World

Displays just Hello World in the terminal:

Hello World

Displaying values of variables

You can also display values of variables in the echo command.

If you want to display the value for the global variable HOME for example, you type:

echo $HOME

In turn, the terminal will display:

/home/whatever-your-username-is

The values of variables can also be displayed alongside non-variable characters.

For example:

echo There is a folder path called $HOME

Will cause the terminal to display:

There is a folder path called /home/whatever-your-username-is

Displaying the dollar sign symbol and one character after it

When using the dollar sign symbol in the echo command, one character after the symbol and the symbol itself will not be displayed.

For example, when typing:

echo This thing costs $100 and is cheap

The $1 part will not be displayed, but the rest of the characters in the echo command will:

This thing costs 00 and is cheap

That's because the $1 part is being treated like a variable, and since we did not create a variable called 1, the terminal treats the $1 part as a variable that hasn't been made.

One solution to fix this is to use air quotes:

echo 'This thing costs $100 and is cheap'

Another solution is to place the backslash character (The \ symbol) before the dollar sign symbol:

echo This thing costs \$100 and is cheap

Either method will display the $1 part:

This thing costs $100 and is cheap

One thing to know is that the air quote and backslash character methods don't treat variables as variables. The methods just display the dollar sign symbol and the character after it regardless if there's a variable created or not.

For example, typing:

echo 'There is a folder path called $HOME'

Or:

echo There is a folder path called \$HOME

Won't treat the global variable HOME as a variable. Thus, the terminal will display:

There is a folder path called $HOME

Executing commands within the echo command

Let's say we want to display today's date in a sentence using the echo command:

echo It is date today

The terminal will display:

It is date today

But we want to show what day is it today between the words is and today. To do this, we'll add backquotes (The ` symbol) around the word date:

echo It is `date` today

For me, the terminal will display:

It is Sun Nov 8 09:49:23 PM UTC 2026 today

The Sun Nov 8 09:49:23 PM UTC 2026 part will be different for you since you're reading this blog post on a different date and/or time.