Questions tagged [source]

Everything that includes the source code of Unix programs for example compiling, installing or how to retrieve the code for studying.

Unix programmers have a long lasting tradition of sharing and exchanging source codes. An important number of tools and application are commonly published under Free Software and/or Open Source licenses, making the necessity to develop some conventions and standards in publishing source code.

Tarballs

Source code is generally distributed as a compressed archive. The most common compression method are and bzip2 (a slower but more effective compression algorithm). The packaged archives are referred to as tarballs. Commonly, here are the filename extension used in naming conventions:

  • .tar.gz and.tgz signaling gzip compression
  • .tar.bz2, .tbz, .tbz2 and .tb2 signaling bzip2 compression.

Here's how to extract the source code from the tarball:

On

tar xvzf foo.tar.gz

tar xvjf foo.tar.bz2

On

gzcat foo.tar.gz | tar xv

bzcat foo.tbz2 | tar xv

A common case: Autotools

The GNU build system (sometimes referred to as autotools, because it includes tools like autoconf or automake) is by far the most common format of Unix-source packages. Here's the most basic use-case to install an autotools package from source:

  • ./configure --prefix=/path

The configure script will detect the tools installed in the user's environment and will generate the Makefile (and other scripts) accordingly. The option --prefix=/path will define the target install directory (if nothing is specified it will use /usr/local by default). More options may be available and can generally be consulted with ./configure --help.

  • make

    This command will compile the code into binaries by calling the tool. It can optionally take specific targets as arguments and/or options.

  • make install

    This command will install the compiled code into the target directory (/usr/local by default). Depending on the user's permission on the directory, it may need to be executed with permissions.

Publicly available Source Control systems

Another form of source code distribution is setting up a publicly available source repository. Some projects make the latest developments of the code available this way. For instance:

Git

git clone http://url-to-git-repo

SVN

svn co http://url-to-svn-repo proj-trunk
344 questions
378
votes
7 answers

How can I find the implementations of Linux kernel system calls?

I am trying to understand how a function, say mkdir, works by looking at the kernel source. This is an attempt to understand the kernel internals and navigate between various functions. I know mkdir is defined in sys/stat.h. I found the…
Navaneeth K N
  • 3,988
  • 3
  • 17
  • 13
117
votes
16 answers

How to determine the path to a sourced tcsh or bash shell script from within the script

Is there a way for a sourced shell script to find the path to itself? I'm mainly concerned with bash, though I have some coworkers who use tcsh. I'm guessing I may not have much luck here since sourcing causes commands to be executed in the current…
Cascabel
  • 1,611
  • 2
  • 12
  • 15
83
votes
6 answers

Which file compression software for Linux offers the highest size reduction for source code?

I do a ton of file compression. Most of the stuff I am compressing is just code, so I need to use lossless compression. I wondered if there was anything that offers a better size reduction than 7zip. It doesn't matter how long it takes to compress…
Zach
  • 961
  • 1
  • 7
  • 5
67
votes
5 answers

What is the difference between building from source and using an install package?

I was wondering: when installing something, there's an easy way of double clicking an install executable file, and on the other hand, there is a way of building it from source. The latter one, downloading a source bundle, is really cumbersome. But…
kwagjj
  • 2,309
  • 6
  • 22
  • 29
66
votes
8 answers

Why does Bash's source not need the execution bit?

With Bash's source it is possible to execute a script without an execution bit set. This is documented and expected behaviour, but isn't this against the use of an execution bit? I know, that source doesn't create a subshell.
Motte001
  • 1,210
  • 3
  • 10
  • 20
55
votes
5 answers

How to compile and install programs from source

This is an issue that really limits my enjoyment of Linux. If the application isn't on a repository or if it doesn't have an installer script, then I really struggle where and how to install an application from source. Comparatively to Windows, it's…
Nitrodist
  • 735
  • 1
  • 7
  • 10
51
votes
8 answers

Where does uname get its information from?

Where does uname really get its information from? I figure this is something that should be straightforward. Unfortunately, I can't find any header containing just that information. Say someone wanted to change the basic output of uname/uname -s …
user237251
  • 690
  • 1
  • 6
  • 5
37
votes
6 answers

Where to download Linux Kernel source code of a specific version?

Is there a resource to download a specific kernel version source? For example, I want to get 2.6.36.2 sources to compare with this package and see what changes were introduced?
RaoulDuke
  • 371
  • 1
  • 3
  • 3
36
votes
2 answers

Why are there no -dev packages in Arch Linux?

I understand that source based distributions like Gentoo or Slackware do not need *-dev versions of programs. They include the source code as well as header files for compiling everything locally. But I never saw *-dev packages in Arch Linux,…
Sebastian
  • 8,677
  • 4
  • 39
  • 49
36
votes
10 answers

Why are programs not distributed in compiled format?

But they give instructions like cd downloaded_program ./configure make install This creates the ELF that is needed, and probably some .so files. Why not put those inside a zip file for download, like with windows apps? Is there any reason why they…
kitty
  • 417
  • 4
  • 3
29
votes
5 answers

Given a git commit hash, how to find out which kernel release contains it?

Assume I have some issue that was fixed by a recent patch to the official Linux git repository. I have a work around, but I’d like to undo it when a release happens that contains my the fix. I know the exact git commit hash, e.g.…
Joachim Breitner
  • 1,347
  • 2
  • 16
  • 25
27
votes
1 answer

What does a kernel source tree contain? Is this related to Linux kernel headers?

In books, I typically read references to the Linux Source Tree at /usr/src/linux with the usual set of subdirectories (arch, block, crypto, ...). I was expecting this tree to contain the binary files making up the kernel. In my system (Ubuntu…
gnometorule
  • 435
  • 1
  • 4
  • 9
25
votes
5 answers

Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?

Both Linux and BSD have common programs like ls and cat and echo and kill. Do they come from the same source code, or do both and Linux and BSD own their own unique source code for these programs?
user341875
  • 259
  • 3
  • 3
25
votes
3 answers

Passing variables to a bash script when sourcing it

Suppose I have in main.sh: $NAME="a string" if [ -f $HOME/install.sh ] . $HOME/install.sh $NAME fi and in install.sh: echo $1 This is supposed to echo "a string", but it echoes nothing. Why?
24
votes
4 answers

Completely restart Bash

Is there a way to completely restart Bash and reload .bashrc and .profile and the like? I'd like to make sure my changes worked out properly after editing these files.
Naftuli Kay
  • 38,686
  • 85
  • 220
  • 311
1
2 3
22 23