One or a set of directives issued in the *nix environment to get information, change the state of something or to execute something. In other words: To gain an objective.

learn more… | top users | synonyms

82
votes
3answers
8k views

Why is “echo” so much faster than “touch”?

I'm trying to update the timestamp to the current time on all of the xml files in my directory (recursively). I'm using Mac OSX 10.8.5. On about 300,000 files, the following echo command takes 10 ...
75
votes
6answers
6k views

Why is cd not a program?

I've always wondered why cd isn't a program, but never managed to find the answer. Anyone know why this is the case?
67
votes
15answers
11k views

What are the legitimate uses of the `touch` command?

What's the point of the touch command? I know I can create empty files with it, but so is also the case with echo -n. Otherwise, why would someone need to change the timestamps of a file? Unless to ...
33
votes
2answers
1k views

What is the point of the `cd` external command?

As referenced in this fine answer, POSIX systems have an external binary cd in addition to the shell builtin. On OS X 10.8 it's /usr/bin/cd. You can't use it like the builtin cd since it exits ...
28
votes
5answers
695 views

How to save a command you entered without executing it? [duplicate]

Every Linux user has experienced this annoying thing: you begin typing a long and boring command, then realise you should have executed another one before. How to save the first one to execute it ...
25
votes
2answers
5k views

How to stop the find command after first match?

Is there a way to force the find command to stop right after finding the first match?
22
votes
3answers
4k views

Why is dmesg called dmesg?

Is there any explanation/history behind the name of the command dmesg (which prints out some kernel messages)?
21
votes
4answers
1k views

Is the shell permitted to optimize out useless terminating commands?

If a shell is asked to perform a probably useless (or partially useless) command known to terminate, such as cat hugeregularfile.txt > /dev/null, can it skip that command's execution (or execute a ...
20
votes
2answers
631 views

How do I move all files output from a command?

I have this grep command to find files without the word Attachments in them. grep -L -- Attachments * I want to move all the files that are output from that command. How do I do that in bash? Do I ...
20
votes
2answers
605 views

What is `--` called?

Recently I got to know of -- that is double-hyphen which is used to tell a command that the option list has ended and what follows should not be considered as a option. So, grep -- 'search_word' * ...
18
votes
3answers
772 views

Which are the standard commands available in every Linux based distribution?

I would like to know which are the standard commands available in every Linux system. For example if you get a debian/ubuntu/redhat/suse/arch/slackware etc, you will always find there commands like: ...
15
votes
2answers
496 views

Is there something like `time` that also records I/O and CPU?

I can pretty quickly monitor the running time of a process with time: x@y ~ $ time foo real 0m14.299s user 0m4.770s sys 0m0.440s Is there a way I can get the same data for ...
15
votes
2answers
2k views

The “yes” command

There is a yes command in unix/linux which basically infinitely prints y to the stdout. What is the point of it, and how is it useful?
13
votes
1answer
511 views

What does yes $(yes yes) do?

Wondering what use the yes command might be, I stumbled upon this comment, and tried to execute yes $(yes yes) From what I understand, this should simply print out an infinite sequence of yes, but ...
12
votes
5answers
4k views

Delete 100 lines from vi editor using single command

I am using Ubuntu and trying to delete all 100 lines from vi editor but I got interview question of doing this in one command.
12
votes
4answers
658 views

What is the difference between running a executable just by name and by appending a dot /slash before it?

This is the output from ls -all command : -rwxr----- 1 subhrcho dba 3600 Nov 13 17:26 jdev -rw-r----- 1 subhrcho dba 1566 Nov 13 17:26 jdev-Darwin.conf -rw-r----- 1 subhrcho dba 347 Mar 6 2009 ...
11
votes
7answers
2k views

What is the symbol *.* called?

What's the name for the *.* symbol and what is its significance?
11
votes
2answers
6k views

How to run time on multiple commands AND write the time output to file?

I want to run time command to measure time of several commands. What I want to do is: Measure the time of running of all of them added together Write the time output to a file Write the STDERR from ...
10
votes
2answers
583 views

What's the reason for this specific “rm” sequence in the xkcd joke?

Here's part of this xkcd comic strip where the idea is that the author can't write a sort program so he adds code to delete all files system("rm -rf ./"); system("rm -rf ~/*"); system("rm -rf /"); ...
8
votes
3answers
360 views

Vim: pasting lines line by line

Let's suppose I have a file containing: xxx yyy zzz and another file: kkk qqq ppp I want to obtain: xxxkkk yyyqqq zzzppp Is that possible in Vim with some command? (I've tried using VISUAL ...
8
votes
6answers
20k views

How to move all files and folders via mv command

How can I move all files and folders from one directory to another via mv command?
8
votes
0answers
208 views

how to get exit status from the command before the last [duplicate]

I have solaris machine ( solaris 10 ) please Look on the following simple commands (haconf -makerw | grep -iq "Cluster already writable") # haconf -makerw VCS WARNING V-16-1-10364 Cluster ...
7
votes
2answers
262 views

Change the order of executables started in bash

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started: $ type test test is a shell builtin $ type -a test test is a shell builtin test is ...
7
votes
2answers
131 views

what is `env <command>` doing?

What is the command env ls -al doing? I had a Linux test and there was question: "How to run command directly, but not its alias?" I knew that there exists solution like prefixing command with some ...
7
votes
2answers
4k views

Execute command in remote active terminal

Suppose you have a terminal emulator (T1) open with a PID of 6350. From another terminal, type this command (C1): echo "ls\n" > /proc/6350/fd/0 This writes ls and the new line in T1 but does ...
7
votes
3answers
478 views

