DEV Community

Cover image for Unix Command Notes
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

Unix Command Notes

This article was originally published on bmf-tech.com.

Overview

Notes on Unix commands.

jq

A command to process data in JSON format.

JSON Pretty Print

echo '[{"name": "Tom", "age": 20}}]' | jq .
Enter fullscreen mode Exit fullscreen mode

Besides Pretty Print, you can extract data by specifying properties from objects, get the length of objects, and use it in various other ways.

tee

Outputs standard input to both standard output and a file. Can be used with sudo. Overwrites without options, appends with option -a.

echo 'hello world' | sudo tee ./sample.txt
Enter fullscreen mode Exit fullscreen mode

In the case of redirection, > overwrites, >> appends. sudo cannot be used.

at

Allows you to schedule the execution time of a command.

at -f ./sample.txt 2230
Enter fullscreen mode Exit fullscreen mode

There are various formats for the date and time part.

mktemp

Creates a file with a random name under the /tmp directory.

mktemp
Enter fullscreen mode Exit fullscreen mode

lsof

List of open files
Outputs files opened by processes.

-i
Filters output by port number.

-i tcp or udp
Filters output by TCP or UDP.

-P
Outputs port numbers as digits.

-n
Outputs without reverse DNS lookup of IP addresses to hostnames.

nmap

Examines the port status of a target host over the network.

nmap 192.168.33.10
Enter fullscreen mode Exit fullscreen mode

fsfreeze

A command to temporarily suspend file system I/O.

Temporarily suspends file system I/O (freeze process).

fsfreeze -f /data
Enter fullscreen mode Exit fullscreen mode

Releases file system I/O (unfreeze process).

fsfreeze -u /data
Enter fullscreen mode Exit fullscreen mode

findmnt

Outputs information about mounted file systems.

Top comments (0)