Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Okay, one part of my question is good summarized by chrism01.
Thank you.
But my main question is still missing:
If in the path /usr/bin/ps the file respectively command "ps" could be found, I want to see the source code of "ps".
How I can get it in linux ? It is still open source ;-)
How can I see the program lines of this command and where is this command located in the structure ?
There's several possible ways to interpret this.
The above answers assume you're referring to reading long output, and other interpretations might suggest pstree, or type -a ps, or other things.
I'm wondering if you're maybe asking how to see the source code of "ps", and how specifically it implements the three options you provided?
Not sure about RHEL, but for Debian, I start by going to the online man page (i.e. //manpages.debian.org/ps), then following the "package tracker" link (in this case it's //tracker.debian.org/procps) and on that page there's a "browse source code" link (where we can see the ps command is written in C, not Bash).
Navigating source code to discover how things are implemented can sometimes be simple and other times be more complex - there's no single approach that always works, and not much point going on if this turns out to not be what you're asking about...
I'm wondering if you're maybe asking how to see the source code of "ps", and how specifically it implements the three options you provided?
Not sure about RHEL, ...
A long time ago that would have been by installing the Source RPM (.srpm) from the repository and examining the resulting files and directories. Either way it is now time to get your money's worth out of your expensive support contract with Red Hat and contact them about RHEL.
If you want to see where it’s located in the filesystem, it’s “which ps”.
By default, "which COMMAND" only searches the path, it ignores aliases and built-ins, and (depending on the version of which used) may or not support the -a/--all option.
Using "type COMMAND" will identify when the command would execute a file or something else - compare "which ls" and "which echo" to "type -a ls" and "type -a echo"; in many cases type will identify echo as a shell builtin and show an alias for ls (in addition to the path to the executable).
As others have noted, it's not clear whether you are interested in the output of ps or it's source code.
There are various ways, but on eg Centos 7.9
Code:
# find it
which ps
/usr/bin/ps
# what filetype is it
file /usr/bin/ps
/usr/bin/ps: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=36fb21d67d92790800dc4212bd9f610602e3dc08, stripped
so its a binary executable and (most likely) written in C.
As above if you're on RHEL as per your sig, you could install the SRPM (source RPM), but the code is likely complex.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.