Questions tagged [command-line]

The command-line is the interactive interface to your shell.

A command line is a user interface for interacting with software via text commands. They are most often seen as an alternative to the more popular graphical user interfaces (GUI). Because of this, some people use the acronym CLI — command line interface — particularly when drawing parallels and distinctions with GUIs.

Although command line interfaces are found in all kinds of software, the term when used without explicit context usually refers to an operating system's command shell. (e.g. Bourne shell on Unix, cmd.exe on Windows, etc.) This is the sense meant when this tag is used on this website.

Further reading

5889 questions
1473
votes
16 answers

How do I get the size of a directory on the command line?

I tried to obtain the size of a directory (containing directories and sub directories) by using the ls command with option l. It seems to work for files (ls -l file name), but if I try to get the size of a directory (for instance, ls -l /home), I…
Abdul Al Hazred
  • 23,792
  • 22
  • 62
  • 85
740
votes
40 answers

Tracking down where disk space has gone on Linux?

When administering Linux systems I often find myself struggling to track down the culprit after a partition goes full. I normally use du / | sort -nr but on a large filesystem this takes a long time before any results are returned. Also, this is…
Owen Fraser-Green
734
votes
5 answers

What does "--" (double-dash) mean?

I have seen -- used in the compgen command. For example: compgen -W "foo bar baz" -- b What is the meaning of the -- in there?
dogbane
  • 27,629
  • 13
  • 78
  • 60
675
votes
5 answers

Zip all files in directory?

Is there a way to zip all files in a given directory with the zip command? I've heard of using *.*, but I want it to work for extensionless files, too.
tkbx
  • 9,867
  • 12
  • 34
  • 41
663
votes
9 answers

How do I zip/unzip on the unix command line?

How can I create and extract zip archives from the command line?
joachim
  • 7,427
  • 4
  • 16
  • 8
603
votes
25 answers

Repeat a Unix command every x seconds forever

There's a built-in Unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat. For example, % repeat 100 echo "I will not automate…
dreeves
  • 6,179
  • 3
  • 14
  • 7
478
votes
8 answers

How can I pass a command line argument into a shell script?

I know that shell scripts just run commands as if they were executed in at the command prompt. I'd like to be able to run shell scripts as if they were functions... That is, taking an input value or string into the script. How do I approach doing…
Paul
  • 8,323
  • 12
  • 30
  • 29
463
votes
10 answers

How do I delete a file whose name begins with "-" (hyphen a.k.a. dash or minus)?

How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory: tohru:~ $ ls -l total 8 -rw-r--r-- 1 me staff 1352 Aug 18 14:33 --help ... How in the…
Astra
  • 4,733
  • 2
  • 15
  • 6
433
votes
11 answers

How can I run a command which will survive terminal close?

Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in such a way that I can close the terminal without…
Matthew
  • 5,187
  • 4
  • 18
  • 11
429
votes
9 answers

When should I not kill -9 a process?

I am always very hesitant to run kill -9, but I see other admins do it almost routinely. I figure there is probably a sensible middle ground, so: When and why should kill -9 be used? When and why not? What should be tried before doing it? What kind…
Mikel
  • 54,321
  • 12
  • 124
  • 144
396
votes
17 answers

How to do integer & float calculations, in bash or other languages/frameworks?

Using echo "20+5" literally produces the text "20+5". What command can I use to get the numeric sum, 25 in this case? Also, what's the easiest way to do it just using bash for floating point? For example, echo $((3224/3807.0)) prints 0 :(. I am…
Michael Durrant
  • 38,917
  • 68
  • 153
  • 227
367
votes
31 answers

What is the fastest way to view images from the terminal?

The terminal is very fast and convenient way to quickly access directories and files (faster than find and click on the directory). One thing that it cannot show in text-mode is "pictures". What is a best way to view pictures (like you see images…
fronthem
  • 4,747
  • 6
  • 23
  • 30
339
votes
12 answers

How to remove a single line from history?

I'm working in Mac OSX, so I guess I'm using bash...? Sometimes I enter something that I don't want to be remembered in the history. How do I remove it?
B Seven
  • 7,209
  • 7
  • 21
  • 20
325
votes
20 answers

How can I get a count of files in a directory using the command line?

I have a directory with a large number of files. I don't see a ls switch to provide the count. Is there some command line magic to get a count of files?
Blake
  • 3,437
  • 2
  • 15
  • 8
314
votes
23 answers

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I setup for a tail command that would help me do this?
Amir Afghani
  • 6,773
  • 11
  • 25
  • 23
1
2 3
99 100