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
62 answers

How can I pretty-print JSON in a shell script?

Is there a (Unix) shell script to format JSON in human-readable form? Basically, I want it to transform the following: { "foo": "lorem", "bar": "ipsum" } ... into something like this: { "foo": "lorem", "bar": "ipsum" }
38 answers

Git is not working after macOS update ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools")

I updated to the latest OS, and/or restarted my computer (this happens on every major update, but this time all I did was restart my computer on 2022-09-13). This morning I navigated to my work's codebase in the command line on my MacBook Pro, typed…
  • 79,958
  • 7
  • 21
  • 41
14 answers

How do I copy a folder from remote to local using scp?

How do I copy a folder from remote to local host using scp? I use ssh to log in to my server. Then, I would like to copy the remote folder foo to local /home/user/Desktop. How do I achieve this?
  • 33,707
  • 3
  • 14
  • 10
26 answers

Is there an equivalent of 'which' on the Windows command line?

As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name. Is there…
  • 37,139
  • 8
  • 58
  • 74
55 answers

How do I import an SQL file using the command line in MySQL?

I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the command line. I have a Windows Server 2008 R2 installation. I placed the .sql file on the C drive, and I tried this command database_name <…
  • 39,043
  • 40
  • 128
  • 221
33 answers

How to change the output color of echo in Linux

I am trying to print a text in the terminal using echo command. I want to print the text in a red color. How can I do that?
  • 29,947
  • 10
  • 34
  • 34
41 answers

How do I parse command line arguments in Bash?

Say, I have a script that gets called with this line: ./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile or this one: ./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile What's the accepted way of parsing this such that in each…
  • 66,744
  • 41
  • 126
  • 187
16 answers

How do I set a variable to the output of a command in Bash?

I have a pretty simple script that is something like the following: #!/bin/bash VAR1="$1" MOREF='sudo run command against $VAR1 | grep name | cut -c7-' echo $MOREF When I run this script from the command line and pass it the arguments, I am not…
  • 24,083
  • 5
  • 24
  • 25
16 answers

How can I get a list of user accounts using the command line in MySQL?

I'm using the MySQL command-line utility and can navigate through a database. Now I need to see a list of user accounts. How can I do this? I'm using MySQL version 5.4.1.
  • 57,360
  • 21
  • 58
  • 81
28 answers

How to count lines in a document?

I have lines like these, and I want to know how many lines I actually have... 09:16:39 AM all 2.00 0.00 4.00 0.00 0.00 0.00 0.00 0.00 94.00 09:16:40 AM all 5.00 0.00 0.00 4.00 0.00 0.00 0.00 0.00 …
  • 16,628
  • 7
  • 24
  • 23
23 answers

How do I run two commands in one line in Windows CMD?

I want to run two commands in a Windows CMD console. In Linux I would do it like this touch thisfile ; ls -lstrh How is it done on Windows?
  • 261,858
  • 191
  • 397
  • 503
16 answers

git undo all uncommitted or unsaved changes

I'm trying to undo all changes since my last commit. I tried git reset --hard and git reset --hard HEAD after viewing this post. I responds with head is now at 18c3773... but when I look at my local source all the files are still there. What am I…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
15 answers

How to reload .bash_profile from the command line

How can I reload file .bash_profile from the command line? I can get the shell to recognize changes to .bash_profile by exiting and logging back in, but I would like to be able to do it on demand.
  • 139,374
  • 27
  • 55
  • 71
21 answers

How to pass command line arguments to a rake task

I have a rake task that needs to insert a value into multiple databases. I'd like to pass this value into the rake task from the command line, or from another rake task. How can I do this?
  • 48,165
  • 17
  • 52
  • 58
25 answers

Including all the jars in a directory within the Java classpath

Is there a way to include all the jar files within a directory in the classpath? I'm trying java -classpath lib/*.jar:. my.package.Program and it is not able to find class files that are certainly in those jars. Do I need to add each jar file to…
Chris Serra
  • 13,226
  • 3
  • 25
  • 25
2 3
99 100