Technically , yes. At the very basic level you can use the following commands to create cmdonly
user:
sudo useradd cmdonly
sudo passwd cmdonly
Unlike adduser
command (which is a Perl script by the way), useradd
doesn't set up user profile or home directory in any way. What you have is the following entry in /etc/passwd
cmdonly:x:1007:1008::/home/cmdonly:
Such user only belongs to only its own group, and has home directory assigned, but not created
$ ls -ld /home/cmdonly/
ls: cannot access /home/cmdonly/: No such file or directory
Notice that shell is also unset there, which will default to bash
if you have multiple shells.
As for GUI user, they have privilege to log into both console and GUI. There's no way to avoid cmd login for such user to the best of my knowledge yet. To create gui capable user, it's sufficient to run sudo adduser newusername