How can I make the directory writable, permanently, without having to run the command again? - linux

I have a problem with making /dao permanently writable. I use this command:
chmod -R 777 /opt/project/newproject/target/scala-2.11/classes/dao
I am using Play-Framework. But when I run activator, the command delete the directory "dao" and create a new one.
I am working with Debian and trying start a bash file in Jenkins to create the Project on a Server

Related

Azure Ubuntu VM - Execute Custom Script (Permission Denied)

I created an Azure ARM template, which is using the Microsoft.Compute/virtualMachines/extensions in an Ubuntu 18.04 in order to execute a custom script. Once the machine is provisioned, the ubuntu user (non-root) should be able to run the custom script from the following directory /var/lib/waagent/custom-script/download/0 it receives "permission denied". I added the following lines to make sure the ubuntu user owns the file and is able to execute, but without success.
sudo chown ubuntu install_metaport.sh
chmod +x install_metaport.sh
sh install_metaport.sh
I then, changed my approach and added the following inline commands to my Azure ARM script, which worked fine. But I am trying to avoid having to copy/move the file around, and have this executed from its original directory, which is /var/lib/waagent/custom-script/download/0, but again, I end up with "permission denied" and can't figure it out how to get around this issue
cp install_metaport.sh /tmp && chown ubuntu /tmp/install_metaport.sh && chmod +x /tmp/install_metaport.sh && cd /tmp && sh install_metaport.sh
Any advise?
Thank you
Your file install_metaport.sh can be executed by user Ubuntu. You verified that by putting in another directory.
The fact that the file can be executed from another directory tells that permissions are denied at a lower level. Root folder permission limits child files permission, so most likely you cannot execute in the /var/lib/waagent/custom-script/download/0 directory. Give the user ubuntu executions rights there, and it'll work like a charm.

Create directory "/dotenv" on MacOs, Read-only file system

I tried to create a directory under root (the directory when I open terminal)
sudo mkdir /dotenv
But the system says:
mkdir: /dotenv: Read-only file system
My OS is Catalina 10.15.2
Is there any way to create the dir? I need to run a node.js server locally which requires .env file in the /dotenv dir
You'll need to use mkdir dotenv if you are at your profile root (which it appears you are). That was the only way I could get it to work (I am on Catalina 10.15.3).
Using mkdir /dotenv (notice the /) I got the same error as you.
If you really want to, you can disable the read-only file system in Catalina by following these steps (which are also listed below).
Problem because of Read-only file system in mac os catalina
Boot you mac system into recovery mode. (by bootup system with holding CMD+R).
Open terminal (Present in "Utilities" in the top left menu).
Just run command
csrutil disable
Restart your system and Bootup normally
Before doing any activity open terminal and run command.
sudo mount -uw /
Once this all done you can do write in root location
Require the result in command: csrutil status
If result is enabled, you need to restart machine and press command + R, open the terminal in the recovery, so input csrutil diabled.
Restart, and check the status: csrutil status.
Here are two methods:
you are root.
sudo mount -uw /
so, you could mkdir or touch new file.
If you still can't read or write any, you maybe try this:
cd ~ # cd home directory
sudo vim /etc/synthetic.conf # create new file if this doesn't exist
In the conf files, add new line
dotenv /User/xx/dotenv # Notice: the space between this two strings is tab
Restart, and you will find a link named /dotenv in the root.

Run jenkins job as another user

I Installed jenkins using a guide, and that guide created a "jenkins" user in the server and apparently runs the jenkins server under it.
All my setup on the server (virtual env, python package installations) is for a different user ("ci-user"). Is there any way for me to run my jobs as "ci_user" instead of as "jenkins"? I'd like to avoid doing all the setup again for the "jenkins" user.
There is JENKINS_USER variable in etc/default/jenkins file. You could change it to ci_user, then you will need to change the ownership of several folders and reboot the machine.
chown -R ci_user /var/lib/jenkins
chown -R ci_user /var/log/jenkins
chown -R ci_user /var/cache/jenkins
Reference

"Unable to create home directory" error when changing JENKINS_HOME

Jenkins was running all fine on a RedHat Linux machine (a clean EC2 machine on AWS), until I decided to change the JENKINS_HOME. I simply moved the Jenkins directory from /var/lib/jenkins to /home/ec2-user/jenkins and then created a symlink. (I followed the first answer to this question: Change JENKINS_HOME on Red Hat Linux?).
However when I restart Jenkins I get the error:
Unable to create the home directory ‘/var/lib/jenkins’. This is most
likely a permission problem. To change the home directory, use
JENKINS_HOME environment variable or set the JENKINS_HOME system
property.
I tried changing JENKINS_HOME in /etc/sysconfig/jenkins, setting it to the new folder (which I suppose defeats the point of a symlink?) and I still get the same error
Unable to create the home directory ‘/home/ec2-user/jenkins’.
It is for backup purposes, so that I have all Jenkins data in a mounted external data storage (AWS Elastic File System).
I've figured it out. This error was persisting because the /jenkins/ folder needs to be accessible to user 'jenkins' to run processes, but it couldn't access this folder because it is belongs to the particular logged in user. I changed the mounting to /var/ where jenkins can access as global process, and it solved the problem.
I ran into the same problem, so sharing my solution here:
The user jenkins does not have access to the folder home/ec2-user/jenkins. You can modify the access rights of the folder home/ec2-user/home by changing or adding the user jenkins to owner
sudo chown jenkins /home/ec2-user/jenkins
sudo chmod u+w /home/ec2-user/jenkins
To verify the new ownership, you can do:
ls -ld /home/ec2-user/jenkins
The error seems pretty obvious: "This is most likely a permission problem."
I assume /home/jenkins does not exists, and the user jenkins does not have write permissions in /home. If you moved the Jenkins home, then you probably did it as root and just forgot to update owner permissions.
You would need to create the home, something like this:
sudo service jenkins stop
# make the changes in /etc/sysconfig/jenkins
sudo mkdir --parents /home/jenkins # or mv, in your case
sudo chown --recursive jenkins /home/jenkins
sudo service jenkins start

working on lamp server in ubuntu

i m working on ubuntu and just installed lamp.As i m new to linux i m not sure how to create a directory or file under /var/www of lamp server to start working on my website project
Under *nix you can create a directory using mkdir newdirname and you can create a new and empty file, using touch newfilename. Those are commands you need to execute from a shell/terminal. In order to get to /var/www, you will need to cd /var/www.
If you are new to Linux I suggest reading any guide on basic like this or this.
Chances are you do not have sufficient privileges as your normal user to add files or create directories. You can either change the ownership of the /var/www directory (and everything within) or you can sudo each one you want to add.
From the prompt: chown [your_user_name].users -R /var/www
Then you can mkdir [directory name] to make a directory or touch [filename] to create a file.
If you do not change the permissions of the /var/www you may need to put sudo in front of each of the above commands (will be prompted for password)

Resources