溫馨提示×

Ubuntu Notepad文件共享方法

小樊
51
2025-10-02 09:24:16
欄目: 智能運維

Using Samba for File Sharing (Recommended for Cross-OS Compatibility)
Samba is a widely-used service that enables Ubuntu to share files with Windows, macOS, and other Linux systems over a local network. Below are the step-by-step instructions to set it up:

  1. Install Samba: Open a terminal and run the following commands to update your package list and install Samba:
    sudo apt update
    sudo apt install samba
    
  2. Create a Shared Folder: Choose a directory you want to share (e.g., ~/shared_folder) and create it using:
    mkdir ~/shared_folder
    
  3. Adjust Folder Permissions: Grant read/write access to all users (or restrict as needed) with:
    chmod 777 ~/shared_folder
    
  4. Configure Samba: Edit the Samba configuration file (/etc/samba/smb.conf) using a text editor (e.g., nano):
    sudo nano /etc/samba/smb.conf
    
    Add the following block at the end of the file (replace your_username with your Ubuntu username and adjust the path if needed):
    [shared_folder]
    path = /home/your_username/shared_folder
    browseable = yes
    writable = yes
    create mask = 0777
    directory mask = 0777
    guest ok = yes
    
    • browseable: Allows the folder to appear in network listings.
    • writable: Enables file modifications.
    • guest ok: Permits anonymous access (remove if password protection is needed).
  5. Restart Samba: Apply changes by restarting the Samba services:
    sudo systemctl restart smbd
    sudo systemctl restart nmbd
    
  6. Access the Share: On a Windows PC, open File Explorer and enter \\Ubuntu_IP_Address\shared_folder in the address bar (replace Ubuntu_IP_Address with your Ubuntu machine’s IP). For Linux clients, use smbclient or mount the share via mount.cifs.

Using Nautilus (GUI) for Quick Sharing
If you prefer a graphical interface, Ubuntu’s default file manager (Nautilus) supports one-click sharing:

  1. Install Nautilus Share Plugin: If the “Local Network Share” option is missing, install the plugin:
    sudo apt install nautilus-share
    
  2. Restart Nautilus: Run nautilus -q to apply changes.
  3. Share a Folder: Right-click the target folder, select Properties, go to the Local Network Share tab, and check “Share this folder.” Enable “Allow others to create and delete files” for write access, then click “Create Share.”

Troubleshooting Common Issues

  • Service Not Starting: Ensure the Samba service is enabled and running:
    sudo systemctl enable smbd
    sudo systemctl status smbd
    
  • Permission Denied: Verify folder permissions (chmod 777) and Samba user credentials (smbpasswd -a your_username).
  • Firewall Blocking: Allow Samba traffic through the firewall:
    sudo ufw allow samba
    

By following these steps, you can easily share files from Ubuntu using Samba (for cross-OS compatibility) or Nautilus (for quick GUI-based sharing). Adjust permissions and configurations based on your specific needs (e.g., restricting access to specific users).

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女