automated terminal push
All checks were successful
code.softwareshinobi.com-learn/docker.softwareshinobi.com/pipeline/head This commit looks good

This commit is contained in:
2025-06-04 11:50:30 -04:00
parent 5770800032
commit f1997cab0f
195 changed files with 12169 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
# The `ps` command
The `ps` command is used to identify programs and processes that are running on the system and the resources they are using.
Its frequently [pipelined](<https://en.wikipedia.org/wiki/Pipeline_(Unix)>) with other commands like `grep` to search for a program/process or `less`
so that the user can analyze the output one page at a time.
Let's say you have a program like openshot which is notorious for hogging system resources when exporting a video, and you want to close it, but the GUI has become unresponsive.
### Example
1. You want to find the PID of openshot and kill it.
```
ps aux | grep openshot
kill - <openshot PID>
```
2. To Show all the running processes:
```
ps -A
```
### Syntax
`ps [options]`
When run without any options, it's useless and will print: `CMD` - the executable processes/(program) running, their `PID` - process ID, `TTY` - terminal type and `Time` - How long the process has utilized the CPU or thread.
### Common Option
If you are going to remember only one thing from this page let it be these three letter `aux`:
`a` - which displays all processes running, including those being run by other users.
`u` - which shows the effective user of a process, i.e. the person whose file access permissions are used by the process.
`x` - which shows processes that do not have a `TTY` associated with them.
### Additional Options:
|**Option** |**Description** |
|:---|:---|
|`a`|Shows list all processes with a terminal (tty)|
|`-A`|Lists all processes. Identical to `-e`|
|`-a`|Shows all processes except both session leaders and processes not associated with a terminal|
|`-d`|Select all processes except session leaders|
|`--deselect`|Shows all processes except those that fulfill the specified conditions. Identical to `-N`|
|`-e`|Lists all processes. Identical to `-A`|
|`-N`|Shows all processes except those that fulfill the specified conditions. Identical to `-deselect`|
|`T`|Select all processes associated with this terminal. Identical to the `-t` option without any argument|
|`r`|Restrict the selection to only running processes|
|`--help simple`|Shows all the basic options|
|`--help all`|Shows every available options|
Another useful command which give a realtime snapshot of the processes and the resources they are using about every ten seconds is `top`.

View File

@@ -0,0 +1,89 @@
# The `kill` command
`kill` command in Linux (located in /bin/kill), is a built-in command which is used to terminate processes manually. The `kill` command sends a signal to a process which terminates the process. If the user doesnt specify any signal which is to be sent along with kill command then default _TERM_ signal is sent that terminates the process.
Signals can be specified in three ways:
- **By number (e.g. -5)**
- **With SIG prefix (e.g. -SIGkill)**
- **Without SIG prefix (e.g. -kill)**
### Syntax
```
kill [OPTIONS] [PID]...
```
### Examples:
1. To display all the available signals you can use below command option:
```
kill -l
```
2. To show how to use a _PID_ with the _kill_ command.
```
$kill pid
```
3. To show how to send signal to processes.
```
kill {-signal | -s signal} pid
```
4. Specify Signal:
- using numbers as signals
```
kill -9 pid
```
- using SIG prefix in signals
```
kill -SIGHUP pid
```
- without SIG prefix in signals
```
kill -HUP pid
```
### Arguments:
The list of processes to be signaled can be a mixture of names and PIDs.
pid Each pid can be expressed in one of the following ways:
n where n is larger than 0. The process with PID n is signaled.
0 All processes in the current process group are signaled.
-1 All processes with a PID larger than 1 are signaled.
-n where n is larger than 1. All processes in process group n are signaled.
When an argument of the form '-n' is given, and it is meant to denote a
process group, either a signal must be specified first, or the argument must
be preceded by a '--' option, otherwise it will be taken as the signal to
send.
name All processes invoked using this name will be signaled.
### Options:
-s, --signal signal
The signal to send. It may be given as a name or a number.
-l, --list [number]
Print a list of signal names, or convert the given signal number to a name. The
signals can be found in /usr/include/linux/signal.h.
-L, --table
Similar to -l, but it will print signal names and their corresponding numbers.
-a, --all
Do not restrict the command-name-to-PID conversion to processes with the same UID
as the present process.
-p, --pid
Only print the process ID (PID) of the named processes, do not send any signals.
--verbose
Print PID(s) that will be signaled with kill along with the signal.

View File

@@ -0,0 +1,129 @@
# The `killall` command
`killall` sends a signal to **all** processes running any of the specified commands. If no signal name is specified, `SIGTERM` is sent. In general, `killall` command kills all processes by knowing the name of the process.
Signals can be specified either by name (e.g. `-HUP` or `-SIGHUP`) or by number (e.g. `-1`) or by option `-s`.
If the command name is not a regular expression (option `-r`) and contains a slash (`/`), processes executing that particular file will be selected for killing, independent of their name.
`killall` returns a zero return code if at least one process has been killed for each listed command, or no commands were listed and at least one process matched the `-u` and `-Z` search criteria. `killall` returns non-zero otherwise.
A `killall` process never kills itself (but may kill other `killall` processes).
### Examples:
1. Kill all processes matching the name `conky` with `SIGTERM`:
```sh
killall conky
# OR
killall -SIGTERM conky
# OR
kilall -15 conky
```
I was able to kill Wine ( which are Windows exe files running on Linux ) applications this way too.
```sh
killall TQ.exe
```
2. List all the supported signals:
```sh
$ killall -l
HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT
CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS
```
As for the numbers.
```sh
$ for s in $(killall -l); do echo -n "$s " && kill -l $s; done
HUP 1
INT 2
QUIT 3
ILL 4
TRAP 5
ABRT 6
BUS 7
FPE 8
KILL 9
USR1 10
SEGV 11
USR2 12
PIPE 13
ALRM 14
TERM 15
STKFLT 16
CHLD 17
CONT 18
STOP 19
TSTP 20
TTIN 21
TTOU 22
URG 23
XCPU 24
XFSZ 25
VTALRM 26
PROF 27
WINCH 28
POLL 29
PWR 30
SYS 31
```
3. Ask before killing, to prevent unwanted kills:
```sh
$ killall -i conky
Kill conky(1685) ? (y/N)
```
4. Kill all processes and wait until the processes die.
```sh
killall -w conky
```
5. Kill based on time:
```sh
# Kill all firefox younger than 2 minutes
killall -y 2m firefox
# Kill all firefox older than 2 hours
killall -o 2h firefox
```
### Syntax:
```sh
killall [OPTION]... [--] NAME...
killall -l, --list
killall -V, --version
```
### Additional Flags and their Functionalities:
|**Short Flag** |**Long Flag** |**Description** |
|:---|:---|:---|
|`-e`|`--exact`|require an exact match for very long names|
|`-I`|`--ignore-case`|case insensitive process name match|
|`-g`|`--process-group`|kill process group instead of process|
|`-y`|`--younger-than`|kill processes younger than TIME|
|`-o`|`--older-than`|kill processes older than TIME|
|`-i`|`--interactive`|ask for confirmation before killing|
|`-l`|`--list`|list all known signal names|
|`-q`|`--quiet`|don't print complaints|
|`-r`|`--regexp`|interpret NAME as an extended regular expression|
|`-s`|`--signal SIGNAL`|send this signal instead of SIGTERM|
|`-u`|`--user USER`|kill only process(es) running as USER|
|`-v`|`--verbose`|report if the signal was successfully sent|
|`-w`|`--wait`|wait for processes to die|
|`-n`|`--ns PID`|match processes that belong to the same namespaces as PID
|`-Z`|`--context`|REGEXP kill only process(es) having context (must precede other arguments)
### Related commands
[kill](/ebook/en/content/034-the-kill-command.md), `pidof`

View File

@@ -0,0 +1,18 @@
# The `nohup` command
When a shell exits (maybe while logging out of an SSH session), the HUP ('hang up') signal is send to all of its child processes, causing them to terminate. If you require a long-running process to continue after exiting shell, you'll need the `nohup` command. Prefixing any command with `nohup` causes the command to become _immune_ to HUP signals. Additionally, STDIN is being ignored and all output gets redirected to local file `./nohup.out`.
### Examples:
1. Applying nohup to a long-running debian upgrade:
```
nohup apt-get -y upgrade
```
### Syntax:
```
nohup COMMAND [ARG]...
nohup OPTION
```