- About
- Usage
- Media
- Contribute
- LICENSE
Description of and information about this project.
List integer PIDS (process identification numbers) from the '/proc' directory in Linux (and Android - Termux) with some formatting options.
I do a lot with pids across all operating systems (as with most computer oriented people) and I often need a quick list or array of said pids with various formatting and this program provides these features in a quick and simple manner.
When, where, and how to use this program.
This is an open-source (FOSS) command line utility for use in Linux and Android shells (terminals/ttys/Termux/etc.). This can be built from source (as per the LICENSE file provided), used portably (single executable put wherever you like), or installed via the provided Debian (.deb) package.
The recommended method of use is via the Debian package installation for the Debian (apt, deb) packager manager, but there are other methods provided here or if you would care to provide an installer for a different package manager then please fork this project, build the appropriate workflow and source files, and make a pull-request. More information about contributing here.
All currently built and released files can be found at the releases page:
This information is generated in a GitHub Action immediately after the successful build of this project.
Code Factor IO grade from combined source files and workflow scripts in this project (currently 7 files).
I personally recommend this method as it automatically installs a basic Bash Completion file, a hicolor icon theme, and a man page entry.
- Download and install the current .deb installer file at the releases page.
- Use one of various command line tools to install the package:
- APT
sudo apt install /path/to/lspids-1.0.0.deb -y # -y to skip affirmation, not necessary
- DPKG
sudo dpkg -i /path/to/lspids-1.0.0.deb
- GDEBI
gdebi-gtk /path/to/lspids-1.0.0.deb # or sudo gdebi /path/to/lspids-1.0.0.deb
The deb installer provides a few features (among providing a way to cleany install and uninstall all features):
The Bash Completion File provides basic Bash completion for switches and parameters and is installed to /usr/share/bash-completion/completions/lspids
when installed with the deb package.
More infomation can be found here:
The deb package installer provide an icon theme for HiColor in case you want to make a .desktop shortcut or anything else. Icons are installed to /usr/share/icons/hicolor/{16,32,48,64,128,256}/apps/lspids.png
.
The manual page is a more advanced verion of a Help Message and can be accessed from the command line via: man lspids
.
$ man lspids
...
NAME
lspids - List PIDS from the `/proc' directory in Linux
SYNOPSIS
lspids [OPTIONS [PARAMETER]]...
DESCRIPTION
List integer PIDS from the `/proc' directory in Linux with some formatting options.
OPTIONS
-h, –help
This HELP message.
-0, –null
Output is null terminated. If this switch is enabled before delimiter is set then you can still delimiter the output.
-d, –delim
Set a string delimiter to separate output. Defaults to a new line, but can be any string.
EXIT CODES
0 No errors.
1 Too many options passed to the program.
2 `/proc' doesn’t exist.
3 `/proc' is not a directory.
4 Could not iterate `/proc' for an unknown reason.
5 No option provided for the given argument.
AUTHORS
Ian Pride.
lspids - 1.0.0 Sat 09 Jul 2022 07:51:17 PM UTC LSPIDS(1)
You can use this portably by downloading the lspids
executable bin file from the releases page and putting it anywhere you like; most preferably in one of your $PATH
(echo $PATH
) directories.
As with any executable file in most operating systems if this is not installed to $PATH
then you must provide the full path when you run it. If it is in your $PATH
then you can just run it with the file name.
# In $PATH
$ lpsids --help
# Not in $PATH
$ /full/or/relative/path/to/lspids --help
The Android executables (.arm32 and .aarch64) are portable and should probably be installed to /data/data/com.termux/files/usr/bin/lspids
(removing the extensions if you like) and you must have root access. I plan to build a deb installer in the future.
You can, of course, build this yourself the from source located in the linux directory of this repository. You can download the whole project in a compressed archive from the current releases page.
Extract the project to wherever you want to build:
tar -xvzf /path/to/lspids-1.0.0.tar.gz -C /path/to/where/you/want/to/build
I created and use a custom Makefile system not reliant on CMAKE and only reliant on GNU++17/MAKE, but it shouldn't be too hard to figure out. I build objects from src/include
to a lib archive src/lib
in and build with -Lsrc/lib
and -llib<BIN NAME>.a
.
All packages you will need to build this:
make, g++[4:9,gnu++17], build-essential, binutils
which you can install in with APT in a Debian based system:
sudo apt install make g++ build-essential binutils -y
Run make first to test; no ./configure:
make
and if successful; install and clean (need to fix the regular and all build):
sudo make releasedynamicall install && sudo make clean
Bash completion can be provided by placing the lspids Bash completion file to /usr/share/bash-completion/completions
. This is already done if installed with a package manager.
lspids Bash Completion File:
lspids_list=(
-h --help
-0 --null
-d --delim
)
complete -W "$(printf '%s\n' "${lspids_list[@]}")" lspids
$ lspids --help
┌────────────────────────────────────────────────┐
│ lspids - 'List PIDS' │
├────────────────────────────────────────────────┤
│ Usage: lspids [OPTIONS [PARAMETER]]... │
│ List integer PIDS from the '/proc' directory │
│ in Linux. │
├────────────────────────────────────────────────┤
│ OPTIONS: switches and arguments │
│ -h,--help This HELP message. │
│ -0,--null Output is null terminated. If │
│ this switch is enabled before │
│ delimiter is set then you can │
│ still delimiter the output. │
│ -d,--delim Set a string delimiter to │
│ separate output. Defaults to a │
│ new line, but can be any │
│ string. │
├────────────────────────────────────────────────┤
│ Exit Codes: Error codes and their meanings. │
│ 0 No errors. │
│ 1 Too many options passed to the │
│ program. │
│ 2 '/proc' doesn't exist. │
│ 3 '/proc' is not a directory. │
│ 4 Could not iterate '/proc' for an unknown │
│ reason. │
│ 5 No option provided for the given │
│ argument. │
└────────────────────────────────────────────────┘
$ lspids
...
1641
1655
1665
1666
1667
1691
1697
1701
1703
...
$
$ lspids -0 # or --null
...241 247 251 252 253 260 274 275 323 343 344 349 357 362 379 390 391 392 393 429 430 433 461 462 494 535 536 537 538 539 540 541 542 544 545 548 574 575 576 577 589 631 798 812 834 838 839 847 848 849 850 851 852 853 854 855 856 857 858 911 916 917 918 944 958 959 960 963 1004 1005 1009 1011 1015 1016 1017... $
$ lspids -d $'\t'
...2160 2162 2163 2173 2175 2179 21962198 2206 2209 2221 2222 2223 2230 2235 2249 2272 2284 2656 2687 2708 2710 27122717 2725 2734 2738 2744 2754 2756 2769 2772 2774 2776 2778 2786 2795 2800 28052824 2828 2831 2843 2850 2854 2863 2880 2901 2904 2915 2951 3007 3012 3023 30303051 3056 3100 3128 3129 3130 3131 3132 3133 3137 3138 3142 3144 3149 3151 31543156 3158 3293 3691 3695 3698 3708 3719 3837 3841...
$
Ways you can help if you like.
You can fork this project, make your contributions, and make a pull-request.
If you like this project and care to donate to my PayPal:
Or Buy Me A Coffee if your prefer:
License Excerpt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.