`cd` to a folder in bash script not working: No such folder [duplicate] - linux

This question already has answers here:
Why can't I change directories using "cd" in a script?
(33 answers)
'\r': command not found [duplicate]
(3 answers)
Closed 4 years ago.
This is my entire script. it is simply to avoid having to type it again and again
cd api
rails s -p 3001 -b 0.0.0.0
cd ..
When I am in the directory of the script and run cd api it works just fine. However when I run the script via ./start_server It does not work. Here is the output of ls -al:
mendel#DESKTOP-LIKG5E5:/mnt/c/Projects/chaverim-update$ ls -al
total 8
drwxrwxrwx 0 root root 512 Apr 13 12:32 .
drwxrwxrwx 0 root root 512 Apr 5 12:40 ..
drwxrwxrwx 0 root root 512 Apr 13 12:09 api
-rwxrwxrwx 1 root root 1237 Apr 5 12:40 boxfile.yml
drwxrwxrwx 0 root root 512 Apr 8 16:54 .bundle
drwxrwxrwx 0 root root 512 Apr 8 16:54 client
drwxrwxrwx 0 root root 512 Apr 13 12:09 .git
-rwxrwxrwx 1 root root 11 Apr 5 12:40 .gitignore
-rwxrwxrwx 1 root root 1097 Apr 5 12:40 LICENSE
drwxrwxrwx 0 root root 512 Apr 5 12:40 nginx
-rwxrwxrwx 1 root root 82 Apr 5 12:40 Procfile
-rwxrwxrwx 1 root root 67 Apr 5 12:40 README.md
-rwxrwxrwx 1 root root 188 Apr 5 12:40 run_tests
-rwxrwxrwx 1 root root 28 Apr 5 12:40 start_client
-rwxrwxrwx 1 root root 41 Apr 13 12:52 start_server
drwxrwxrwx 0 root root 512 Apr 8 16:54 vendor
As you can see there is a folder called api at the top and the start_server script is set to have execution permissions.

Related

AWS cli is installed but doesn't work, Centos8

Hi I have installed awscli in centos8 trough pip3, I can see the files in my /root/.local/bin directory
-rwxr-xr-x 1 root root 817 Mar 4 18:50 aws
-rwxr-xr-x 1 root root 204 Mar 4 18:49 aws_bash_completer
-rwxr-xr-x 1 root root 1432 Mar 4 18:49 aws.cmd
-rwxr-xr-x 1 root root 1138 Mar 4 18:50 aws_completer
-rwxr-xr-x 1 root root 1807 Mar 4 18:49 aws_zsh_completer.sh
-rwxr-xr-x 1 root root 218 Mar 4 18:49 pyrsa-decrypt
-rwxr-xr-x 1 root root 234 Mar 4 18:49 pyrsa-decrypt-bigfile
-rwxr-xr-x 1 root root 218 Mar 4 18:49 pyrsa-encrypt
-rwxr-xr-x 1 root root 234 Mar 4 18:49 pyrsa-encrypt-bigfile
-rwxr-xr-x 1 root root 216 Mar 4 18:49 pyrsa-keygen
-rwxr-xr-x 1 root root 239 Mar 4 18:49 pyrsa-priv2pub
-rwxr-xr-x 1 root root 212 Mar 4 18:49 pyrsa-sign
-rwxr-xr-x 1 root root 216 Mar 4 18:49 pyrsa-verify
but when I try to entablish the credentials with "aws configure" or simply view the version with "aws --version" I get:
bash: aws: command not found
when I run "pip3 uninstall awscli" and before uninstalling it shows me a list of files, some of them I can not find when I look for them like the ones on the site-package folder, ex:
Uninstalling awscli-1.18.14:
/root/.local/bin/aws
/root/.local/bin/aws.cmd
/root/.local/bin/aws_bash_completer
/root/.local/bin/aws_completer
/root/.local/bin/aws_zsh_completer.sh
/root/.local/lib/python3.6/site-packages/awscli-1.18.14.dist-info/DESCRIPTION.rst
/root/.local/lib/python3.6/site-packages/awscli-1.18.14.dist-info/INSTALLER
/root/.local/lib/python3.6/site-packages/awscli-1.18.14.dist-info/METADATA
/root/.local/lib/python3.6/site-packages/awscli-1.18.14.dist-info/RECORD
What should I do?

Jenkinsfile ,by using sh, says No such file or directory, but it exists

