Linux: Acquiring Source Code

From BS Wiki
Revision as of 16:32, 27 May 2021 by Bs (talk | contribs)
Jump to navigation Jump to search


See Linux: Compiling and Installing Source Code from the Terminal for compiling and installing.

Acquiring Source Code in Ubuntu (Hirsute)

  1. Update/enable the source package URLs. Note that in Ubuntu, these should already be in the sources.list file and just need to be uncommented. i.e. remove the "#" from the deb-src lines.
    sudo gedit /etc/apt/sources.list
    An example line might look like this:
    deb-src http://us.archive.ubuntu.com/ubuntu/ hirsute main restricted
  2. Update the new package information that was added in step 1.
    sudo apt-get update
  3. Navigate to the directory that the source code will reside in, and download it.
    Example for downloading the source code for the grep utility
    sudo apt-get source grep
    Example for downloading the source code for bash
    sudo apt-get source bash
  4. There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
    If the directory doesn't exist, run this command on the .dsc file acquired from step 3 above:
    dpkg-source -x yourfile.dsc
    If you get an error message that dpkg-source can not be found, install the package:
    sudo apt install dpkg-dev


Acquiring Source Code in Mint 20.1 Cinnamon

  1. Bring up the Software Sources
    Menu Button -> Administration -> Software Sources
  2. Toggle the "Source code repositories" button to enabled state, under Optional Sources
  3. Press the OK button
  4. Navigate to the directory that the source code will reside in, and download it.
    Example for downloading the source code for the grep utility
    sudo apt-get source grep
    Example for downloading the source code for bash
    sudo apt-get source bash
  5. There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
    If the directory doesn't exist, run this command on the .dsc file acquired from step 4 above:
    dpkg-source -x yourfile.dsc
    If you get an error message that dpkg-source can not be found, install the package:
    sudo apt install dpkg-dev