0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

使いこなすと便利かも?Linux代替コマンド

Posted at

はじめに

Linuxコマンドには古くから使われているコマンドに比べて、見た目的にわかりやすかったり操作性の良い代替コマンドがあります。
そのうちのいくつかを紹介します。

※代替コマンドの中にはRust製のものもあるので記事の終わりにRustのインストール方法も掲載しています。

コマンド

ncdu

ncdu

元となったコマンド

$ du

機能

  • ディスク使用量表示ツール
  • ディレクトリやファイルごとにディスクの使用量の分析ができる

インストール方法

$ sudo apt-get install ncdu # Debian系
$ sudo yum install ncdu     # RedHat系
$ brew install ncdu         # macOS/Homebrew
$ sudo port install ncdu    # macOS/MacPorts

使用方法

$ ncdu             # カレントディレクトリ
$ ncdu /directory  # ディレクトリを指定して実行

Untitled.png

カーソル移動→Enterでディレクトリを移動することもできる(←キーで上階層へ)

Untitled (1).png

?キーでヘルプを確認できる

htop

htop

元となったコマンド

$ top

機能

稼働プロセスの表示
CPU負荷やメモリ、スワップ使用率のグラフ表示

インストール方法

$ sudo apt-get install htop # Debian系
$ sudo yum install htop     # RedHat系
$ brew install htop         # macOS/Homebrew
$ sudo port install htop    # macOS/MacPorts

使用方法

$ htop

Untitled (2).png

画面下部に表示されているコマンドでフィルターやソート、キル等が可能

tldr

tldr

元となったコマンド

$ man

機能

manコマンドよりも概要と使用例を簡潔に表示する

インストール方法

$ sudo apt-get install tldr # Debian系
$ sudo yum install tldr     # RedHat系
$ brew install tldr         # macOS/Homebrew
$ sudo port install tldr    # macOS/MacPorts

使用方法

$ tldr find

Untitled (3).png

jq

jq

元となったコマンド

$ grep
$ awk

機能

JSONのパーサ
JSONから値を抜き出したり、整形して表示したりできる

インストール方法

$ sudo apt-get install jq   # Debian系
$ sudo yum install jq       # RedHat系
$ brew install jq           # macOS/Homebrew
$ sudo port install jq      # macOS/MacPorts

使用方法

$ curl https://XXXXX | jq
など

Untitled (4).png

fd

fd

元となったコマンド

$ find

機能

findよりもオプション指定がかんたんで出力に色付けされて出力される

インストール方法

$ sudo apt-get install fd-find   # Debian系
$ sudo yum install fd-find       # RedHat系
$ brew install fd-find           # macOS/Homebrew
$ sudo port install fd-find      # macOS/MacPorts

使用方法

$ fdfind {pattern} {directory}

Untitled (5).png

exa

exa

元となったコマンド

$ ls

機能

ファイルやディレクトリの確認を行うlsを見やすく、カラフルに表示する

インストール方法

$ cargo install exa

使用方法

$ exa -l
$ exa -ahl --git # ヘッダ付き、gitのステータス付き表示
$ exa -T         # -T ツリー表示
$ exa -T --git-ignore # -T ツリー表示 --git-ignore .gitignore記載のファイルを無視

Untitled (6).png
Untitled (7).png
Untitled (8).png

bat

bat

元となったコマンド

$ cat

機能

syntaxハイライトやGitのステータス表示のできるcat

インストール方法

$ cargo install bat

使用方法

$ bat text.txt

Untitled (9).png

tokei

tokei

元となったコマンド

$ ps

機能

言語ごとのファイル数、ステップ数、コード数、空行数、コメント数を出力

インストール方法

$ cargo install procs
$ procs
$ procs -w   # ウォッチモード(1秒毎に更新)

Untitled (10).png

procs

procs

機能

出力の色つけ、値の単位がわかりやすい、検索のしやすいps

使用方法

Untitled (11).png

procs -w

Untitled (12).png

[付録]Rustのインストール

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

## これでrustc, cargo, rustup のコマンドがインストールされる
## error: linker `cc` not found のようなエラーメッセージが表示される場合は
## gccコンパイラをインストールする
$ yum install -y gcc
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?