Questions tagged [utilities]

small programs used on the command line to do a specific job

Filter by
Sorted by
Tagged with
469
votes
4answers
165k views

What does “--” (double-dash) mean? (also known as “bare double dash”)

I have seen -- used in the compgen command. For example: compgen -W "foo bar baz" -- b What is the meaning of the -- in there?
258
votes
3answers
138k views

What is the difference between curl and wget?

I am keen to know the difference between curl and wget. Both are used to get files and documents but what the key difference between them. Why are there two different programs?
243
votes
14answers
333k views

How can I use sed to replace a multi-line string?

I've noticed that, if I add \n to a pattern for substituting using sed, it does not match. Example: $ cat > alpha.txt This is a test Please do not be alarmed $ sed -i'.original' 's/a test\nPlease ...
135
votes
3answers
624k views

How to list disks, partitions and filesystems in Linux? [duplicate]

In Windows, if you type LIST DISK using DiskPart in a command prompt it lists all physical storage devices, plus their size, format, etc. What is the equivalent of this in Linux?
110
votes
5answers
246k views

Usage of dash (-) in place of a filename

For a command, if using - as an argument in place of a file name will mean STDIN or STDOUT. But in this example, it creates a file with the name -: echo hello > - How can I make - in this ...
94
votes
15answers
42k views

A standard tool to convert a byte-count into human KiB MiB etc; like du, ls1

Is there a standard tool which converts an integer count of Bytes into a human-readable count of the largest possible unit-size, while keeping the numeric value between 1.00 and 1023.99 ? I have my ...
81
votes
11answers
22k views

Linux tools to treat files as sets and perform set operations on them

Does anyone know of any linux tool specifically designed to treat files as sets and perform set operations on them? Like difference, intersection, etc?
76
votes
3answers
44k views

What is the point of the `yes` command? [duplicate]

This question concerns the yes command found in UNIX and Linux machines: Basically, what is the point (if any) and history of this tool? Are there practical applications for it? Can an example be ...
72
votes
4answers
22k views

What is the difference between a builtin command and one that is not?

Is there any intrinsic difference between a builtin command and another command which can nominally do the same thing? eg. Do builtins get "special" treatement? ... is there less overhead running ...
72
votes
4answers
26k views

Fix or alternative for mktemp in OS X

I'm looking at a bash script someone else wrote that uses mktemp: TEMP=`mktemp --directory` However, this line does not work on my machine (OS X 10.6). How would I fix this line so that it is cross-...
72
votes
9answers
80k views

Is there any option with 'ls' command that I see only the directories?

Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that? EDIT: I'm using Mac OS X, and ls -d gives me . even though ...
66
votes
4answers
12k views

Why use install rather than cp and mkdir?

I've seen in many places used install -d to create directories and install -c to copy a file. Why not use mkdir and cp? Is there an advantage in using install?
51
votes
5answers
65k views

What is the mknod command used for?

I just started using Ubuntu as my main OS and I wanted to learn about things I should not do, and learn by the bad things people have done in the past. I came across these email about horror stories ...
45
votes
8answers
4k views

Why are POSIX mandatory utilities not built into the shell?

The purpose of this question is to answer a curiosity, not to solve a particular computing problem. The question is: Why are POSIX mandatory utilities not commonly built into shell implementations? ...
45
votes
3answers
94k views

How can I test the encoding of a text file… Is it valid, and what is it?

I have several .htm files which open in Gedit without any warning/error, but when I open these same files in Jedit, it warns me of invalid UTF-8 encoding... The HTML meta tag states "charset=ISO-8859-...
37
votes
6answers
8k views

How to trick a command into thinking its output is going to a terminal

Given a command that changes its behaviour when its output is going to a terminal (e.g. produce coloured output), how can that output be redirected in a pipeline while preserving the changed behaviour?...
35
votes
5answers
9k views

Why use superflous dash (-) to pass option flags to tar?

To create a tar file for a directory, the tar command with compress, verbose and file options can be typed thus: $ tar -cvf my.tar my_directory/ But it also works to do it this way: $ tar cvf my....
30
votes
6answers
16k views

Alternative to find? [closed]

Is there an alternative find program with a more conventional CLI interface? find works and expects parameters in a painfully different way from most other utils. Clarification: I'm looking for a ...
29
votes
4answers
5k views

Can a file that was originally sparse and then expanded be made sparse again?

I know that copying or transferring what was originally a sparse file without using a utility that understands sparse files will cause the 'holes' to be filled out. Is there a method or utility to ...
28
votes
5answers
51k views

creating a sequence of numbers, one per line in a file

Is there a way to create out of thin air, a file that is a sequence of numbers, starting at a given number, one per line? something like magic_command start 100 lines 5 > b.txt and then, b.txt ...
28
votes
5answers
27k views

Setting the window dimensions of a running application

I'm trying to start an application within Ubuntu (xfce or gnome) and via the command line and was wondering if there's a generic way to set the dimensions of a given window of a given app that is ...
27
votes
3answers
6k views

What is the purpose of square bracket executable

I see there is an executable called "[" in /usr/bin. What is its purpose?
27
votes
4answers
22k views

I try to add passwords to the “pass” password manager. But my attempts fail with “no public key” GPG errors. Why?

I am trying to install Pass: the standard Unix password manager, however, when I try to add passwords to the appliation I get these errors gpg: Kelly's Passwords: skipped: No public key gpg: [stdin]: ...
23
votes
5answers
93k views

How to recover data from a bad SD card?

I have a 4GB SD card with some family pictures on it that I need to recover. When I insert the card into my card reader, it shows up as an unknown 32MB device (as /dev/sde) and cannot be mounted. When ...
23
votes
4answers
2k views

Are Linux utilities smart when running piped commands?

