Ubuntu adding a user not setting a home directory - ubuntu-18.04

I am trying to add a user in ubuntu using the following command, but the home directory is not getting created.
sudo useradd -p $(openssl passwd -1 MyPassWord) myUserName
But it doesn't seem to add a home directory by default. What should I add to get a home directory created for the user by default

It is right there in the man page for useradd(8):
-m, --create-home
Create the user's home directory if it does not exist. The files and directories contained
in the skeleton directory (which can be defined with the -k option) will be copied to the
home directory.
By default, if this option is not specified and CREATE_HOME is not enabled, no home
directories are created.

Related

Ubuntu nautilus Home's path is /root,how can i change it to /home/username?

At first,the file icon was lost in my Ubuntu 20.04.Later i run the sudo root,but I still have some trouble in clicking the icon on the desktop to open the files. And now i run the sudo nautilus,i see the Home is /root,and when i open terminal in these file,the user is root,i don't know what happened.How can i change the Home to /home/username?and how can i reserve it to be username's terminal by default?
files images
Terminal images(when open in files)
As you run nautilus with sudo, you are running it as the user root. This user has it's home directory at /root.
Try to run nautilus without root, i.e. as a normal user (by simply typing nautilus), and your "Home" will be at /home/username.
Your "terminal user" will be your normal user account.
Please see the sudo man page

How do I edit a plesk subdomain home folder from command line

How do I edit a plesk subdomain home folder from command line in Linux?
I can create the subdomain and assign the home folder from command no problem but now I need to update the home folder.
Try to use something like:
plesk bin subdomain -u subdomain.domain.com -www-root /var/www/vhosts/subdomain.doman.com/wwwroot
More details you can find with help of:
plesk bin subdomain --help

Change document root in ubuntu 12.04

I have tried every possible solution to change the document root on ubuntu to my new site but nothing works. I have changed the setting in available sites default file (both document root and directory root) to my new directory housing the website or creating a new available sites file pointing to my web directory and switching the site through a2ensite and a2dissite commands. But still it goes to the same default page
I already fixed that :
Install webmin
From webmin goto servers->Apache webserver
Edit the default "virtual host" :
handle all connections
add your doc-root
use httpd.conf file ..
Once done do a server restart from webmin or the command line:
sudo /etc/init.d/apache2 restart

DatabaseError unable to open database file

My sqlite db file is this: unable to open database file i chowned all folders until my dbfile to root. but i am still getting this error. but i remember that while creating my django project on server, i created a superuser, and now if i do ls -l i see that the user is that superuser. how is it possible to tell apache that this superuser should have that right to write/read the db file? or how to solve the problem, i am not apache/linux guru..
Execute chown www-data:www-data directory on the directory you want apache to be able to write to.
You should be able to just leave the file as owned by the super user and just change the group so that apache can read/write it as well.
Change the group for the sqlite file and the containing directory. Try this:
cd <directory with sqlite file>
sudo chgrp www-data . <sqlitefile>
You can find write group and www user and change permissions.
Say: cat /etc/passwd - for find right user, It may be apache or http or www.
And say to terminal: cat /etc/group -for find right group.
In my system group=apache, user = apache.

SplFileInfo::openFile(/app/tmp/cache/persistent/cake_core_cake_console_):failed to open stream:Permission denied in /lib/.../FileEngine.php line 293

I am working on a CakePHP 2 project. It originally started out in 2.0.x and then recently migrated to 2.1.0. Throughout the whole development process, I have been receiving the error message below.
It pops up at the top of the page unpredictably. It can be when I am just viewing different pages, or even after I add a record to the database (yet the record properly saves).
Warning:
SplFileInfo::openFile(/var/www/cake_prj/app/tmp/cache/persistent/cake_core_cake_console_):
failed to open stream:
Permission denied in
/var/www/cake_prj/lib/Cake/Cache/Engine/FileEngine.php on line 293
I recursively set the owner and group of the tmp folder to apache, and still received the message. In addition, I then recursively set the permissions to read, write, and execute for all (chmod 777). The error message still pops up.
Even after changing both the owner, group, and permissions, the file in question:
cake_prj/app/tmp/cache/persistent/cake_core_cake_console_
will have its owner and group set back to root, and its permissions set back to default.
What could be causing this problem? Is there a way to ensure that every time this file is generated, that it will always have be apache:apache with read/write/execute permissions?
You can resolve this by adding a mask to your config in core.php
Cache::config('default', array(
'engine' => 'File',
'mask' => 0666,
));
There was a bug report there http://cakephp.lighthouseapp.com/projects/42648/tickets/2172 but it was considered as not being a bug.
What I personaly noticed is that some file owner may be modified when you use the cake script in the console (for instance to make a bake). The modified files then belong to the user you use in the console.
Would this mean you call cake while being root ? Or do you have any root cron job that calls a Cake shell script ?
Personaly I have now the habit to chmod the whole tmp folder content back to the apache user after having used the cake script and it seems to prevent the warning to appear.
Instead of setting giving read/write access to everyone on the tmp/cache directory I did this:
chgrp -R www-data app/tmp
chmod -R g+rw app/tmp
find app/tmp -type d -exec chmod g+s {} \;
Setting the group of the directories to the Apache user and then setting the setgid bit will allow you to ensure that files created in that directory get the proper group permissions regardless of what user runs the shell script. This also allows you to exclude read/write permissions to "other" users.
I think the reason of the problem is already explained, as the cron runs under root user and created files in tmp are not accessible by web user. The other solutions did not work for me and I did not want to set tmp permissions to 777, I ended up setting a cron job for the web user, in debian specifically it would be
crontab -u www-data -e
Taken from this answer How to specify in crontab by what user to run script?
If you're encountering the SplFileInfo error in CakePHP2 and you're absolutely certain that your file/directory permissions are set up properly, then one other thing to check is your PHP version. Cake2 requires PHP 5.2.8 or greater and although you'd usually be alerted on the default page if you were using the wrong version, you wouldn't be alerted if you'd developed your app on one server and then moved it to another.
I experienced this error after developing a Cake2 app on a PHP5.3 server and then moving it to a PHP 5.1 server. Upgrading to 5.2.17 (which is above 5.2.8) solved the problem.
Use this ..
cd cakephp/app/tmp/cache/persistent
sudo chmod 666 myapp*
cd ..
cd models
sudo chmod 666 myapp*
You need to make the app/tmp directory writable by the webserver. Find out what user your webserver runs as (in my case _www) and change the ownership of the app/tmp directory to that user: $ chown -R _www app/tmp
Another solution. Permission conflicting occurred because multi users share same files. Thus, if we split cache directory into multi sub directories, no conflicting occur and no changing default permission of directories and files required.
As following, each sub cache directory is defined by type of php api handler:
define('CACHE', TMP . 'cache' . DS . php_sapi_name() . DS);
When browser the website, active user is apache. And the sub
directory is cache/apache2handler.
When run a batch, active user is root or logging-in user.
And the sub directory is cache/cli.
Other side, current user account can be used to name sub directory. Check at
How to check what user php is running as?

Resources