I am working on a remote Linux server, connected using SSH. I am new to Unix.
My repo is stored in root/data/anj/myrepo. Now my home directory root/home/anj/ contains a bash file which executes the code stored in myrepo. But when I run the bash file, it doesn't seem to recognize the root directory and reach the repo. I get the output "file not found" when it tries to execute a file in my repo. How do I get the bash script to recognize the path from the root directory to the repo? It seems that the file is interpreting /data/anj/myrepo as root/home/anj/data/anj/myrepo, which shouldn't be happening.
You have to put a / in front of root, because if you don't do that then you are looking for a relative path, but i guess you are looking for the absolute path. so try /root/data/anj/myrepo instead of root/data/anj/myrepo :D
Good luck!
Related
I'm not sure exactly what to call what I'm trying to do, but I have a node script that accesses a folder (./commands relative to the script file), but when I run the script from somewhere other than the folder, it is unable to find ./commands.
I.e. when I'm in the folder with the script in it, ./commands refers to \script-folder\commands, but when I'm on the desktop, the script looks in Desktop\commands and finds nothing.
Is there any way to tell the script to run relative to its own folder, or do I just have to hard-code the full location of the commands folder in the script?
./ means current working directory. you can check with pwd command.
You can use path.join(__dirname,yourpath);
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 have some python scripts running on AWS-ec2 instance on crontab. Every day I found "~" directory in my home directory. Don't know why this happening.
I have to manually remove the ~ (tilde) directory from home-dir.
When I run these script on local ubuntu machine. It's working fine.
There is a bug in the one of the scripts that you are running that is creating this.
Typical shells ~ is used to refer to the users home. And somewhere this is being used where is is not really replaced. Because these are python scripts you might need to manually handle those.
See - How to get the home directory in Python?
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'm trying to use rsync to backup windows servers to an rsync server. I'm having problems with rsync on the linux side though, it doesn't like symlinks.
Currently I'm trying to use the module path of ~/backup, but rsync says that the chroot failed. I looked up what to do and saw that I needed to add the option use chroot = no and munge symlinks = no. That fixed the #ERROR: chroot failed but now it's telling me #ERROR: chdir failed and the log files say that there is no ~/backup directory. I know the user I'm authenticating with has a backup folder in his directory.
How can I fix this?
For reference I'm using a .NET port of rsync called NetSync and tunneling it over a port forwarded SSH connection generated with granados.
IIRC, tilde (~) expansion is done by the shell. chdir() doesn't handle this.
Try an absolute path. If you don't like that, then try using "backup" (or ./backup) on the assumption that after login, the current directory will be set to the user's home directory.
As far as i understand it, it seems that your path should be /home, and that it is up to your user to move into his own directory.
There is another solution that involves declaring a module for each user, but that seems overly complex for the purpose.
This is a bit too late, but chroot fails if the directory does not exist. Did you check if ~/backup has actually been created?