Difference between sudo -i and sudo su [duplicate]

I was wondering what the difference is between sudo -i and sudo su?
6
votes
4answers
124 views

Is there a tool for summarizing what all commands do?

So I understand that there are man pages for getting the documentation when the internet is unavailable, or when you need advanced uses, but what if I'm offline and I don't even know what tool I need ...
6
votes
3answers
841 views

Difference between commands in bash script and commands in terminal

Are there any differences between commands that you type into the terminal and commands you include in a script?
5
votes
3answers
1k views

Difference between 'ifconfig' and 'ip' commands

I read some articles/tutorials on 'ifconfig' command, most of them included a common statement - "ifconfig is deprecated by ip command" and suggested to learn ip command. But none of them ...
5
votes
3answers
2k views

Why doesn't ln -s tell that it fails when creating a symlink to an existing symlinked directory?

When running (on linux different ubuntu variations): >ln -s dir_1 symlink_dir >ln -s dir_2 symlink_dir It fails without telling that it fails. But if you do the same thing on a file instead ...
5
votes
3answers
539 views

Linux Rename File Beginning with “--” [duplicate]

Possible Duplicate: How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)? This is an awkward one, I have received some files from a windows machine ...
5
votes
4answers
2k views

In UNIX, how to find the most commonly used commands in history of unix?

In UNIX, how to find the most commonly used commands in history?
5
votes
1answer
372 views

What exactly are commands? How to identify? [duplicate]

I want to know what exactly are Linux commands? & how to identify and locate them?
5
votes
3answers
936 views

Test command in unix doesn't print an output

When I type this in the terminal test 4 -lt 6 I don't get any output. Why not? I need that 0 or 1
5
votes
2answers
2k views

What's the difference between “dir” and “ls”?

I have compared the man pages of dir and ls and they seem to be exactly the same. Both are part of GNU coreutils and "list directory contents". The only difference I've seen so far is that dir ...
5
votes
2answers
280 views

Get the actions for a command programmatically

Let's take the git example: $ git<TAB><TAB> git git-import-dscs git-shell git-buildpackage git-import-orig git-upload-archive git-dch git-pbuilder ...
5
votes
3answers
673 views

What does “rm is hashed” mean?

I'm going through http://mywiki.wooledge.org/BashGuide/CommandsAndArguments and came across this: $ type rm rm is hashed (/bin/rm) $ type cd cd is a shell builtin Just a little earlier, the guide ...
5
votes
2answers
3k views

Which of these three commands is telling the TRUE Redhat release information

I was checking for the Redhat release so this time I used three different commands. Two commands gave the same result but the third command gave different result. Which one is right. ...
5
votes
1answer
2k views

What does <defunct> mean in the output of ps?

I had issued the ps -ef|grep java command and this is one of the entries that I got : subhrcho 875 803 0 Jan23 pts/5 00:02:27 [java] <defunct> What is <defunct> implying here ? ...
5
votes
1answer
761 views

Git auto-complete

I am using Git as many of you do. Also, I don't use any GUI for that — just CLI. So I was wondering: are there any way to make Git commands (git status, git checkout etc.) complete themselves when ...
5
votes
3answers
464 views

Get a list of 3 letter commands on Mac OS X

How can I either create or find a list of 3-letter unix commands on Mac OS X? I'd like to create a new program/command for a project. I'd like to make it a 3-letter name, but I don't want to conflict ...
5
votes
1answer
85 views

What's the difference between “realpath” and “readlink -f”

I've read a lot about realpath command and how it has been deprecated with the readlink -f being now recommended. I have also seen in some places that the reason why realpath was introduced was for ...
5
votes
2answers
227 views

Why is cd not a file in /bin? [duplicate]

Possible Duplicate: Why is cd not a program? I noticed that every other commonly used util, like ls, cp, rm, etc. are actually files in /bin -- but cd is not. Nor is it in any other ...
4
votes
1answer
319 views

Which 2-letter POSIX command is different from all the others?

I was interviewed for an internship and I got the same question as this one: http://www.glassdoor.com/Interview/Which-2-letter-POSIX-command-is-different-from-all-the-others-QTN_498236.htm The ...
4
votes
4answers
539 views

What does <<< mean? [duplicate]

What does <<< mean? Here is an example: $ sed 's/a/b/g' <<< "aaa" bbb Is it something general that works with more Linux commands? It looks like it's feeding the sed program with ...
4
votes
2answers
356 views

Command completion does not complete the files in the current directory

Something is wrong with my tab completion. Let's say I do this: cd test // works fine, go into test directory ls // works fine, displays all of the files Let's assume I have the following files: ...
4
votes
4answers
449 views

Is there a practical use for the GNU factor command?

Looking through the GNU Coreutils, I spotted the factor command, that I had never noticed before. Reading the man page: Print the prime factors of each specified integer NUMBER. If none are ...
4
votes
2answers
267 views

Redhat Linux: How to know my system configuration?

I am using Red Hat Enterprise Linux Server release 5.9 (Tikanga). For installation of any application, it is very important to know the system configuration, is it 32 bit or 64 bit system, Installed ...
4
votes
4answers
624 views

How to randomly sample a subset of a file

Is there any Linux command one can use to sample subset of a file? For instance, a file contains one million lines, and we want to randomly sample only one thousand lines from that file. For random ...
4
votes
5answers
951 views

Execute string result from shell script as a set of shell commands

I create a string result from my shell script and i want to execute it as a shell command. For example file_a is: user1@gmail.com user2@gmail.com script: awk '{print "mail -s \"welcome\"", $1}' ...