I'm studying jenkins, trying to package a maven project to a war, then move it to a previously started tomcat webapps directory(/opt/tomcat/latest/webpass), but it reports 'No such file or directory'.
Already find out what causes this, but don't know why. Jenkins don't use the same filesystem as original?
Here is my troubleshooting:
1、I create a directory in my linux server under / as temp20190808.
2、then in jenkins file add sh 'ls / -l', there is no temp20190808,also the description of each file in ls form show differenly compare with original(there are details under).
3、using jenkins file, i create a file under / as jenkinstmp2019, then ls / -l, it's there, but after rm the code of creating jenkinstmp2019, then rebuild, ls / -l, jenkinstmp2019 no longer there, so the jenkins file system is a onetime job?
Here are code elaboration on point 1,2:
in my linux server, using ls / -l, there is a tmp20190808 i just created.
total 24
lrwxrwxrwx. 1 root root 7 Jun 19 16:53 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Aug 1 04:55 boot
drwxr-xr-x. 17 root root 2860 Aug 7 02:48 dev
drwxr-xr-x. 86 root root 8192 Aug 7 20:52 etc
drwxr-xr-x. 4 root root 46 Jul 12 08:12 home
lrwxrwxrwx. 1 root root 7 Jun 19 16:53 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jun 19 16:53 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 media
drwxr-xr-x. 2 root root 6 Apr 11 2018 mnt
drwxr-xr-x. 5 root root 53 Jul 23 08:11 opt
dr-xr-xr-x. 101 root root 0 Aug 7 02:47 proc
dr-xr-x---. 7 root root 215 Aug 6 02:53 root
drwxr-xr-x. 28 root root 920 Aug 8 02:03 run
lrwxrwxrwx. 1 root root 8 Jun 19 16:53 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Apr 11 2018 srv
dr-xr-xr-x. 13 root root 0 Aug 7 02:47 sys
drwxr-xr-x. 2 root root 6 Aug 8 01:50 temp1
drwxrwxrwt. 20 root root 4096 Aug 8 02:23 tmp
drwxr-xr-x. 2 root root 22 Aug 8 01:39 tmp20190808
drwxr-xr-x. 13 root root 155 Jun 19 16:53 usr
drwxr-xr-x. 20 root root 4096 Jul 12 07:36 var
in jenkins.
total 8448
drwxr-xr-x. 1 root root 19 Jun 9 2016 bin
drwxr-xr-x. 2 root root 6 May 30 2016 boot
-rw-------. 1 root root 8646656 Jun 9 2016 core
drwxr-xr-x. 5 root root 360 Aug 8 01:58 dev
drwxr-xr-x. 1 root root 66 Aug 8 01:58 etc
drwxr-xr-x. 2 root root 6 May 30 2016 home
drwxr-xr-x. 1 root root 45 Jun 9 2016 lib
drwxr-xr-x. 2 root root 34 Jun 8 2016 lib64
drwxr-xr-x. 2 root root 6 Jun 8 2016 media
drwxr-xr-x. 2 root root 6 Jun 8 2016 mnt
drwxr-xr-x. 2 root root 6 Jun 8 2016 opt
dr-xr-xr-x. 123 root root 0 Aug 8 01:58 proc
drwx------. 1 root root 33 Aug 8 01:58 root
drwxr-xr-x. 3 root root 30 Jun 8 2016 run
drwxr-xr-x. 2 root root 4096 Jun 8 2016 sbin
drwxr-xr-x. 2 root root 6 Jun 8 2016 srv
dr-xr-xr-x. 13 root root 0 Aug 7 02:47 sys
drwxrwxrwt. 1 root root 29 Jun 9 2016 tmp
drwxr-xr-x. 1 root root 30 Jun 10 2016 usr
drwxr-xr-x. 1 root root 41 Jun 9 2016 var
As you can see, it's like two totally different linux server, but it's the same one.
So i'm wondering whether jenkins create a temp virtual file server to execute it's job, so can't access to original file except it's own directory.
Find out the reason by myself.
The real cause is agent, i before used agent { docker { image 'XXX' } }, which makes jenkins run its job on docker image.Then i change it to agent any, so job will run on the server jenkins is deployed on.

Docker "not found" for existing file

