why '~' tilde directory is created automatically in home directory on AWS EC2 instance - linux

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?

Related

Webmin cron does not use files from home directory?

I have Webmin installed on WSL. And I'm trying to run a cron, from Webmin, which references a file in my home directory. However, it produces an error because the path to the file is prefixed with /usr/share/webmin/cron/. It otherwise runs fine when it's triggered by the schedule.
Error: Cannot find module '/usr/share/webmin/cron//home
I've got this to work previously with Webmin somehow, but can no longer find the solution.
Is there any way to allow Webmin to run crons with references to the home directory?

Bash script not recognizing root directory on remote server

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!

Can someone help me figure out why terminal (MacOS) will no longer find python files I have saved?

So I'm new to learning python. I have python 3.8.2 installed on my MacBook Pro. It was working fine for a week, and I was creating code in atom, saving as .py files to a folder on my desktop. Terminal was locating and running those files easy. However, now when I go into terminal it does not see that any of my files are in the folder, just a hello.py which prints "Hello World" but I do not have any such file in that folder.
For more background, I believe the source of the error is from my earlier command. I was unsure of how to quickly navigate terminal, and as I was in a folder in a folder and wanted to leave the second folder, I thought it was similar to those old command games were you tell them to do something. So in my dumb head I typed "MacBook-Pro:FolderName user$ exit foldername" then clicked return. After this I got a message that I didn't save so I don't remember it but it was a few more lines and I believe it said it exited. I could no longer type in terminal. I closed the shell and opened a new one and thats what lead to my current issue and why I am here seeking help.
I have included a photo of my atom code, what terminal says now and my folder of files terminal can't find.
Edit: I cannot include pictures yet due to reputation being low so it has been changed to a link photo of issue here
EDIT: To add to this, I created a new save folder, moved one of the old files over to the new folder, and it ran normally. This leads me to believe that I used terminal to somehow ignore or forget that initial save folder and all its content. Is that a thing that can happen?
Based on your picture, it looks like the misconception is about how directories work in MacOS. In your terminal, you type cd ~/py4e; in Unix systems, ~ is your home directory, so you’re navigating to the py4e subdirectory under your home directory.
Then, however, you type cd ~/ex_04 (or something), which means you’re trying to navigate to the ex_04 subdirectory under your home directory. This isn’t what you want; you want to navigate to ex_04 under the py4e directory.
In the Terminal, when you’re working in a current folder, you can change to another folder within that current directory by just typing the name of that subdirectory, i.e. cd ex_04 once you have run cd ~/py4e.
If you’re just starting out with the command line in MacOS, I would definitely recommend looking up some beginner tutorials online so you can get a better feel of navigating and working in the Terminal.

Spring Tool Suite 3.8.2 - Installation on Ubuntu

I managed to install STS 3.8.2 on Ubuntu 16.04 - with a lot of hacking experiments. I have it working, but I am not happy with my solution.
Here is what I had to do:
Extracted the tar file into /opt/sts-bundle.
If you put it anywhere else, like /opt/sts, the TC server fails to start from STS.
With files in /opt/sts-bundle, TC server still fails to start from STS - permission errors. To get it to work you need to futz around with permissions of the pivotal-c-server subdirectories, essentially you need to open it up your group (the same one running STS) (security hole ?).
A local install in your own ~/sts-bundle fails on "files not found" while attempting to backup - all the conf files. It still looks in /opt/sts-bundle for all these config files (just to copy them to /backup). You can change the top directory of the server in STS server properties - but it still looks in /opt/sts-bundle. Seems hard-coded - don't know where. So you have to create all the config files in the conf directory in the tree rooted at /opt/sts-bundle ("touch" works - creating empty files). TC Server still fails to start with a "failed to clean" error - with no clue from the detailed message what files are being "cleaned".
I tried creating a non-privileged user "tcserver" per suggestion from the Pivotal TC Server docs. I installed to /opt/sts-bundle, while logged in as tcserver (with sudo privileges). That fails when I am using STS as a regular developer that is not "tcserver". Could not figure out how to tell TC server to run under a different user than the one that started STS.
The solution I have working and I am not happy with, starts by extracting the tar.gz file into /opt/sts-bundle, as it wants. Then changing owner and group of sts-bundle to my id and my group (same ones that are used in STS UI). I am not happy with that. It seems wrong to put things in /opt that are owned by a single developer.
I am new to Linux, and I still have some Windows habits that need to be unlearned.
The question is: how do I get the clean solution (installing using a "tcserver" user in the global /opt directory) to work for developers who are not "tcserver"? How should the tcserver user be related to the developers (same group?).
Am I making this problem harder than it should be? What am I missing?
I'm not sure this what you want, but I don't install the STS bundles in some kind of shared directory as a special user at all. I just install it in my user.home dir, as myself, and launch it from there.
It is very unsophisticated. I just download the tar.gz file, unpack it in my home dir and then launch it from a trivial bash script which looks something like this:
#!/bin/bash
/home/kdvolder/Applications/sts-bundle/sts-*/STS
That script is on my PATH. So I can just type 'STS' in a terminal and STS will start.
I don't have to do anything else and it works.
If you are trying to somehow install this so that several different users can run a shared installation then this isn't a good setup. But I think for your own personal laptop or desktop which only you are using, this simple setup is perfectly fine.
For a shared-user env, unfortunately, I don't know how to help you. It could be complicated to sort out all the permissions issues etc because Eclipse is a complicated beast w.r.t to installation of plugins etc.

Can I delete the Matlab installation file in root user home directory

I just found Matlab (2016a) put a 2.5 Gb installation files that it fetched during the installation in the root home directory (Linux mint 18), under /root/Downloads/MathWorks. I guess it is probably because I use sudo for installation.
My question is:
Is it normal that program store information when user executes it with sudo?
Can I delete the file under /root/Downloads? (My limited Linux knowledge told me do not touch anything in the /root folder)
When you execute anything with su...do, you basically execute it 'as' root.
Mathworks uses the Download-Folder (which is in your case /root/Downloads - since you have executed the installer as root) for temporary data (According to https://de.mathworks.com/matlabcentral/answers/229835-is-the-mathworks-folder-necessary-to-run-properly?requestedDomain=www.mathworks.com).
So, yes. It seems like you can delete the folder.
Or just move it to MathWorks.bak and check if Mathworks still works properly. In case everything is working fine, you can delete MathWorks.bak.
A program can do anything when run as sudo and depends only on what the program is designed to do. sudo simply elevates the permissions when running a given command.
I would have thought that the installer would have downloaded everything to /tmp instead of /root/Downloads, but as long as you didn't select /root/Downloads as your installation directory for MATLAB and this is only the temporary download location you can certainly remove it after successfully installing MATLAB to a "typical" location such as /usr/local/MATLAB/R2016a.

Resources