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
23
votes
5 answers

Event-driven Model in C with Sockets

I am really interested in event-driven programming in C especially with sockets so I am going to dedicate some time doing my researches. Let's assume that I want to build a program with much File and Network I/O like a client/server app, basically,…
iNDicator
  • 534
  • 2
  • 6
  • 15
23
votes
5 answers

OS X mount local directory

Is it possible to mount a local directory into another one? Using Perforce, I want to do something equivalent to symlinking a directory, but in a way that fools it into thinking it's really just another directory in the project. I would like to do…
user79854
22
votes
5 answers

unix command line execute with . (dot) vs. without

At a unix command line, what's the difference between executing a program by simply typing it's name, vs. executing a program by typing a . (dot) followed by the program name? e.g.: runme vs. . runme
Landon Kuhn
  • 76,451
  • 45
  • 104
  • 130
22
votes
3 answers

Change datetime to Unix time stamp in Python

Please help me to change datetime object (for example: 2011-12-17 11:31:00-05:00) (including timezone) to Unix timestamp (like function time.time() in Python).
Thelinh Truong
  • 564
  • 1
  • 8
  • 19
22
votes
5 answers

How to fire and forget a subprocess?

I have a long running process and I need it to launch another process (that will run for a good while too). I need to only start it, and then completely forget about it. I managed to do what I needed by scooping some code from the Programming Ruby…
kch
  • 77,385
  • 46
  • 136
  • 148
22
votes
12 answers

Can I get the absolute path to the current script in KornShell?

Is it possible to find out the full path to the script that is currently executing in KornShell (ksh)? i.e. if my script is in /opt/scripts/myscript.ksh, can I programmatically inside that script discover /opt/scripts/myscript.ksh ? Thanks,
brabster
  • 42,504
  • 27
  • 146
  • 186
22
votes
8 answers

Detecting a chroot jail from within

How can one detect being in a chroot jail without root privileges? Assume a standard BSD or Linux system. The best I came up with was to look at the inode value for "/" and to consider whether it is reasonably low, but I would like a more accurate…
Topaz
  • 233
  • 1
  • 3
  • 8
22
votes
4 answers

Bad file descriptor

I'm learning about file descriptors and I wrote this code: #include #include #include #include int fdrd, fdwr, fdwt; char c; main (int argc, char *argv[]) { if((fdwt = open("output", O_CREAT, 0777))…
Lucy
  • 241
  • 1
  • 3
  • 6
22
votes
7 answers

Line-end agnostic diff?

I'm working on a Mac, with some fairly old files. Different files were created by different programs, so some of them end with \r (Mac) and some with \n (Unix). I want to be able to run commands like diff, grep, etc. on these files, but the ones…
Brian Postow
  • 11,709
  • 17
  • 81
  • 125
22
votes
4 answers

view a particular line of a file denoted by a number

Okay, this is probably an evident thing but it escapes me, as in it could probably be done in a much simpler way that I'm not aware of, so far.. Say there's a "file" and I want to view only what's on line number "X" of that file, what would be the…
XXL
  • 1,224
  • 4
  • 12
  • 25
22
votes
1 answer

How is % (percent sign) special in crontab?

In crontab, can you do something like this? * * * * * echo $( date +%F) >> /path/date.txt
JuanPablo
  • 23,792
  • 39
  • 118
  • 164
22
votes
2 answers

Under what circumstances does the read() syscall return 0?

I'm looking at the read syscall in Unix, which (at least in Linux) has this signature: [1] ssize_t read(int fd, void* buf, size_t count); Let's assume that the call succeeds (i.e. no negative return values) and that count > 0 (i.e. the buffer…
Stefan Majewsky
  • 5,427
  • 2
  • 28
  • 51
22
votes
4 answers

Monitor Directory for Changes

Much like a similar SO question, I am trying to monitor a directory on a Linux box for the addition of new files and would like to immediately process these new files when they arrive. Any ideas on the best way to implement this?
Nate
  • 18,892
  • 27
  • 70
  • 93
22
votes
2 answers

What is the difference between `chmod go-rwx` and `chmod 700`

My goal is to prevent modify/read permission of other users except the owner. On ubuntu forums as solutions both approach is given. sudo useradd -d /home/newuser -m newuser chmod 700 /home/newuser # or # chmod go-rwx /home/newuser [Q] Is there…
alper
  • 2,919
  • 9
  • 53
  • 102
22
votes
4 answers

compare two files in UNIX

I would like to compare two files [ unsorted ] file1 and file2. I would like to do file2 - file1 [ the difference ] irrespective of the line number? diff is not working.
Balualways
  • 4,250
  • 10
  • 38
  • 51