Questions tagged [unix]

NOTICE: All Unix questions must be related to programming; those that aren't will be closed. Use this tag only if your question relates to programming using Unix APIs or Unix-specific behavior, not just because you happen to run your code on Unix. General software issues should be directed to Unix & Linux Stack Exchange or to Super User.

Tag usage

The tag can be used for Unix system programming related problems. The tag can also contain programming questions about using the Unix platform. For non-programming Unix usage questions, visit the Unix & Linux Stack Exchange site.

Background

Unix was developed as an in-house operating system for AT&T, but in the 1980s became both a prime academic operating system (with U.C. Berkeley's version, called BSD, being the reference platform for development of what would become the Internet) and a commercial success in the form of AT&T's System V, Microsoft/SCO's XENIX (PCs) and various workstation versions from Sun, Silicon Graphics, and others.

In the 1990s, Sun's Solaris and the free Unix clone Linux would rise in popularity. Linux is largely Unix-compatible but lacks the trademark. Currently, Unix is commonly found on server platforms; the primary desktop variant is Mac OS X, based on BSD.

Apart from its command-line interface, most "Unices" support the standardized X Window System for GUIs. (So does Mac OS X, but its primary GUI is Apple's proprietary Quartz.)

The various Unix implementation (and to a lesser extent, clones such as Linux) are unified in a standard called POSIX. C has been its primary programming language since the 1970s, but many other languages are available.

Read more

47509 questions
4361
votes
35 answers

How do I check if a directory exists or not in a Bash shell script?

What command checks if a directory exists or not within a Bash shell script?
Grundlefleck
  • 124,925
  • 25
  • 94
  • 111
3609
votes
62 answers

How can I pretty-print JSON in a shell script?

Is there a (Unix) shell script to format JSON in human-readable form? Basically, I want it to transform the following: { "foo": "lorem", "bar": "ipsum" } ... into something like this: { "foo": "lorem", "bar": "ipsum" }
AnC
3103
votes
19 answers

What does " 2>&1 " mean?

To combine stderr and stdout into the stdout stream, we append this to a command: 2>&1 e.g. to see the first few errors from compiling g++ main.cpp: g++ main.cpp 2>&1 | head What does 2>&1 mean, in detail?
Tristan Havelick
  • 67,400
  • 20
  • 54
  • 64
2218
votes
8 answers

What do 'real', 'user' and 'sys' mean in the output of time(1)?

$ time foo real 0m0.003s user 0m0.000s sys 0m0.004s $ What do real, user and sys mean in the output of time? Which one is meaningful when benchmarking my app?
Iraimbilanja
2118
votes
27 answers

How do I recursively grep all directories and subdirectories?

How do I recursively grep all directories and subdirectories? find . | xargs grep "texthere" *
wpiri
  • 21,337
  • 3
  • 17
  • 6
2041
votes
16 answers

Looping through the content of a file in Bash

How do I iterate through each line of a text file with Bash? With this script: echo "Start!" for p in (peptides.txt) do echo "${p}" done I get this output on the screen: Start! ./runPep.sh: line 3: syntax error near unexpected token…
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1989
votes
19 answers

Why should text files end with a newline?

I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why?
Will Robertson
  • 62,540
  • 32
  • 99
  • 117
1810
votes
11 answers

Difference between sh and Bash

When writing shell programs, we often use /bin/sh and /bin/bash. I usually use bash, but I don't know what's the difference between them. What's main difference between Bash and sh? What do we need to be aware of when programming in Bash and sh?
Weiwei Yang
  • 18,261
  • 3
  • 15
  • 10
1515
votes
11 answers

How do I remove the passphrase for the SSH key without having to create a new key?

I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit (Git and SVN) to a remote location over SSH many times in an hour. One way I can think of is, delete my SSH keys…
btbytes
  • 85
  • 3
  • 4
  • 10
1485
votes
39 answers

How to fix npm throwing error without sudo

I just installed node and npm through the package on nodejs.org, and whenever I try to search or install something with npm, it throws the following error unless I sudo the command. I have a feeling this is a permissions issue? I am already the…
Chad
  • 18,076
  • 8
  • 31
  • 41
1397
votes
34 answers

How to kill a process running on particular port in Linux?

I tried to close the tomcat using ./shutdown.sh from tomcat /bin directory. But found that the server was not closed properly. And thus I was unable to restartMy tomcat is running on port 8080. I want to kill the tomcat process running on 8080. I…
veer7
  • 20,074
  • 9
  • 46
  • 74
1163
votes
29 answers

Using ls to list directories and their total sizes

Is it possible to use ls in Unix to list the total size of a sub-directory and all its contents as opposed to the usual 4K that (I assume) is just the directory file itself? total 12K drwxrwxr-x 6 *** *** 4.0K 2009-06-19 10:10 branches drwxrwxr-x…
kmorris511
  • 16,392
  • 7
  • 28
  • 29
1085
votes
14 answers

How can I exclude directories from grep -R?

I want to traverse all subdirectories, except the node_modules directory.
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
1085
votes
11 answers

How do I pause my shell script for a second before continuing?

I have only found how to wait for user input. However, I only want to pause so that my while true doesn't crash my computer. I tried pause(1), but it says -bash: syntax error near unexpected token '1'. How can it be done?
user3268208
1072
votes
15 answers

What is the meaning of "POSIX"?

What is POSIX? I have read the Wikipedia article and I read it every time I encounter the term. The fact is that I never really understood what it is. Can anyone please explain it to me by explaining "the need for POSIX" too?
claws
  • 52,236
  • 58
  • 146
  • 195
1
2 3
99 100