EC2 instance - unable to read write files though they exists - amazon-web-services

Please help with this strange problem that i am facing with aws EC2 instance. I have launched a EC2 instance & installed git to clone my repo. all good untill this, but i am unable to read/write those files though they exists in the same path. observed the same behaviour in Amazon Linux instance as well.
ubuntu#ip-172-31-54-19:~/win2win$
ubuntu#ip-172-31-54-19:~/win2win$ cd $HOME
ubuntu#ip-172-31-54-19:~$
ubuntu#ip-172-31-54-19:~$
ubuntu#ip-172-31-54-19:~$ cd win2win/
ubuntu#ip-172-31-54-19:~/win2win$
ubuntu#ip-172-31-54-19:~/win2win$ cat myscript.sh
cat: myscript.sh: No such file or directory
ubuntu#ip-172-31-54-19:~/win2win$
ubuntu#ip-172-31-54-19:~/win2win$ ls -lrt
total 28
drwxrwxr-x 2 ubuntu ubuntu 4096 Apr 5 09:21 templates
-rw-rw-r-- 1 ubuntu ubuntu 792 Apr 5 09:21 sampleIDs
-rw-rw-r-- 1 ubuntu ubuntu 2614 Apr 5 09:30 myscript.sh
ubuntu#ip-172-31-54-19:~/win2win$
ubuntu#ip-172-31-54-19:~/win2win$ pwd
/home/ubuntu/win2win
ubuntu#ip-172-31-54-19:~/win2win$
Can anyone help.
thanks in advance.

Related

SageMaker Studio Image - pip not found and no python 3 in terminal for Python 3 notebook instance

Launched Data Science Python 3 instance in the SageMaker Studio.
Launched a terminal from the Notebook menu "Launch terminal in current SageMaker image".
Tried to run pip but it says not found. Do I need to install pip by myself?
root#datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~/# pip
bash: pip: command not found
Alto there is no Python3 available apparently from within the terminal.
root#datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~# python3
bash: python3: command not found
root#datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~# python --version
Python 2.7.16
root#datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:/usr/bin# ls -lrt | grep python
lrwxrwxrwx 1 root root 29 Mar 4 2019 pyversions -> ../share/python/pyversions.py
lrwxrwxrwx 1 root root 9 Mar 4 2019 python2 -> python2.7
lrwxrwxrwx 1 root root 7 Mar 4 2019 python -> python2
-rwxr-xr-x 1 root root 1056 Mar 4 2019 dh_python2
-rwxr-xr-x 1 root root 3689352 Oct 10 2019 python2.7
lrwxrwxrwx 1 root root 23 Oct 10 2019 pdb2.7 -> ../lib/python2.7/pdb.py
However, the notebook says it is Python3.
from platform import python_version
print(python_version())
---
3.7.10
And can run pip in the cell.
Appreciate any explanation what is going on.
SageMaker Studio image terminals use conda for package management. The data science notebook uses the base environment. You can use pip once you switch to base (also note that the python version is 3.7).
root#datascience-1-0-ml-t3-medium-xx:~# conda env list
# conda environments:
#
base * /opt/conda
root#datascience-1-0-ml-t3-medium-xx:~# conda activate base
(base) root#datascience-1-0-ml-t3-medium-xx:~# pip show pip
Name: pip
Version: 21.3.1
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig#python.org
License: MIT
Location: /opt/conda/lib/python3.7/site-packages
Requires:
Required-by:
(base) root#datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395:~# python --version
Python 3.7.10
I work at AWS and my opinions are my own.
Was stuck in the same issue in Sagemaker notebook instance. Followed the guide here and resolved it by running:
%pip install matplotlib
Attaching the screenshot for your reference:

"attempt to write a readonly database" - Give permissions to db.sqlite3

I am trying to deploy my Django project on a Bitnami server, but when I try to login through admin with my superuser i get the following error:
attempt to write a readonly database
Exception Location: /opt/bitnami/python/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py, line 413, in execute
I have the following permissions to my project files:
drwxrwxr-x 6 bitnami www-data 4096 Mar 12 08:01 .
drwxr-xr-x 3 bitnami root 4096 Mar 11 10:00 ..
drwxr-xr-x 2 bitnami bitnami 4096 Mar 11 11:48 conf
-rw-rw-r-- 1 bitnami www-data 147456 Mar 12 08:01 db.sqlite3
-rw-r--r-- 1 bitnami bitnami 287 Mar 11 13:29 .env
drwxr-xr-x 5 bitnami bitnami 4096 Mar 11 10:26 app
-rwxr-xr-x 1 bitnami bitnami 667 Mar 11 10:00 manage.py
drwxr-xr-x 3 bitnami bitnami 4096 Mar 11 13:52 django_project
drwxr-xr-x 5 bitnami bitnami 4096 Mar 11 10:26 users
and this to the project directory
drwxrwxr-x 6 bitnami www-data 4096 Mar 12 08:01 django_project
I tried to run the following to give permission but without luck:
sudo chown :www-data /opt/bitnami/projects/django_project/db.sqlite3
sudo chmod 664 /opt/bitnami/projects/django_project/db.sqlite3
sudo chown :www-data /opt/bitnami/projects/django_project/
sudo chmod 775 /opt/bitnami/projects/django_project/
Can you help me? :)
Bitnami developer here. You are setting the group to www-data. The Bitnami Apache user is "daemon".

