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

6116 questions
1582
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
  • 25,760
  • 23
  • 64
  • 88
788
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
  • 29,087
  • 16
  • 80
  • 60
785
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
731
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
  • 10,597
  • 13
  • 35
  • 41
673
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,617
  • 4
  • 17
  • 8
635
votes
24 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,499
  • 3
  • 15
  • 7
529
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
  • 9,163
  • 12
  • 32
  • 30
483
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,933
  • 2
  • 16
  • 6
451
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,417
  • 4
  • 19
  • 11
434
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
  • 56,387
  • 13
  • 130
  • 149
409
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
  • 41,213
  • 69
  • 165
  • 232
388
votes
32 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,957
  • 6
  • 24
  • 31
376
votes
13 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,659
  • 7
  • 23
  • 20
345
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,637
  • 2
  • 16
  • 8
331
votes
12 answers

How to terminate a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to terminate its process, then re-run the command. How can I terminate it? I haven't closed its shell window. But as you know it doesn't stop using…
1
2 3
99 100