how to run create file in ubuntu when user login automatically

You can add those lines at the end of your ~/.bashrc file which will get executed when you login.

I’m talking about the ~/.bashrc serverside. When you have added your lines and logout and ssh back in these lines will get executed. You can leave out the last line of your script.

If the ~/.bashrc does not exist you can simply create it or even better copy it:

cp /etc/skel/.bashrc ~/.bashrc

and make sure your ~/.profile file contains the following lines:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"

Leave a Reply