-
Linux樹林
[Linux] Execute Commands in Bulk with Standard Input Using the xargs Command
Overview The xargs command takes a list of data from standard input (such as a pipeline) and converts it into "arguments" for a specific command. It is a key tool for pipeline processing and automation. For example, you can use it to del... -
Linux樹林
【Linux】xargsコマンドで標準入力を引数にしてコマンドを一括実行する
概要 標準入力(パイプラインなど)から渡されたデータリストを、指定したコマンドの「引数」として変換し、実行するためのコマンドです。 find コマンドで検索した大量のファイルを一括で削除したり、テキストリストを読み込んで複数のディレクトリを作成... -
Linux樹林
[Linux] Search and Manipulate Files with the find Command
Overview The find command is a powerful tool used to search for files within a system based on various conditions such as filename, modification time, size, permissions, and ownership. It does more than just locate files; it can also per... -
Linux樹林
【Linux】findコマンドで条件を絞ってファイルを検索・操作する
概要 システム内に存在する膨大なファイルの中から、ファイル名、更新日時、サイズ、権限、所有者など、あらゆる条件を組み合わせてファイルを検索する強力なコマンドです。 単に場所を探すだけでなく、検索したファイルに対して「削除する」「移動する」... -
Linux樹林
[Linux] Set Default Permissions for New Files with the umask Command
Overview The umask command controls the default access permissions (permissions) assigned to files and directories when they are newly created. Unlike commands that specify which permissions to give, umask works by specifying which permi... -
Linux樹林
[Linux] Change File Attributes and Prevent Deletion with the chattr Command
Overview The chattr command is used to set and change "special attributes" (extended attributes) in Linux file systems like ext2, ext3, ext4, and XFS. These attributes are different from standard permissions (read, write, execute). It is... -
Linux樹林
【Linux】umaskコマンドでファイル作成時の初期権限(マスク値)を設定する
概要 Linuxにおいて、ファイルやディレクトリを新規作成した際に、デフォルトで付与されるアクセス権限(パーミッション)を制御するためのコマンドです。 「どの権限を与えるか」ではなく「どの権限を禁止するか(マスクするか)」という引き算の考え方で... -
Linux樹林
【Linux】chattrコマンドでファイルの属性変更・削除禁止設定を行う
概要 Linuxの標準的なファイルシステム(ext2/ext3/ext4)やXFSなどにおいて、通常のパーミッション(読み書き実行)とは異なる「特殊属性(拡張属性)」を設定・変更するためのコマンドです。 特に、rootユーザーであっても削除や変更ができなくなる「不... -
Linux樹林
[Linux] Display Special File Attributes with the lsattr Command
Overview The lsattr command is used in standard Linux file systems (such as ext2, ext3, and ext4) to check "special attributes" (extended attributes) that are separate from normal permissions (rwx). This command allows you to identify fi... -
Linux樹林
【Linux】lsattrコマンドでファイルの特殊属性(拡張属性)を表示する
概要 Linuxの標準的なファイルシステム(ext2/ext3/ext4など)において、通常のパーミッション(rwx)とは別の「特殊属性(拡張属性)」を確認するためのコマンドです。 「root権限があっても削除できないファイル」や「追記しかできないログファイル」な... -
Linux樹林
[Linux] Change Group Ownership with the chgrp Command
Overview The chgrp command is specifically designed to change the "owning group" of files and directories. While you can also change groups with the chown command, chgrp has a simpler syntax. It is frequently used when you want to manage... -
Linux樹林
【Linux】chgrpコマンドでファイルのグループ所有権を変更する
概要 ファイルやディレクトリの「所有グループ」を変更することに特化したコマンドです。 chown コマンドでもグループの変更は可能ですが、chgrp は構文がシンプルで、特に「プロジェクトメンバー内での共有設定」や「Webサーバーの書き込み権限設定」など... -
Linux樹林
[Linux] Change File and Directory Owner and Group with the chown Command
Overview The chown command is used to change the "owner" and "group" of files and directories in Linux. By default, the user who creates a file becomes its owner. However, you often need to change ownership when deploying web servers or ... -
Linux樹林
【Linux】chownコマンドでファイル・ディレクトリの所有者とグループを変更する
概要 Linuxにおけるファイルやディレクトリの「所有者(オーナー)」および「所有グループ」を変更するためのコマンドです。 通常、ファイルを作成したユーザーがその所有者となりますが、Webサーバーのデプロイ時や、バックアップファイルを別ユーザーに... -
Linux樹林
[Linux] Change File and Directory Permissions with the chmod Command
Overview The chmod command is a fundamental tool for security management in Linux. It sets access permissions—"who" (owner, group, others) can do "what" (read, write, execute)—for files and directories. You will use this command frequent... -
Linux樹林
【Linux】chmodコマンドでファイル・ディレクトリの権限(パーミッション)を変更する
概要 Linuxにおけるセキュリティ管理の基本となるコマンドで、ファイルやディレクトリに対する「誰が(所有者・グループ・その他)」「何をできるか(読み・書き・実行)」というアクセス権限(パーミッション)を設定します。 Webサーバーの公開設定や、... -
Linux樹林
[Linux] Display the Target of Symbolic Links with the readlink Command
Overview The readlink command is used to find the "actual file path" that a symbolic link (shortcut) points to. While you can check a link's target with ls -l, readlink is better for shell scripts because it outputs only the path itself.... -
Linux樹林
【Linux】readlinkコマンドでシンボリックリンクのリンク先を表示する
概要 シンボリックリンク(ショートカット)が実際に指し示している「実体ファイルのパス」を取得するためのコマンドです。 ls -l でもリンク先を確認できますが、readlink はリンク先パスのみを標準出力するため、シェルスクリプト内で「実行ファイルの絶... -
Linux樹林
[Linux] Create Hard Links and Symbolic Links with the ln Command
Overview The ln command creates "links" to files or directories in the Linux file system. You can create two types of links: "Symbolic Links," which are like Windows shortcuts, and "Hard Links," which allow a single file to have multiple... -
Linux樹林
【Linux】lnコマンドでハードリンク・シンボリックリンクを作成する
概要 Linuxファイルシステムにおいて、ファイルやディレクトリへの「リンク」を作成するコマンドです。 Windowsの「ショートカット」に相当する「シンボリックリンク」と、1つのファイル実体に複数の名前(アクセス経路)を持たせる「ハードリンク」の2種... -
C#樹林
Unit Testing Classes with Dependency Injection in C# using xUnit and Moq
Overview This article explains a unit testing method for classes that use the Dependency Injection (DI) pattern, which is a standard in modern C# development. Instead of directly creating instances of classes that access external service... -
C#樹林
【C#】xUnitとMoqで依存性注入(DI)を利用したクラスの単体テストを作成する方法
概要 モダンなC#開発において標準的な「依存性注入(Dependency Injection: DI)」パターンを採用したクラスの単体テスト手法です。 外部サービスやデータベースへのアクセスを行うクラスを直接インスタンス化せず、インターフェース経由でモックオブジェ... -
未分類
[C#] Testing Class Logic Using Partial Mocks with xUnit and Moq
Overview This article explains "Partial Mocking," a technique using xUnit and Moq to mock only specific methods of a class while keeping the original implementation for the remaining methods. This is effective when there is a need to iso... -
C#樹林
【C#】xUnitとMoqでクラスの一部だけをモック化してテストする(Partial Mock)
概要 xUnitとMoqを使用して、クラスの一部のメソッドだけをモック(偽装)し、残りのメソッドは本来の実装をそのまま動作させる「Partial Mock(部分モック)」の手法です。 乱数生成や現在時刻の取得など、テストのたびに結果が変わる不安定なメソッドだ... -
C#樹林
[C#]Executing Custom Logic during Method Calls with Callback in Moq
Overview This article explains how to execute arbitrary code when a method of a mock object is called using Moq. Beyond just returning a value, the Callback method allows you to define "side effects," such as saving the arguments passed ... -
C#樹林
【C#】Moqでメソッド呼び出し時に独自の処理を実行する(Callback)
概要 Moqを使用して、モックオブジェクトのメソッドが呼び出されたタイミングで任意のコードを実行する方法です。 単に値を返すだけでなく、呼び出された際の引数を変数に保存して後で検証したり、デバッグ用にコンソール出力を行ったりといった「副作用」... -
C#樹林
[C#]Throwing Exceptions with Moq when a Method is Called
Overview Confirming the behavior of "error handling" and "exception cases" is crucial in unit testing. Using the Moq library, you can intentionally throw an exception when a method is called. This allows you to safely test the applicatio... -
C#樹林
【C#】Moqでメソッド呼び出し時に例外を発生させる方法
概要 単体テストにおいて「エラー処理」や「異常系」の動作を確認することは非常に重要です。 Moqライブラリを使用すると、メソッドが呼び出された際に意図的に例外(Exception)を発生させることができます。これにより、例外発生時のアプリケーションの... -
C#樹林
[C#]Defining Argument Conditions and Dynamic Return Values with Moq
Overview This article explains how to define method behavior when using the Moq library for .NET. We will cover three patterns: "Exact Match" which returns a value only for a specific argument, "Conditional Match" which responds to argum... -
C#樹林
【C#】Moqでメソッドの引数条件と動的な戻り値を定義する方法
概要 .NETのモックライブラリ「Moq」を使用して、メソッドが呼び出された際の振る舞いを定義する方法です。 特定の引数が渡された場合のみ値を返す「完全一致」、条件を満たす引数に反応する「条件マッチ」、そして渡された引数を使って計算結果を返す「動...