Connecting two computers directly enables faster file transfers than other methods and allows sharing one machine's internet connection with the other. The connection process depends on your operating system and your intended purpose: whether it's for file sharing or internet sharing.
Steps
File Sharing (Windows to Windows)

Disable the wireless adapter on the computer (optional). If the computer has a wireless adapter, turn it off before connecting. This helps prevent network conflicts.
- Click the Start menu, type ncpa.cpl and hit Enter.
- Right-click on the wireless connection and select "Disable".

Connect the two computers using an Ethernet cable. Modern computers can use a standard Ethernet cable since the network adapter will automatically detect that you're connecting two computers. Older computers may need to use a crossover cable, which is a standard Ethernet cable with a reversed connection at one end.

Go to the computer you want to share from. Although you can transfer files between the two computers, setting up the sharing feature on the newer computer will make things easier.

Right-click the network icon on the System Tray. Open the "Open Network and Sharing Center" to proceed with the setup.

Click on "Local Area Connection" next to "Unidentified network". This step will open the connection details for the new link between the two computers.

Click on .Properties (Properties). Select "Internet Protocol Version 4" and click on the Properties button.

Select 'Use the following IP address.' This action allows you to manually enter an IP address.

Enter an IP address. Since you're not using the internet, you can choose any IP address. For simplicity, set it as 192.168.1.10.

Press Tab to automatically fill in the subnet mask. Click 'OK.'

Switch to the other computer. Open the Network and Sharing Center just like the first one.

Click on 'Local Area Connection' next to 'Unidentified network.' This will open the connection details for the new link between the two computers.

Click on 'Properties.' Select 'Internet Protocol Version 4' and click on 'Properties.'

Select 'Use the following IP address.' This will allow you to manually enter an IP address on the second computer.

Enter an IP address with a different last set of numbers from the first computer. Since we used 192.168.1.10 on the first machine, enter 192.168.1.11 on the second one.

Press Tab to automatically fill in the subnet mask. Click 'OK.' The two computers are now connected on their private network.

Go back to the computer used for data sharing. Locate the drive, file, or folder you want to share with the second computer.

Right-click on the object you wish to share and select 'Properties.' Then, click on the 'Sharing' tab.

Click on 'Advanced Sharing' and check the box labeled 'Share this folder.'

Click on 'Permissions' and check the 'Allow' box next to 'Full Control.' This action grants the second computer read and write access to the shared folder. Then, click 'Apply.'

Return to the Properties window for the object and select the 'Security' tab. Make sure 'Everyone' is listed in the user list. If it's missing, click on the 'Add...' button and follow the instructions to add 'Everyone' to the list.

Click on the Start menu on the computer accessing the shared folder, which, in our example, is the second computer.

Type .\\IP address and press Enter. Using the previously entered IP address, type \\192.168.1.10.

Navigate to the shared folder. Now you should see the entire directory you shared from the first computer. If the permissions were set correctly, you’ll be able to copy, delete, and add files to the shared folder.
File Sharing (Windows to Mac)

Open the Control Panel on the Windows machine. You’ll need to enable the Guest account for easier connection.

Click on "User Accounts" and then select "Manage another account". This action will allow you to add the Guest account to the computer. You can remove the account after transferring the files.

Click on "Guest Account" (Tài khoản Khách), then select .Turn On (Enable). This step will activate the Guest account.

Go back to the Control Panel and choose "Network and Sharing Center" (Trung tâm Mạng và Chia sẻ). You will need to make a few more changes before you can connect the two computers.

Click on "Change advanced sharing settings" (Thay đổi cài đặt chia sẻ nâng cao). Scroll down and select "Turn off password protected sharing" (Disable password protected sharing).

Connect the two computers using an Ethernet cable. Most modern computers support the standard Ethernet cable. If you're unable to connect the two systems, you may need to use a crossover cable.

Click the Start menu on your Windows machine. Type ncpa.cpl and press Enter.

Double-click on Local Area Connection. This action allows you to modify the settings of the new connection between the two computers.

Click on the .Details... (Information) and record the line "Auto-configuration IPv4 Address" (Auto-configured IPv4 Address).

Identify the drive, file, or folder you wish to share with the Mac. If you want to share everything on the Windows machine, choose the hard drive containing the data.

