Questions tagged [unix]

This tag is EXCLUSIVELY for PROGRAMMING questions that are directly related to Unix; general software issues should be directed to the Unix & Linux Stack Exchange site or to Super User. The Unix operating system is a general-purpose OS that was developed by Bell Labs in the late 1960s and today exists in various versions.

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

45195 questions
3968
votes
36 answers

How can I check if a directory exists in a Bash shell script?

What command can be used to check if a directory exists or not, within a Bash shell script?
Grundlefleck
  • 115,195
  • 22
  • 89
  • 108
3275
votes
57 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
2542
votes
18 answers

In the shell, what does " 2>&1 " mean?

In a Unix shell, if I want to combine stderr and stdout into the stdout stream for further manipulation, I can append the following on the end of my command: 2>&1 So, if I want to use head on the output from g++, I can do something like this: g++…
Tristan Havelick
  • 58,645
  • 19
  • 52
  • 64
1923
votes
7 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
1841
votes
26 answers

How do I grep recursively?

How do I recursively grep all directories and subdirectories? find . | xargs grep "texthere" *
wpiri
  • 18,559
  • 3
  • 15
  • 6
1630
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
  • 55,636
  • 31
  • 91
  • 113
1616
votes
15 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
  • 28,342
  • 21
  • 95
  • 123
1521
votes
12 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
  • 15,361
  • 3
  • 13
  • 10
1361
votes
37 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
  • 16,774
  • 8
  • 29
  • 41
1206
votes
7 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
  • 75
  • 3
  • 4
  • 10
960
votes
14 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
  • 47,010
  • 55
  • 140
  • 185
957
votes
24 answers

How to permanently set $PATH on Linux/Unix?

I'm trying to add a directory to my path so it will always be in my Linux path. I've tried: export PATH=$PATH:/path/to/dir This works, however each time I exit the terminal and start a new terminal instance, this path is lost, and I need to run the…
Click Upvote
  • 235,452
  • 251
  • 553
  • 736
943
votes
30 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
  • 14,540
  • 8
  • 37
  • 62
940
votes
28 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
  • 13,542
  • 6
  • 26
  • 29
894
votes
24 answers

How do I list all cron jobs for all users?

Is there a command or an existing script that will let me view all of a *NIX system's scheduled cron jobs at once? I'd like it to include all of the user crontabs, as well as /etc/crontab, and whatever's in /etc/cron.d. It would also be nice to see…
yukondude
  • 22,441
  • 13
  • 45
  • 56
1
2 3
99 100