How to access files on a USB flash drive in Linux?

In Linux, you can access files on a USB drive by following these steps:

  1. After inserting the USB drive into the computer’s USB port, wait for the system to automatically detect and mount the USB drive. If the system does not automatically mount the USB drive, you can manually mount it using the following command:
sudo mkdir /media/usb     # 创建一个挂载点(如果不存在)
sudo mount /dev/sdb1 /media/usb   # 将U盘挂载到挂载点

The above command assumes that the USB drive is on /dev/sdb1. If the USB drive is on a different device, you can modify it accordingly.

  1. After successful mounting, you can open the mounting point (/media/usb) using a file manager like Nautilus to access the files on the USB drive.
  2. In the terminal, you can also access files on a USB drive using the command line. For example, you can use the following command to list the files on the USB drive:
ls /media/usb

You can use the cd command to enter the directory of the USB drive.

cd /media/usb

You can use the cp command to copy files to a USB drive.

cp /path/to/source/file /media/usb

You can use the mv command to move files to or from a USB drive.

mv /path/to/source/file /media/usb
mv /media/usb/file /path/to/destination

You can use the “rm” command to delete files on a USB flash drive.

rm /media/usb/file

When accessing files in a USB drive, it’s necessary to run commands with root privileges (using sudo) or add the current user to the sudo group in order to have sufficient permissions to access the USB drive.

bannerAds