A square of side $n$ is formed from $n^2$ unit squares, each colored in red, yellow or green. Find minimal $n$, such that for each coloring, there exists a line and a column with at least 3 unit squares of the same color (on the same line or column).
To solve this problem, we need to find the smallest \( n \) such that in any \( n \times n \) grid colored with three colors (red, yellow, green), there is at least one row or one column with at least three squares of the same color. We will use the pigeonhole principle to determine this.

1. **Understanding the Pigeonhole Principle**:
   The pigeonhole principle states that if \( n \) items are put into \( m \) containers, with \( n > m \), then at least one container must contain more than one item. In this problem, we will use this principle to ensure that at least one row or column has three squares of the same color.

2. **Analyzing the Grid**:
   Consider an \( n \times n \) grid. Each row and each column contains \( n \) squares. We need to ensure that in any coloring, there is at least one row or one column with at least three squares of the same color.

3. **Applying the Pigeonhole Principle**:
   - For a row or column to avoid having three squares of the same color, each color must appear at most twice in that row or column.
   - Therefore, each row or column can have at most \( 2 \times 3 = 6 \) squares if we are to avoid having three squares of the same color.

4. **Finding the Minimum \( n \)**:
   - If \( n \leq 6 \), it is possible to color the grid such that no row or column has three squares of the same color. For example, we can use a repeating pattern like RYG (Red, Yellow, Green) to ensure that no color appears more than twice in any row or column.
   - However, if \( n = 7 \), each row and each column contains 7 squares. By the pigeonhole principle, since there are only three colors, at least one color must appear at least \( \lceil \frac{7}{3} \rceil = 3 \) times in that row or column.

5. **Verification**:
   - For \( n = 7 \), consider any arbitrary coloring of the grid. Since each row and each column has 7 squares and only three colors are available, at least one color must appear at least three times in each row or column.
   - Therefore, \( n = 7 \) is the smallest value for which the condition is satisfied.

Conclusion:
The minimal \( n \) such that for each coloring, there exists a line and a column with at least 3 unit squares of the same color is \( n = 7 \).

The final answer is \( \boxed{ n = 7 } \).