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
153
votes
5 answers

Run a JAR file from the command line and specify classpath

I've compiled a JAR file and specified the Main-Class in the manifest (I used the Eclipse Export function). My dependencies are all in a directory labeled lib. I can't seem to get a straight answer on how to execute my JAR file while specifying it…
SnakeDoc
  • 13,611
  • 17
  • 65
  • 97
152
votes
15 answers

How to detect if CMD is running as Administrator/has elevated privileges?

From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges. The username doesn't change when "Run as Administrator" is selected, so that doesn't work. If there were a universally available command,…
Jeff
  • 2,023
  • 2
  • 14
  • 10
151
votes
13 answers

Is there a way to ignore header lines in a UNIX sort?

I have a fixed-width-field file which I'm trying to sort using the UNIX (Cygwin, in my case) sort utility. The problem is there is a two-line header at the top of the file which is being sorted to the bottom of the file (as each header line begins…
Rob Gilliam
  • 2,680
  • 4
  • 26
  • 29
150
votes
18 answers

List of Java processes

How can I list all Java processes in bash? I need an command line. I know there is command ps but I don't know what parameters I need to use.
Jacek Koralik
  • 1,755
  • 2
  • 12
  • 9
149
votes
14 answers

Grep and Sed Equivalent for XML Command Line Processing

When doing shell scripting, typically data will be in files of single line records like csv. It's really simple to handle this data with grep and sed. But I have to deal with XML often, so I'd really like a way to script access to that XML data via…
Joseph Holsten
  • 20,672
  • 6
  • 25
  • 29
149
votes
3 answers

How do you commit code as a different user?

I want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be able to add in the commits to Git while preserving…
Carl
  • 43,122
  • 10
  • 80
  • 104
149
votes
13 answers

How do I get the name of the active user via the command line in OS X?

How do I get the name of the active user via the command line in OS X?
Redwood
  • 66,744
  • 41
  • 126
  • 187
148
votes
2 answers

How to append the output to a file?

How can I do something like command > file in a way that it appends to the file, instead of overwriting?
The Student
  • 27,520
  • 68
  • 161
  • 264
148
votes
2 answers

Where are sudo incidents reported?

Attempting something devious on my machine leads to ryan@debian:~$ sudo EAT_ALL_THE_COOKIES_BEFORE_DINNER [sudo] password for ryan: ryan is not in the sudoers file. This incident will be reported. Where is this incident reported, and how do I get…
user1717828
  • 7,122
  • 8
  • 34
  • 59
148
votes
9 answers

Useless use of cat?

This is probably in many FAQs - instead of using: cat file | command (which is called useless use of cat), correct way supposed to be: command < file In the 2nd, "correct" way - OS does not have to spawn an extra process. Despite knowing that, I…
Leonid Volnitsky
  • 8,854
  • 5
  • 38
  • 53
147
votes
22 answers

Automatically capture output of last command into a variable using Bash?

I'd like to be able to use the result of the last executed command in a subsequent command. For example, $ find . -name foo.txt ./home/user/some/directory/foo.txt Now let's say I want to be able to open the file in an editor, or delete it, or do…
armandino
  • 17,625
  • 17
  • 69
  • 81
147
votes
4 answers

How to check if SMTP is working from commandline (Linux)

I have a SMTP-server, for the purpose of this question lets call it: smtp.mydomain.example. How do I check if the SMTP-server is in working? Can I send emails manually from Linux commandline?
balanv
  • 10,686
  • 27
  • 91
  • 137
146
votes
16 answers

Using 'diff' (or anything else) to get character-level diff between text files

I'd like to use 'diff' to get a both line difference between and character difference. For example, consider: File 1 abcde abc abcccd File 2 abcde ab abccc Using diff -u I get: @@ -1,3 +1,3 @@ abcde -abc -abcccd \ No newline at end of…
VitalyB
  • 12,397
  • 9
  • 72
  • 94
145
votes
13 answers

How to beautify JSON in Python?

Can someone suggest how I can beautify JSON in Python or through the command line? The only online based JSON beautifier which could do it was: http://jsonviewer.stack.hu/. I need to use it from within Python, however. This is my dataset: { "head":…
Khwaishien
  • 1,818
  • 4
  • 15
  • 14
144
votes
5 answers

What's the magic of "-" (a dash) in command-line parameters?

Examples: Create an ISO image and burn it directly to a CD. mkisofs -V Photos -r /home/vivek/photos | cdrecord -v dev=/dev/dvdrw - Change to the previous directory. cd - Listen on port 12345 and untar data sent to it. nc -l -p 12345 | tar xvzf…
chemila
  • 4,231
  • 4
  • 22
  • 18