-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
792ebad
commit 8bcad13
Showing
6 changed files
with
225 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ ns/ftp.md | |
ns/file.md | ||
ns/color.md | ||
ns/format.md | ||
ns/process.md | ||
ns/system.md | ||
ns/git.md | ||
ns/misc.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## process | ||
|
||
Contains `Process` related information and operations. | ||
|
||
### list | ||
|
||
List all system processes. | ||
|
||
```bash | ||
#!/usr/bin/env bash | ||
|
||
ps -A | ||
# PID TTY TIME CMD | ||
# 1 ? 00:00:03 systemd | ||
# 2 ? 00:00:00 kthreadd | ||
# 3 ? 00:00:01 ksoftirqd/0 | ||
# 5 ? 00:00:00 kworker/0:0H | ||
# 7 ? 00:01:46 rcu_sched | ||
# ... | ||
``` | ||
|
||
### ID | ||
|
||
Get process ID by its name. Many Linux commands need *process id* (PID). | ||
|
||
```bash | ||
#!/usr/bin/env bash | ||
|
||
firefoxPID=`pgrep firefox` | ||
echo $firefoxPID | ||
``` | ||
|
||
### Kill | ||
|
||
Kill a process by its name. `kill` command needs a *PID* (process ID) which we can find by `pgrep` command via [command substitution](#command-substitution). | ||
|
||
```bash | ||
#!/usr/bin/env bash | ||
|
||
sudo kill -9 `pgrep firefox` | ||
``` | ||
|
||
In above example we find *firefox* `PID` and pass it to `kill` command. Here `-9` is a switch of `kill` command (kill signal). You can see a list of all signals by typing `kill -l` in terminal. |
Oops, something went wrong.