I am using Docker to build an electron node app and I'm getting some odd behavior. The build seems successful but when I run the electron app I get a "not found" error but the file does exist. I can ls the file and cat the file but cannot source/execute the file.
$ docker -v
Docker version 17.03.1-ce, build c6d412e
Dockerfile:
FROM node:alpine
RUN mkdir -p /usr/src
WORKDIR /usr/src
COPY package.json /usr/src
RUN npm install
COPY . /usr/src
RUN npm run build:linux
ENTRYPOINT "/usr/src/docker-entrypoint.sh"
This will result in the generation of this directory:
/usr/src/app/builds/app-linux-x64
With a bunch of files including an executable named app.
/usr/src/app/docker-entrypoint.sh: line 5: ./app: not found
It does exist.
/usr/src/app/builds/app-linux-x64 # ls -lah
total 124472
drwxr-xr-x 4 root root 4.0K Apr 28 20:07 .
drwxrwxr-x 1 root root 4.0K Apr 28 20:07 ..
-rw-r--r-- 1 root root 1.0K Apr 28 20:07 LICENSE
-rw-r--r-- 1 root root 1.6M Apr 28 20:07 LICENSES.chromium.html
-rw-r--r-- 1 root root 24.3K Apr 28 20:07 blink_image_resources_200_percent.pak
-rw-r--r-- 1 root root 15 Apr 28 20:07 content_resources_200_percent.pak
-rw-r--r-- 1 root root 9.7M Apr 28 20:07 content_shell.pak
-rw-r--r-- 1 root root 9.7M Apr 28 20:07 icudtl.dat
-rw-r--r-- 1 root root 2.8M Apr 28 20:07 libffmpeg.so
-rwxr-xr-x 1 root root 19.4M Apr 28 20:07 libnode.so
drwxr-xr-x 2 root root 4.0K Apr 28 20:07 locales
-rw-r--r-- 1 root root 334.7K Apr 28 20:07 natives_blob.bin
-rw-r--r-- 1 root root 136.6K Apr 28 20:07 pdf_viewer_resources.pak
drwxr-xr-x 2 root root 4.0K Apr 28 20:07 resources
-rw-r--r-- 1 root root 970.2K Apr 28 20:07 snapshot_blob.bin
-rwxr-xr-x 1 root root 76.7M Apr 28 20:07 app
-rw-r--r-- 1 root root 159.4K Apr 28 20:07 ui_resources_200_percent.pak
-rw-r--r-- 1 root root 6 Apr 28 20:07 version
-rw-r--r-- 1 root root 58.7K Apr 28 20:07 views_resources_200_percent.pak
I can ls it:
/usr/src/app/builds/app-linux-x64 # ls -lah app
-rwxr-xr-x 1 root root 76.7M Apr 28 20:07 app
But I cannot run it:
/usr/src/app/builds/app-linux-x64 # ./app
/bin/sh: ./app: not found
I had a similar problem myself which was solved by putting sh infront of the script to run. For you it would be:
ENTRYPOINT "sh" "/usr/src/docker-entrypoint.sh"

Searching shared libraries in Linux

please explain me why on x86_64 Scientific Linux no file under /etc/ld.so.conf.d contains the directory /usr/lib64?
The list of directories to be searched by program loader is stored in the file /etc/ld.so.conf. On my distributive, this file stores this row: include ld.so.conf.d/.conf*
And the above directory consists of:
[root#dev_host build]$ ls -la /etc/ld.so.conf.d
total 36
drwxr-xr-x. 2 root root 4096 Aug 29 23:13 .
drwxr-xr-x. 103 root root 12288 Sep 18 03:41 ..
-rw-r--r--. 1 root root 17 Mar 20 2012 atlas-x86_64.conf
-r--r--r--. 1 root root 324 May 7 23:40 kernel-2.6.32-431.17.1.el6.x86_64.conf
-r--r--r--. 1 root root 324 Nov 22 2013 kernel-2.6.32-431.el6.x86_64.conf
-rw-r--r--. 1 root root 17 Feb 12 2014 mysql-x86_64.conf
lrwxrwxrwx 1 root root 31 Aug 11 14:46 postgresql-pgdg-libs.conf -> /etc/alternatives/pgsql-ld-conf
-rw-r--r--. 1 root root 22 Sep 7 2011 qt-x86_64.conf
I examined all these files - there is no /usr/lib64. Why? Is it stored in /etc/ld.so.cache?

CHROOT : Allowing outside access to chrooted users with mount bind

I have a chrooted user(username: clientdev) which I have jailed inside their home directory. This chroot directory is /home/clientdev/ which is owned by root.
Now I need this clientdev user to be able access the tomcat web application folder which is residing under /mnt/datadrive/tomcat/webapps.
What I have done is :
chroot the user with a public key of their own to the home
directory.
Create a folder under /home/clientdev called tomcat_ROOT and gave
the ownership to clientdev.
Now when I run the command :
mount -bind /mnn/datadrive/tomcat/webapps /home/clientdev/tomcat_ROOT
The folder disappears from the directory listing inside /home/clientdev if I login with clientdev. My root user can see it but now the desired user.
Any help would be greatly appreciated
Thanks in advance,
Peter
Output of ls -l /home/clientdev/tomcat_ROOT:
drwxr-xr-x. 6 root root 4096 Apr 11 15:07 .
drwxrwxr-x. 12 root root 4096 Apr 11 15:07 ..
drwxr-xr-x. 3 root root 4096 Apr 9 22:10 webapp1
drwxr-xr-x. 4 root root 4096 Mar 18 18:43 webapp2
drwxr-xr-x. 3 root root 4096 Apr 9 22:11 webapp3
drwxrwxr-x. 10 root root 4096 Apr 11 15:20 ROOT
Output of ls -l /home/clientdev/:
drwx------. 4 clientdev clientdev 4096 Apr 10 21:36 .
drwxr-xr-x. 7 root root 4096 Apr 10 22:07 ..
-rw-------. 1 clientdev clientdev 664 Apr 10 21:43 .bash_history
-rw-r--r--. 1 clientdev clientdev 18 Apr 23 2012 .bash_logout
-rw-r--r--. 1 clientdev clientdev 176 Apr 23 2012 .bash_profile
-rw-r--r--. 1 clientdev clientdev 124 Apr 23 2012 .bashrc
drwx------. 2 clientdev clientdev 4096 Apr 10 19:20 .ssh
drwxr-xr-x. 2 clientdev clientdev 4096 Apr 10 21:34 tomcat_ROOT

Resources