Copying files to a USB drive [closed]
The command you want is:
cp -r /opt/biweb/app/* /dev/sdb1/
Don't forget the asterix (*)! The above command will copy everything in the /app
folder into the /sdb1
folder.
If you want to copy the app
folder itself into the destination, then do:
cp -r /opt/biweb/app /dev/sdb1/
The above has no trailing slash after "app". This will copy the app
folder as well as its contents.
The device description for the partition on the USB drive is
/dev/sdxn
where x is the drive letter and n is the partition number, In your case it seems to be /dev/sdb1
. But you should not write directly to the device. Instead you should mount it and write to the file system at the mountpoint. First you should create a mountpoint, or use one that already exists. Text after #
is a comment (not used as a command).
sudo mkdir /mnt/sdn # only the first time
sudo mount /dev/sdxn /mnt/sdn
or in your case
sudo mkdir /mnt/sd1
sudo mount /dev/sdb1 /mnt/sd1
You may want to make sure that you are allowed to write to the USB pendrive from a regular user by the following method,
sudo mkdir -p /mnt/sd1 # only if you want a new mountpoint
sudo umount /dev/sdxn # general: only if already mounted (with bad permissions).
sudo umount /dev/sdb1 # example
sudo mount -o rw,users,umask=000 /dev/sdxn /mnt/sd1 # general: mount
sudo mount -o rw,users,umask=000 /dev/sdb1 /mnt/sd1 # example
ls -ld /mnt/sd1 # check permissions
sudo bash -c "echo 'Hello World' > /mnt/sd1/hello.txt" # test writing with sudo
cat /mnt/sd1/hello.txt # test reading (as user)
ls -l /mnt/sd1 # check permissions of the content
rm /mnt/sd1/hello.txt # test removing (as user)
echo 'I am a user' > /mnt/sd1/user.txt # test writing (as user)
Edit 1: Sometimes (I would even say often) the partition on the USB drive will be mounted automatically. You will find it with the following commands,
df -h
sudo lsblk -f
sudo lsblk -m
The automatic mounting may or may not make it read-write for the regular user, but it will usually be possible to write with superuser privileges, with sudo
.
You can inspect how it is mounted with the command
mount
but it will display a lot of information (about everything that is mounted).
Edit 2: copying command
After finding out that the pendrive is automatically mounted on /data
, the following command line should work, if [the partition in] the USB drive is mounted read/write and with permissions for your regular user ID.
cp -r /opt/biweb/app /data
It should create a directory /data/app
on the USB drive with the content (the directory tree and the files). If it does not work, you can try the special mounting method, that I showed above, but modified for the current mountpoint,
sudo umount /data # unmount
sudo mount -o rw,users,umask=000 /dev/sdb1 /data # mount with 'full' permissions
Edit 3: Please edit your original question, where you can use formatting tools.