What Does ‐‐ (double dash) Mean In SSH Shell Command?

There is no greater hope in human life than survival. At the same time, it is important to live well. With that in mind, every content on the website is written so that a person can get all the information from here to start his life to make beautifully.

According to that, Technology is one of the topics. It is also a part of life. Read carefully Details of Technology related article

What Does ‐‐ (double dash) Mean In SSH Shell Command?

I see lots of seasoned admins and cloud provider wrapper scripts use ssh client command as follows in shell:
ssh --
What the double “--” (double dash) does here? Why it is used in this shell command and why not just use the ssh syntax? What is the meaning of the -- in there?

This quick tutorial explains the use of the double-dash in shell and ssh commands. But, first, let us see what it does and when you might need it.

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux/Unix/macOS shell
Est. reading time 4 minuets

What does “--” (double-dash) mean?

The double dash “--” means “end of command line flags.” It tells ssh or any other valid shell command not to try to parse what comes after command line options. You will see something as follows when you use gcutil ssh vmNameHere python wrapper. It will display and execute ssh as follows:
ssh -o UserKnownHostsFile=/dev/null
-o CheckHostIP=no
-o StrictHostKeyChecking=no
-i /Users/vivek/.ssh/google_compute_engine -A -p 22 --

This syntax ensures that you can run commands on the remote server without ssh parsing them:
ssh -- command1 --arg1 --arg2
The above syntax tell ssh not try to parse --arg1 and --arg2 after -- command line options. This ensures that command1 will accept --arg1 and --arg2 (or -opt1) as command-line arguments.

What does a double-Dash in shell commands mean?

In other words, a -- (double-dash) in a shell command indicates the end of options and incapacitates further option processing for the Unix or Linux command.

## safe examples ##
ssh -- --commandName --arg1 --arg2

This kind of behavior is mostly defined and handled by the ssh command and not by your bash/ksh/csh/sh/fish or any other Unix shell. This is also true for many other Linux and macOS commands.


Patreon supporters only guides 🤓

    • No ads and tracking



    • Join my Patreon to support independent content creators and start reading latest guides:


Join Patreon

When is it needed?

So now you know more about double-dash, and specific Unix commands only support it. Sadly, not all Linux commands support the double-dash syntax and feature. So when is it needed? For example you can not create or view a file named --file or -f using cat command, run:

## This should fail ##
cat --file
cat -f

Instead try passing double dash “--” to instruct cat command not to try to parse what comes after command line options:

## This should work ##
cat -- --file
cat -- -f

Let us try to remove a file named ‘--file‘:

rm --file # fail #
rm -- '--file' # works

You can pass options to the rm command as follows:

rm -v -i -- '--file'
rm -f -v -i -- '--f'

What does “--” (double-dash) mean under Linux, macOS or Unix-like OS?

Shell script example

We can use the lxc command command as follows to update the Linux container powered by LXD as follows:

lxc exec bash-wiki -- apt update
lxc exec bash-wiki -- apt -y upgrade
lxc exec nginx-proxy 
--env DEBIAN_FRONTEND=noninteractive 
-- sh -c "/usr/bin/apt-get update && /usr/bin/apt-get -y upgrade"

Not all commands support -- syntax

A word of caution, not all commands support -- syntax, and it will not work with all Unix or Linux commands. For instance:

/usr/bin/echo -- -n
echo -- --test

From bash documentation:

Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options. The :, true, false, and test/[ builtins do not accept options and do not treat -- specially. The exit, logout, return command, break command, continue command, let command, and shift command builtins accept and process arguments beginning with - without requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.


We explained what the double-dash (--) do in shell commands or commands executed using ssh. The first -- command-line argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the ‘-‘ or ‘--‘ character. It is a safety feature, but we also know that not all Linux/Unix commands support such options. You may also want to read the following tutorial useful:

Make sure you read bash man page by tying the following man command or help command for internal commands:
man bash
man ssh
man rm
help :
help echo
help printf
help let
help exit
help logout




Did you like this article?
Share it on any of the following social media channels below to give us your vote. Your feedback helps us improve.

Other related Technologies ideas you might enjoy

Related Articles

Leave a Reply

Your email address will not be published.