Questions tagged [command-line]

A command line is a string given to a command interpreter that tells it actions to take, such as running programs or copying files. The interpreter processes command lines with escapes and substitutions.

A command-line interface () is a mechanism for interacting with a computer operating system or software by typing commands to perform specific tasks. This text-only interface contrasts with the use of a mouse pointer with a graphical user interface (GUI) to click on options, or menus on a text user interface (TUI) to select options.

This method of instructing a computer to perform a given task is referred to as entering a command. The system waits for the user to conclude the submitting of the text command by pressing the Enter key (a descendant of the carriage return key of a typewriter keyboard). A command-line interpreter then receives, parses, and executes the requested user command. The command-line interpreter may be run in a text terminal or in a terminal emulator window as a remote shell client such as .

Upon completion, the command usually returns output to the user in the form of text lines on the CLI.

Related tag:

See also: Wikipedia Command-line_interface.

23435 questions
333
votes
15 answers

What is a faster alternative to Python's http.server (or SimpleHTTPServer)?

Python's http.server (or SimpleHTTPServer for Python 2) is a great way of serve the contents of the current directory from the command line: python -m http.server However, as far as web servers go, it's very slooooow... It behaves as though it's…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
331
votes
20 answers

Linux command to list all available commands and aliases

Is there a Linux command that will list all available commands and aliases for this terminal session? As if you typed 'a' and pressed tab, but for every letter of the alphabet. Or running 'alias' but also returning commands. Why? I'd like to run…
ack
  • 14,285
  • 22
  • 55
  • 73
328
votes
5 answers

Why use argparse rather than optparse?

I noticed that the Python 2.7 documentation includes yet another command-line parsing module. In addition to getopt and optparse we now have argparse. Why has yet another command-line parsing module been created? Why should I use it instead of…
fmark
  • 57,259
  • 27
  • 100
  • 107
323
votes
25 answers

How to use sed to replace only the first occurrence in a file?

I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file. How do I get sed to replace just the…
David Dibben
  • 18,460
  • 6
  • 41
  • 41
321
votes
8 answers

Find and replace with sed in directory and sub directories

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site: find ./ -exec sed -i 's/apple/orange/g' {} \; But it doesn't go through sub directories. What is wrong with this command? Here are some…
hd.
  • 17,596
  • 46
  • 115
  • 165
316
votes
15 answers

Is there a better Windows Console Window?

I find working on the command line in Windows frustrating, primarily because the console window is wretched to use compared to terminal applications on linux and OS X such as "rxvt", "xterm", or "Terminal". Major complaints: No standard…
Alana Storm
  • 164,128
  • 91
  • 395
  • 599
314
votes
7 answers

diff to output only the file names

I'm looking to run a Linux command that will recursively compare two directories and output only the file names of what is different. This includes anything that is present in one directory and not the other or vice versa, and text differences.
barfoon
  • 27,481
  • 26
  • 92
  • 138
313
votes
27 answers

Create an empty file on the commandline in windows (like the linux touch command)

On a windows machine I get this error 'touch' is not recognized as an internal or external command, operable program or batch file. I was following these instructions which seem to be linux specific, but on a standard windows commandline it does…
CuriousAboutNode
  • 3,157
  • 2
  • 11
  • 6
313
votes
18 answers

Stop and Start a service via batch or cmd file?

How can I script a bat or cmd to stop and start a service reliably with error checking (or let me know that it wasn't successful for whatever reason)?
Keng
  • 52,011
  • 32
  • 81
  • 111
311
votes
23 answers

Get most recent file in a directory on Linux

Looking for a command that will return the single most recent file in a directory. Not seeing a limit parameter to ls...
ack
  • 14,285
  • 22
  • 55
  • 73
307
votes
25 answers

How to echo with different colors in the Windows command line

I know that the color bf command sets the colors of the whole command line window but I wanted to to print one single line in a different color.
rui
  • 11,015
  • 7
  • 46
  • 64
307
votes
25 answers

How do I send a file as an email attachment using Linux command line?

I've created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them together as a compressed .tar file. The next step I want to accomplish is to send that tar file…
Kit Roed
  • 5,167
  • 5
  • 30
  • 34
305
votes
11 answers

How to list running screen sessions?

I have a bunch of servers, on which I run experiments using screen. The procedure is the following : ssh to server XXX launch screen start experiments in a few tabs detach screen disconnect from the server While the experiments are running, I can…
Wookai
  • 20,883
  • 16
  • 73
  • 86
302
votes
19 answers

How to check if a process is running via a batch script

How can I check if an application is running from a batch (well cmd) file? I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.) Also the application could be running as any…
Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
298
votes
8 answers

Pass variables to Ruby script via command line

I've installed RubyInstaller on Windows and I'm running IMAP Sync but I need to use it to sync hundreds of accounts. If I could pass these variables to it via command line I could automate the whole process better. # Source server connection…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607