docker-compose on windows directory sync

Running the django tutorial for docker compose, but the command to init the django project is not working as expected.
$ docker-compose run web django-admin.py startproject composeexample .
[31mERROR[0m: Interactive mode is not yet supported on Windows.
Please pass the -d flag when using `docker-compose run`.
In windows "interactive" mode is not supported so I modified the command to run in "detached" mode.
$ docker-compose run -d web django-admin.py startproject composeexample .
Creating network "djangotest_default" with the default driver
...
Successfully built 0fb90648c1d8
[33mWARNING[0m: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
djangotest_web_run_1
This seems to create the boxes.. but my current directory shows no new files (from the django-admin command).
$ ls
docker-compose.yml Dockerfile requirements.txt
How do I get the container output to sync with the current working directory as expected?
The fix was to uninstall Windows 10 and install a *nix system. The files then appear as per the tutorial.
~/docker/django-test $ ll
total 60
drwxr-xr-x 4096 Sep 24 00:47 ./
drwxr-xr-x 4096 Sep 24 00:40 ../
drwxr-xr-x 4096 Sep 24 00:47 composeexample/
-rw-r--r-- 209 Sep 24 00:41 docker-compose.yml
-rw-r--r-- 146 Sep 24 00:41 Dockerfile
-rwxr-xr-x 812 Sep 24 00:47 manage.py*
-rw-r--r-- 16 Sep 24 00:41 requirements.txt

How to know what commands are executed on a directory in Centos?

I have three directories(farmio,farmio-table,farmio-table-throttle) in apps directory of AWS-Centos server under username ec2-user, every time I do a ls -la I see two folders(farmio-table,farmio-table-throttle) accessed frequently and the pid file stored inside the folder are wiped out for which my java programs doesn't execute properly.
[ec2-user#ip-10-94-221-19 apps]$ ls -la
total 49036
drwxrwxr-x 5 ec2-user root 4096 Nov 7 09:39 .
drwxrwxr-x 3 ec2-user root 4096 May 29 12:20 ..
-rw-rw-r-- 1 ec2-user ec2-user 29 Nov 6 06:26 date.txt
drwxrwxr-x 4 ec2-user ec2-user 4096 Nov 6 06:42 farmio
drwxrwxrwx 7 ec2-user ec2-user 4096 Nov 7 2015 farmio-table
-rw-r----- 1 ec2-user ec2-user 25090806 Nov 7 09:43 farmio-table-bin.zip
drwxrwxrwx 7 ec2-user ec2-user 4096 Nov 7 2015 farmio-table-throttle
-rw-r----- 1 ec2-user ec2-user 25092514 Nov 7 09:39 farmio-table-throttle-bin.zip
Every time I try to check the folders are changed or replaced after five minutes.
Is there any way I could know which user and which command is executed in this directory so that its files are replaced/modified in Centos.
Use command history to check all the previously run commands.
$ history

fossil v1.24 fails on linux with 'no such file'

If I download fossil v1.23 to my linux server, everything goes fine.
root#x:/home/james/test# unzip fossil-linux-x86-20120808112557.zip
Archive: fossil-linux-x86-20120808112557 (1).zip
inflating: fossil
root#x:/home/james/test# mv fossil fossil_1_23
root#x:/home/james/test# chmod 777 fossil_1_23
root#x:/home/james/test# ./fossil_1_23 help
Usage: ./fossil_1_23 help COMMAND
Common COMMANDs: (use "./fossil_1_23 help --all" for a complete list)
add clean gdiff mv rm timeline
addremove clone help open settings ui
all commit import pull sqlite3 undo
annotate diff info push stash update
bisect export init rebuild status version
branch extras ls remote-url sync
changes finfo merge revert tag
This is fossil version 1.23 [957b17af58] 2012-08-08 11:25:57 UTC
But 1.24 fails, with 'No such file' even though a ls command shows the file is present, like this:
root#x:/home/james/test# unzip fossil-linux-x86-20121022124804.zip
Archive: fossil-linux-x86-20121022124804.zip
inflating: fossil
oot#x:/home/james/test# mv fossil fossil_1_24
root#x:/home/james/test# chmod 777 fossil_1_24
root#x:/home/james/test# ls -l
total 3620
-rw-r--r-- 1 root root 528859 Oct 24 10:04 fossil-linux-x86-20120808112557.zip
-rw-r--r-- 1 root root 670298 Oct 24 10:04 fossil-linux-x86-20121022124804.zip
-rwxrwxrwx 1 root root 1061584 Aug 11 10:30 fossil_1_23
-rwxrwxrwx 1 root root 1418656 Oct 22 09:16 fossil_1_24
root#x:/home/james/test# ./fossil_1_24 help
-bash: ./fossil_1_24: No such file or directory
Richard Hipp rebuilt the 1.24 linux binary. The new version works fine.