I am working on an application which deals with all kinds of USB storage devices(such as taking backup, updating DataLogFile etc)   My problem is :  I want to write a shell script which is stored in this USB drive(As usb is at center of my project so USB is going to be same but PC's will change) AND this script should be executed as soon as the USB drive is connected to my Linux system.I will not need any kind of "root" or "sudo" permissions for other tasks which I am going to do in this shell script.
123659
What can I do to run automatically a script after I mount/plugin or unmount/unplug a USB device?
70746
How can I tell which device the USB drive is assigned as?  Before inserting the USB drive:  $ lsblk NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT nvme0n1     259:0    0 238.5G  0 disk  ├─nvme0n1p5 259:3    0  15.9G  0 part [SWAP] ├─nvme0n1p1 259:1    0 222.6G  0 part / └─nvme0n1p2 259:2    0     1K  0 part    After:  $ lsblk NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT sda           8:0    1   1.9G  0 disk  ├─sda2        8:2    1   2.4M  0 part  └─sda1        8:1    1   1.2G  0 part  nvme0n1     259:0    0 238.5G  0 disk  ├─nvme0n1p5 259:3    0  15.9G  0 part [SWAP] ├─nvme0n1p1 259:1    0 222.6G  0 part / └─nvme0n1p2 259:2    0     1K  0 part    Is it /dev/sda??
45294
The situation is:  I have a shared directories from many other machines where other users work on.  I need to be notified whenever a user create, modify or delete a directory or file from his local directory which I share using smb...  It looks like the folder actions in the MAC systems..  Is there a software that do that?!  If there is no such application, any help in writing a script for that is appreciated..  Thanks in advanced...
96060
I have a Clonezilla installation on a USB stick and I'd like to make some modifications to the operating system. Specifically, I'd like to insert a runnable script into /usr/sbin to make it easy to run my own backup command to make backups less painful.   The main filesystem lives under /live/filesystem.squashfs on the USB FAT-32 partition.   How can I mount this read/write on my Linux machine in order to be able to add/remove/change files? I'm running an Ubuntu 12.04 derivative.
24604
I have usb barcode scanner that emulates keyboard. When it is connected, X gets the control and handles it as an usual keyboard and sends keyboard events to the current focused window.  This is not what I want to do. I have a program that read barcodes from ascii input stream and process them. This program runs at background and has no user interface at all.  How to configure Linux to not use this usb keyboard in X, but map it as a ascii stream device. This way, I will be able to redirect it as an input device for my program and to provide reading the barcodes, regardless of the input focus changes. And the barcodes should not be passed to the currently focused window at all.  In addition, it is better to not run the barcode handling program as a root, so the keyboard device should have read permissions for everyone.
3414
I have a script that I need to execute on an NTFS partition. The script's permission is set to 600.  I attempted to modify the permissions by running chmod 755 script.sh, which doesn't report a failure or anything - but it also doesn't change the permissions on the file:  $ stat script.sh    File: `script.sh'   Size: 297070      Blocks: 584        IO Block: 4096   regular file Device: 811h/2065d  Inode: 35515       Links: 1 Access: (0600/-rw-------)  Uid: ( 1000/  xxxxxx)   Gid: ( 1000/  xxxxxx) Access: 2010-09-30 14:05:16.041621000 -0700 Modify: 2010-09-30 14:05:05.070157000 -0700 Change: 2010-09-30 14:05:05.070475000 -0700  $ chmod 755 script.sh $ stat script.sh    File: `script.sh'   Size: 297070      Blocks: 584        IO Block: 4096   regular file Device: 811h/2065d  Inode: 35515       Links: 1 Access: (0600/-rw-------)  Uid: ( 1000/  xxxxxx)   Gid: ( 1000/  xxxxxx) Access: 2010-09-30 14:05:16.041621000 -0700 Modify: 2010-09-30 14:05:05.070157000 -0700 Change: 2010-09-30 14:05:05.070475000 -0700   As you can see, it remains unchanged.
121871
I'm attempting to write a script that will be run in a given directory with many single level sub directories. The script will cd into each of the sub directories, execute a command on the files in the directory, and cd out to continue onto the next directory. What is the best way to do this?
121067
I have a script which can run as sudo script.sh or pkexec script.sh  It would be much nicer from the user point of view if the script asked for the password from the user when just running it by name script.sh.   How can I "embed" request to pkexec or sudo to run the whole script with root privilege?  Note that running everything with sudo sh -c might not be the best solution as I have functions in the script.
26983
I've recently installed Ubuntu 11.10 on my laptop, but I can't do anything with my 1.5TB external drive, and my 500GB because I don't have write permission. Are there any specific commands I can use in the terminal to set the read/write permissions?  The external is NTFS, and the 500GB is ext4.
55832
I tried to create some udev rules to mount and unmount my USB flash drives; the rules for the moment are very simple:  ACTION=="add",KERNEL=="sd[b-z]",RUN+="/root/scripts/plug_flash_drive.sh %k" ACTION=="remove",KERNEL=="sd[b-z]",RUN+="/root/scripts/unplug_flash_drive.sh %k"   plug_flash_drive.sh is also very simple:  device_name=$1 mount_options="umask=000,utf8" if [ ! -e "/media/$device_name" ]; then     mkdir "/media/$device_name" fi sleep 1 /usr/bin/mount "/dev/$device_name" "/media/$device_name" -o "$mount_options"   unplug_flash_drive.sh:  device_name=$1  umount "/dev/$device_name" rmdir "/media/$device_name"   I have done some tests so I can ascertain that:   When plugged in, my flash drive is detected; a file is created in /dev plug_flash_drive.sh is called by udev the mkdir part of the script works however, it seems that the "mount" part of the script is not executed, so my drive is not mounted when I call my scripts on the command line, they perfectly work   Does anybody know why mount is not executed when called by udev?  EDIT 28/08/14: I added "grep -q /proc/mounts &amp;&amp; echo success || echo failure" at the end of my script to check in my debug log if the device is actually mounted before the script ends. It appears that the device is mounted at that point even when the script is called by udev. So the real problem is now "my block device is seemingly unmounted after the mount script end when called through udev" :s
117884
I'm constructing a backup script for Windows 7, and the last action I want it to perform is to safely "remove" the USB drive that it is backing up to. I am under the impression that plugging the drive into the same USB port all the time will keep the same DEV_ID (correct me if I'm wrong). With a command line (or PowerShell), how can I tell Windows to safely remove the hardware automatically without user input?  Just as a place holder, other OSes that may have a way to do this would be great to know as well.
75007
A colleague told me that it is not recommended to use USB hard disks due to the lack of inherent integrity checking of copied files. I am looking for details on that. In what respect is copying to a USB device different from copying to a hard disk connected via e.g. SATA? If anybody has further sources/information on that, I would appreciate sharing it with me.  edit: As explained below, I know that in many cases, the used hard disk is effectively nothing else but a SATA disk in a casing. My question is whether the USB &lt;=> SATA interface introduces data security issues. My colleague referred to a case where a broken USB controller led to data loss. Data could be copied to the hard disk without any problems, but the data written to the disk was corrupted. Replacement of the USB controller resolved the issue in this case.
101878
I'm writing a simple bash script, but I need it to check whether it's being run as root or not. I know there's probably a very simple way to do that, but I have no idea how.  Just to be clear: What's a simple way to write a script foo.sh, so that the command ./foo.sh outputs 0, and the command sudo ./foo.sh outputs 1?
81410
I'm trying to copy a file to a USB flash drive. The drive does not have a write-protect switch.  df gives the following:  $ df -h . Filesystem      Size  Used Avail Use% Mounted on /dev/sde1       1.9G  622M  1.3G  33% /media/lindenb/803C-078D   df -i produces strange output to me (0 everywhere)  $ df -i . Filesystem     Inodes IUsed IFree IUse% Mounted on /dev/sde1           0     0     0     - /media/lindenb/803C-078D   Number of files on the drive:  $ find . |wc -l 170   But when I try to copy a file, I get this:  $ mv ~/file.txt ./ mv: cannot create regular file ‘./file.txt’: No space left on device   How can I fix this ?
115938
I am a novice linux/Ubuntu user who is just discovering the joys of a lightweight, free software environment which gives control to the user.   To protect some of my data (photos) from the rigours of OS crashes/reinstallation etc. I have created a small storage partition on my primary hard disk using gparted at /dev/sda3 using the ext4 filesystem.   On startup the partition auto-mounts to /media/chris/photo storage. I can see the drive at this location, and in the Unity launcher.   The only problem is I have no permissions to use the 'drive' and hence cannot copy files into it, add folders or in fact do anything in the storage area. My question is how to I give myself permissions within my normal Ubuntu account to use it?  Best Regards,   Chris
50090
I have created a USB flash drive with the latest Ubuntu version, but it is not persistent. How can I make it persistent without repeating the whole process?
13582
I have read-only access to a database on a remote server. So, I can execute:  COPY products TO '/tmp/products.csv' DELIMITER ',';   But on that server I don't have permissions to create/save a file, so I need to do this on my local machine.  When I connect to the remote database, how can I execute a command to save the file on my local machine instead of the remote server?  Or, how can I execute a Linux command to connect to the remote database, execute a query, and save the output as a file to my local machine?