I was just running a few commands in a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands? For example, let's say I have a file with one million lines, the ...
23
votes
2answers
20k views

Does hexdump respect the endianness of its system?

On my machine I get the following output when I run these commands: $ echo foos > myfile $ hexdump myfile 6f66 736f 000a The output from hexdump is little-endian. Does this mean that my machine ...
22
votes
11answers
19k views

Tool in UNIX to subtract dates

Is there any tool in Solaris UNIX (so no GNU tool available) to subtract dates? I know that in Linux we have gawk that can subtract one date from another. But in Solaris the maximum we have is nawk (...
22
votes
8answers
3k views

What are the best general purpose programming tools to complement Vim? [closed]

I've been using Vim as my text editor for a little while now and I feel like I'm taking the long way to do anything. I use ctags to tag my code base for navigation and I use grep (although ...
21
votes
6answers
76k views

Why is 'df' hanging?

I have recently been having problems running df, where it just hangs. Here's strace output, and in it, you'll see that I killed since it was just sitting there: $ strace /bin/df execve("/bin/df", ["/...
21
votes
1answer
7k views

What are the differences between xdotool and xautomation?

xdotool and xautomation are two command line X11 automation tools. I've used the former for a while and only recently found out about the existence of the latter, and I'm curious to know what someone ...
20
votes
8answers
31k views

How do I find the X window ID under the mouse pointer in bash?

From a bash script, is there some way to get the ID of the X window under the mouse pointer? (edit) I need the process to be non-interactive.
19
votes
3answers
3k views

Universal extractors

With an increasing number of archive/compression file formats, is there a single free/open-source command line tool to rule them all? Perhaps something with a consistent / unified set of flags? (note ...
16
votes
4answers
45k views

touch: cannot touch file: No such file or directory [duplicate]

I am getting the error: touch: cannot touch `/opt/tsrm/compliance/cme/log/20121207.log`: No such file or directory on the touch command: touch $LOGFILE I also checked the link: touch: cannot touch ...
15
votes
3answers
1k views

head eats extra characters

The following shell command was expected to print only odd lines of the input stream: echo -e "aaa\nbbb\nccc\nddd\n" | (while true; do head -n 1; head -n 1 >/dev/null; done) But instead it just ...
15
votes
4answers
1k views

Is there a tool to find out the general state of the machine? [closed]

I am longing for a tool for linux that would give me a general idea what is happening on a machine. Example information I am looking for: What daemons are installed (www, db, others) Config locations ...
15
votes
2answers
15k views

Problem with install command to copy a whole directory

So I have a repo with some of my config files and I'm trying to create a makefile to install them in the homedir. The problem I have is that when I run the following command straight in bash install -...
15
votes
4answers
3k views

Store output of a command into a ring-buffer

I've got a long-running command that generates a lot of output on stdout. I'd like to be able to retain, for instance, only the last three days or the last gibibyte (avoiding cutting lines in the ...
14
votes
2answers
6k views

Is '-9' a flag to kill command?

What does -9 do? It does not show up in the syntax: $ kill kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] $
14
votes
1answer
2k views

Understanding the output of the `who -a` command

I am asking this question because, while there are many answers on the internet showing that who -a is an option, nobody explains how to read the output. If you could provide a link to an online site ...
13
votes
1answer
5k views

`unbuffer` or `stdbuf` for removing stdout buffering?

Is there a difference between unbuffer(1) and stdbuf(1)? From what I gather, unbuffer makes more than the "best effort" of calling the libc function set(X)buf at the beginning, and then letting things ...
13
votes
2answers
557 views

`test` and `[` - different binaries, any difference?

I noticed while answering another question that test and [ are different binaries, but the [ manpage pulls up test's. Besides the requirement for an ending ], is there any difference? If not, why are ...
13
votes
3answers
13k views

Are there alternatives for `dd`?

What other tools should I use to read and write files with truncation, seeking and skipping. dd's command line options seem inconvenient and foreign and I don't like choosing between slow, but precise ...
12
votes
2answers
9k views

sponge from moreutils - what's the difference to shell redirect? useful examples?

> brew install moreutils ==> Downloading https://homebrew.bintray.com/bottles/moreutils-0.55.yosemite.bottle.tar.gz #################...
12
votes
3answers
905 views

Is there a way to make perl -i not clobber symlinks?

A friend of mine points out that if you do: perl -pi.bak -e 's/foo/bar/' somefile when "somefile" is actually a symlink, perl does just what the docs say it will do: It does this by renaming the ...
12
votes
2answers
5k views

Alternative to watch which support colors

I have a command (phpunit) which has a colored output. According to the watch, command I should be able to use the --color flag to allow color rendering to pass through. However, this isn't working. ...
11
votes
4answers
4k views

Get line number from byte offset

Having byte offset for a file. Is there a tool that gives line number for this byte? Byte count starting with zero, as in: first byte is 0 not 1. Line number starting with 1. File can have both ...
11
votes
2answers
3k views

Can hd and od replace each other?

hd and od are both dump viewers of binary content. Can hd be used wherever od is and vice versa?
10
votes
2answers
239 views

Why is there a mix of symlinks and hardlinks in /bin?

I understand the technical difference between symlinks and hardlinks, this is a question about their use in practice, particularly I'm curious to know why both are used in seemingly similar conditions:...
9
votes
2answers
1k views

Finding a file type assuming wrong extension

I have an image archive I keep up. Sometimes, the sites I pull them from reformat the file while keeping the extension the same, most often making PNG images into JPG's that are still named ".png". ...
9
votes
3answers
605 views

Doing two things with output from a command

I have a program texcount that outputs the number of words in my LaTeX document. I can also pipe the output of this to sed to make the newlines TeX linebreaks and write this to a file which I can then ...