Linux shell source code

Read the Source Code of Shell Commands on Linux

To read the source code of shell commands on Linux, you can use the command line utility cat or less to view the file. You can also use a text editor such as vi, nano, or emacs to open and edit the code.

For example, to view the source code of the ls command, you can use the command −

If you want to view the source code of a command that is installed from a package manager, you can use package manager command to find the location of the source code. For example, on a Debian-based system, you can use the command −

This will list the files included in the package, and you can then navigate to the appropriate file to view the source code.

You can also use the command find to locate the source code of command, for example −

This will search your entire file system for a file named ls, and display its location.

Please note that Some commands may not have a source code, they are built in the shell or are binary files, in those cases you can use the command strings or objdump to see some of the code that the command is using.

Find the Source Code

To find the source code of a particular program, there are several methods you can try −

Check the official website of the program or project. Many open-source programs have their source code available for download on their official website.

Search for the program on GitHub, GitLab, or other code hosting platforms. Many open-source programs are hosted on these platforms, and you can easily find and download the source code.

Use package manager command, like apt-get source, yumdownloader, dnf download etc depends on the Linux distribution. These commands will download the source code of the package for you.

Check for the source code in the program’s documentation. Some programs include links to their source code in their documentation.

Use a search engine to find the source code. You can search for the program’s name followed by the keywords «source code» or «github» to find the source code.

It’s worth noting that some software is closed-source, and the source code is not publicly available. In this case, you will not be able to find the source code.

Use the Package Manager

To use a package manager to find and download the source code of a program, you will first need to know the name of the package that the program is contained in. Once you know the package name, you can use the package manager command to download the source code.

Here are some examples of how to use a package manager to download the source code of a program on different Linux distributions −

Читайте также:  Linux manjaro nvidia drivers

On Debian-based systems (such as Ubuntu), you can use the command apt-get source to download the source code of a package. For example, to download the source code of the ls command, you would use the command −

On Fedora, Red Hat and CentOS systems, you can use the command yumdownloader —source to download the source code of a package. For example, to download the source code of the ls command, you would use the command −

yumdownloader --source coreutils

On Arch Linux-based systems, you can use the command pacman -S —needed base-devel to install the base development package, and then yaourt -S —aur to download the source code of a package.

On OpenSuse systems, you can use the command zypper source-install to download the source code of a package.

It’s worth noting that some packages may not have the source code available, in that case you will get an error message.

Also it’s good to note that before installing or building the source code, make sure you have the necessary dependencies and development tools installed on your system.

Debian-Based Systems

On Debian-based systems (such as Ubuntu, Mint, Debian, etc), you can use the apt-get command to download the source code of a package. The apt-get source command will download the source code of a package and all of its dependencies.

Here’s an example of how to use the apt-get command to download the source code of the ls command on a Debian-based system −

This command will download the source code of the package coreutils which includes ls command, and all of its dependencies. The source code will be downloaded to the current working directory, and will be in the form of a .tar.gz file.

You can also use apt-get build-dep to install the dependencies required to build the package.

You can then extract the source code using the command tar -xzvf .tar.gz, and then navigate to the extracted directory to build and install the package using the command dpkg-buildpackage -us -uc

It’s worth noting that apt-get source command will download the source code of the package in the version that is currently installed on your system. If you want to download a specific version of the package source code, you can use the -t option followed by the version number you want to download.

For example, to download version 8.31 of the coreutils package, you can use the command −

apt-get source -t 8.31-1 coreutils

Also, it’s good to note that you need to have the apt-src package installed on your system to use the apt-get source command.

Red Hat-Based Systems

On Red Hat-based systems (such as Fedora, Red Hat Enterprise Linux, CentOS, etc), you can use the yumdownloader command to download the source code of a package.

Here’s an example of how to use the yumdownloader command to download the source code of the ls command on a Red Hat-based system −

yumdownloader --source coreutils

This command will download the source code of the package coreutils, which includes the ls command, in the form of a .src.rpm file. The downloaded file will be located in the current working directory.

Читайте также:  Aomei backupper linux bootable disk image

You can also use the yum-builddep command to install the dependencies required to build the package.

