49
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【現場で使える】Linuxコマンド早見表

Last updated at Posted at 2025-11-30

はじめに:christmas_tree:

現場で実際に使用したLinuxコマンドを、自分用の備忘録も兼ねてまとめました。
今回は使用頻度の多かった4つのコマンドをご紹介いたします。
すぐに試せるようシンプルな例も添えています。

使用コマンド:snowman2:

・uname -n

用途:ホスト名を表示
書式:uname [オプション]
   -n:ホスト名を表示
補足:unameコマンドはカーネルのバージョンを調べるコマンドで-nを付けることで
  ホストネームのみ表示させることが可能となります。

#実行例

$ uname -n
host001

・date

用途:現在の日付と時刻を表示
書式:date [オプション]
補足:日付,時刻表示が重要なのか!?と思うかもしれませんが、非常に重要なんです。。
   障害対応やログ確認の際は「いつ発生したか」確認をします。
  dateを使い時刻を手がかりにログを遡ることが可能となります。
  

#実行例

$ date
2025年 10月 2日 木曜日 10:45:32 JST

・ls

用途:ファイルやディレクトリの一覧を表示
書式:ls [オプション]
   -a:隠しファイルを含め、すべてのファイルを表示する
   -l: 権限,所有者,更新日時などの詳細情報を表示する(1番使います)
補足:ls -l はディレクトリ名に加え、パーミッションやタイムスタンプが表示されるため
  業務でよく使います。(ls -l はllと打つことが多いです。)

#実行例

$ ls
dir1  file1.txt  file2.txt
#実行例

$ ls -a
.  ..  .hidden_file  dir1  file1.txt  file2.txt
#実行例

$ ls -l
total 16
drwxr-xr-x  2 user user 4096 Oct  2 11:30 dir1
-rw-r--r--  1 user user    0 Oct  2 11:29 file1.txt
-rw-r--r--  1 user user    0 Oct  2 11:29 file2.txt

・grep

用途:ファイルや標準出力から特定の文字列を検索・抽出
書式:grep [オプション] "検索文字列" ファイル名
補足:grepは|(パイプ)と組み合わせて、他のコマンド出力から抽出するのが定番。

コマンド | grep [オプション] 検索パターン

#実行例:ファイル内で「error」を含む行を検索

$ grep "error" /var/log/syslog
Oct  3 10:02:15 myhost kernel: error -32
Oct  3 10:03:01 myhost systemd: Job failed: error code 1
#実行例:パイプを用いてファイル一覧から特定の拡張子だけ抽出

$ ls -l | grep "\.log"
-rw-r--r--  1 user user   2048 Oct  3 09:12 app.log
-rw-r--r--  1 user user   4096 Oct  3 09:18 access.log

最後に:snowflake:

これらのコマンドはシステム運用やトラブルシューティングで非常によく使われます。
普段から手に馴染ませておくことで、急な対応にも落ち着いて対処できるようになります。
以上、現場で使ったLinuxコマンド(一部抜粋)でした。

49
6
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
49
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?