Hi,
I am new in Linux Ubuntu and want to learn a bit. I have a question, it might be very simple for you. I have only "root" as a user in my system.

1. I want to create a new user called "user_1"
2. I want to create a folder called "project_1" in var/www
3. I want to give "user_1" R+W permisions to "project_1" folder only.
4. I want to do all these in "root@ubuntu:/home/ubuntu#" command line

Thank you in advance.

Dani AI

Generated

— short, safe recipe that follows up on and but fixes a few important points for Ubuntu.

On Ubuntu prefer the interactive adduser helper (it creates the home and password prompts). Don’t make the directory world-writable (the 666 approach is unsafe and, for directories, also breaks access because the execute bit is needed). A more typical setup is: make the project directory, set the owner to the new Unix user and the group to the web server group, enable the setgid bit so new files inherit the group, and use ACLs if you need exact per-user defaults.

adduser user_1

mkdir -p /var/www/project_1

chown -R user_1:www-data /var/www/project_1

chmod 2750 /var/www/project_1

# optional: default ACLs so new items keep the same owner/group/rights
setfacl -R -m d:u:user_1:rwx,d:g:www-data:rx /var/www/project_1

Notes and troubleshooting: 2750 gives user_1 full access, the www-data group read/execute (so the web server can serve files) and denies others; the leading 2 sets the setgid bit so new files inherit the group. If the web server must also write (uploads), use group-write on a specific subfolder (e.g., chmod 2770 on an uploads dir) rather than making everything world-writable. If setfacl isn’t available, install the acl package and verify with getfacl. Finally, confirm permissions with ls -ld /var/www/project_1 and test as the target user (su or sudo -u) while working from your root prompt.

Recommended Answers

All 2 Replies

To create a new user you need to use useradd (see the help file to do it properly).
To create a folder use mkdir with root and use chown to change the propietary user of the folder.
Use chmod 666 /var/www/project_1 to change permissions (RW to all users).

If you want the user has access only to that folder, you must maintain permissions for other users.

Anyway all this can be found with a simple search in google/yahoo.

I use the man page or .

They are both handy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.