LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 10-29-2011, 01:10 AM   #1
kujirasan
Member
 
Registered: Mar 2007
Posts: 168

Rep: Reputation: 19
How to manipulate USB from command line


Hi, is there any way to manipulate files and anything on a USB stick or drive from command line, rather than from the usual desktop file managers like Nautilus, Dolphin , Krusader etc .


Thanking you all
 
Old 10-29-2011, 01:19 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Yes. Not when "anything" is "everything" but generally yes.

If you want a more specific answer, a more specific question would help.

EDIT: if it's just files then the mount command can be used to mount the file system after which there are many file manipulation commands ...

Last edited by catkin; 10-29-2011 at 01:21 AM.
 
Old 10-29-2011, 01:22 AM   #3
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
You can mount the usb drive with the standard mount utility, once that's done you can manipulate the files like any other file. Do you need to know how to mount the device?
 
Old 10-29-2011, 01:51 AM   #4
kujirasan
Member
 
Registered: Mar 2007
Posts: 168

Original Poster
Rep: Reputation: 19
Mounting:

The USB is automatically mounted, if it wasn't , it would not show up in the File Manger,
Mounting was preformed in the era of floppy etc, now Linux has caught up and mounts it fast!
In the DOS there was a command that was C:, or D: would mount the disk etc, Linux hasn't got that, like /dev/sda: or sda:
Which cause the head ache.
 
Old 10-29-2011, 01:53 AM   #5
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Do you have a specific question? If you already know how to mount the device, what do you want to do with the files?
 
Old 10-29-2011, 01:57 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Linux is a little more powerful and flexible than DOS; that inevitably means it is more complex too.

Here's mounting a file system on USB at the command line, as root
Code:
root@CW8:~# blkid
[snip] 
/dev/sdc1: LABEL="USBSLACKINS" UUID="8666-680D" TYPE="vfat" 
root@CW8:~# mount /dev/sdc1 /mnt
root@CW8:~# mount
[snip]
/dev/sdc1 on /mnt type vfat (rw)
To be able to do that, I had to be familiar with the block devices on the system and recognise that /dev/sdc1 was the USB stick.

Last edited by catkin; 10-29-2011 at 01:58 AM. Reason: typos
 
Old 10-29-2011, 02:00 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by kujirasan View Post
The USB is automatically mounted, if it wasn't , it would not show up in the File Manger
The Xfce file manager does not mount the USB device and shows it greyed out. It is not mounted until the user opens it.
 
Old 10-29-2011, 02:19 AM   #8
kujirasan
Member
 
Registered: Mar 2007
Posts: 168

Original Poster
Rep: Reputation: 19
you can give the usb a universal access :

Now it will be mounted under a specific directory, say for example /media/stuff

Now, as root, set the permissions of that directory by issuing the following commands.

cd /media
chmod -R 777 stuff/

You can also do

cd /media/stuff/
chmod -R 777 .
Same thing really..
this will give read write access for all users to the whole partition. This command operates on the root filesystem of the partition mounted there. You can also use chown to change the owner if you want. 'Nobody' is a good option if you dont want access control.

Your second option is to (as root) make a directory on your new filesystem and give the directory write permissions to all. This option confines 'free for all' permissions to just one directory. Either way, it works the same.


still I cannot access from the command line and manipulate the files etc .
 
Old 10-29-2011, 02:22 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by kujirasan View Post
still I cannot access from the command line and manipulate the files etc .
Please post the commands you are using to manipulate files and any error messages
 
Old 10-29-2011, 02:25 AM   #10
kujirasan
Member
 
Registered: Mar 2007
Posts: 168

Original Poster
Rep: Reputation: 19
Hi Nylex:
Some of the file need to be accessed only "root", and I use Debian, in Debian you cannot log in as root , from the start, or use the Desktop as root, you can get access to everything as root only from console/terminal etc.
 
Old 10-29-2011, 02:26 AM   #11
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Yes, but what exactly do you want to do with the files? We can't read your mind!
 
Old 10-29-2011, 02:50 AM   #12
kujirasan
Member
 
Registered: Mar 2007
Posts: 168

Original Poster
Rep: Reputation: 19
Catkin, Thanks for you post, I don't have any command to access the usb stick and disk, from command line, if I did, I would not come and post here!

Nylex, thanks again, for the reply, I just do the usual thing with a file , copy, paste, alter few lines here and there, I usually do on fedora as root, on friend's computer!
But doing it on Debian is not possible, I believe KDE's Krusader has root access capability, but I use Gnome, and KDE does not do well on Debian, so I don't install KDE specific software.
Thanking you all for your replies, much appreciated!
 
Old 10-29-2011, 02:53 AM   #13
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Are they plain text files? Just use your editor (e.g. vi(m), Emacs, nano, etc.) as usual..

Edit: So, is the device mounted or not now?

Last edited by Nylex; 10-29-2011 at 02:55 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cleaning a usb disk with viruses using the command line ifranklin Linux - Software 5 10-26-2010 03:44 PM
USB command line for turning it on cmessina Linux - Newbie 2 05-29-2009 11:34 AM
Mount USB drive from command line rcrummett Linux - Newbie 10 09-25-2008 05:16 PM
usb/cd automounting but access through command line stu_mueller Slackware 5 04-24-2008 02:17 AM
mounting usb from command line - hotplug? FogSwimmer Ubuntu 4 09-28-2006 03:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration