Viewable With Any Browser

STATS

Todays date:
Thursday 28th of March 2024 10:41:29 PM

You are visitor

47792


Your IP address is 44.222.249.19


Page last updated
09 September 2022

Users, folders, files and permissions

Users     The Raspberry Pi uses an operating system which is different to Windows. The Linux operating system requires that users be given permissions before they can perform any meaningful task. Users can also be added to groups, which may also have permissions to perform certain functions.


In our case, we need a user to be able edit our web pages on our web server.

We also need a PLACE on the server, a directory, or folder, where they have permission to edit files.

Add a user

Users    

Login to the Pi console as user pi. Then type:

sudo adduser USERNAME

Where USERNAME can be any name meaningful to you.

You will be asked to enter a password twice. You will be asked to enter some other information too, but may just press enter for default settings. Just follow the instructions on screen.

Notice that a group was also added, bearing the same name as the username. Each time a new user is added, he is given his own group. You can check this by typing:

groups USERNAME

This will list all the groups, USERNAME belongs to. Try typing:

groups pi

You will see that user pi belongs to many more groups than the user we just added. You will also see that one of the groups is called 'users'.

We want our new user to also belong to group 'users'(more on this later). Let's add our new user to the 'users' group. Type:

sudo adduser USERNAME users

Typing:

groups USERNAME

Will confirm that USERNAME now belongs to two groups, one of them being 'users'.

Glitches

Glitches     Several glitches have been noted so far.

The /home/user directories are not created for the newly created user. It seems if the user can log into startx, these directories are then created.

The new user cannot startX from the pi console.

If the new user can login to desktop via Remote Desktop, the home directories are created.

Creating folders

Folder    
Lets create a folder in which our new user can add, delete and edit files.

Log into the commandline as user pi and issue the commands:

sudo mkdir /var/www

sudo chown -R USERNAME:users /var/www

Substitute USERNAME with any user you have added.

sudo chmod -R 775 /var/www

What we have done here is created a folder named /var/www, changed the owership of the folder to USERNAME and group 'users'.

Next we will setup sharing files accros a network.

sharing files

Folder    
We would like our web development team to be able to work on our web pages remotely. This is handy because they can all contribute to the content of our web server, from the comfort of their own office chair.

We use Samba to allow our RPI to be visible to our windows network.

Login to a command console as user pi, then type:

sudo apt install samba samba-common-bin smbclient

Then we need to edit some configuration files.

sudo nano /etc/samba/smb.conf

Find the entries for workgroup and wins support, and set them up as follows:

workgroup = your_workgroup_name
wins support = yes

Add the following to the end of that file:

[www]
comment = www
path = /var/www
valid users = @users
force group = users
create mask = 0775
directory mask = 0775
read only = no

save and close (CTRL-x, followed by 'y')

Next we need to add a samba user and password

sudo smbpasswd -a USERNAME

Click the refresh button in the Network pane in Windows Explorer.
You should now be able to see the www share from your Windows machine.

Sometimes the refresh button will not find the new share. We found this to be true on Windoze 10.

Entering "\\raspberryPi" into the run dialog is enough to get an explorer window showing available shares.

Next we will set up our Raspberry Pi to publish our web pages.

>>next>>