How to create a new user and set a working directory in Ubuntu?
To create a new user and set a work directory in Ubuntu, you can follow these steps:
- Open the terminal and log in with root privilege.
- Create a new user using the following command, for example, the new user name is newuser:
sudo adduser newuser
- Enter the password and other information for the new user.
- Set the working directory for a new user using the following command, for example setting the working directory to /home/newuser/work:
sudo mkdir /home/newuser/work
sudo chown newuser:newuser /home/newuser/work
- Ensure that new users have access to the work directory.
sudo chmod 755 /home/newuser/work
- The new user has been created and the working directory has been set up. You can now switch to the new user and start using it.
su - newuser
cd /home/newuser/work
By following the above steps, you have successfully created a new user and set a working directory in Ubuntu. You can adjust the permissions and other settings of the working directory as needed.