ok how can i copy files to my flash using commands in linux ??
use dd for creating a large backup, otherwise just use a simple cp command,
Copy /homedirectory/filename to /yourflashdrive/filename:
cp /home/filename /media/sdb1/filename
Edited by nonshatter: n/a
ok , but do i have to do anything when i plug in my flash if my computer doesn't have Graphic user interface
If there's no graphic interface, you may have to manually mount your usb drive (unless your OS happens to auto-mount drives).
NOTES: Before we start, This is completely off the top of my head, I've not got a *nix box in front of me to test any of this atm, but it should work. Apologies if there are any errors though! Also you should be aware that I tend to use debian based distros, so I've included use of sudo to get root access in the following guide. You'll need to substitute sudo for su, or whatever your distro uses to get root access.
Anyway, moving onward!
To manually mount, you'll need to do the following:
1. After plugging a USB drive into your machine, you need to use the lsusb command to see what devices are connected via USB and search the output for anything that refers to your USB stick.
If you can see something which refers to your USB stick (manufacturer, capacity etc.), you'll know for certain that your system has recognised the device and you can continue on to mount it.
But if you don't see anything, there's no point attempting to mount the device, as the OS has not detected/recognised it!
2. Assuming you found your device, next you'll need to get a list of connected drives using:
dmesg | grep -i "SCSI device"
Again take a look in the output for something that refers to your USB stick. So if your stick is 1GB and you see a drive listed that has 1GB capacity, then it's most likely to be your device (provided there aren't more than one 1Gb drives plugged in!)
Once you've identified your device in the list (it could be /dev/sda, /dev/sdb, /dev/sdb1, /dev/sdc etc.), you need to make a note of it.
For this example, lets assume that I've identified /dev/sdb1 as my USB drive.
3. Next we'll need to create a directory to act as a mount point.
Where you choose to put this directory is up to you. You could put it in a directory in /media/, which is where some distros auto mount drives to. Or you could create a folder in your home directory, or wherever.
Going with /home/ for my example:
This creates a folder on my desktop called 'myflash', which I'll use as a mount-point for my USB drive.
4. OK, So now we've identified our USB device and created a mount point, we can finally mount it. To do this, we'll need use the mount command. The syntax for which will look something like this:
"mount -t TYPE -o uid=YOUR_USERNAME,gid=users /dev/YOUR_DRIVE MOUNT_POINT"
Where TYPE is the filesystem in use on the drive. For a typical USB drive I'd assume 'vfat' would most likely be used. But if your USB stick has been formatted in ext3, ext4 or some other format, then it should be specified here. Anyway, for the purposes of this example, I'll use 'vfat'!
Substitute YOUR_USERNAME with your username, in my case it would be 'jason'.
Substitute YOUR_DRIVE with the drive you identified as yours (for this example, I'll use 'sdb1')
Finally substitute MOUNT_POINT with the directory you created to mount the drive (in the case of this example, '/home/jason/Desktop/myflash')
So putting it all together; for my USB drive, I'd need to use:
mount -t vfat -o uid=jason,gid=users /dev/sdb1 /home/jason/Desktop/myflash
(But obviously, you need to use the information for your drive and your preferred mount-point etc!)
All being well, my drive should now be mounted at /home/jason/Desktop/myflash.
If you use cd to navigate to your mount-point, you should now be able to list/view the contents of the drive using ls.
e.g. for my drive:
cd /home/jason/Desktop/myflash && ls -a -l
To copy a file to the drive, you can simply use cp to copy to the mount point:
cp ~/somefile.txt /home/jason/Desktop/myflash/
The previous example is OK if you only use the USB drive occasionally, but if you plan to use the USB stick often; you could make an entry in etc/fstab, which will prepare your computer to mount the USB stick every time it is booted. This will simplify the mounting process for you somewhat.
BTW: In case you are worried the system might try to mount the drive even when it is not plugged in, you should know that this doesn't try to mount the drive at all! It simply makes it quicker and easier to mount for when the device IS plugged in!
Anyway, to do this, you need to gather some information about your drive (as per the previous example) by using lsusb, dmesg and grep (see the previous example for the exact commands!)
Next, create a back-up of the current version of /etc/fstab (in case of emergency!):
sudo cp /etc/fstab /etc/fstab.bak
You then need to open etc/fstab for edit like this:
sudo vim /etc/fstab
(In my case I've used vim, you could substitute that for whatever command-line text editor you prefer!)
With the file open; simply add the following line, save the file and quit the editor:
/dev/sdb1 /home/jason/Desktop/myflash vfat users,noauto,uid=jason,gid=users 0 0
Obviously, I've used my example data there, but again, you need to substitute the information you gathered about your USB drive and your mount point etc.
Once that's done, whenever you plug in your USB stick you can simply use:
And the code added to /etc/fstab will allow the USB stick to be mounted at your specified mount-point.
So in my example. Where I'd used /home/jason/Desktop/myflash as a mount point, I could plug my drive in and use:
And thanks to the entry in /etc/fstab, my USB drive would be mounted to /home/jason/Desktop/myflash
Hope this is of some help!
Cheers for now,
Edited by JasonHippy: n/a