Hi again folks!
I have installed Raspbian Buster Lite on a headless pi zero w. I’ve SSH into the Pi0W into a terminal. The problem is that I log in as a normal user, not the root.
I have plugged in a usb drive. When I type in ‘sudo fdisk -l’, it shows the usb device as ‘/dev/sda1’.
So I type
sudo mkdir /media/usb-drive
sudo mount /dev/sda1 /media/usb-drive/
Then I try to access the drive:
But get the error message: ‘cd: /media/usb-drive/: Permission denied’ because I am not root.
So I try ‘sudo cd /media/usb-drive’ and get the error message 'cd: command not found.
So how do I access the usb drive as a normal user? And if the only way for me to access the drive is as root, how can I become root? According to the raspberry documentation, users can only use ‘sudo’ to execute some commands as root, but I can’t find any information via google about how to actually become root.
Any and all help would be greatly appreciated. Thank you.
Well, it turns out that ‘sudo su’ can be used to become root. And then the drive can be accessed via ‘cd /media/usb-drive’.
Rather than delete this thread, I’ll leave it as it is so that hopefully it will help someone (linux newbie) with the same problem in the future.
Having to be superuser to access the USB drive is silly. What are the permissions on the /media/usb-drive and the /media directories? Use “ls -ld /media /media/*” to find out.
You need to see -rwxr-xr-x as a minimum. If not, then
sudo chmod 755 /media /media/usb-drive
You need to do this with the drive both unmounted, and mounted, as the permissions on the mount point can interfere with what’s shown when the drive is mounted.
Been a while but I should also say that removable media is usually mounted specifying the option uid=1000
sudo mount -t vfat -o uid=1000 /dev/sda1 /media/USBstick
This sets the user ID of the files on the usb stick to 1000, which is usually the default user. Use the “id” command to check if you’re unsure of your user ID.