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

85
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 ...
79
votes
6answers
7k 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?
68
votes
15answers
12k 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 ...
30
votes
5answers
801 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 ...
27
votes
3answers
7k 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?
25
votes
20answers
6k views

How do I print pi (3.14159)? [closed]

What command could print pi for me? I want to specify how many digits it prints, I couldn't find anything online. I just want to be able to print pi.
24
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)?
22
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 ...
21
votes
2answers
769 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
633 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' * ...
19
votes
4answers
1k views

The difference between -r and -R

It often happens that I want to apply an operation recursively. Some commands, such as grep, use a lowercase r to indicate recursion. For example grep -r foo . Other commands seem to prefer an ...
19
votes
3answers
847 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: ...
17
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?
15
votes
2answers
538 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 ...
14
votes
1answer
531 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 ...
13
votes
4answers
761 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 ...
13
votes
2answers
8k 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 ...
12
votes
5answers
10k 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.
11
votes
7answers
2k views

What is the symbol *.* called?

What's the name for the *.* symbol and what is its significance?
11
votes
5answers
33k 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?
10
votes
2answers
635 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 /"); ...
9
votes
6answers
1k views

How do you remember command options? [closed]

I am curious to know what trick you use to remember options for various commands? Looking up man pages all the time is time consuming and not so cool!
8
votes
3answers
416 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
0answers
209 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
308 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
3answers
1k 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 ...
7
votes
2answers
307 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
5k 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. ...
7
votes
2answers
5k 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
1k views

Difference between sudo -i and sudo su [duplicate]

I was wondering what the difference is between sudo -i and sudo su?
6
votes
3answers
2k 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 ...
6
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?
6
votes
4answers
135 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
1answer
443 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 ...
6
votes
3answers
534 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 ...
6
votes
2answers
413 views

what is the meaning of this sed command: `;/@/{h;s/test/next/g;x;G}`?

sed -e 's/72;/72, next_val = 0x11111111;/;/@/{h;s/test/next/g;x;G}' fmt_vuln.c > fmt_vuln2.c could you tell me about what is the meaning of ;/@/{h;s/test/next/g;x;G}?
6
votes
3answers
1k 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
658 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
3answers
3k 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
1answer
403 views

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

I want to know what exactly are Linux commands? & how to identify and locate them? (Say Introduce the "commands") In other words what are different kind/type/category of commands? How to identify ...
5
votes
3answers
2k 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
4answers
2k 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 ...
5
votes
2answers
324 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
1answer
3k 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
2k views

What is the use of literal command in ftp?

Browsing through FTP help (i.e. ftp> ?), showed me a command name literal, description of which is ftp> ? literal literal Send arbitrary ftp command I tried to do some trial and ...
5
votes
1answer
883 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
1answer
182 views

What does `init [2]` mean in the COMMAND column of ps?

Reading What do the brackets around processes mean? I understand that the executable name is printed. Linux ps man page: Sometimes the process args will be unavailable; when this happens, ps will ...
5
votes
2answers
325 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 ...