7
5

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】よく使うコマンドと使用タイミングをまとめてみた

Posted at

はじめに

この記事ではLinuxでよく使うコマンドとその使用例を簡単に載せています。
利用法を忘れた際にご覧いただければと思います


📝 Linuxコマンド解説

📂 移動・ディレクトリ操作

  • cd (Change Directory)

    • ディレクトリを移動するためのコマンド。
    • 例: cd /home/user/Documents/home/user/Documents に移動

  • pwd (Print Working Directory)

    • 現在のディレクトリのパスを表示する。(カレントディレクトリともいう)
    • 例: pwd/home/user

  • ls (List)

    • ディレクトリの中のファイルやフォルダを一覧表示する。
    • 例: ls -l → 詳細な情報付きで表示

  • mkdir (Make Directory)

    • 新しいディレクトリを作成する。
    • 例: mkdir new_foldernew_folder を作成

  • rmdir (Remove Directory)

    • 空のディレクトリを削除する。
    • 例: rmdir old_folderold_folder を削除

📄 ファイル操作

  • cat (Concatenate)

    • ファイルの内容を表示する。(本来の文字の意味的には複数のファイルを連結するコマンドだが、ファイル1つ指定でその内容を表示するコマンドとして使用されることが多い)
    • 例: cat file.txtfile.txt の内容を表示

  • less

    • ファイルの内容をスクロールしながら表示する。
    • 例: less file.txtfile.txt の表示を制御できる。(catで表示しようとすると、行数が多い場合は表示が流れて行ってしまうため)

  • tail

    • ファイルの末尾を表示する。
    • 例: tail -n 10 file.txtfile.txt の最後の10行を表示

  • touch

    • 空のファイルを作成する、または既存のファイルの更新日時を変更する。
    • 例: touch newfile.txtnewfile.txt を作成

  • rm (Remove)

    • ファイルを削除する。
    • 例: rm file.txtfile.txt を削除

  • mv (Move)

    • ファイルやディレクトリを移動・名前変更する。
    • 例(移動): mv sample.txt dirsample.txtdirディレクトリ に移動
    • 例(名前変更): mv oldname.txt newname.txtoldname.txtnewname.txt に変更

  • cp (Copy)

    • ファイルやディレクトリをコピーする。
    • 例: cp file.txt copy.txtfile.txtcopy.txt にコピー

  • ln (Link)

    • ファイルのハードリンクやシンボリックリンクを作成する。
    • 例: ln -s target_file link_nametarget_file のシンボリックリンクを link_name で作成
    • ▼より詳細を知りたい方は以下記事を参考にしてみてください


🔎 検索・アクセス権限操作

  • find
    • ファイルやディレクトリを検索する。
    • 例: find /home -name "*.txt"/home 内の .txt ファイルを検索
    • ▼より詳細を知りたい方は以下の記事を参考にしてみてください


  • chmod (Change Mode)

    • ファイルやディレクトリのアクセス権を変更する。
    • 例: chmod 755 script.shscript.sh に実行権限を付与

  • chown (Change Owner)

    • ファイルやディレクトリの所有者を変更する。
    • 例: chown user:user file.txtfile.txt の所有者を user に変更

🖥 プロセス管理

  • ps (Process Status)

    • 現在動作しているプロセスを表示する。
    • 例: ps aux → 実行中のプロセス一覧を詳細表示

  • kill

    • プロセスを終了させる
    • 例: kill 1234 → プロセスID 1234 を終了

7
5
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
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?