CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Installation (https://www.cfd-online.com/Forums/openfoam-installation/)
-   -   [OpenFOAM.com] How to change installation from root to new user ?? (https://www.cfd-online.com/Forums/openfoam-installation/233814-how-change-installation-root-new-user.html)

nikag123 February 12, 2021 15:18

How to change installation from root to new user ??
 
Hello Everyone.
I have accidentally installed my openfoam 8.0 in the root directory. By this I mean that the setup files (the ones which include pre loaded tutorials) are in /opt/openfoam8 and the case files (which are accessed by $FOAM_RUN, where I copy the tutorials) are stored in /root/OpenFOAM/root-8/run.

But now I created a new user, copied the tutorials in it from /opt/openfoam8/tutorials and performed blockMesh in the cavity tutorial.
The error appeared was "Cannot find 'blockMesh' command". This is I suppose occurred due to location of openfoam in different directory.

So my question is, how to move the openfoam installation from the /root folder to the new user directory (which is /home/new_user ). I have tried by giving all types of root privileges to the new_user but was unable to run the case files while I login in the new user directory.

Any help would be great !!

HPE February 12, 2021 15:43

Hi,
- maybe just remove (`rm -rf`) all OF from the root, and reinstall it locally?

nikag123 February 12, 2021 16:10

hii HPE,
I can surely do that, but was hoping for some other way without re-installing

olesen February 13, 2021 14:28

Quote:

Originally Posted by nikag123 (Post 796082)
hii HPE,
I can surely do that, but was hoping for some other way without re-installing

It would certainly help with understanding if you define what you mean by "installing openfoam". Are you unpacking a precompiled binary pack somewhere, downloaded source and compiled in the wrong directory etc? In general it does not pose a problem to compile OpenFOAM in a particular directory and then move everything into another directory (this is after all what we do when creating binary packs for ubuntu, centos/redhat opensuse, or with spack or easybuild) so there must be something that I am missing.

nikag123 February 14, 2021 02:34

Thank You Olesen
What I meant was I could not perform commands like blockmesh when I am logged in as normal user. Of Course, when I am logged in as root user, I easliy run the blockmesh command for a file in any directory.

This was because, as I understood, I do not have the permission to access the /root folder (root user's home directory) when I am logged in as a normal user

With sudo, I was able to give the new user access to commands like "ls -" but not access the /root folder.

So I now figured that it may be vulnerable to give the new user access to the /root folder in order to accomplish my problem.

I should rather install the OpenFOAM folder (which is currently in the /root directory) in the my new user directory.

If the above is true, now my question is how to install openfoam such that I can run the case files when I am logged in as new user?

olesen February 21, 2021 03:00

Still not sure if this is indeed an issue with running blockMesh, or if it is because you are trying create files in a location that doesn't belong to that particular user.
In general, you will want to change the ownership of the OpenFOAM installation. Use the chown command. Next ensure that the OpenFOAM files are usable by all users. For that the 'chmod -R a+rX' command is what you want. It is important to notice that it is a large 'X', which on adjusts the execution permission if the file is already executeable. This probably is your issue in the first place. Usually the root user will have a strict umask that prevents non-group members from having permissions.

JonW December 4, 2021 09:24

Moving my old foam-extend-3.1 installation
 
Just now I had to move my old foam-extend-3.1 installation.
What I did was open my etc/baschrc and replace $HOME with the home directory of the new place.

Here is what I did for this case
NOTE username is explicit, . . . do not replace it with $HOME

/users/home/username is the new place

cd /users/home/username/foam/foam-extend-3.1/etc
gedit bashrc
---------------------------------------------------------
# foamInstall=$HOME/$WM_PROJECT
foamInstall=/users/home/username/$WM_PROJECT

# foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
foamOldDirs="$FOAM_INST_DIR /users/home/username/$WM_PROJECT/$USER"

# export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
export WM_PROJECT_USER_DIR=/users/home/username/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
---------------------------

….and in my .bashrc for the new location
alias foam31_ihpc='source /users/home/username/foam/foam-extend-3.1/etc/bashrc && PS1="\[\e[0;35m\][E.3.1.ihpc]\[\e[0m\]\[\e[0;31m\][\W]\[\e[0m\]: " '

I have been testing this now (by doing some mpi runs), and all seems to work perfectly. Note, this will be different for other installs like of-v2012, but the approach would be the same.

hope this helps
cheers
JE.


All times are GMT -4. The time now is 18:30.