Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Linux utility gPhoto2 to back up mobile phone storage

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the Linux utility gPhoto2 backup mobile phone storage, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Install gPhoto2

It is likely that your Linux system has libgphoto2 installed because it is a key library for connecting to mobile devices, but you may also need to install the command gphoto2, which may be in your repository.

On Fedora or RHEL:

$sudo dnf install gphoto2

On Debian or Ubuntu:

$sudo apt install gphoto2 verifies compatibility

To confirm that your mobile device is supported, use-- list-cameras and pipe it to less:

$gPhoto2-- list-cameras | less

Or you can pipe it to grep to search for a word. For example, if you have a Samsung Galaxy, use grep and turn off case sensitivity with the option-I:

$gphoto2-- list-cameras | grep-I galaxy "Samsung Galaxy models (MTP)"Samsung Galaxy models (MTP+ADB)"Samsung Galaxy models Kies mode"

This confirms that Samsung Galaxy devices support both MTP connection and ADB connection to MTP.

If you don't find your mobile device in the list, you can still try using gphoto2. Maybe your device uses a different name in the list.

Find mobile Devic

To use gPhoto2, you must first plug the mobile device into the computer, set it to MTP mode, and grant the computer permission to interact with it. This usually requires operating on your mobile device, often by pressing a button on the screen to allow its file system to be accessed by the computer to which it has just been connected.

Screenshot of allow access message

If you don't authorize your computer to access your mobile device, gPhoto2 can detect your mobile device, but it can't interact with it.

To ensure that your computer detects the mobile device you are connected to, use the-- auto-detect option:

$gphoto2-auto-detectModel Port--Samsung Galaxy models (MTP) usb:002010

If your mobile device is not detected, check the data line first, and then check if your device is configured to connect through MTP, ADB, or other protocols supported by gPhoto2, as shown in-- list-cameras.

Query the features supported by your device

For modern devices, there are usually too many potential features, but not all mobile devices support these features. You can use the-- abilities option to determine which features your mobile device supports. I think the result looks intuitive.

Gphoto2-- abilitiesAbilities for camera: Samsung Galaxy models (MTP) Serial port support: noUSB support: yesCapture choices: Capture not supported by driverConfiguration support: noDelete selected files on camera: yesDelete all files on camera: noFile preview (thumbnail) support: noFile upload support: yes

If only one device is connected, you do not need to specify the device for the query. However, if you have multiple devices connected to which gPhoto2 can interact, you can specify the device by port, camera model, or usbid.

Interact with your mobile device

If your device supports shooting, you can call your camera from your computer to get the media. For example, to take a picture:

$gphoto2-capture-image

To take a picture and immediately transfer it to the connected computer:

$gphoto2-capture-image-and-download

You can also record videos and sounds. If more than one shooting device is connected, you can specify the device to use by port, camera model, or usbid:

$gphoto2-camera "Samsung Galaxy models (MTP)"\-capture-image-and-download files and folders

To manage files on mobile devices more intelligently, you need to understand the structure of gPhoto2-connected file systems.

You can use the-- get-folders option to view the available folders:

$gphoto2-list-foldersThere are 2 folders in folder'/'. -store_00010001-store_00020002There are 0 folders in folder'/ store_00010001'.There are 0 folders in folder'/ store_00020002'.

Each folder represents a storage unit on the device. In this case, store_00010001 is the internal memory and store_00020002 is the SD card, which may be different from the structure of your device.

Get Fil

Now that you know the folder layout of the device, you can get photos from the device. You can use many different options, depending on what you want from the device.

If you know the absolute path, you can get the specified file:

$gphoto2-get-file IMG_0001.jpg-folder / store_00010001/myphotos

You can get all the files at the same time:

$gphoto2-get-all-files-folder / store_00010001/myfiles

You can only get audio files:

Gphoto2-get-all-audio-data-folder / store_00010001/mysounds

GPhoto2 has other options, most of which depend on the device you are connected to and whether the protocol is supported or not.

Upload files

Now that you know the potential target folder, you can upload files from your computer to your device. For example, suppose there is a file named example.epub in the current directory, and you can use the-- upload-file option and-- folder option to send the file to the device and specify the directory to upload to:

$gphoto2-upload file example.epub\-folder store_00010001

If you want to upload multiple files to the same location, you can create a directory on your device:

$gphoto2-- mkdir books\-- folder store_00010001 $gphoto2-- upload-file * .epub\-- folder store_00010001/books lists files

To view files on a device, use the-- list-files option:

Gphoto2-- list-files-- folder / store_00010001There is 1 file in folder'/ store_00010001'#1 example.epub 17713 KB application/x-unknown$ gphoto2-- list-files-- folder / store_00010001/booksThere is 1 file in folder'/ store_00010001'#1 example0.epub 17713 KB application/x-unknown#2 example1.epub 12264 KB application/x-unknown [...] Thank you for reading this article carefully. I hope the article "how to use the Linux utility gPhoto2 to back up mobile phone storage" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report