1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/README.md

2656 lines
55 KiB
Markdown
Raw Normal View History

2020-04-03 14:47:08 -07:00
![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master)
2020-04-07 08:44:15 -07:00
![Pypi](https://img.shields.io/pypi/v/jc.svg)
2020-04-02 10:55:32 -07:00
2019-10-15 15:06:09 -07:00
# JC
2019-10-17 13:04:34 -07:00
JSON CLI output utility
2019-10-15 15:06:09 -07:00
2020-05-21 11:10:00 -07:00
`jc` JSONifies the output of many CLI tools and file-types for easier parsing in scripts. See the [**Parsers**](#parsers) section for supported commands and file-types.
2019-10-15 15:06:09 -07:00
2020-05-20 16:14:03 -07:00
This allows further command-line processing of output with tools like `jq` by piping commands:
2020-06-25 21:11:21 -07:00
```bash
ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'
```
2020-06-25 12:28:23 -07:00
```json
2019-10-18 09:57:10 -07:00
{
2019-11-12 11:46:52 -08:00
"filename": "docker",
"flags": "-rwxr-xr-x",
"links": 1,
2019-10-18 09:57:10 -07:00
"owner": "root",
2019-11-12 11:46:52 -08:00
"group": "root",
"size": 68677120,
"date": "Aug 14 19:41"
2019-10-18 09:57:10 -07:00
}
```
2020-02-13 17:24:10 -08:00
or using the alternative "magic" syntax:
2020-06-25 21:11:21 -07:00
```bash
jc ls -l /usr/bin | jq '.[] | select(.size > 50000000)'
2020-06-25 21:12:30 -07:00
```
2020-06-25 12:28:23 -07:00
```json
2020-02-13 17:20:00 -08:00
{
"filename": "docker",
"flags": "-rwxr-xr-x",
"links": 1,
"owner": "root",
"group": "root",
"size": 68677120,
"date": "Aug 14 19:41"
}
```
2020-02-24 13:05:35 -08:00
The `jc` parsers can also be used as python modules. In this case the output will be a python dictionary, or list of dictionaries, instead of JSON:
2020-06-25 12:28:23 -07:00
```python
2019-10-22 07:40:42 -07:00
>>> import jc.parsers.ls
2019-10-25 15:39:48 -07:00
>>>
2019-10-22 07:40:42 -07:00
>>> data='''-rwxr-xr-x 1 root wheel 23648 May 3 22:26 cat
... -rwxr-xr-x 1 root wheel 30016 May 3 22:26 chmod
... -rwxr-xr-x 1 root wheel 29024 May 3 22:26 cp
... -rwxr-xr-x 1 root wheel 375824 May 3 22:26 csh
... -rwxr-xr-x 1 root wheel 28608 May 3 22:26 date
... -rwxr-xr-x 1 root wheel 32000 May 3 22:26 dd
... -rwxr-xr-x 1 root wheel 23392 May 3 22:26 df
... -rwxr-xr-x 1 root wheel 18128 May 3 22:26 echo'''
2019-11-12 11:46:52 -08:00
>>>
2019-10-22 07:40:42 -07:00
>>> jc.parsers.ls.parse(data)
2019-11-12 11:49:14 -08:00
[{'filename': 'cat', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23648,
'date': 'May 3 22:26'}, {'filename': 'chmod', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root',
'group': 'wheel', 'size': 30016, 'date': 'May 3 22:26'}, {'filename': 'cp', 'flags': '-rwxr-xr-x',
'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 29024, 'date': 'May 3 22:26'}, {'filename': 'csh',
'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 375824, 'date': 'May 3
22:26'}, {'filename': 'date', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel',
'size': 28608, 'date': 'May 3 22:26'}, {'filename': 'dd', 'flags': '-rwxr-xr-x', 'links': 1, 'owner':
'root', 'group': 'wheel', 'size': 32000, 'date': 'May 3 22:26'}, {'filename': 'df', 'flags':
'-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 23392, 'date': 'May 3 22:26'},
{'filename': 'echo', 'flags': '-rwxr-xr-x', 'links': 1, 'owner': 'root', 'group': 'wheel', 'size': 18128,
'date': 'May 3 22:26'}]
2019-10-25 15:39:48 -07:00
```
2019-12-17 09:38:50 -08:00
Two representations of the data are possible. The default representation uses a strict schema per parser and converts known numbers to int/float JSON values. Certain known values of `None` are converted to JSON `null`, known boolean values are converted, and, in some cases, additional semantic context fields are added.
2019-11-12 07:18:27 -08:00
2019-11-14 13:43:07 -08:00
To access the raw, pre-processed JSON, use the `-r` cli option or the `raw=True` function parameter in `parse()`.
2019-11-12 07:18:27 -08:00
2020-02-19 07:12:43 -08:00
Schemas for each parser can be found in the [`docs/parsers`](https://github.com/kellyjonbrazil/jc/tree/master/docs/parsers) folder.
2019-10-21 14:13:31 -07:00
2020-03-03 11:37:59 -08:00
Release notes can be found [here](https://blog.kellybrazil.com/category/jc-news/).
2020-06-26 09:53:57 -07:00
## Why Would Anyone Do This!?
2020-05-27 09:52:13 -07:00
For more information on the motivations for this project, please see my [blog post](https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/).
2020-02-14 09:43:02 -08:00
2020-06-26 09:53:57 -07:00
See also:
- [libxo on FreeBSD](http://juniper.github.io/libxo/libxo-manual.html)
- [powershell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertto-json?view=powershell-7)
- [blog: linux apps should have a json flag](https://thomashunter.name/posts/2012-06-06-linux-cli-apps-should-have-a-json-flag)
2019-10-17 15:03:32 -07:00
## Installation
2020-06-27 12:58:59 +03:00
There are several ways to get `jc`. You can install via `pip`; other OS package repositories like `dnf`, `zypper`, `nix-env`, `guix`, `brew`, or `portsnap`; via DEB/RPM packages; or by downloading the correct binary for your architecture and running it anywhere on your filesystem.
2020-04-15 21:22:43 -07:00
2020-04-16 14:03:31 -07:00
### Pip (macOS, linux, unix, Windows)
2020-06-25 12:28:23 -07:00
```bash
pip3 install jc
2019-10-17 15:03:32 -07:00
```
2020-05-27 14:58:16 -07:00
### OS Package Repositories
2020-05-27 17:08:54 -07:00
2020-06-27 18:53:19 -07:00
| OS | Command |
|-----------------------|-------------------------------------------------------------------------------|
| Fedora linux | `dnf install jc` |
2020-06-27 18:53:19 -07:00
| openSUSE linux | `zypper install jc` |
2020-07-01 13:28:58 -07:00
| Arch linux | `pacman -S jc` |
2020-06-27 18:53:19 -07:00
| NixOS linux | `nix-env -iA nixpkgs.jc` |
| Guix System linux | `guix install jc` |
| MacOS | `brew install jc` |
| FreeBSD | `portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean` |
2020-05-27 14:58:16 -07:00
2020-06-27 18:53:19 -07:00
> For more packages and binaries, see https://kellyjonbrazil.github.io/jc-packaging/.
2020-04-15 21:22:43 -07:00
2019-10-15 15:06:09 -07:00
## Usage
2020-02-13 18:19:19 -08:00
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`.
2020-06-25 12:28:23 -07:00
```bash
2020-02-13 17:20:00 -08:00
COMMAND | jc PARSER [OPTIONS]
```
Alternatively, the "magic" syntax can be used by prepending `jc` to the command to be converted. Options can be passed to `jc` immediately before the command is given. (Note: command aliases are not supported)
2020-06-25 12:28:23 -07:00
```bash
2020-02-13 17:20:00 -08:00
jc [OPTIONS] COMMAND
2019-10-21 13:47:22 -07:00
```
2020-02-13 18:19:19 -08:00
The JSON output can be compact (default) or pretty formatted with the `-p` option.
2019-10-15 15:06:09 -07:00
2019-10-22 11:15:44 -07:00
### Parsers
2020-03-10 21:51:02 -07:00
- `--airport` enables the `airport -I` command parser (OSX)
- `--airport-s` enables the `airport -s` command parser (OSX)
2020-02-13 17:20:00 -08:00
- `--arp` enables the `arp` command parser
2020-02-27 21:21:19 -08:00
- `--blkid` enables the `blkid` command parser
2020-02-13 17:20:00 -08:00
- `--crontab` enables the `crontab` command and file parser
2020-02-05 10:58:26 -08:00
- `--crontab-u` enables the `crontab` file parser with user support
2020-03-04 08:30:52 -08:00
- `--csv` enables the `CSV` file parser
2020-02-13 17:20:00 -08:00
- `--df` enables the `df` command parser
- `--dig` enables the `dig` command parser
2020-05-20 16:14:03 -07:00
- `--dmidecode` enables the `dmidecode` command parser
2020-02-13 17:20:00 -08:00
- `--du` enables the `du` command parser
- `--env` enables the `env` command parser
2020-03-11 12:20:58 -07:00
- `--file` enables the `file` command parser
2020-02-13 17:20:00 -08:00
- `--free` enables the `free` command parser
2019-11-15 09:32:12 -08:00
- `--fstab` enables the `/etc/fstab` file parser
2020-03-03 09:36:16 -08:00
- `--group` enables the `/etc/group` file parser
- `--gshadow` enables the `/etc/gshadow` file parser
2020-02-13 17:20:00 -08:00
- `--history` enables the `history` command parser
2019-11-14 21:59:06 -08:00
- `--hosts` enables the `/etc/hosts` file parser
2020-02-13 17:20:00 -08:00
- `--id` enables the `id` command parser
- `--ifconfig` enables the `ifconfig` command parser
2020-02-04 21:44:10 -08:00
- `--ini` enables the `INI` file parser
2020-02-13 17:20:00 -08:00
- `--iptables` enables the `iptables` command parser
- `--jobs` enables the `jobs` command parser
2020-02-27 21:21:19 -08:00
- `--last` enables the `last` and `lastb` command parser
2020-02-13 17:20:00 -08:00
- `--ls` enables the `ls` command parser
- `--lsblk` enables the `lsblk` command parser
- `--lsmod` enables the `lsmod` command parser
- `--lsof` enables the `lsof` command parser
- `--mount` enables the `mount` command parser
- `--netstat` enables the `netstat` command parser
2020-03-10 18:00:26 -07:00
- `--ntpq` enables the `ntpq -p` command parser
- `--passwd` enables the `/etc/passwd` file parser
2020-02-13 17:20:00 -08:00
- `--pip-list` enables the `pip list` command parser
- `--pip-show` enables the `pip show` command parser
- `--ps` enables the `ps` command parser
- `--route` enables the `route` command parser
- `--shadow` enables the `/etc/shadow` file parser
2020-02-13 17:20:00 -08:00
- `--ss` enables the `ss` command parser
- `--stat` enables the `stat` command parser
- `--systemctl` enables the `systemctl` command parser
- `--systemctl-lj` enables the `systemctl list-jobs` command parser
- `--systemctl-ls` enables the `systemctl list-sockets` command parser
- `--systemctl-luf` enables the `systemctl list-unit-files` command parser
2020-03-10 18:37:55 -07:00
- `--timedatectl` enables the `timedatectl status` command parser
2020-02-13 17:20:00 -08:00
- `--uname` enables the `uname -a` command parser
- `--uptime` enables the `uptime` command parser
- `--w` enables the `w` command parser
2020-03-01 17:07:28 -08:00
- `--who` enables the `who` command parser
2020-02-03 22:13:06 -08:00
- `--xml` enables the `XML` file parser
2020-02-03 21:38:08 -08:00
- `--yaml` enables the `YAML` file parser
2019-10-15 15:06:09 -07:00
2019-10-22 11:15:44 -07:00
### Options
2019-12-14 23:27:56 -08:00
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!)
2020-06-25 07:38:39 -07:00
- `-d` debug mode. Prints trace messages if parsing issues encountered (use `-dd` for verbose debugging)
2020-04-02 17:40:06 -07:00
- `-m` monochrome JSON output
2019-11-04 12:50:37 -08:00
- `-p` pretty format the JSON output
2019-11-12 07:18:27 -08:00
- `-q` quiet mode. Suppresses warning messages
2020-04-29 15:57:55 -07:00
- `-r` raw output. Provides a more literal JSON output with all values as strings and no additional sematic processing
2019-10-15 15:06:09 -07:00
2020-04-12 13:10:57 -07:00
### Setting Custom Colors via Environment Variable
2020-04-12 13:13:28 -07:00
You can specify custom colors via the `JC_COLORS` environment variable. The `JC_COLORS` environment variable takes four comma separated string values in the following format:
2020-06-25 12:28:23 -07:00
```bash
2020-04-12 13:23:58 -07:00
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
2020-04-12 13:10:57 -07:00
```
Where colors are: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `gray`, `brightblack`, `brightred`, `brightgreen`, `brightyellow`, `brightblue`, `brightmagenta`, `brightcyan`, `white`, or `default`
For example, to set to the default colors:
2020-06-25 12:28:23 -07:00
```bash
2020-04-12 13:10:57 -07:00
JC_COLORS=blue,brightblack,magenta,green
```
or
2020-06-25 12:28:23 -07:00
```bash
2020-04-12 13:10:57 -07:00
JC_COLORS=default,default,default,default
```
2020-06-08 10:44:09 -07:00
### Custom Parsers
Custom local parser plugins may be placed in a `jc/jcparsers` folder in your local **"App data directory"**:
- Linux/unix: `$HOME/.local/share/jc/jcparsers`
- macOS: `$HOME/Library/Application Support/jc/jcparsers`
2020-06-08 10:48:58 -07:00
- Windows: `$LOCALAPPDATA\jc\jc\jcparsers`
Local parser plugins are standard python module files. Use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) parser as a template and simply place a `.py` file in the `jcparsers` subfolder.
Local plugin filenames must be valid python module names, therefore must consist entirely of alphanumerics and start with a letter. Local plugins may override default plugins.
> Note: The application data directory follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
2020-02-27 09:36:57 -08:00
## Compatibility
Some parsers like `ls`, `ps`, `dig`, etc. will work on any platform. Other parsers that are platform-specific will generate a warning message if they are used on an unsupported platform. To see all parser information, including compatibility, run `jc -ap`.
You may still use a parser on an unsupported platform - for example, you may want to parse a file with linux `lsof` output on an OSX laptop. In that case you can suppress the warning message with the `-q` cli option or the `quiet=True` function parameter in `parse()`:
2020-06-25 12:28:23 -07:00
```bash
cat lsof.out | jc --lsof -q
2020-02-27 09:36:57 -08:00
```
Tested on:
- Centos 7.7
- Ubuntu 18.4
2020-05-21 09:07:01 -07:00
- Fedora32
2020-02-27 09:36:57 -08:00
- OSX 10.11.6
- OSX 10.14.6
- NixOS
- FreeBSD12
2020-02-27 09:36:57 -08:00
2020-05-21 09:07:01 -07:00
## Contributions
Feel free to add/improve code or parsers! You can use the [`jc/parsers/foo.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/foo.py) parser as a template and submit your parser with a pull request.
2020-02-27 09:36:57 -08:00
## Acknowledgments
2020-06-07 12:23:28 -07:00
- Local parser plugin feature contributed by [Dean Serenevy](https://github.com/duelafn)
2020-06-07 12:29:10 -07:00
- CI automation and code optimizations by [philippeitis](https://github.com/philippeitis)
- [`ifconfig-parser`](https://github.com/KnightWhoSayNi/ifconfig-parser) module by KnightWhoSayNi
- [`xmltodict`](https://github.com/martinblech/xmltodict) module by Martín Blech
- [`ruamel.yaml`](https://pypi.org/project/ruamel.yaml) module by Anthon van der Neut
- Parsing [code](https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501) from Conor Heine adapted for some parsers
- Excellent constructive feedback from [Ilya Sher](https://github.com/ilyash-b)
2020-02-27 09:36:57 -08:00
2019-10-15 15:06:09 -07:00
## Examples
2020-03-10 21:51:02 -07:00
### airport -I
2020-06-25 21:11:21 -07:00
```bash
airport -I | jc --airport -p # or: jc -p airport -I
```
2020-06-25 12:28:23 -07:00
```json
{
"agrctlrssi": -66,
"agrextrssi": 0,
"agrctlnoise": -90,
"agrextnoise": 0,
"state": "running",
"op_mode": "station",
"lasttxrate": 195,
"maxrate": 867,
"lastassocstatus": 0,
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": 0,
"channel": "48,80"
}
```
2020-03-10 21:51:02 -07:00
### airport -s
2020-06-25 21:11:21 -07:00
```bash
airport -s | jc --airport-s -p # or: jc -p airport -s
```
2020-06-25 12:28:23 -07:00
```json
2020-03-10 21:51:02 -07:00
[
{
"ssid": "DIRECT-4A-HP OfficeJet 3830",
"bssid": "00:67:eb:2a:a7:3b",
"rssi": -90,
"channel": "6",
"ht": true,
"cc": "--",
"security": [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "Latitude38",
"bssid": "c0:ff:d5:d2:7a:f3",
"rssi": -85,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "xfinitywifi",
"bssid": "6e:e3:0e:b8:45:99",
"rssi": -83,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
"NONE"
]
2020-06-25 12:56:06 -07:00
}
2020-03-10 21:51:02 -07:00
]
```
2019-10-30 13:22:12 -07:00
### arp
2020-06-25 21:11:21 -07:00
```bash
arp | jc --arp -p # or: jc -p arp
```
2020-06-25 12:56:06 -07:00
```json
2019-10-30 13:22:12 -07:00
[
{
"address": "gateway",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"flags_mask": "C",
"iface": "ens33"
},
2019-10-30 13:52:31 -07:00
{
"address": "192.168.71.1",
"hwtype": "ether",
"hwaddress": "00:50:56:c0:00:08",
"flags_mask": "C",
"iface": "ens33"
},
2019-10-30 13:22:12 -07:00
{
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"flags_mask": "C",
"iface": "ens33"
}
]
```
2020-06-25 21:11:21 -07:00
```bash
arp -a | jc --arp -p # or: jc -p arp -a
```
2020-06-25 12:56:06 -07:00
```json
2019-10-30 13:52:31 -07:00
[
{
2019-11-12 13:05:19 -08:00
"name": null,
2019-10-30 13:52:31 -07:00
"address": "192.168.71.1",
"hwtype": "ether",
"hwaddress": "00:50:56:c0:00:08",
"iface": "ens33",
"permanent": true
2019-10-30 13:52:31 -07:00
},
{
2019-11-12 13:05:19 -08:00
"name": null,
2019-10-30 13:52:31 -07:00
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"iface": "ens33",
"permanent": true
2019-10-30 13:52:31 -07:00
},
{
"name": "_gateway",
"address": "192.168.71.2",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33",
"permanent": false,
"expires": 110
2019-10-30 13:52:31 -07:00
}
]
```
2020-02-27 21:21:19 -08:00
### blkid
2020-06-25 21:11:21 -07:00
```bash
blkid | jc --blkid -p # or: jc -p blkid
```
2020-06-25 12:56:06 -07:00
```json
2020-02-27 21:21:19 -08:00
[
{
"device": "/dev/sda1",
"uuid": "05d927ab-5875-49e4-ada1-7f46cb32c932",
"type": "xfs"
},
{
"device": "/dev/sda2",
"uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
"type": "LVM2_member"
},
{
"device": "/dev/mapper/centos-root",
"uuid": "07d718ff-950c-4e5b-98f0-42a1147c77d9",
"type": "xfs"
},
{
"device": "/dev/mapper/centos-swap",
"uuid": "615eb89a-bcbf-46fd-80e3-c483ff5c931f",
"type": "swap"
}
]
```
2020-06-25 21:11:21 -07:00
```bash
blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev -ip /dev/sda2
```
2020-06-25 12:56:06 -07:00
```json
2020-02-27 21:21:19 -08:00
[
{
"id_fs_uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
"id_fs_uuid_enc": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
2020-06-25 12:59:56 -07:00
"id_fs_version": "LVM220001",
2020-02-27 21:21:19 -08:00
"id_fs_type": "LVM2_member",
"id_fs_usage": "raid",
"id_iolimit_minimum_io_size": 512,
"id_iolimit_physical_sector_size": 512,
"id_iolimit_logical_sector_size": 512,
"id_part_entry_scheme": "dos",
"id_part_entry_type": "0x8e",
"id_part_entry_number": 2,
"id_part_entry_offset": 2099200,
"id_part_entry_size": 39843840,
"id_part_entry_disk": "8:0"
}
]
```
2019-12-16 17:50:52 -08:00
### crontab
2020-06-25 21:11:21 -07:00
```bash
cat /etc/crontab | jc --crontab -p # or: jc -p crontab -l
```
2020-06-25 12:56:06 -07:00
```json
2019-12-16 17:50:52 -08:00
{
"variables": [
{
"name": "MAILTO",
"value": "root"
},
{
"name": "PATH",
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
},
{
"name": "SHELL",
"value": "/bin/bash"
}
],
"schedule": [
{
"minute": [
"5"
],
"hour": [
"10-11",
"22"
],
"day_of_month": [
"*"
],
"month": [
"*"
],
"day_of_week": [
"*"
],
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
},
{
"minute": [
"30"
],
"hour": [
"4/2"
],
"day_of_month": [
"*"
],
"month": [
"*"
],
"day_of_week": [
"*"
],
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
},
{
"occurrence": "yearly",
"command": "/home/maverick/bin/annual-maintenance"
},
{
"occurrence": "reboot",
"command": "/home/cleanup"
},
{
"occurrence": "monthly",
"command": "/home/maverick/bin/tape-backup"
}
]
}
```
2020-02-05 10:58:26 -08:00
### crontab-u (with user support)
2020-06-25 21:11:21 -07:00
```bash
cat /etc/crontab | jc --crontab-u -p
```
2020-06-25 12:56:06 -07:00
```json
2020-02-04 14:36:03 -08:00
{
"variables": [
{
"name": "MAILTO",
"value": "root"
},
{
"name": "PATH",
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
},
{
"name": "SHELL",
"value": "/bin/bash"
}
],
"schedule": [
{
"minute": [
"5"
],
"hour": [
"10-11",
"22"
],
"day_of_month": [
"*"
],
"month": [
"*"
],
"day_of_week": [
"*"
],
"user": "root",
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
},
{
"minute": [
"30"
],
"hour": [
"4/2"
],
"day_of_month": [
"*"
],
"month": [
"*"
],
"day_of_week": [
"*"
],
"user": "root",
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
},
{
"occurrence": "yearly",
"user": "root",
"command": "/home/maverick/bin/annual-maintenance"
},
{
"occurrence": "reboot",
"user": "root",
"command": "/home/cleanup"
},
{
"occurrence": "monthly",
"user": "root",
"command": "/home/maverick/bin/tape-backup"
}
]
}
```
2020-03-02 14:07:29 -08:00
### CSV files
2020-06-25 21:11:21 -07:00
```bash
cat homes.csv
```
2020-06-25 13:01:10 -07:00
```
2020-03-02 14:07:29 -08:00
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
...
2020-06-25 13:01:10 -07:00
```
2020-06-25 21:11:21 -07:00
```bash
cat homes.csv | jc --csv -p
```
2020-06-25 13:01:10 -07:00
```json
2020-03-02 14:07:29 -08:00
[
{
"Sell": "142",
"List": "160",
"Living": "28",
"Rooms": "10",
"Beds": "5",
"Baths": "3",
"Age": "60",
"Acres": "0.28",
"Taxes": "3167"
},
{
"Sell": "175",
"List": "180",
"Living": "18",
"Rooms": "8",
"Beds": "4",
"Baths": "1",
"Age": "12",
"Acres": "0.43",
"Taxes": "4033"
},
{
"Sell": "129",
"List": "132",
"Living": "13",
"Rooms": "6",
"Beds": "3",
"Baths": "1",
"Age": "41",
"Acres": "0.33",
"Taxes": "1471"
2020-06-25 12:56:06 -07:00
}
2020-03-02 14:07:29 -08:00
]
```
2019-10-22 11:10:11 -07:00
### df
2020-06-25 21:11:21 -07:00
```bash
df | jc --df -p # or: jc -p df
```
2020-06-25 12:56:06 -07:00
```json
2019-10-22 11:10:11 -07:00
[
{
2019-11-12 13:05:19 -08:00
"filesystem": "devtmpfs",
2019-12-11 16:39:30 -08:00
"1k_blocks": 1918816,
2019-11-12 13:05:19 -08:00
"used": 0,
"available": 1918816,
"use_percent": 0,
"mounted_on": "/dev"
2019-10-22 11:10:11 -07:00
},
{
2019-10-25 14:58:15 -07:00
"filesystem": "tmpfs",
2019-12-11 16:39:30 -08:00
"1k_blocks": 1930664,
2019-11-12 13:05:19 -08:00
"used": 0,
"available": 1930664,
"use_percent": 0,
"mounted_on": "/dev/shm"
2020-06-25 12:56:06 -07:00
}
2019-10-22 11:10:11 -07:00
]
```
2019-10-31 07:27:12 -07:00
### dig
2020-06-25 21:11:21 -07:00
```bash
dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p # or: jc -p dig cnn.com www.cnn.com @205.251.194.64
```
2020-06-25 12:56:06 -07:00
```json
2019-10-31 07:27:12 -07:00
[
{
2019-11-12 07:18:27 -08:00
"id": 5509,
2019-10-31 07:27:12 -07:00
"opcode": "QUERY",
"status": "NOERROR",
2019-11-12 07:18:27 -08:00
"flags": [
"qr",
"rd",
"ra"
],
"query_num": 1,
"answer_num": 4,
"authority_num": 0,
"additional_num": 1,
2019-10-31 07:27:12 -07:00
"question": {
"name": "cnn.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
2019-11-12 07:18:27 -08:00
"ttl": 60,
"data": "151.101.129.67"
2019-10-31 07:27:12 -07:00
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
2019-11-12 07:18:27 -08:00
"ttl": 60,
"data": "151.101.193.67"
2019-10-31 07:27:12 -07:00
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
2019-11-12 07:18:27 -08:00
"ttl": 60,
"data": "151.101.1.67"
2019-10-31 07:27:12 -07:00
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
2019-11-12 07:18:27 -08:00
"ttl": 60,
2019-10-31 07:27:12 -07:00
"data": "151.101.65.67"
}
],
2019-11-12 07:18:27 -08:00
"query_time": 28,
"server": "2600",
"when": "Tue Nov 12 07:13:03 PST 2019",
"rcvd": 100
2019-10-31 07:27:12 -07:00
},
{
2019-11-12 07:18:27 -08:00
"id": 62696,
2019-10-31 07:27:12 -07:00
"opcode": "QUERY",
"status": "NOERROR",
2019-11-12 07:18:27 -08:00
"flags": [
"qr",
"aa",
"rd"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 4,
"additional_num": 1,
2019-10-31 07:27:12 -07:00
"question": {
"name": "www.cnn.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "www.cnn.com.",
"class": "IN",
"type": "CNAME",
2019-11-12 07:18:27 -08:00
"ttl": 300,
2019-10-31 07:27:12 -07:00
"data": "turner-tls.map.fastly.net."
}
],
"authority": [
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
2019-11-12 07:18:27 -08:00
"ttl": 3600,
2019-10-31 07:27:12 -07:00
"data": "ns-1086.awsdns-07.org."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
2019-11-12 07:18:27 -08:00
"ttl": 3600,
2019-10-31 07:27:12 -07:00
"data": "ns-1630.awsdns-11.co.uk."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
2019-11-12 07:18:27 -08:00
"ttl": 3600,
2019-10-31 07:27:12 -07:00
"data": "ns-47.awsdns-05.com."
},
{
"name": "cnn.com.",
"class": "IN",
"type": "NS",
2019-11-12 07:18:27 -08:00
"ttl": 3600,
2019-10-31 07:27:12 -07:00
"data": "ns-576.awsdns-08.net."
}
],
2019-11-12 07:18:27 -08:00
"query_time": 29,
2019-10-31 07:27:12 -07:00
"server": "205.251.194.64#53(205.251.194.64)",
2019-11-12 07:18:27 -08:00
"when": "Tue Nov 12 07:13:03 PST 2019",
"rcvd": 212
2019-10-31 07:27:12 -07:00
}
]
```
2020-06-25 21:11:21 -07:00
```bash
dig -x 1.1.1.1 | jc --dig -p # or: jc -p dig -x 1.1.1.1
```
2020-06-25 12:56:06 -07:00
```json
2019-10-31 07:27:12 -07:00
[
{
2019-11-12 07:18:27 -08:00
"id": 50324,
2019-10-31 07:27:12 -07:00
"opcode": "QUERY",
"status": "NOERROR",
2019-11-12 07:18:27 -08:00
"flags": [
"qr",
"rd",
"ra"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
2019-10-31 07:27:12 -07:00
"question": {
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
"type": "PTR"
},
"answer": [
{
2019-11-12 07:18:27 -08:00
"name": "1.1.1.1.in-addr.arpa.",
2019-10-31 07:27:12 -07:00
"class": "IN",
"type": "PTR",
2019-11-12 07:18:27 -08:00
"ttl": 1634,
2019-10-31 07:27:12 -07:00
"data": "one.one.one.one."
}
],
2019-11-12 07:18:27 -08:00
"query_time": 36,
"server": "2600",
"when": "Tue Nov 12 07:13:49 PST 2019",
"rcvd": 78
2019-10-31 07:27:12 -07:00
}
]
```
2020-05-20 16:14:03 -07:00
### dmidecode
2020-06-25 21:11:21 -07:00
```bash
dmidecode | jc --dmidecode -p # or: jc -p dmidecode
```
2020-06-25 12:56:06 -07:00
```json
2020-05-26 17:31:56 -07:00
[
2020-05-20 16:14:03 -07:00
{
"handle": "0x0000",
"type": 0,
"bytes": 24,
"description": "BIOS Information",
"values": {
"vendor": "Phoenix Technologies LTD",
"version": "6.00",
"release_date": "04/13/2018",
"address": "0xEA490",
"runtime_size": "88944 bytes",
"rom_size": "64 kB",
"characteristics": [
"ISA is supported",
"PCI is supported",
"PC Card (PCMCIA) is supported",
"PNP is supported",
"APM is supported",
"BIOS is upgradeable",
"BIOS shadowing is allowed",
"ESCD support is available",
"Boot from CD is supported",
"Selectable boot is supported",
"EDD is supported",
"Print screen service is supported (int 5h)",
"8042 keyboard services are supported (int 9h)",
"Serial services are supported (int 14h)",
"Printer services are supported (int 17h)",
"CGA/mono video services are supported (int 10h)",
"ACPI is supported",
"Smart battery is supported",
"BIOS boot specification is supported",
"Function key-initiated network boot is supported",
"Targeted content distribution is supported"
],
"bios_revision": "4.6",
"firmware_revision": "0.0"
}
2020-06-25 12:56:06 -07:00
}
2020-05-20 16:14:03 -07:00
]
```
2019-12-16 14:31:21 -08:00
### du
2020-06-25 21:11:21 -07:00
```bash
du /usr | jc --du -p # or: jc -p du /usr
```
2020-06-25 12:56:06 -07:00
```json
2019-12-16 14:31:21 -08:00
[
{
"size": 104608,
"name": "/usr/bin"
},
{
"size": 56,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/_CodeSignature"
},
{
"size": 0,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local/standalone"
},
{
"size": 0,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr/local"
},
{
"size": 0,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/usr"
},
{
"size": 1008,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/Contents/Resources/Firmware/dfu"
2020-06-25 12:56:06 -07:00
}
2019-12-16 14:31:21 -08:00
]
```
2019-10-22 11:10:11 -07:00
### env
2020-06-25 21:11:21 -07:00
```bash
env | jc --env -p # or: jc -p env
```
2020-06-25 12:56:06 -07:00
```json
2019-11-12 13:05:19 -08:00
[
{
"name": "XDG_SESSION_ID",
"value": "1"
},
{
"name": "HOSTNAME",
"value": "localhost.localdomain"
},
{
"name": "TERM",
"value": "vt220"
},
{
"name": "SHELL",
"value": "/bin/bash"
},
{
"name": "HISTSIZE",
"value": "1000"
2020-06-25 12:56:06 -07:00
}
2019-11-12 13:05:19 -08:00
]
2019-10-22 11:10:11 -07:00
```
2020-03-11 12:20:58 -07:00
### file
2020-06-25 21:11:21 -07:00
```bash
file * | jc --file -p # or: jc -p file *
```
2020-06-25 12:56:06 -07:00
```json
2020-03-11 12:20:58 -07:00
[
{
"filename": "Applications",
"type": "directory"
},
{
"filename": "another file with spaces",
"type": "empty"
},
{
"filename": "argstest.py",
"type": "Python script text executable, ASCII text"
},
{
"filename": "blkid-p.out",
"type": "ASCII text"
},
{
"filename": "blkid-pi.out",
"type": "ASCII text, with very long lines"
},
{
"filename": "cd_catalog.xml",
"type": "XML 1.0 document text, ASCII text, with CRLF line terminators"
},
{
"filename": "centosserial.sh",
"type": "Bourne-Again shell script text executable, UTF-8 Unicode text"
2020-06-25 12:56:06 -07:00
}
2020-03-11 12:20:58 -07:00
]
```
2019-10-24 17:09:32 -07:00
### free
2020-06-25 21:11:21 -07:00
```bash
free | jc --free -p # or: jc -p free
```
2020-06-25 12:56:06 -07:00
```json
2019-10-24 17:09:32 -07:00
[
{
"type": "Mem",
2019-11-12 13:05:19 -08:00
"total": 3861340,
"used": 220508,
"free": 3381972,
"shared": 11800,
"buff_cache": 258860,
"available": 3397784
2019-10-24 17:09:32 -07:00
},
{
"type": "Swap",
2019-11-12 13:05:19 -08:00
"total": 2097148,
"used": 0,
"free": 2097148
2019-10-24 17:09:32 -07:00
}
]
```
2020-02-04 21:46:52 -08:00
### /etc/fstab file
2020-06-25 21:11:21 -07:00
```bash
cat /etc/fstab | jc --fstab -p
```
2020-06-25 12:56:06 -07:00
```json
2019-11-15 09:29:54 -08:00
[
{
"fs_spec": "/dev/mapper/centos-root",
"fs_file": "/",
"fs_vfstype": "xfs",
"fs_mntops": "defaults",
"fs_freq": 0,
"fs_passno": 0
},
{
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
"fs_file": "/boot",
"fs_vfstype": "xfs",
"fs_mntops": "defaults",
"fs_freq": 0,
"fs_passno": 0
},
{
"fs_spec": "/dev/mapper/centos-swap",
"fs_file": "swap",
"fs_vfstype": "swap",
"fs_mntops": "defaults",
"fs_freq": 0,
"fs_passno": 0
}
]
```
2020-03-03 09:36:16 -08:00
### /etc/group file
2020-06-25 21:11:21 -07:00
```bash
cat /etc/group | jc --group -p
```
2020-06-25 12:56:06 -07:00
```json
2020-03-03 09:36:16 -08:00
[
{
"group_name": "nobody",
"password": "*",
"gid": -2,
"members": []
},
{
"group_name": "nogroup",
"password": "*",
"gid": -1,
"members": []
},
{
"group_name": "wheel",
"password": "*",
"gid": 0,
"members": [
"root"
]
},
{
"group_name": "certusers",
"password": "*",
"gid": 29,
"members": [
"root",
"_jabber",
"_postfix",
"_cyrus",
"_calendar",
"_dovecot"
]
2020-06-25 12:56:06 -07:00
}
2020-03-03 09:36:16 -08:00
]
```
### /etc/gshadow file
2020-06-25 21:11:21 -07:00
```bash
cat /etc/gshadow | jc --gshadow -p
```
2020-06-25 12:56:06 -07:00
```json
2020-03-03 09:36:16 -08:00
[
{
"group_name": "root",
"password": "*",
"administrators": [],
"members": []
},
{
"group_name": "adm",
"password": "*",
"administrators": [],
"members": [
"syslog",
"joeuser"
]
2020-06-25 12:56:06 -07:00
}
2020-03-03 09:36:16 -08:00
]
```
2019-10-24 17:09:32 -07:00
### history
2020-06-25 21:11:21 -07:00
```bash
history | jc --history -p
```
2020-06-25 12:56:06 -07:00
```json
2019-11-12 13:05:19 -08:00
[
{
2020-02-04 14:36:03 -08:00
"line": 118,
2019-11-12 13:05:19 -08:00
"command": "sleep 100"
},
{
2020-02-04 14:36:03 -08:00
"line": 119,
2019-11-12 13:05:19 -08:00
"command": "ls /bin"
},
{
2020-02-04 14:36:03 -08:00
"line": 120,
2019-11-12 13:05:19 -08:00
"command": "echo \"hello\""
},
{
2020-02-04 14:36:03 -08:00
"line": 121,
2019-11-12 13:05:19 -08:00
"command": "docker images"
2020-06-25 12:56:06 -07:00
}
2019-11-12 13:05:19 -08:00
]
2019-10-24 17:09:32 -07:00
```
2020-02-04 21:46:52 -08:00
### /etc/hosts file
2020-06-25 21:11:21 -07:00
```bash
cat /etc/hosts | jc --hosts -p
```
2020-06-25 12:56:06 -07:00
```json
2019-11-14 21:59:06 -08:00
[
{
"ip": "127.0.0.1",
"hostname": [
"localhost"
]
},
{
"ip": "127.0.1.1",
"hostname": [
"root-ubuntu"
]
},
{
"ip": "::1",
"hostname": [
"ip6-localhost",
"ip6-loopback"
]
},
{
"ip": "fe00::0",
"hostname": [
"ip6-localnet"
]
},
{
"ip": "ff00::0",
"hostname": [
"ip6-mcastprefix"
]
},
{
"ip": "ff02::1",
"hostname": [
"ip6-allnodes"
]
},
{
"ip": "ff02::2",
"hostname": [
"ip6-allrouters"
]
}
]
```
2020-02-04 21:09:42 -08:00
### id
2020-06-25 21:11:21 -07:00
```bash
id | jc --id -p # or: jc -p id
```
2020-06-25 12:56:06 -07:00
```json
2020-02-04 21:12:32 -08:00
{
"uid": {
"id": 1000,
2020-02-04 21:17:03 -08:00
"name": "joeuser"
2020-02-04 21:12:32 -08:00
},
"gid": {
"id": 1000,
2020-02-04 21:17:03 -08:00
"name": "joeuser"
2020-02-04 21:12:32 -08:00
},
"groups": [
2020-02-04 21:09:42 -08:00
{
2020-02-04 21:12:32 -08:00
"id": 1000,
2020-02-04 21:17:03 -08:00
"name": "joeuser"
2020-02-04 21:12:32 -08:00
},
{
"id": 10,
"name": "wheel"
2020-02-04 21:09:42 -08:00
}
2020-02-04 21:12:32 -08:00
],
"context": {
"user": "unconfined_u",
"role": "unconfined_r",
"type": "unconfined_t",
"level": "s0-s0:c0.c1023"
}
}
2020-02-04 21:09:42 -08:00
```
2019-10-18 09:57:10 -07:00
### ifconfig
2020-06-25 21:11:21 -07:00
```bash
ifconfig | jc --ifconfig -p # or: jc -p ifconfig
```
2020-06-25 12:56:06 -07:00
```json
2019-10-15 15:32:23 -07:00
[
{
"name": "ens33",
2019-11-12 13:05:19 -08:00
"flags": 4163,
"state": [
"UP",
"BROADCAST",
"RUNNING",
"MULTICAST"
],
2019-11-12 13:05:19 -08:00
"mtu": 1500,
"ipv4_addr": "192.168.71.137",
2019-10-15 15:32:23 -07:00
"ipv4_mask": "255.255.255.0",
"ipv4_bcast": "192.168.71.255",
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
2019-11-12 13:05:19 -08:00
"ipv6_mask": 64,
"ipv6_scope": "0x20",
2019-10-15 15:32:23 -07:00
"mac_addr": "00:0c:29:3b:58:0e",
"type": "Ethernet",
"rx_packets": 8061,
"rx_bytes": 1514413,
2019-11-12 13:05:19 -08:00
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
"tx_packets": 4502,
"tx_bytes": 866622,
2019-11-12 13:05:19 -08:00
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
2019-10-15 15:32:23 -07:00
"metric": null
},
{
"name": "lo",
2019-11-12 13:05:19 -08:00
"flags": 73,
"state": [
"UP",
"LOOPBACK",
"RUNNING"
],
2019-11-12 13:05:19 -08:00
"mtu": 65536,
2019-10-15 15:32:23 -07:00
"ipv4_addr": "127.0.0.1",
"ipv4_mask": "255.0.0.0",
"ipv4_bcast": null,
"ipv6_addr": "::1",
2019-11-12 13:05:19 -08:00
"ipv6_mask": 128,
"ipv6_scope": "0x10",
2019-10-15 15:32:23 -07:00
"mac_addr": null,
"type": "Local Loopback",
"rx_packets": 73,
"rx_bytes": 6009,
2019-11-12 13:05:19 -08:00
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
"tx_packets": 73,
"tx_bytes": 6009,
2019-11-12 13:05:19 -08:00
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
2019-10-15 15:32:23 -07:00
"metric": null
}
]
2019-10-17 15:03:32 -07:00
```
2020-02-04 21:46:52 -08:00
### INI files
2020-06-25 21:11:21 -07:00
```bash
cat example.ini
```
2020-02-03 21:38:08 -08:00
```
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes
[bitbucket.org]
User = hg
[topsecret.server.com]
Port = 50022
ForwardX11 = no
2020-06-25 12:56:06 -07:00
```
2020-06-25 21:11:21 -07:00
```bash
cat example.ini | jc --ini -p
```
2020-06-25 12:56:06 -07:00
```json
2020-02-03 21:38:08 -08:00
{
"bitbucket.org": {
"serveraliveinterval": "45",
"compression": "yes",
"compressionlevel": "9",
"forwardx11": "yes",
"user": "hg"
},
"topsecret.server.com": {
"serveraliveinterval": "45",
"compression": "yes",
"compressionlevel": "9",
"forwardx11": "no",
"port": "50022"
}
}
```
2019-10-22 16:40:27 -07:00
### iptables
2020-06-25 21:11:21 -07:00
```bash
iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p iptables --line-numbers -v -L -t nat
```
2020-06-25 12:56:06 -07:00
```json
2019-10-22 16:40:27 -07:00
[
{
"chain": "PREROUTING",
"rules": [
{
2019-11-12 13:05:19 -08:00
"num": 1,
"pkts": 2183,
"bytes": 186000,
2019-10-22 16:40:27 -07:00
"target": "PREROUTING_direct",
"prot": "all",
2019-11-12 13:05:19 -08:00
"opt": null,
"in": "any",
"out": "any",
2019-10-22 16:40:27 -07:00
"source": "anywhere",
"destination": "anywhere"
},
{
2019-11-12 13:05:19 -08:00
"num": 2,
"pkts": 2183,
"bytes": 186000,
2019-10-22 16:40:27 -07:00
"target": "PREROUTING_ZONES_SOURCE",
"prot": "all",
2019-11-12 13:05:19 -08:00
"opt": null,
"in": "any",
"out": "any",
2019-10-22 16:40:27 -07:00
"source": "anywhere",
"destination": "anywhere"
},
{
2019-11-12 13:05:19 -08:00
"num": 3,
"pkts": 2183,
"bytes": 186000,
2019-10-22 16:40:27 -07:00
"target": "PREROUTING_ZONES",
"prot": "all",
2019-11-12 13:05:19 -08:00
"opt": null,
"in": "any",
"out": "any",
2019-10-22 16:40:27 -07:00
"source": "anywhere",
"destination": "anywhere"
},
{
2019-11-12 13:05:19 -08:00
"num": 4,
"pkts": 0,
"bytes": 0,
2019-10-22 16:40:27 -07:00
"target": "DOCKER",
"prot": "all",
2019-11-12 13:05:19 -08:00
"opt": null,
"in": "any",
"out": "any",
2019-10-22 16:40:27 -07:00
"source": "anywhere",
"destination": "anywhere",
"options": "ADDRTYPE match dst-type LOCAL"
}
]
2020-06-25 12:56:06 -07:00
}
2019-10-22 16:40:27 -07:00
]
```
2019-10-23 14:10:10 -07:00
### jobs
2020-06-25 21:11:21 -07:00
```bash
jobs -l | jc --jobs -p # or: jc -p jobs
```
2020-06-25 12:56:06 -07:00
```json
2019-10-23 14:10:10 -07:00
[
{
2019-11-12 13:05:19 -08:00
"job_number": 1,
"pid": 5283,
2019-10-23 14:10:10 -07:00
"status": "Running",
2019-11-12 13:05:19 -08:00
"command": "sleep 10000 &"
2019-10-23 14:10:10 -07:00
},
{
2019-11-12 13:05:19 -08:00
"job_number": 2,
"pid": 5284,
2019-10-23 14:10:10 -07:00
"status": "Running",
2019-11-12 13:05:19 -08:00
"command": "sleep 10100 &"
2019-10-23 14:10:10 -07:00
},
{
2019-11-12 13:05:19 -08:00
"job_number": 3,
"pid": 5285,
2019-10-23 14:10:10 -07:00
"history": "previous",
"status": "Running",
2019-11-12 13:05:19 -08:00
"command": "sleep 10001 &"
2019-10-23 14:10:10 -07:00
},
{
2019-11-12 13:05:19 -08:00
"job_number": 4,
"pid": 5286,
2019-10-23 14:10:10 -07:00
"history": "current",
"status": "Running",
2019-11-12 13:05:19 -08:00
"command": "sleep 10112 &"
2019-10-23 14:10:10 -07:00
}
]
```
2020-02-27 21:21:19 -08:00
### last and lastb
2020-06-25 21:11:21 -07:00
```bash
last | jc --last -p # or: jc -p last
```
2020-06-25 12:56:06 -07:00
```json
2020-02-27 21:21:19 -08:00
[
{
"user": "joeuser",
"tty": "ttys002",
"hostname": null,
"login": "Thu Feb 27 14:31",
"logout": "still logged in"
},
{
"user": "joeuser",
"tty": "ttys003",
"hostname": null,
"login": "Thu Feb 27 10:38",
"logout": "10:38",
"duration": "00:00"
},
{
"user": "joeuser",
"tty": "ttys003",
"hostname": null,
"login": "Thu Feb 27 10:18",
"logout": "10:18",
"duration": "00:00"
2020-06-25 12:56:06 -07:00
}
2020-02-27 21:21:19 -08:00
]
```
2019-10-21 17:26:00 -07:00
### ls
2020-06-25 21:11:21 -07:00
```bash
2020-02-13 17:20:00 -08:00
$ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin
2020-06-25 21:11:21 -07:00
```
```json
2019-10-21 17:26:00 -07:00
[
{
2019-10-25 15:39:48 -07:00
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
2019-11-12 13:05:19 -08:00
"links": 1,
2019-10-21 17:26:00 -07:00
"owner": "root",
2019-10-25 15:39:48 -07:00
"group": "root",
2019-11-12 13:05:19 -08:00
"size": 6,
2019-10-25 15:39:48 -07:00
"date": "Aug 15 10:53"
2019-10-21 17:26:00 -07:00
},
{
2019-11-12 13:05:19 -08:00
"filename": "ar",
2019-10-25 15:39:48 -07:00
"flags": "-rwxr-xr-x.",
2019-11-12 13:05:19 -08:00
"links": 1,
2019-10-21 17:26:00 -07:00
"owner": "root",
2019-10-25 15:39:48 -07:00
"group": "root",
2019-11-12 13:05:19 -08:00
"size": 62744,
"date": "Aug 8 16:14"
2019-10-25 15:39:48 -07:00
},
{
2019-11-12 13:05:19 -08:00
"filename": "arch",
2019-10-25 15:39:48 -07:00
"flags": "-rwxr-xr-x.",
2019-11-12 13:05:19 -08:00
"links": 1,
2019-10-25 15:39:48 -07:00
"owner": "root",
"group": "root",
2019-11-12 13:05:19 -08:00
"size": 33080,
2019-10-25 15:39:48 -07:00
"date": "Aug 19 23:25"
2020-06-25 12:56:06 -07:00
}
2019-10-21 17:26:00 -07:00
]
```
2019-10-22 11:55:11 -07:00
### lsblk
2020-06-25 21:11:21 -07:00
```bash
lsblk | jc --lsblk -p # or: jc -p lsblk
```
2020-06-25 12:56:06 -07:00
```json
2019-10-22 11:55:11 -07:00
[
{
2019-10-25 14:58:15 -07:00
"name": "sda",
"maj_min": "8:0",
2019-11-12 13:05:19 -08:00
"rm": false,
2019-10-25 14:58:15 -07:00
"size": "20G",
2019-11-12 13:05:19 -08:00
"ro": false,
"type": "disk",
"mountpoint": null
2019-10-25 14:58:15 -07:00
},
{
"name": "sda1",
"maj_min": "8:1",
2019-11-12 13:05:19 -08:00
"rm": false,
2019-10-25 14:58:15 -07:00
"size": "1G",
2019-11-12 13:05:19 -08:00
"ro": false,
2019-10-25 14:58:15 -07:00
"type": "part",
"mountpoint": "/boot"
2020-06-25 12:56:06 -07:00
}
2019-10-22 11:55:11 -07:00
]
```
2019-10-23 18:30:55 -07:00
### lsmod
2020-06-25 21:11:21 -07:00
```bash
lsmod | jc --lsmod -p # or: jc -p lsmod
```
2020-06-25 12:56:06 -07:00
```json
2019-10-23 18:30:55 -07:00
[
{
2019-11-12 13:05:19 -08:00
"module": "nf_nat",
"size": 26583,
"used": 3,
2019-10-25 14:58:15 -07:00
"by": [
2019-10-23 18:30:55 -07:00
"nf_nat_ipv4",
"nf_nat_ipv6",
2019-11-12 13:05:19 -08:00
"nf_nat_masquerade_ipv4"
2019-10-23 18:30:55 -07:00
]
},
{
2019-11-12 13:05:19 -08:00
"module": "iptable_mangle",
"size": 12695,
"used": 1
2019-10-23 18:30:55 -07:00
},
{
2019-11-12 13:05:19 -08:00
"module": "iptable_security",
"size": 12705,
"used": 1
2019-10-23 18:30:55 -07:00
},
{
2019-11-12 13:05:19 -08:00
"module": "iptable_raw",
"size": 12678,
"used": 1
2019-10-23 18:30:55 -07:00
},
{
2019-11-12 13:05:19 -08:00
"module": "nf_conntrack",
"size": 139224,
"used": 7,
2019-10-25 14:58:15 -07:00
"by": [
2019-11-12 13:05:19 -08:00
"nf_nat",
"nf_nat_ipv4",
"nf_nat_ipv6",
"xt_conntrack",
"nf_nat_masquerade_ipv4",
"nf_conntrack_ipv4",
"nf_conntrack_ipv6"
2019-10-23 18:30:55 -07:00
]
2020-06-25 12:56:06 -07:00
}
2019-10-23 18:30:55 -07:00
]
```
2019-10-23 17:37:25 -07:00
### lsof
2020-06-25 21:11:21 -07:00
```bash
lsof | jc --lsof -p # or: jc -p lsof
```
2020-06-25 12:56:06 -07:00
```json
2019-10-23 17:37:25 -07:00
[
{
2019-10-25 14:58:15 -07:00
"command": "systemd",
2019-11-12 13:05:19 -08:00
"pid": 1,
2019-10-25 14:58:15 -07:00
"tid": null,
"user": "root",
"fd": "cwd",
"type": "DIR",
2019-11-12 13:05:19 -08:00
"device": "253,0",
"size_off": 224,
"node": 64,
2019-10-25 14:58:15 -07:00
"name": "/"
2019-10-23 17:37:25 -07:00
},
{
2019-10-25 14:58:15 -07:00
"command": "systemd",
2019-11-12 13:05:19 -08:00
"pid": 1,
2019-10-25 14:58:15 -07:00
"tid": null,
"user": "root",
"fd": "rtd",
"type": "DIR",
2019-11-12 13:05:19 -08:00
"device": "253,0",
"size_off": 224,
"node": 64,
2019-10-25 14:58:15 -07:00
"name": "/"
2019-10-23 17:37:25 -07:00
},
{
2019-10-25 14:58:15 -07:00
"command": "systemd",
2019-11-12 13:05:19 -08:00
"pid": 1,
2019-10-25 14:58:15 -07:00
"tid": null,
"user": "root",
"fd": "txt",
"type": "REG",
2019-11-12 13:05:19 -08:00
"device": "253,0",
"size_off": 1624520,
"node": 50360451,
"name": "/usr/lib/systemd/systemd"
2020-06-25 12:56:06 -07:00
}
2019-10-23 17:37:25 -07:00
]
```
2019-10-22 12:54:41 -07:00
### mount
2020-06-25 21:11:21 -07:00
```bash
mount | jc --mount -p # or: jc -p mount
```
2020-06-25 12:56:06 -07:00
```json
2019-10-22 12:54:41 -07:00
[
{
"filesystem": "sysfs",
"mount_point": "/sys",
"type": "sysfs",
2019-11-12 13:05:19 -08:00
"options": [
2019-10-22 12:54:41 -07:00
"rw",
"nosuid",
"nodev",
"noexec",
"relatime"
]
},
{
"filesystem": "proc",
"mount_point": "/proc",
"type": "proc",
2019-11-12 13:05:19 -08:00
"options": [
2019-10-22 12:54:41 -07:00
"rw",
"nosuid",
"nodev",
"noexec",
"relatime"
]
},
{
"filesystem": "udev",
"mount_point": "/dev",
"type": "devtmpfs",
2019-11-12 13:05:19 -08:00
"options": [
2019-10-22 12:54:41 -07:00
"rw",
"nosuid",
"relatime",
"size=977500k",
"nr_inodes=244375",
"mode=755"
]
2020-06-25 12:56:06 -07:00
}
2019-10-22 12:54:41 -07:00
]
```
2019-10-18 09:57:10 -07:00
### netstat
2020-06-25 21:11:21 -07:00
```bash
netstat -apee | jc --netstat -p # or: jc -p netstat -apee
```
2020-06-25 12:56:06 -07:00
```json
2019-10-21 13:47:22 -07:00
[
{
2019-11-12 13:05:19 -08:00
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "systemd-resolve",
"inode": 26958,
"program_name": "systemd-resolve",
"kind": "network",
"pid": 887,
"local_port": "domain",
"foreign_port": "*",
2019-10-21 18:22:51 -07:00
"transport_protocol": "tcp",
2019-11-12 13:05:19 -08:00
"network_protocol": "ipv4"
2019-10-21 13:47:22 -07:00
},
{
2019-11-12 13:05:19 -08:00
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "0.0.0.0",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "root",
"inode": 30499,
"program_name": "sshd",
"kind": "network",
"pid": 1186,
"local_port": "ssh",
"foreign_port": "*",
2019-10-21 18:22:51 -07:00
"transport_protocol": "tcp",
2019-11-12 13:05:19 -08:00
"network_protocol": "ipv4"
},
2019-10-21 13:47:22 -07:00
{
2019-11-12 13:05:19 -08:00
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "localhost",
"state": "ESTABLISHED",
"user": "root",
"inode": 46829,
"program_name": "sshd: root",
"kind": "network",
"pid": 2242,
"local_port": "ssh",
"foreign_port": "52186",
2019-10-21 18:22:51 -07:00
"transport_protocol": "tcp",
2019-10-21 13:47:22 -07:00
"network_protocol": "ipv4",
2019-11-12 13:05:19 -08:00
"foreign_port_num": 52186
2019-10-21 13:47:22 -07:00
},
{
2019-11-12 13:05:19 -08:00
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "localhost",
"state": "ESTABLISHED",
"user": "root",
"inode": 46828,
"program_name": "ssh",
"kind": "network",
"pid": 2241,
"local_port": "52186",
"foreign_port": "ssh",
2019-10-21 18:22:51 -07:00
"transport_protocol": "tcp",
2019-10-21 13:47:22 -07:00
"network_protocol": "ipv4",
2019-11-12 13:05:19 -08:00
"local_port_num": 52186
},
{
"proto": "tcp6",
"recv_q": 0,
"send_q": 0,
"local_address": "[::]",
"foreign_address": "[::]",
2019-10-21 13:47:22 -07:00
"state": "LISTEN",
2019-11-12 13:05:19 -08:00
"user": "root",
"inode": 30510,
2019-10-21 13:47:22 -07:00
"program_name": "sshd",
2019-11-12 13:05:19 -08:00
"kind": "network",
"pid": 1186,
"local_port": "ssh",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv6"
2019-10-21 13:47:22 -07:00
},
{
2019-11-12 13:05:19 -08:00
"proto": "udp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": null,
"user": "systemd-resolve",
"inode": 26957,
"program_name": "systemd-resolve",
"kind": "network",
"pid": 887,
"local_port": "domain",
2019-10-21 13:47:22 -07:00
"foreign_port": "*",
2019-11-12 13:05:19 -08:00
"transport_protocol": "udp",
"network_protocol": "ipv4"
2019-10-21 13:47:22 -07:00
},
{
2019-11-12 13:05:19 -08:00
"proto": "raw6",
"recv_q": 0,
"send_q": 0,
"local_address": "[::]",
"foreign_address": "[::]",
"state": "7",
"user": "systemd-network",
"inode": 27001,
"program_name": "systemd-network",
"kind": "network",
"pid": 867,
"local_port": "ipv6-icmp",
2019-10-21 13:47:22 -07:00
"foreign_port": "*",
2019-11-12 13:05:19 -08:00
"transport_protocol": null,
"network_protocol": "ipv6"
},
{
"proto": "unix",
"refcnt": 2,
"flags": null,
"type": "DGRAM",
"state": null,
"inode": 33322,
"program_name": "systemd",
"path": "/run/user/1000/systemd/notify",
"kind": "socket",
"pid": 1607
},
{
"proto": "unix",
"refcnt": 2,
"flags": "ACC",
"type": "SEQPACKET",
"state": "LISTENING",
"inode": 20835,
"program_name": "init",
"path": "/run/udev/control",
"kind": "socket",
"pid": 1
2020-06-25 12:56:06 -07:00
}
2019-10-21 13:47:22 -07:00
]
2020-06-25 21:11:21 -07:00
```
```bash
netstat -r | jc --netstat -p # or: jc -p netstat -r
```
```json
2020-05-22 12:56:27 -07:00
[
{
"destination": "default",
"gateway": "gateway",
"genmask": "0.0.0.0",
"route_flags": "UG",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "ens33",
2020-05-30 20:33:00 -07:00
"kind": "route",
"route_flags_pretty": [
"UP",
"GATEWAY"
]
2020-05-22 12:56:27 -07:00
},
{
"destination": "172.17.0.0",
"gateway": "0.0.0.0",
"genmask": "255.255.0.0",
"route_flags": "U",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "docker0",
2020-05-30 20:33:00 -07:00
"kind": "route",
"route_flags_pretty": [
"UP"
]
2020-05-22 12:56:27 -07:00
},
{
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"route_flags": "U",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "ens33",
2020-05-30 20:33:00 -07:00
"kind": "route",
"route_flags_pretty": [
"UP"
]
2020-05-22 12:56:27 -07:00
}
]
2020-06-25 21:11:21 -07:00
```
```bash
netstat -i | jc --netstat -p # or: jc -p netstat -i
```
```json
2020-05-22 14:04:11 -07:00
[
{
"iface": "ens33",
"mtu": 1500,
"rx_ok": 476,
"rx_err": 0,
"rx_drp": 0,
"rx_ovr": 0,
"tx_ok": 312,
"tx_err": 0,
"tx_drp": 0,
"tx_ovr": 0,
"flg": "BMRU",
"kind": "interface"
},
{
"iface": "lo",
"mtu": 65536,
"rx_ok": 0,
"rx_err": 0,
"rx_drp": 0,
"rx_ovr": 0,
"tx_ok": 0,
"tx_err": 0,
"tx_drp": 0,
"tx_ovr": 0,
"flg": "LRU",
"kind": "interface"
}
]
2019-12-16 18:36:13 -08:00
```
2020-03-10 18:00:26 -07:00
### ntpq
2020-06-25 21:11:21 -07:00
```bash
ntpq -p | jc --ntpq -p # or: jc -p ntpq -p
```
2020-06-25 12:56:06 -07:00
```json
2020-03-10 18:00:26 -07:00
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 1,
"poll": 64,
"reach": 1,
"delay": 23.399,
"offset": -2.805,
"jitter": 2.131,
"state": null
2020-03-10 18:00:26 -07:00
},
{
"remote": "mirror1.sjc02.s",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 2,
"poll": 64,
"reach": 1,
"delay": 29.325,
"offset": 1.044,
"jitter": 4.069,
"state": null
2020-03-10 18:00:26 -07:00
}
]
```
### /etc/passwd file
2020-06-25 21:11:21 -07:00
```bash
cat /etc/passwd | jc --passwd -p
```
2020-06-25 12:56:06 -07:00
```json
[
{
"username": "nobody",
"password": "*",
"uid": -2,
"gid": -2,
"comment": "Unprivileged User",
"home": "/var/empty",
"shell": "/usr/bin/false"
},
{
"username": "root",
"password": "*",
"uid": 0,
"gid": 0,
"comment": "System Administrator",
"home": "/var/root",
"shell": "/bin/sh"
},
{
"username": "daemon",
"password": "*",
"uid": 1,
"gid": 1,
"comment": "System Services",
"home": "/var/root",
"shell": "/usr/bin/false"
2020-06-25 12:56:06 -07:00
}
]
```
2019-12-16 18:36:13 -08:00
### pip list
2020-06-25 21:11:21 -07:00
```bash
pip list | jc --pip-list -p # or: jc -p pip list # or: jc -p pip3 list
```
2020-06-25 12:56:06 -07:00
```json
2019-12-16 18:36:13 -08:00
[
{
"package": "ansible",
"version": "2.8.5"
},
{
"package": "antlr4-python3-runtime",
"version": "4.7.2"
},
{
"package": "asn1crypto",
"version": "0.24.0"
2020-06-25 12:56:06 -07:00
}
2019-12-16 18:36:13 -08:00
]
2019-12-17 09:24:08 -08:00
```
### pip show
2020-06-25 21:11:21 -07:00
```bash
pip show wrapt wheel | jc --pip-show -p # or: jc -p pip show wrapt wheel # or: jc -p pip3 show wrapt wheel
```
2020-06-25 12:56:06 -07:00
```json
2019-12-17 09:24:08 -08:00
[
{
"name": "wrapt",
"version": "1.11.2",
"summary": "Module for decorators, wrappers and monkey patching.",
"home_page": "https://github.com/GrahamDumpleton/wrapt",
"author": "Graham Dumpleton",
"author_email": "Graham.Dumpleton@gmail.com",
"license": "BSD",
"location": "/usr/local/lib/python3.7/site-packages",
"requires": null,
"required_by": "astroid"
},
{
"name": "wheel",
"version": "0.33.4",
"summary": "A built-package format for Python.",
"home_page": "https://github.com/pypa/wheel",
"author": "Daniel Holth",
"author_email": "dholth@fastmail.fm",
"license": "MIT",
"location": "/usr/local/lib/python3.7/site-packages",
"requires": null,
"required_by": null
}
]
2019-10-15 15:06:09 -07:00
```
2019-10-18 13:34:28 -07:00
### ps
2020-06-25 21:11:21 -07:00
```bash
ps -ef | jc --ps -p # or: jc -p ps -ef
```
2020-06-25 12:56:06 -07:00
```json
2019-10-18 13:34:28 -07:00
[
{
2019-10-25 14:58:15 -07:00
"uid": "root",
2019-11-12 13:05:19 -08:00
"pid": 1,
"ppid": 0,
"c": 0,
"stime": "Nov01",
"tty": null,
"time": "00:00:11",
"cmd": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
2019-10-18 13:34:28 -07:00
},
{
2019-10-25 14:58:15 -07:00
"uid": "root",
2019-11-12 13:05:19 -08:00
"pid": 2,
"ppid": 0,
"c": 0,
"stime": "Nov01",
"tty": null,
2019-10-25 14:58:15 -07:00
"time": "00:00:00",
2019-11-12 13:05:19 -08:00
"cmd": "[kthreadd]"
2019-10-18 13:34:28 -07:00
},
{
2019-10-25 14:58:15 -07:00
"uid": "root",
2019-11-12 13:05:19 -08:00
"pid": 4,
"ppid": 2,
"c": 0,
"stime": "Nov01",
"tty": null,
2019-10-25 14:58:15 -07:00
"time": "00:00:00",
2019-11-12 13:05:19 -08:00
"cmd": "[kworker/0:0H]"
2020-06-25 12:56:06 -07:00
}
2019-11-12 13:05:19 -08:00
]
```
2020-06-25 21:11:21 -07:00
```bash
ps axu | jc --ps -p # or: jc -p ps axu
```
2020-06-25 12:56:06 -07:00
```json
2019-11-12 13:05:19 -08:00
[
2019-10-18 13:34:28 -07:00
{
2019-11-12 13:05:19 -08:00
"user": "root",
"pid": 1,
2019-11-12 15:05:21 -08:00
"cpu_percent": 0.0,
"mem_percent": 0.1,
"vsz": 128072,
"rss": 6784,
2019-11-12 13:05:19 -08:00
"tty": null,
"stat": "Ss",
"start": "Nov09",
2019-11-12 15:05:21 -08:00
"time": "0:08",
2019-11-12 13:05:19 -08:00
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
2019-10-25 14:58:15 -07:00
},
{
2019-11-12 13:05:19 -08:00
"user": "root",
"pid": 2,
2019-11-12 15:05:21 -08:00
"cpu_percent": 0.0,
"mem_percent": 0.0,
"vsz": 0,
"rss": 0,
2019-11-12 13:05:19 -08:00
"tty": null,
"stat": "S",
"start": "Nov09",
"time": "0:00",
"command": "[kthreadd]"
},
{
"user": "root",
"pid": 4,
2019-11-12 15:05:21 -08:00
"cpu_percent": 0.0,
"mem_percent": 0.0,
"vsz": 0,
"rss": 0,
2019-11-12 13:05:19 -08:00
"tty": null,
"stat": "S<",
"start": "Nov09",
"time": "0:00",
"command": "[kworker/0:0H]"
2020-06-25 12:56:06 -07:00
}
2019-10-18 13:34:28 -07:00
]
```
2019-10-18 14:18:34 -07:00
### route
2020-06-25 21:11:21 -07:00
```bash
route -ee | jc --route -p # or: jc -p route -ee
```
2020-06-25 12:56:06 -07:00
```json
2019-10-18 14:18:34 -07:00
[
{
2019-10-25 14:58:15 -07:00
"destination": "default",
2020-05-30 20:33:00 -07:00
"gateway": "_gateway",
2019-10-25 14:58:15 -07:00
"genmask": "0.0.0.0",
"flags": "UG",
2020-05-30 20:33:00 -07:00
"metric": 202,
2019-11-12 13:05:19 -08:00
"ref": 0,
"use": 0,
"iface": "ens33",
"mss": 0,
"window": 0,
2020-05-30 20:33:00 -07:00
"irtt": 0,
"flags_pretty": [
"UP",
"GATEWAY"
]
2019-10-18 14:18:34 -07:00
},
{
2019-10-25 14:58:15 -07:00
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"flags": "U",
2020-05-30 20:33:00 -07:00
"metric": 202,
2019-11-12 13:05:19 -08:00
"ref": 0,
"use": 0,
"iface": "ens33",
"mss": 0,
"window": 0,
2020-05-30 20:33:00 -07:00
"irtt": 0,
"flags_pretty": [
"UP"
]
2019-10-18 14:18:34 -07:00
}
]
```
### /etc/shadow file
2020-06-25 21:11:21 -07:00
```bash
cat /etc/shadow | jc --shadow -p
```
2020-06-25 12:56:06 -07:00
```json
[
{
"username": "root",
"password": "*",
"last_changed": 18113,
"minimum": 0,
"maximum": 99999,
"warn": 7,
"inactive": null,
"expire": null
},
{
"username": "daemon",
"password": "*",
"last_changed": 18113,
"minimum": 0,
"maximum": 99999,
"warn": 7,
"inactive": null,
"expire": null
},
{
"username": "bin",
"password": "*",
"last_changed": 18113,
"minimum": 0,
"maximum": 99999,
"warn": 7,
"inactive": null,
"expire": null
2020-06-25 12:56:06 -07:00
}
]
```
2019-11-12 18:51:21 -08:00
### ss
2020-06-25 21:11:21 -07:00
```bash
ss -a | jc --ss -p # or: jc -p ss -a
```
2020-06-25 12:56:06 -07:00
```json
2019-11-12 18:51:21 -08:00
[
{
"netid": "nl",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
2019-11-14 09:46:10 -08:00
"peer_address": "*",
"channel": "rtnl:kernel"
2019-11-12 18:51:21 -08:00
},
{
"netid": "nl",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
2019-11-14 09:46:10 -08:00
"peer_address": "*",
"pid": 893,
"channel": "rtnl:systemd-resolve"
2019-11-12 18:51:21 -08:00
},
{
2019-11-14 09:46:10 -08:00
"netid": "p_raw",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"peer_address": "*",
"link_layer": "LLDP",
"interface": "ens33"
},
{
"netid": "u_dgr",
2019-11-12 18:51:21 -08:00
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
2019-11-14 09:46:10 -08:00
"local_port": "93066",
"peer_address": "*",
"peer_port": "0",
"path": "/run/user/1000/systemd/notify"
},
{
"netid": "u_seq",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_port": "20699",
"peer_address": "*",
"peer_port": "0",
"path": "/run/udev/control"
2019-11-12 18:51:21 -08:00
},
2019-11-14 09:46:10 -08:00
{
"netid": "icmp6",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"local_address": "*",
"local_port": "ipv6-icmp",
"peer_address": "*",
"peer_port": "*",
"interface": "ens33"
},
{
"netid": "udp",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"local_address": "127.0.0.53",
"local_port": "domain",
"peer_address": "0.0.0.0",
"peer_port": "*",
"interface": "lo"
},
2019-11-12 18:51:21 -08:00
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
2019-11-14 09:46:10 -08:00
"local_address": "127.0.0.53",
"local_port": "domain",
2019-11-12 18:51:21 -08:00
"peer_address": "0.0.0.0",
"peer_port": "*",
"interface": "lo"
},
2019-11-14 09:46:10 -08:00
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_address": "0.0.0.0",
"local_port": "ssh",
"peer_address": "0.0.0.0",
"peer_port": "*"
},
2019-11-12 18:51:21 -08:00
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_address": "[::]",
"local_port": "ssh",
"peer_address": "[::]",
"peer_port": "*"
},
{
"netid": "v_str",
"state": "ESTAB",
"recv_q": 0,
"send_q": 0,
"local_address": "999900439",
"local_port": "1023",
"peer_address": "0",
"peer_port": "976",
"local_port_num": 1023,
"peer_port_num": 976
}
]
```
2019-11-14 16:31:52 -08:00
### stat
2020-06-25 21:11:21 -07:00
```bash
2020-06-25 21:16:52 -07:00
stat /bin/* | jc --stat -p # or: jc -p stat /bin/*
2020-06-25 21:11:21 -07:00
```
2020-06-25 12:56:06 -07:00
```json
2019-11-14 16:31:52 -08:00
[
{
"file": "/bin/bash",
"size": 1113504,
"blocks": 2176,
"io_blocks": 4096,
"type": "regular file",
"device": "802h/2050d",
"inode": 131099,
"links": 1,
"access": "0755",
"flags": "-rwxr-xr-x",
"uid": 0,
"user": "root",
"gid": 0,
"group": "root",
"access_time": "2019-11-14 08:18:03.509681766 +0000",
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
"change_time": "2019-08-12 17:21:29.521945390 +0000",
2019-11-14 17:36:29 -08:00
"birth_time": null
2019-11-14 16:31:52 -08:00
},
{
"file": "/bin/btrfs",
"size": 716464,
"blocks": 1400,
"io_blocks": 4096,
"type": "regular file",
"device": "802h/2050d",
"inode": 131100,
"links": 1,
"access": "0755",
"flags": "-rwxr-xr-x",
"uid": 0,
"user": "root",
"gid": 0,
"group": "root",
"access_time": "2019-11-14 08:18:28.990834276 +0000",
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
"change_time": "2019-08-12 17:21:29.545944399 +0000",
2019-11-14 17:36:29 -08:00
"birth_time": null
2020-06-25 12:56:06 -07:00
}
2019-11-14 16:31:52 -08:00
]
```
2019-11-15 11:58:17 -08:00
### systemctl
2020-06-25 21:11:21 -07:00
```bash
systemctl -a | jc --systemctl -p # or: jc -p systemctl -a
```
2020-06-25 12:56:06 -07:00
```json
2019-11-15 11:58:17 -08:00
[
{
"unit": "proc-sys-fs-binfmt_misc.automount",
"load": "loaded",
"active": "active",
"sub": "waiting",
"description": "Arbitrary Executable File Formats File System Automount Point"
},
{
"unit": "dev-block-8:2.device",
"load": "loaded",
"active": "active",
"sub": "plugged",
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM on /dev/sda2 2"
},
{
"unit": "dev-cdrom.device",
"load": "loaded",
"active": "active",
"sub": "plugged",
"description": "VMware_Virtual_IDE_CDROM_Drive"
2020-06-25 12:56:06 -07:00
}
2019-11-15 11:58:17 -08:00
]
```
2019-11-15 19:18:31 -08:00
### systemctl list-jobs
2020-06-25 21:11:21 -07:00
```bash
systemctl list-jobs | jc --systemctl-lj -p # or: jc -p systemctl list-jobs
```
2020-06-25 12:56:06 -07:00
```json
2019-11-15 19:18:31 -08:00
[
{
"job": 3543,
"unit": "nginxAfterGlusterfs.service",
"type": "start",
"state": "waiting"
},
{
"job": 3545,
"unit": "glusterReadyForLocalhostMount.service",
"type": "start",
"state": "running"
},
{
"job": 3506,
"unit": "nginx.service",
"type": "start",
"state": "waiting"
}
]
```
### systemctl list-sockets
2020-06-25 21:11:21 -07:00
```bash
systemctl list-sockets | jc --systemctl-ls -p # or: jc -p systemctl list-sockets
```
2020-06-25 12:56:06 -07:00
```json
2019-11-15 19:18:31 -08:00
[
{
"listen": "/dev/log",
"unit": "systemd-journald.socket",
"activates": "systemd-journald.service"
},
{
"listen": "/run/dbus/system_bus_socket",
"unit": "dbus.socket",
"activates": "dbus.service"
},
{
"listen": "/run/dmeventd-client",
"unit": "dm-event.socket",
"activates": "dm-event.service"
2020-06-25 12:56:06 -07:00
}
2019-11-15 19:18:31 -08:00
]
```
### systemctl list-unit-files
2020-06-25 21:11:21 -07:00
```bash
systemctl list-unit-files | jc --systemctl-luf -p # or: jc -p systemctl list-unit-files
```
2020-06-25 12:56:06 -07:00
```json
2019-11-15 19:18:31 -08:00
[
{
"unit_file": "proc-sys-fs-binfmt_misc.automount",
"state": "static"
},
{
"unit_file": "dev-hugepages.mount",
"state": "static"
},
{
"unit_file": "dev-mqueue.mount",
"state": "static"
2020-06-25 12:56:06 -07:00
}
2019-11-15 19:18:31 -08:00
]
```
2020-03-10 18:37:55 -07:00
### timedatectl status
2020-06-25 21:11:21 -07:00
```bash
timedatectl | jc --timedatectl -p # or: jc -p timedatectl
```
2020-06-25 12:56:06 -07:00
```json
2020-03-10 18:37:55 -07:00
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": true,
"ntp_synchronized": true,
"rtc_in_local_tz": false,
"dst_active": true
}
```
2019-10-22 13:28:15 -07:00
### uname -a
2020-06-25 21:11:21 -07:00
```bash
uname -a | jc --uname -p # or: jc -p uname -a
```
2020-06-25 12:56:06 -07:00
```json
2019-10-22 13:28:15 -07:00
{
"kernel_name": "Linux",
"node_name": "user-ubuntu",
"kernel_release": "4.15.0-65-generic",
"operating_system": "GNU/Linux",
"hardware_platform": "x86_64",
"processor": "x86_64",
"machine": "x86_64",
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
}
```
2019-10-24 17:09:32 -07:00
### uptime
2020-06-25 21:11:21 -07:00
```bash
uptime | jc --uptime -p # or: jc -p uptime
```
2020-06-25 12:56:06 -07:00
```json
2019-10-24 17:09:32 -07:00
{
2019-11-12 13:05:19 -08:00
"time": "11:30:44",
"uptime": "1 day, 21:17",
"users": 1,
"load_1m": 0.01,
"load_5m": 0.04,
"load_15m": 0.05
2019-10-24 17:09:32 -07:00
}
```
2019-10-24 16:06:55 -07:00
### w
2020-06-25 21:11:21 -07:00
```bash
w | jc --w -p # or: jc -p w
```
2020-06-25 12:56:06 -07:00
```json
2019-10-24 16:06:55 -07:00
[
2019-11-12 13:05:19 -08:00
{
"user": "root",
"tty": "tty1",
"from": null,
"login_at": "07:49",
"idle": "1:15m",
"jcpu": "0.00s",
"pcpu": "0.00s",
"what": "-bash"
},
2019-10-24 16:06:55 -07:00
{
2019-10-25 14:58:15 -07:00
"user": "root",
"tty": "ttyS0",
2019-11-12 13:05:19 -08:00
"from": null,
"login_at": "06:24",
2019-10-25 14:58:15 -07:00
"idle": "0.00s",
2019-11-12 13:05:19 -08:00
"jcpu": "0.43s",
2019-10-25 14:58:15 -07:00
"pcpu": "0.00s",
2019-11-12 13:05:19 -08:00
"what": "w"
2019-10-24 16:06:55 -07:00
},
{
2019-10-25 14:58:15 -07:00
"user": "root",
"tty": "pts/0",
"from": "192.168.71.1",
2019-11-12 13:05:19 -08:00
"login_at": "06:29",
"idle": "2:35m",
"jcpu": "0.00s",
"pcpu": "0.00s",
2019-10-25 14:58:15 -07:00
"what": "-bash"
2019-10-24 16:06:55 -07:00
}
]
```
2020-03-01 17:07:28 -08:00
### who
2020-06-25 21:11:21 -07:00
```bash
who | jc --who -p # or: jc -p who
```
2020-06-25 12:56:06 -07:00
```json
2020-03-01 21:16:57 -08:00
[
{
2020-03-01 21:17:50 -08:00
"user": "joeuser",
2020-03-01 21:16:57 -08:00
"tty": "ttyS0",
"time": "2020-03-02 02:52"
},
{
2020-03-01 21:17:50 -08:00
"user": "joeuser",
2020-03-01 21:16:57 -08:00
"tty": "pts/0",
"time": "2020-03-02 05:15",
"from": "192.168.71.1"
}
]
2020-06-25 21:11:21 -07:00
```
```bash
who -a | jc --who -p # or: jc -p who -a
```
```json
2020-03-01 17:07:28 -08:00
[
{
"event": "reboot",
"time": "Feb 7 23:31",
"pid": 1
},
{
"user": "joeuser",
2020-03-01 17:39:02 -08:00
"writeable_tty": "-",
2020-03-01 17:07:28 -08:00
"tty": "console",
"time": "Feb 7 23:32",
"idle": "old",
"pid": 105
},
{
"user": "joeuser",
"writeable_tty": "+",
"tty": "ttys000",
"time": "Feb 13 16:44",
"idle": ".",
"pid": 51217,
"comment": "term=0 exit=0"
},
{
"user": "joeuser",
2020-03-01 17:39:02 -08:00
"writeable_tty": "?",
2020-03-01 17:07:28 -08:00
"tty": "ttys003",
"time": "Feb 28 08:59",
"idle": "01:36",
"pid": 41402
},
{
"user": "joeuser",
"writeable_tty": "+",
"tty": "ttys004",
"time": "Mar 1 16:35",
"idle": ".",
"pid": 15679,
"from": "192.168.1.5"
}
]
```
2020-02-04 21:46:52 -08:00
### XML files
2020-06-25 21:11:21 -07:00
```bash
cat cd_catalog.xml
2020-02-03 22:13:06 -08:00
```
2020-06-25 21:11:21 -07:00
```xml
2020-02-03 22:13:06 -08:00
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
...
2020-06-25 12:56:06 -07:00
```
2020-06-25 21:11:21 -07:00
```bash
cat cd_catalog.xml | jc --xml -p
```
2020-06-25 12:56:06 -07:00
```json
2020-02-03 22:13:06 -08:00
{
"CATALOG": {
"CD": [
{
"TITLE": "Empire Burlesque",
"ARTIST": "Bob Dylan",
"COUNTRY": "USA",
"COMPANY": "Columbia",
"PRICE": "10.90",
"YEAR": "1985"
},
{
"TITLE": "Hide your heart",
"ARTIST": "Bonnie Tyler",
"COUNTRY": "UK",
"COMPANY": "CBS Records",
"PRICE": "9.90",
"YEAR": "1988"
2020-06-25 12:56:06 -07:00
}
]
}
2020-02-03 22:25:30 -08:00
}
2020-02-03 22:13:06 -08:00
```
2020-02-04 21:46:52 -08:00
### YAML files
2020-06-25 21:11:21 -07:00
```bash
cat istio.yaml
2020-02-03 21:38:08 -08:00
```
2020-06-25 21:11:21 -07:00
```yaml
2020-02-03 21:38:08 -08:00
apiVersion: "authentication.istio.io/v1alpha1"
kind: "Policy"
metadata:
name: "default"
namespace: "default"
spec:
peers:
- mtls: {}
---
apiVersion: "networking.istio.io/v1alpha3"
kind: "DestinationRule"
metadata:
name: "default"
namespace: "default"
spec:
host: "*.default.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
2020-06-25 12:56:06 -07:00
```
2020-06-25 21:11:21 -07:00
```bash
cat istio.yaml | jc --yaml -p
```
2020-06-25 12:56:06 -07:00
```json
2020-02-03 21:38:08 -08:00
[
{
"apiVersion": "authentication.istio.io/v1alpha1",
"kind": "Policy",
"metadata": {
"name": "default",
"namespace": "default"
},
"spec": {
"peers": [
{
"mtls": {}
}
]
}
},
{
"apiVersion": "networking.istio.io/v1alpha3",
"kind": "DestinationRule",
"metadata": {
"name": "default",
"namespace": "default"
},
"spec": {
"host": "*.default.svc.cluster.local",
"trafficPolicy": {
"tls": {
"mode": "ISTIO_MUTUAL"
}
}
}
}
]
2020-02-27 09:36:57 -08:00
```