Question: **note**: I don't want to use a udev rule.

I need to change (programmatically) the permissions of some device. To understand what I have to do (in code) I want to do this using just `chmod` command.

So far, I've tried this:

```
root# ls -l /dev/sdb
brw-rw-rw- 1 root disk 8, 16 Apr 7 05:27 /dev/sdb

root# chmod 0600 /dev/sdb 

root# ls -l /dev/sdb
brw------- 1 root disk 8, 16 Apr 7 05:27 /dev/sdb

```

as you can see, `/dev/sdb` has read and write permissions only for the owner (root). But I'm still able to create new files and read files from my connected flash drive.

What am I missing? How can I use `chmod` to prevent users from writing to some device?

Answer: 
If I understand you right then there is some file system on /dev/sdb that you have mounted. What matters here are the permissions **in the file system** that resides on /dev/sdb, the permissions of /dev/sdb are completely irrelevant for your question. Except that with permissions 0666 anyone can bypass the access control mechanisms for that file system and access the content on the device arbitrarily, but this is a different issue.

If you want to restrict access to the files within the file system, then you have to assign appropriate ownership and permissions to the files (beginning with the root of that file system). For file systems like FAT mount(8) lets you set the ownership and access permissions for all files within the file system. If you want to expose the entire tree to certain users only and hide it from all others, then mount it somewhere where only those users have access to. But note that any user can see that something is being mounted (mount(8) or df(1) will show them).

chroot(1) is not going to help you at all.
`/dev/sdb` is the block device name. Changing the permission of `/dev/sdb` will not affect the filesystem on `/dev/sdb`.

Use `mount` to get the list of mounted mediums and mountpoints.

Use `chmod` to change permissions in mountpoint.

e.g.
`mount` will show lines which looks something like

```
/dev/sdb1 on /run/mount/pioneeraxon/disk1 type ext4 (...)

```

In such case `/run/mount/pioneeraxon/disk1` is the mountpoint for `/dev/sdb1`. You need to change the permissions in `/run/mount/pioneeraxon/disk1`.