Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am a beginner of Linux, so this is maybe a silly question:

What does the '-c' or '-m' mean in the command line? For example 'python3 -c 'from ....'.

2 Answers

On the command line, you can place arguments after the command in order to give the software you're about to run some more information about what you'd like it to do.

The accepted arguments and their format varies between commands and software, but there are some general conventions.

A flag is an argument that simply turns something on or off or specifies a mode. Examples

  • -c one letter flag
  • -d -c two flags specified
  • -dc software often allows combining flags like this
  • --more-descriptive-flag a flag that is one or more words spelled out rather than a single letter. Often programs require two dashes in front of these to distinguish them from one-letter flags which are combined.

In addition to flags, there are arguments which take a parameter. These begin with an argument label which looks the same as a flag, but the very next word or quoted string after that argument label will be its parameter(s).

For example

python3 -c 'print("hello world")'

For python, the -c argument requires a parameter specifying a command you would like the python interpreter to run. This command is enclosed here in single quote marks since it would otherwise be ambiguous where the command ends due to the punctuation and spacing inside the command.

To read about the supported arguments for a given command, you can look up that command's manpage - a documentation page usually simplified down to just what you need to know in order to run the command. To check the manpage for python3, use

man python3

When viewing the manpage, you'll be inside a file viewer. While the file viewer may support vim-like shortcuts, it can usually be navigated fairly simply with arrow keys and/or space for skipping down a page, and q to quit.

There is no singular meaning of -c or any other letter/number in commands. They are parameters for your command python3 so you need to check it's man(ual) page.

man python3 says

 -c command Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command). -m module-name Searches sys.path for the named module and runs the corresponding .py file as a script.

Note in this case I used my box (Lubuntu 20.04) so those are from the manual pages for my release of Lubuntu/Ubuntu. Your own man (manual) pages will tell you what those options are for your specific release.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy