how to see or view the code of various linux commands
There is many ways to find the source code of packages that provide you commands.
You can go to https://src.fedoraproject.org/projects/rpms/* and search for the package you are interested in.
Today, most code is somehow available on github and gitlab. Just search the internet for “ source code”
If you want to clone, edit, and merge code you should make use of git.
I see you are an enthusiast eager to learn Linux!
That’s awesome … don’t forget to keep things in context (This is a place to ask about “Fedora”). But since Fedora is Linux, let’s see:
If you want to be viewing “source code” for commands, then go to the repository maintained by the developer for that command. Here is an example:
You know about
dnf? You can see the source code of the popular package manager in Fedora. How? First find out where the code lives:
sudo dnf info dnf
Installed Packages Name : dnf Version : 4.2.21 Release : 1.fc33 Architecture : noarch Size : 1.7 M Source : dnf-4.2.21-1.fc33.src.rpm Repository : @System From repo : schemed-rawhide Summary : Package manager URL : https://github.com/rpm-software-management/dnf License : GPLv2+ and GPLv2 and GPL Description : Utility that allows users to manage packages on their systems. : It supports RPMs, modules and comps groups & environments.
Take a look at the
URL in that output. That is where
dnf’s source code lives.
Have fun looking at the source codes of commands in Fedora.
You can also get the exact source code that was used to built your software by using
dnf to download the source version of a package instead of the compiled one.
dnf download <a package> --source
which will download a
.src.rpm file - the source package, which contains the source files as well as a file with instructions to the system on how to build it. Check out this article for details - if you’re interested, it also explains how to actually build the package from the src.rpm you downloaded.