I have installed SDKMAN! as root on my server and want all my users (developers) to have access to it.
For that I did:
export SDKMAN_DIR="/usr/local/sdkman" && curl -s "https://get.sdkman.io" | bash
source "/usr/local/sdkman/bin/sdkman-init.sh"
Then for a user, I added these lines at the end of .profile and .bashrc:
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/usr/local/sdkman"
[[ -s "/usr/local/sdkman/bin/sdkman-init.sh" ]] && source "/usr/local/sdkman/bin/sdkman-init.sh"
From that user (non root), the sdk command works, but when I try to install Java, I get a lot of errors for folders and files permissions, that's OK because most of those where created by root, not by my current user.
Then I try:
sudo sdk install java 9.0.4-open
And got:
sudo: sdk: command not found
Not sure what I'm doing wrong, maybe I need to install SDKMAN! for each user on my server, which would be a pain.
Any suggestions?
It seems it is not possible to install SDKMAN! once as root and that be available for all users. I guess each user needs to install it and then each users needs to install it's own version of Java, which is a pain if I manage one server and need several users to have the same configuration.
Related
I have been attempting to run powershell as my terminal on windows in pycharm, so I did the following:
However, when I try this, it says that it cannot execute my scripts, and hence I get the following error: SecurityError and the Fully Qualified Id is : UnAuthorizedAccess.
This arises from the fact that pycharm's terminal cannot execute my Powershell_profile.ps1 profile file.
How can I successfully run Pycharm's terminal with Powershell?
What I have tried so far, is going into my main powershell directory as in %windir%/system32/WindowsPowerShell/1.0/profile.ps1, and then change it to include the following:
Set-ExecutionPolicy Unrestricted
However, this does not help, and I get the same error when I try to open of pycharm's terminal.
I have also tried to run pycharm as Admin, however this does not solve the problem either, and I get the same aforementioned error.
I've replaced cmd.exe with powershell.exe in a simpler way and hope it can help.
I'm using webstorm2017 and Win10 os.
1.Find the exact location of powershell.exe.In mine and I believe in most computers the location would be C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.Copy the whole path into your clipboard.
2.In your IDE open File=>Setting=>Tools=>Terminal, and paste the path into "Shell path" blank.
3.Restart the IDE and everything would be ok.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
I updated the powershell.exe path in IntelliJ -> Settings -> Terminal
Opened a powershell instance in Admin mode.
Executed Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Restarted IntelliJ and the issue was solved.
Step 3 is from ebelanger's answer.
Browse to the PowerShell executable, right-click, run as administrator.
From the prompt, use the same command you tried:
Set-ExecutionPolicy Unrestricted
Once that is done, close PowerShell, and attempt to use it again from your application.
Note:
You can't set the execution policy from a script, as the default execution policy prevents you from running scripts. (even if it's the profile script - still a script)
In PyCharm
File->Settings->Tools->Terminal
Shell path:
"powershell.exe -ExecutionPolicy Bypass"
Then restart PyCharm
In the Default Shell TextBox you can append the execution policy command line option like so:
powershell.exe -Executionpolicy Unrestricted
If you're running on Windows 8 x64 then running both the commands below may help. It worked for me.
Set-ExecutionPolicy Unrestricted
start-job { Set-ExecutionPolicy Unrestricted -Force } -RunAs32
Credit to a comment found here:
Powershell on Windows 7: Set-ExecutionPolicy for regular users
As mentioned in other answers, if after setting powershell.exe as your terimal in IntelliJ → Settings → Tools → Terminal → Shell path it throws UnAuthorizedAccess errors, normal way to solve this is to alter execution policy:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Note that Unrestricted level is the least secure of all, and you're usually can go with RemoteSigned in order to disable unsigned scripts downloaded from the web until you manually remove Internet or Intranet Zone.Identifier from them, usually with Unlock button in file properties.
However, you may run to an occasion when you're not able to change execution policy. Usually that's because of corporate security settings in Active Directory. In PowerShell, that corresponds to scopes MachinePolicy and UserPolicy. A primary symptom of this situation is the following message:
Set-ExecutionPolicy : Windows PowerShell updated your execution policy
successfully, but the setting is overridden by a policy defined at a
more specific scope. Due to the override, your shell will retain its
current effective execution policy of AllSigned. Type
"Get-ExecutionPolicy -List" to view your execution policy settings.
For more information please see "Get-Help Set-ExecutionPolicy".
You can't set execution policies at this scopes with PowerShell or gpedit.msc. Attempts to change this settings directly in registry is also ineffective: they're applied on restart or login, but at the same time they're being re-imported from Active Directory. However, while you won't be able to run arbitrary PowerShell scripts all around, for profiles and other local scripts that's only modified manually there's still a solution:
Run the following command in PowerShell to create ceritificate files root.pvk and root.cer - it will ask you to define and then confirm password to the certificate:
makecert -n "CN=PowerShell Local Certificate Root" -a sha1 -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer -ss Root -sr localMachine
In the same folder, run the following command to import generated certificate files as your self-signed certificate - it will ask for the password you're defined above:
makecert -pe -n "CN=PowerShell User" -ss MY -a sha1 -eku 1.3.6.1.5.5.7.3.3 -iv root.pvk -ic root.cer
Sign your profile script with the following command:
Set-AuthenticodeSignature "[script path]" #(Get-ChildItem cert:\CurrentUser\My -codesign)[0]
When running a script signed with self-ceritificate for the first time, PowerShell will ask you about trusting the certificate like this:
The file [script path] is published by CN=PowerShell User. This publisher is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D")
Answer A to always run self-signed certificates.
Now your profile script won't cause any errors. However, note that signing a certificate adds a signature block in the end of your script containing its hash. If you're about to modify the script, remove that block and, after you're done with editing the script, sign it again by repeating step 3.
Specify the shell that will run by default. Here are some examples of different shells:
Bash: /bin/bash
Z shell: /bin/zsh
Bash for Windows: bash.exe
WSL: wsl.exe
PowerShell: powershell
Command Prompt: cmd.exe
Cygwin: "C:\cygwin\bin\bash.exe" --login -i
for more info: https://www.jetbrains.com/help/webstorm/settings-tools-terminal.html
As of this writing (2018-9-20), there is now a PowerShell plugin available here.
I have installed v1.1 in PyCharm v2018.2.3 (Professional), and it seems to work like a charm, no pun intended.
This plugin provides Intellisense-type support of PS1 scripts, as well as an integrated PowerShell terminal. In order to open the terminal, go to Tools > PowerShell Console...
There appears to be no need to muck about with any kinds of settings or permissions in order to get it to work. It Just Works.
You only need to write powershell in the Shell path input, just like in the image, also you can see jetBrains documentation and configure any shell you want.
powershell configuration
For WebStorm and PowerShell 6+ on Windows 10.
Just follow this screenshot and change the default cmd.exe to pwsh.exe from settings. Finally restart the ide. Done!
I have purchased a VPS with a top hosting company. I am new to Linux. Since I am not able to purchase a CPanel License, I need to manually install JDK, Tomcat, and MariaDB. All this through SSH using PUTTY.
There are tutorials which I have followed:
Setting JAVA_HOME & CLASSPATH in CentOS 6
How to Install Apache Tomcat 8.5 on CentOS 7.3
But since I am a newbie in Linux am only able to install JDK8.
Now I need to set JAVA_HOME in a bash file to remain permanent before I can continue with tomcat installation.
From PUTTY, I have login as root user with my password:
I checked the location of the Java "which java" : /usr/bin/java
To get the exact jdk name I used command "sudo update-alternatives --config java" >java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64/jre/bin/java)
I createed a new file through command "vim /etc/profile.d/java.sh" which gave the error below:
E325: ATTENTION
Found a swap file by the name "/etc/profile.d/.java.sh.swp"
owned by: root dated: Thu Oct 19 14:21:28 2017
file name: /etc/profile.d/java.sh
modified: YES
user name: root host name: rtp
process ID: 31766
While opening file "/etc/profile.d/java.sh"
(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/profile.d/java.sh"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/profile.d/.java.sh.swp"
to avoid this message.
Swap file "/etc/profile.d/.java.sh.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
I pressed d to delete the existing one.
I copy this and pasted:
export JAVA_HOME=/usr/bin/java/java-1.8.0-openjdk.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
And then I Press ENTER
The file is in insert mode so I press Esc :w java.sh to save and exit.
Then I closed the PUTTY session and started again to check if the JAVA_HOME has been set: "echo $JAVA_HOME"
No result!
I don't understand what to do again. I kept on repeating this for two days now. Please, any help?
Run below commands on shell prompt before adding it into java.sh:
export JAVA_HOME=/usr/bin/java/java-1.8.0-openjdk.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
Then run echo $JAVA_HOME
If your usage is covered by their licence, I strongly recommend to use Oracle's JDK RPM: when installed it provides much more sane directory layout than OpenJDK RPM package(s): you would be able to use "/usr/java/latest" as Java home.
To have persistent environment variable, add export command to ~/.bashrc or ~/.bash_profile file (depending on how you perform remote login, add it to both if unsure): export JAVA_HOME=/usr/java/latest.
Recently apt-get install -y oracle-java7-installer stopped working.
I know in their roadmap, I think the public version is no longer supported, but it's been working all the way until recently.
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Anyone have a work around for this?
http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1495560077_4041e14adcb5fd7e68827ab0e15dc3b1
Connecting to download.oracle.com (download.oracle.com)|96.6.45.99|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-05-23 10:19:17 ERROR 404: Not Found.
It appears Oracle has moved the download link, you can still fetch the tar ball from the oracle website after jumping through some hoops. The WebUpd8 installer is currently broken. The official explanation can be found at http://www.webupd8.org/2017/06/why-oracle-java-7-and-6-installers-no.html
Download Method 1: Login into to Oracle site
The link now seems to be: http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz
notice "otn" and not "otn-pub", but at least from the website you seem to need to be signed in and not only accept the license agreement.
It may be possible with debconf to change the url from otn-pub to otn and get the installer to work but I haven't tried. You can fetch the binary yourself and either install manually or with the installer pointing it to wherever you put the downloaded tar ball.
Edit: It seems there isn't a way to configure download URL (though you can hijack it with hosts as in another answer).
Download Method 2: Use a trusted mirror
If you want to download jdk-7u80-linux-x64.tar.gz from a script without logging into to oracle it hosted locations include:
http://ftp.osuosl.org/pub/funtoo/distfiles/oracle-java/
http://ftp.heanet.ie/mirrors/funtoo/distfiles/oracle-java/
EDIT: The sha256 has been removed from this answer because (as this edit demonstrates) anyone can edit said hash. Get your hashes from a trusted source. Suggestions include:
https://www.oracle.com/webfolder/s/digest/7u80checksum.html
Install Method 1: Prepopulate cache
#put the file in the default cache location:
sudo mv jdk-7u80-linux-x64.tar.gz /var/cache/oracle-jdk7-installer/
#then install normally:
sudo apt-get install oracle-java7-installer
Install Method 2: (more elegant IMHO) put tar ball anywhere and tell the installer where to look
#setup ppa (you probably came here after already doing this)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
#put the file in a temporary location:
sudo mv jdk-7u80-linux-x64.tar.gz /tmp/
#set local path to /tmp (or any other path)
echo oracle-java7-installer oracle-java7-installer/local select /tmp | \
sudo /usr/bin/debconf-set-selections
#While your at it you may want tp approve license (or skip this and approve when prompted)
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | \
sudo /usr/bin/debconf-set-selections
#then install normally:
sudo apt-get install oracle-java7-installer
So looks like the direct links to the download no longer work( As noted by Meir Maor above)
Here are the steps to get this running again:
Go to http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html and accept the license. Download the file we need (jdk-7u80-linux-x64.tar.gz in this case)
Assuming the file downloaded to your Downloads directory, we need to move it to /var/cache/oracle-jdk7-installer
cd ~/Downloads (Change to directory to which you saved file from step 1)
sudo mkdir /var/cache/oracle-jdk7-installer
sudo mv jdk-7u80-linux-x64.tar.gz /var/cache/oracle-jdk7-installer/
Not sure if necessary but I had luck with this:
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
Run the installer now. It will use the file we saved in /var/cache instead of trying to download it from Oracle
sudo apt-get install oracle-java7-installer
I got step 3 from http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
I just ran into this trying to install Java 6 (don't ask).
Since I'm short on time, I was fine with a quick and dirty answer. I noticed the URL looked for by the installer was http-based (vs https), which makes the below solution possible.
Make sure a web server is installed (I already had Apache on my box)
Download the file that is requested. In your case that is
jdk-7u80-linux-x64.tar.gz. See Meir Maor's answer above
On your local web server, recreate the path structure requested for the
file. In your case that is otn-pub/java/jdk/7u80-b15.
Copy the downloaded file into the path above
Edit /etc/hosts and add 127.0.0.1 download.oracle.com
Run apt-get install -y oracle-java7-installer again.
The installer will now grab the file from your local web server and complete successfully.
There may be a better way to do this, but it worked for me.
As Oracle support for debian packages has gone quite a while ago, I suppose that you use the method of webupd8
Go to their instructions I linked before and check if your configuration is still valid.
They also provide a method to install Java 8: Install Oracle Java 8 in Ubuntu (Debian instructions linked from there.)
Edit: I think that Oracle does not provide a public download of Java 7 anylonger - you would have to download it from the Java Archive. (http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html)
You could try to download the rpm package and use alien to convert it to a .deb package. And did you already consider updating to Java 8?
You can find the webupd8team ppa's online. The oracle-java7-installer has the version number "7u80+7u60arm-0~webupd8~1" I'm guessing this defect would occur for all the provided ubuntu versions!
Looking in one of the ppa's a few of the files directly reference the broken url identified by Meir Maor
debian/oracle-java7-unlimited-jce-policy.postinst:PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/7/$FILENAME
debian/oracle-java7-unlimited-jce-policy.config:PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/7/$FILENAME
debian/oracle-java7-installer.config: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u80-b15/$FILENAME # Must be modified for each release!!!
debian/oracle-java7-installer.config: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u60-b19/$FILENAME # Must be modified for each release!!!
debian/oracle-java7-installer.postinst: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u80-b15/$FILENAME # Must be modified for each release!!!
debian/oracle-java7-installer.postinst: PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/7u60-b19/$FILENAME # Must be modified for each release!!!
unfortunately I can't figure out how to lodge a defect with them (yet) but presumably this would be a quick fix
I have a requirement to install java, Jenkins, maven and some other software on RHEL linux remote system. So far I am able to perform the following:
Copy jdk to Linux and set the path variable
Install Jenkins on the server using "sudo yum -y install jenkins"
Now the problem is that when I am trying to start jenkins as a service using "service start jenkins" I am getting an error and this got resolved after changing Jenkins user to root user and providing path of java in /etc/* (not sure exactly where).
Instead of doing this manually is there a way to add these information to /etc/* or to bashrc programmatically?
Thanks in advance for any input.
I downloaded an Android Studio for linux and then tried to run the studio.sh file inside the 'bin' directory as per the instruction said. The terminal showed an error saying something like this:
bash: ./studio.sh: permission denied
The whole Studio bundle was in .tdz format and I extracted the files before accessing via the terminal. What is the main cause for such error?
Thank you so much!
Got the same problem.
But solved it by following steps:-
Right click on studio.sh and select Properties.
There go to Permissions.
Check "Allow Executing file as program"
And you are done.
Type
sudo ./studio.sh
This should launch android studio with admin privileges. You will need to type your password, assuming you have admin privileges. If you do not have them, you need to contact whoever manages the computer.
When it launches for the first time, it will ask yo to add a shortcut so it is reachable from the GUI app menu. After that, launching android studio should not require sudo permissions.
https://askubuntu.com/questions/421389/where-to-unpack-the-android-studio-file has good recommendations of where to extract android studio to.
You've probably extracted it as root. Change the owner of the file to you with chown command and extract it again, or change the owner of the whole extracted content to you. Example (sudo may be required):
sudo chown yourUserName studio.sh
The other way to do it: change privileges with chmod
sudo chmod a+x studio.sh
Beware, the above one gives every registered user privileges to execute studio script.
--make this--
1°
sudo chown root:YOURUSERHERE /dev/kvm
2°
sudo chmod -R 770 /dev/kvm
so you will be allowed to install and run android studio
Hope this helps :)
I have the same problem, then i used
sudo sh studio.sh
then it`s worked.