Skip to content

Commit

Permalink
preparing for ebook publishing 📗
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed Feb 10, 2019
1 parent 792ebad commit 8bcad13
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 150 deletions.
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,51 @@
"RNFR",
"RNTO",
"Remisa",
"Shellman",
"Yousefvand",
"abcdefg",
"backmatter",
"busybox",
"chmod",
"codename",
"czvf",
"distro",
"dockerd",
"elif",
"epub",
"esac",
"frontmatter",
"glibc",
"gmail",
"icanhazip",
"ifconfig",
"ipecho",
"ipify",
"ipinfo",
"ksoftirqd",
"kthreadd",
"kworker",
"lscpu",
"mainmatter",
"maxdepth",
"meminfo",
"mkdir",
"mobi",
"mtime",
"multiline",
"mylib",
"pagebreak",
"pgrep",
"renice",
"sched",
"setaf",
"shellman",
"shellmen",
"sitm",
"sonatype",
"subarray",
"systemctl",
"systemd",
"tput",
"uname",
"vmlinuz",
Expand Down
1 change: 1 addition & 0 deletions manuscript/Book.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion manuscript/ns/command.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi

### nice

Run a command with modified scheduling priority. Niceness values range from `-20` (most favorable to the process) to `19` (least favorable to the process) and default value is `10`.
Run a command with modified scheduling priority. Niceness values range from `-20` (highest priority) to `19` (lowest priority) and default value is `0`.

```bash
#!/usr/bin/env bash
Expand All @@ -61,6 +61,18 @@ sudo nice -n 19 cp ~/file ~/tmp

In above example we are copying a file from *home* to *tmp* folder, and schedule minimum CPU time to `cp`.

### renice

Change a running process priority. Niceness values range from `-20` (highest priority) to `19` (lowest priority) and default value is `0`.

```bash
#!/usr/bin/env bash

sudo renice -n -5 -p `pgrep dockerd`
```

In above example we are changing priority of `dockerd` process (docker daemon on a system where docker is installed) to higher than normal.

### if cmd exists {#cmd-exist}

Check if a desired command exists (program is installed).
Expand Down
43 changes: 43 additions & 0 deletions manuscript/ns/process.md
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.
Loading

0 comments on commit 8bcad13

Please sign in to comment.