I am working on a security tool for Ubuntu in which I want to remove all permissions for a pendrive when i insert it into my system and ask for a password and then when i enter the right password then again set all permission to the device.But I don't know How can i do this(remove all permissions of a pendrive) using shell commands?
I have already tried these commands but these are not helpful for me:
sudo chown user:user /media/name_of_drive -R
sudo chmod 777 user:user /media/name_of_drive -R
Well,My OS is Ubuntu-16.04 LTS.
Github link of my project is:https://github.com/beNitinhere/Ubuntu-Antivirus
Thanks in advance
you can do this:
$ sudo mount /dev/sda2/media/name_of_drive -t ntfs -o uid=1000,gid=1000,umask=007,auto,locale=en_EN.UTF-8
-t
is the key indicating the type of the file system, in this case it is ntfs
.
-o
sets the mount options. For home systems, probably, it makes no sense, but for self-education, you can only register access to yourself. To do this, enter the terminal:
$ id
and get the values uid
and gid
in the output. This is the id
of the user that is logged in the system, and the id
of his group. They are entered as options after -o
.
umask
is the permissions for files/folders. Differs from chmod
:
0 : read, write and execute
1 : read and write
2 : read and execute
3 : read only
4 : write and execute
5 : write only
6 : execute only
7 : no permissions
Accordingly, the first digit - for the user, the second - for his group, the third - for all others.
You can do this (but then all users will have access rights to read-write-executable):
sudo mount /dev/sda2 /media/name_of_drive -t ntfs -o rw,exec,auto,locale=en_EN.UTF-8