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
1071
votes
24 answers

How to permanently set $PATH on Linux/Unix

On Linux, how can I add a directory to the $PATH so it remains persistent across different sessions? Background 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,…
Ali
  • 261,656
  • 265
  • 575
  • 769
1046
votes
23 answers

What is the difference between a symbolic link and a hard link?

Recently I was asked this during a job interview. I was honest and said I knew how a symbolic link behaves and how to create one, but do not understand the use of a hard link and how it differs from a symbolic one.
Nick Stinemates
  • 41,511
  • 21
  • 59
  • 60
1019
votes
36 answers

How to get full path of a file?

Is there an easy way I can print the full path of file.txt ? file.txt = /nfs/an/disks/jj/home/dir/file.txt The dir> file.txt should print /nfs/an/disks/jj/home/dir/file.txt
Jean
  • 21,665
  • 24
  • 69
  • 119
980
votes
25 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
  • 24,013
  • 13
  • 49
  • 58
969
votes
10 answers

Given two directory trees, how can I find out which files differ by content?

If I want find the differences between two directory trees, I usually just execute: diff -r dir1/ dir2/ This outputs exactly what the differences are between corresponding files. I'm interested in just getting a list of corresponding files whose…
Mansoor Siddiqui
  • 20,853
  • 10
  • 48
  • 67
969
votes
23 answers

How can I convert a Unix timestamp to DateTime and vice versa?

There is this example code, but then it starts talking about millisecond / nanosecond problems. The same question is on MSDN, Seconds since the Unix epoch in C#. This is what I've got so far: public Double CreatedEpoch { get { DateTime epoch…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
923
votes
22 answers

Use grep --exclude/--include syntax to not grep through certain files

I'm looking for the string foo= in text files in a directory tree. It's on a common Linux machine, I have bash shell: grep -ircl "foo=" * In the directories are also many binary files which match "foo=". As these results are not relevant and slow…
Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
850
votes
31 answers

Argument list too long error for rm, cp, mv commands

I have several hundred PDFs under a directory in UNIX. The names of the PDFs are really long (approx. 60 chars). When I try to delete all PDFs together using the following command: rm -f *.pdf I get the following error: /bin/rm: cannot execute…
Vicky
  • 16,679
  • 54
  • 139
  • 232
844
votes
23 answers

Bash tool to get nth line from a file

Is there a "canonical" way of doing that? I've been using head -n | tail -1 which does the trick, but I've been wondering if there's a Bash tool that specifically extracts a line (or a range of lines) from a file. By "canonical" I mean a program…
Vlad Vivdovitch
  • 9,295
  • 8
  • 22
  • 21
842
votes
2 answers

How do SO_REUSEADDR and SO_REUSEPORT differ?

The man pages and programmer documentations for the socket options SO_REUSEADDR and SO_REUSEPORT are different for different operating systems and often highly confusing. Some operating systems don't even have the option SO_REUSEPORT. The WWW is…
Mecki
  • 125,244
  • 33
  • 244
  • 253
829
votes
70 answers

What are the dark corners of Vim your mom never told you about?

There are a plethora of questions where people talk about common tricks, notably "Vim+ctags tips and tricks". However, I don't refer to commonly used shortcuts that someone new to Vim would find cool. I am talking about a seasoned Unix user (be they…
Sasha
828
votes
24 answers

How can I reverse the order of lines in a file?

I'd like to reverse the order of lines in a text file (or stdin), preserving the contents of each line. So, i.e., starting with: foo bar baz I'd like to end up with baz bar foo Is there a standard UNIX commandline utility for this?
Scotty Allen
  • 12,897
  • 9
  • 38
  • 51
818
votes
25 answers

How can I copy the output of a command directly into my clipboard?

How can I pipe the output of a command into my clipboard and paste it back when using a terminal? For instance: cat file | clipboard
Legend
  • 113,822
  • 119
  • 272
  • 400
802
votes
7 answers

How to display line numbers in 'less' (GNU)

What is the command to make less display line numbers in the left column?
Alex. S.
  • 143,260
  • 19
  • 55
  • 62
796
votes
29 answers

How to determine the current interactive shell that I'm in (command-line)

How can I determine the current shell I am working on? Would the output of the ps command alone be sufficient? How can this be done in different flavors of Unix?
josh
  • 13,793
  • 12
  • 49
  • 58