To change the folder where it will log in, you must edit within the file /etc/passwd the following information:
marcosrai:x:1000:1000:Marcos Rai Alves da Cunha,,,:/home/marcosrai:/bin/zsh
Where it is in bold you should put the folder wherever the user is when logging in.
To prevent it from going to the previous directories you should leave the previous folders with user permission at 770 or 700. In 770, only the owner of the directory and the group to which the directory belongs will have access to it, Already in 700 only the owner of the can access it.
How can you do this? By giving an ls -l, you will see the following result:
drwxrwxr-x 3 marcosrai marcosrai 4096 Dec 10 09:01 AndroidStudioProjects
-rw-rw-r-- 1 marcosrai marcosrai 29537 Mar 22 09:12 arquivo_sispag.php
drwx------ 8 marcosrai marcosrai 4096 Mar 4 16:47 curso-react-native-master
-rw-rw-r-- 1 marcosrai marcosrai 7320686 Apr 12 12:13 curso-react-native-master.zip
drwxrwxr-x 4 marcosrai marcosrai 4096 Feb 17 15:13 cursos
drwxr-xr-x 4 marcosrai marcosrai 4096 Apr 9 11:23 dev
-rw-rw-r-- 1 marcosrai marcosrai 967991150 Apr 17 09:46 developer.zip
drwxrwxr-x 12 marcosrai marcosrai 4096 Feb 17 15:24 dev_old
drwxr-xr-x 3 marcosrai marcosrai 4096 Apr 11 17:39 'documentos locatario'
-rw-rw-r-- 1 marcosrai marcosrai 3417907 Apr 8 10:33 'documentos locatario.zip'
-rw-rw-r-- 1 marcosrai marcosrai 21680 Apr 8 09:16 'fio ramais e grupos.pdf'
drwxrwxr-x 2 marcosrai marcosrai 4096 Mar 19 23:00 Mrai
drwxr-xr-x 10 marcosrai marcosrai 4096 Apr 17 09:39 newsbit
-rw-rw-r-- 1 marcosrai marcosrai 23428 Jan 8 20:00 'Planilha Despesas.ods'
drwxr-xr-x 7 marcosrai marcosrai 4096 Feb 12 10:05 scripts
-rw-rw-r-- 1 marcosrai marcosrai 45045 Apr 11 08:50 test.pdf
-rwxrwxrwx 1 marcosrai marcosrai 1769747341 Mar 22 09:52 traccar_315_21-03.sql
-rwxrwxrwx 1 marcosrai marcosrai 1577541648 Mar 12 15:22 traccar_315.sql
Where to find marcosrai marcosrai, it means that I am the owner and the group to which the directories belong.
Leave the user’s home subdirectories in the way that they own or are part of the group.
For more information visit: http://www.bosontreinamentos.com.br/linux/permissoes-de-acesso-a-arquivos-e-pastas-pelo-terminal-no-linux/