I use linux. I'm working on a project where an app I wrote is launched by my runlauncher. At that time the app looks for an environment variable on the sytem. This environment variable contains a path to a text json file. I want to put this file somewhere on the sytem, not in the home directory. Where would be the appropriate place?
The environment variable is GOOGLE_APPLICATION_CREDENTIALS. The app is a flatpak app.
TLDR: Where do I put things on the system that I can read from my application that are not in the home directory?
On Linux, you need super-user rights (or sudo) if you want to write file outside $HOME directory. If you have only user right, then only $HOME directory is writable.
Related
I'm new to WSL and Linux, but I'm trying to follow installation instructions for rhasspy (https://rhasspy.readthedocs.io/en/latest/installation/#windows-subsystem-for-linux-wsl). I have run the make install command successfully and the next step says I should copy rhasspy somewhere in my path but I can't quite figure out what copying to path means.
When installation is finished, copy rhasspy.sh somewhere in your PATH and rename it to rhasspy.
I added it to path but nothing changed so I was wondering if there is something I'm doing wrong. Right now when I run rhasspy on wsl it says rhasspy.sh: command not found. Any help would be really appreciated!
What it says is, put it in some place where the system will look for it when you type its name without full path in the shell.
There is an environment variable PATH that contains all those locations, separated by a :. (Check out echo $PATH.)
So, the author of these instructions leaves it up to you whether...
You want to copy the file to a location of your choice that is already in the PATH, such as /usr/local/bin or ~/bin.
Usually ~/bin is a good choice because it is per-user and doesn't pollute the system.
(Note that the directory ~/bin is added to the PATH by your .profile file only if it exists, so if you don't have this directory yet and create it now, you need to start a new login shell or run . ~/.profile1 before you can use it.)
- OR -
You want to create a new directory specifically for this application (say for example ~/opt/rhasspy) and append that directory to the PATH variable.
This can be done by adding the line export PATH=$PATH:~/opt/rhasspy to your ~/.profile file. Then, start a new login shell or reload the file using . ~/.profile1 for the changes to take effect.
If the directory in which this file is currently located is OK for you to keep permanently, then you can also just add that directory to the PATH instead of creating a new one.
Note: The PATH always contains directory paths in which the shell will look for executable files. It does not contain the actual file paths!
1: Yes, technically it is "cleaner" to log into a new shell or to run that one export statement manually instead of using . ~/.profile because the latter will apply things a second time that were already done before, so for example it can end up with the same directory in the PATH multiple times in the current session. In most cases that is fine though.
PATH is an environment variable. When you launch env, you see the list of known environment variables on your system.
In order to add something to your PATH variable, you need to take the variable, add the mentioned directory (preceeded by a semi-colon, most probably, as a separator) and store this again as the PATH variable. This can be done as follows (own example):
export PATH=$PATH:/home/this_user
the "PATH" it is referring to in linux is just inside the folder called /usr/bin. when you type a command into the terminal it looks for a program with that name inside the location. im not sure if this is the PATH you are looking for but hope it helps
I'm having an old Linux enviroment here which I currently start to move to a new Linux Server.
In the old enviroment, I found inside ~/.profile that the current working directory is being exported to PATH:
export PATH=$PATH:.
What might be the reason that the old administrator has put this inside ~/.profile? Because this only safes two characters when trying to execute a program inside the current working directory, doesn't it? (for example: ./foobar vs. foobar)
We have an application where one shell script file maintains all environmental variables, which are set by export. These variables are used to run external commands in the application. So, we have many users running the same application from the single server from their own home directories. When a user A run the application, the executable which are in user B path are running. But we set the environmental variables for each user so the executable is supposed to run from the user A's own path.
How can I make the executable run from the user's own path?
sample.sh
export HA_INC=/home/A/proj
export HA_EXE=/home/A/proj/bin
these above file is cloned by all users when the application is cloned from git. Whenever the user A is executing a command, which is in HA_EXE directory, the executable is running from some other users' directory. All the users are using their own shells.
I think you can have a system-wide shell script in /etc/profile.
To represent the current user's home directory, use "~". To represent B's home directory, use "~B".
I'm running Cygwin 1.7.17 on Windows Server 2012. My user account is "Administrator". Where should I put a .bashrc file for the Cygwin bash to pick it up?
I've tried the "c:\users\Administrator" folder, which seems to be the HOME in Cygwin 1.7. Tryed c:\cygwin\home\Administrator also.
Start a shell instance and run the command echo $HOME to see what your home path is set to. That's where all your user config files will be read from. It might not be one of the paths you tried.
Once you know where it is, just copy the template .bash_profile and .bashrc files from the /etc/skel folder to get you started.
If you don't like the path that's currently being used as your home, you can change it by editing /etc/passwd. Here's more info on that... Safely change home directory
I've just installed kohana in my new project temp.loc
I type in the browser temp.loc and Environment Tests says:
Cache Directory The /work/temp.loc/wwwroot/application/cache/ directory is not writable.
Logs Directory The /work/temp.loc/wwwroot/application/logs/ directory is not writable.
I'm trying to change the path Kohana::$log->attach(new Log_File(APPPATH.'logs')); in bootstrap.php. BUt, after refreshing the browser, the Environment Test still shows the same path /work/temp.loc/wwwroot/application/logs/, the path is not refreshed. Why?
Don't change the location in bootstrap, that isn't needed. The reason you are receiving this error message is probably because those two directories aren't writable. If you are on Mac OSX or a linux environment you need to set those directory permissions to 777 i.e. "chmod 777 cache". Both are located on your application directory. This is a common issue that I have to resolve every time I install Kohana on a new server.