To answer your question you need a few steps to solve that. As first you create a user and his username, add a group for him and add him to this group.
This you can do with one command or multiple commands, first the multiple approach where I add in comment lines for explanation:
# adding a user hos with password 123 which you have provide by hand
# you can add the password into the line with the -p flag but you have
# provide the password in encrypted format then.
sudo adduser hos
# adding a group with the same name as the user
sudo addgroup hos
# adding the newly created user to this newly created group
sudo usermod -aG hos hos
Same you can achieve with only the adduser
command like in the following line. For options on the adduser
command see its man page.
adduser --ingroup hos hos
Now to the second part of that question, creating a file containing the names of files in /etc
which begin with a
. This is simply achieved by listing the files with ls /etc/a*
.
ls /etc/a* | sudo -u hos tee ~hos/xyz
This should be all.
mkdir
is for making directories. You should be trying to make a file that contains a list of all files and directories starting witha
in/etc
. You shouldn't be trying to make a directory calledxyz
with a copy of every folder and file starting witha
inside.