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:

  1. Open the terminal and log in with root privilege.
  2. Create a new user using the following command, for example, the new user name is newuser:
sudo adduser newuser
  1. Enter the password and other information for the new user.
  2. 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
  1. Ensure that new users have access to the work directory.
sudo chmod 755 /home/newuser/work
  1. 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.

bannerAds