Right-click on the item you wish to share. Select "Share With" and click on "Specific people".

Type "Guest" and click on .Add(Add). Don’t forget to capitalize the "G" in "Guest".

Click on "Read" in the "Permission Level" column next to "Guest". Then, select "Read/Write" to gain access to viewing and editing rights.

Click on the .Share button. Then, click on Next to proceed with sharing the folder.

Open the Finder window on your Mac. Then, press Command + K to access the "Connect to Server" option.

Enter .smb://IP address. Use the IP address you found in step 9. Then, click on Connect to initiate the connection.

Select the "Guest" account to log in. Then, click Connect to establish the connection.

Select the shared folder and click on .OK. Depending on the data shared from your Windows machine, you should see one or more folders available at this stage.

Navigate to the shared file. Now that the connection has been established, you can share data through the folder created on your Windows computer. You can use your Mac to drag and drop files in and out of this folder to access the Windows system.
File Sharing (Mac to Mac)

Purchase a Thunderbolt cable. Thunderbolt provides the fastest and most straightforward way to transfer data between two Mac computers. Most modern Mac models support Thunderbolt connectivity.

Turn off the computer used for file sharing. The Thunderbolt connection will convert the other computer into an external drive, so there is no need to boot up the system for operation.

Connect the two computers using a Thunderbolt cable. A Thunderbolt cable only allows a one-way connection.

Turn on the second computer and hold the T key. This action will boot the computer into Target Disk Mode.

Wait for the Thunderbolt logo to appear. The logo will show up after a few seconds. At this point, you can release the T key.

Access the hard drive on the first Mac. The second computer will appear as an external hard drive on the first Mac. You can open the drive, browse, and transfer files as usual. Since the Thunderbolt cable provides the fastest available connection, data transfer will be very quick.
Internet Sharing (Windows)

Kết nối hai máy tính bằng cáp Ethernet. Máy tính đời mới có thể sử dụng cáp Ethernet vì bộ tiếp hợp sẽ tự động phát hiện rằng bạn đang kết nối hai máy tính. Máy đời cũ có thể sử dụng cáp chéo, đây là cáp Ethernet tiêu chuẩn với kết nối đảo ngược ở 1 đầu.
- Bạn có thể sử dụng chia sẻ kết nối internet để chia sẻ mạng với bất kỳ máy tính nào có thể kết nối qua cáp Ethernet, hệ điều hành nào cũng được.

Nhấp chuột vào trình đơn Start trên máy tính Windows có kết nối internet. Gõ ncpa.cpl và nhấn Enter.

Nhấp chuột phải vào kết nối để truy cập internet. Chọn "Properties" (Đặc tính).

Nhấp chuột vào tab "Sharing" (Chia sẻ). Đây là thao tác cho phép bạn chia sẻ kết nối truy cập internet.

Tích vào hộp thoại "Allow other network users to connect through this computer's Internet connection" (Cho phép người dùng mạng khác kết nối thông qua mạng internet của máy tính này). Nhấp chuột vào nút OK.

Access the internet on the second computer. Once the internet connection has been shared and activated on the first computer, the second computer will immediately be able to access the network.
Internet Sharing (Mac)

Connect the two computers using an Ethernet cable. Newer models can use an Ethernet cable since the network adapter will automatically detect that you are connecting two computers. Older models may require a crossover cable, which is a standard Ethernet cable with one reversed connector at one end.
- You can use internet connection sharing to provide network access to any computer that can connect via Ethernet cable, regardless of the operating system.

Click on the Apple menu on the Mac with the internet connection and select System Preferences. Then, choose "Sharing" from the System Preferences menu.

Click on the "Internet Sharing" option in the left-hand panel. Do not check the box yet.

Select the Mac's internet connection from the drop-down menu. If you are connecting two computers via Ethernet cable, you will typically be sharing a Wi-Fi connection.
- Older Mac models will show "Airport" instead of "Wi-Fi".

Check the "Ethernet" option in the "To computers using" list. This allows your computer to share its network connection with any device connected via Ethernet cable.

Check the "Internet Sharing" box. Click the Start button (Start) if prompted.

Access the network on the second computer. Once network sharing is activated on the first computer, the second computer can access the internet immediately.
- It may take a moment for the second computer to acquire a new IP address.