Is it possible to access source code or a config file of a terminal command, to read how it works and even customize it on local computer? [duplicate]

Quick Answer:

Research the terminal command.

There's no absolute set rule of where the variables or details are stored. If you don't know the details of a terminal command, you'll have to look it up to be sure.

Most terminal commands, especially the commands that have lots of options, have manuals that are installed on the system by default, which makes this looking up easy. That also includes the shell for the terminal commands which in the case of Ubuntu is bash by default.

Before the internet was so popular for performing the not knowing that you refer to, people relied much on the libraries, books, and manuals. People had many books and manuals in their home. The went to the bookstore and library often. I used to spend many hours in the library, almost always had two or three books checked out for home research (or programming and commands). It's been around 20 years since I went to the library to do research. I do from time to time go to the library for some seminars, or meetings. I also belonged to two computer clubs, who shared information. Both clubs published monthly newsletters which included important computer and programming information.

If you don't have access to the Internet you can use the manuals that are already your computer for the terminal commands.

Thank of a terminal command and type this:

$ man [terminal command]

You can research bash and the import command (from your question) with:

$ man bash
$ man import

Both manuals will show you lots of information that you can research without the internet. They also include a glossary which you can use words from those manuals to do further research.

To know the details of the variables of a command, you'd have to research the particular command. Some of the same commands might even have various flavors or variations which might store some of it's variable or details in a different area depending on the Linux distribution or the maintainer of the specific command.

How to download the source code of Ubuntu's commands and applications:

You can download the source code of the commands by adding the source to your repository. You can find this by:

  • Goto Software & Updates ->
  • (click on the tab) Ubuntu Software ->
  • (put a check mark on) Source code

    Use this command to get the source package you want to download:

    $ sudo apt source <package name>
    

  • Ubuntu actually uses gnome-screenshot, not import (at least on 14.04). How did I figure that out? Well first of all, import is quite old, so that tipped me off. But also...

    • man -k can be used to search the descriptions of terminal commands.

      I looked for some keywords related to screenshots, like "screenshot", "capture", "screencap", etc. Depending on the search term, this either brought up a few items or way too many. I saw a few commands keep coming up, mostly gnome-screenshot and shutter (which I installed).

      Where we're dealing with the GUI, it could also help to search the application files, e.g:

      find /usr/share/applications/ ~/.local/share/applications/ -iname "*screenshot*"
      grep -i "screenshot" /usr/share/applications/*.desktop ~/.local/share/applications/*.desktop
      
    • I opened gnome-system-monitor, sorted by Started, and watched to see if a command popped up when I took a screenshot. That's when I confirmed it was gnome-screenshot

      On the command line, you could use

      watch "ps -ef --sort=start_time | tail"