You can then use the rpmbuild command to extract the source code, and build the package.

It’s worth noting that yumdownloader command will download the source code of the package in the version that is currently installed on your system. If you want to download a specific version of the package source code, you can use the —releasever option followed by the version number you want to download.

For example, to download version 8.31 of the coreutils package, you can use the command −

yumdownloader --releasever=8.31 --source coreutils

Also, it’s good to note that you need to have the yum-utils package installed on your system to use the yumdownloader command.

Conclusion

To find and download the source code of a program on Linux, you can use the package manager command that corresponds to your Linux distribution. On Debian-based systems, you can use the apt-get source command, and on Red Hat-based systems, you can use the yumdownloader —source command.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Unofficial mirror of bash repository. Updated daily.

License

bminor/bash

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README

Introduction ============ This is GNU Bash, version 5.2. Bash is the GNU Project's Bourne Again SHell, a complete implementation of the POSIX shell spec, but also with interactive command line editing, job control on architectures that support it, csh-like features such as history substitution and brace expansion, and a slew of other features. For more information on the features of Bash that are new to this type of shell, see the file `doc/bashref.texi'. There is also a large Unix-style man page. The man page is the definitive description of the shell's features. See the file POSIX for a discussion of how the Bash defaults differ from the POSIX spec and a description of the Bash `posix mode'. There are some user-visible incompatibilities between this version of Bash and previous widely-distributed versions, bash-4.4, bash-5.0, and bash-5.1. For details, see the file COMPAT. The NEWS file tersely lists features that are new in this release. Bash is free software, distributed under the terms of the [GNU] General Public License as published by the Free Software Foundation, version 3 of the License (or any later version). For more information, see the file COPYING. A number of frequently-asked questions are answered in the file `doc/FAQ'. (That file is no longer updated.) To compile Bash, type `./configure', then `make'. Bash auto-configures the build process, so no further intervention should be necessary. Bash builds with `gcc' by default if it is available. If you want to use `cc' instead, type CC=cc ./configure if you are using a Bourne-style shell. If you are not, the following may work: env CC=cc ./configure Read the file INSTALL in this directory for more information about how to customize and control the build process. The file NOTES contains platform-specific installation and configuration information. If you are a csh user and wish to convert your csh aliases to Bash aliases, you may wish to use the script `examples/misc/alias-conv.sh' as a starting point. The script `examples/misc/cshtobash' is a more ambitious script that attempts to do a more complete job. Reporting Bugs ============== Bug reports for bash should be sent to: bug-bash@gnu.org using the `bashbug' program that is built and installed at the same time as bash. The discussion list `bug-bash@gnu.org' often contains information about new ports of Bash, or discussions of new features or behavior changes that people would like. This mailing list is also available as a usenet newsgroup: gnu.bash.bug. When you send a bug report, please use the `bashbug' program that is built at the same time as bash. If bash fails to build, try building bashbug directly with `make bashbug'. If you cannot build `bashbug', please send mail to bug-bash@gnu.org with the following information: * the version number and release status of Bash (e.g., 2.05a-release) * the machine and OS that it is running on (you may run `bashversion -l' from the bash build directory for this information) * a list of the compilation flags or the contents of `config.h', if appropriate * a description of the bug * a recipe for recreating the bug reliably * a fix for the bug if you have one! The `bashbug' program includes much of this automatically. Questions and requests for help with bash and bash programming may be sent to the help-bash@gnu.org mailing list. If you would like to contact the Bash maintainers directly, send mail to bash-maintainers@gnu.org. While the Bash maintainers do not promise to fix all bugs, we would like this shell to be the best that we can make it. Other Packages ============== This distribution includes, in examples/bash-completion, a recent version of the `bash-completion' package, which provides programmable completions for a number of commands. It's available as a package in many distributions, and that is the first place from which to obtain it. The latest version of bash-completion is always available from https://github.com/scop/bash-completion. If it's not a package from your vendor, you may install the included version. Enjoy! Chet Ramey chet.ramey@case.edu Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.

About

Unofficial mirror of bash repository. Updated daily.

Читайте также:  Узнать имя устройства linux

Источник

Оцените статью
Adblock
detector