How do I keep a dynamic URL updated? - linux

I am writing a that will allow me to automate the customization of a fresh Linux installation. The script generally runs
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
for all programs that are in the apt repository, but I'm here to ask for help about programs that aren't found in a package manager.
For example, lets say I want to install "IDEA".
Manually I'd
Go to the Jetbrains website
Download the appropriate .tar.gz file
Install said .tar.gz
My question stems from the second step "Download the appropriate .tar.gz file". If I were to download this manually now, I'd use wget against the URL "https://download-cf.jetbrains.com/idea/ideaIU-2016.1.3.tar.gz".
As you can see, the URL changes with each version. My question is, how would you write a BASH script to always download the newest version of Idea.
I am also looking into programs like Vagrant and the likes, but still curious to see if there is a solution for this problem.

Related

What are the differences between apt clean/remove/purge etc. commands?

I am quite new to Linux and Apt package manager. I try to build my first docker image (write my first Dockerfile) based on other Dockerfiles written by co-workers for other projects. I came across these commands and however I tried to google them separately one-by-one, as a Linux newbie I still don't really understand what are the differences between them or which one should I use or should I use them all together?
This is a piece from the Dockerfile:
RUN rm -rf /var/lib/apt/lists/*; \
apt-get purge -y --auto-remove; \
apt-get autoremove; \
apt-get clean;
Could you please explain briefly what is the difference?
The differences between the command you metioned are described as follows. Hope these can help you a little.
apt remove
remove is identical to install except that packages are removed instead of installed.
It will remove the binaries, but leave configuration files, data files, and dependencies installed with it on installation time untouched.
apt purge
purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).
It will remove about everything regarding the package, but not the dependencies installed with it on installation, which is particularly useful when you want to “start all over” with an application because you messed up the configuration.
However, purge won’t touch configuration or data files inside the user’s home folder (e.g. /home/User/hiddenFolders). There is no easy way to get those removed as well.
Note that other tools like aptitude will only remember dependency information for packages that it has installed.
apt autoremove
autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
In other words, it will only goes through the catalog and remove any left over packages that were not directly installed and that are not required by packages that are installed. Say that you install apache, it will install a lot of libraries. If you remove apache, all these libraries will be left behind until you run autoremove.
The only thing you should watch for, is if you started using one of the dependencies say “Python” but never actually installed it yourself; then it will be removed.
apt clean
clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archieves/partial/.
apt autoclean
Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it going out of control.
Extra
This part of contents is not closely related to the question, but I think it's necessary to give you some extra suggestions.
Do not remove files belonging to packages without using the package manager! It will get confused and is the wrong way to do things.
If you don’t know to which package a file belongs, try this:
dpkg -S /path/to/file
For some applications compiled from their source codes, the best way is to refer to its README, and remove it manually.

wget command not found on linux server

I have a linux server (completely new, web hosting, nothing is installed into it), and want to use a "wget" command. Currently, it is not found. Kernel version 2.6.32-896.16.1.lve1.4.54.el6.x86_64
I am completely new to linux, tried to solve this issue by myself, but couldn't do it. I log in into this linux server via PuTTY via my Windows OS laptop.
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
To get "wget" to work, I will need to install it. I guess I will need to install first "sudo" and/or "apt" and/or "apt-get". But couldn't do it. Please give me a short list of steps in which order to install them.
Given your kernel version, it looks like your Linux distribution is CentOS 6 or RHEL 6. Try installing wget with this command:
yum install wget
You must be root when you run this command.
Incase you using Debian version of Linux, use the following:
sudo apt-get install wget
From kernel version, it looks like you are using RHEL/Centos 6.
Please check -
https://centos.pkgs.org/6/centos-x86_64/wget-1.12-10.el6.x86_64.rpm.html
If the mentioned dependencies exist in your system, you can directly fire the rpm command
rpm command guide -
https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch02s03.html
If it doesn't work, you need to use yum command. (You need to configure yum command first, if not configured already)
yum install wget
To configure yum command in centos6 -
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-configuring_yum_and_yum_repositories
Note - you need to be root user for above activities.

What's the difference between yum -y install and yum install in CentOS

I've seen two ways to install packages,for example,squid on CentOS:
1.yum -y install squid
2.yum install squid
can anyone tell me what's the difference between them ?
also, I'm using CentOS v.6.6
If you supply -y it automatically chooses "yes" for future questions, i.e. are you sure you want to install squid? [Y/n]?.
It is handy if the installation takes a long time and asks multiple questions, which happens when you install multiple programs at once. In that case, having to type enter every now and again for the process to continue can be annoying.
For a full list of yum options and their definitions take a look at the help message for yum:
yum -h
With -y option, yum will install specified package along with its dependent package without asking for confirmation.
Without -y option, yum will show information related to specified package and its dependent packages and will ask for confirmation to install.
-y option will be useful if package is going to be installed through some scripts.

how to update make 3.81 linux

I am new to Linux (new as in installed it yesterday), I need it for my programming course in the university and I've been told to install specific versions of specific programs, but though I've used apt-get install to install them (having previously done apt-get update) they aren't in the correct version.
The programs that I need are make 4.0 and valgrind 3.10.1.
apt-get installs make 3.81 and valgrind 3.10.0.SVN.
I have tried typing "apt-get install make4.0" and "apt-get install valgrind10.3.1" to no avail. I have downloaded them from the internet and followed what instructions I could understand to install the newer versions but it keeps saying that I have the older ones. (I'm not sure if I can post direct links here, if I can let me know and I'll post where I got them from).
What have I been doing wrong? How can I fix this?
I am currently running Linux Mint.
Thanks for any answer in advance.
Due to a long-standing unresolved Debian bug report, GNU Make remained the age-old 3.81 in Debian for a very long time, and as a consequence, in Debian-based distributions such as Ubuntu and Mint.
The latest Debian release, Jessie, has upgraded to 4.0, so Debian-based distributions will have that upgrade. However, it is better to use 4.1.
This has been discussed many times on the GNU Make mailing list and elsewhere.
So to get a newer version, you must compile it from scratch.
This is easy:
Install the required packages (gcc, make and such).
Open up a shell (if you're using the GUI, a terminal window).
Type the following commands (or something equivalent, e.g. you can use curl instead of wget):
cd /tmp
wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gz
tar xvf make-4.1.tar.gz
cd make-4.1/
./configure
make
sudo make install
cd ..
rm -rf make-4.1.tar.gz make-4.1
Now, make 4.1 is in /usr/local/bin/make.
You can verify it is there with whereis make.
You can make it your default make by prefixing /usr/local/bin to your $PATH variable in your shell startup file; for instance, in .profile or .bashrc if you use the bash shell.
Don't try to install a self-compiled make (or anything else that doesn't come from the distribution's package manager) into /bin or /usr/bin; doing that will confuse your package manager.

Python3.X.X Proper Setup with Virtualenv and multiple installs to /OPT/

I have spent about a week trying to get python python 3.x.x setup “properly” on my system. It has been quite a battle and I'm just about there with one final obstacle I can't seem to resolve. Many forums discuss setting up Python 3.X.X on various distro's and each has different methods, goals, outcomes, errors/issues with no clear answer. By now I have put in over 100 hours and have busted/reinstalled my system with clonzilla images dozens to times. But after all that, I have captured all the steps necessary to have the ultimate python setup in this posting - minus the answer to the final obstacle which I'm hoping someone can help me with:
The end goal I'm aiming for is the “ultimate python3.x.x setup” that I define as having the following characteristics:
has clean installation/configurations of python3.x.x. that are built from source, and include multiple side-by-side python3.x.x. versions (e.g. python3.0.1, python3.2.5, python3.3.0) with preserved root permissions assigned to each folder as part of the default /opt/ directory
Each installation does not interfere with the system's default interpreter,has pip, easy install, distribute tools, and virtualenv all properly configured and working and can run in isolation with different modules via virtualenv's
each python3.x.x is compiled, installed and named clearly in the /opt/ directory (e.g. python3.3.0, python3.3.1, python3.3.2), and is configured such that when calling whatever python3.x.x from the terminal window or using that version that it does not screwup the system's default interpretor, its dependencies/packages (plenty of forums on this one)
Each python3.x.x is working in pycharm's stupidly simplistic and awesome virtualenv manager - my last hurdle
The following steps are my setup so far and it compiled from multiple forums necessary to accomplish all of the above minus the last hurdle. Two important points are 1) I'm running Linux Mint LTS 13 and 2) I have NOT ran “sudo apt-get install python3” or any similar apt-get of python3xxxxx (this is deliberate for reasons below).
These are the steps I have taken on a fresh install of Linux mint 13, and now have backed up clonezilla image as well as virtual box's which I'm now using to solve this last hurdle.
Step 1:
This mega-command will download and setup pycharm, including the program's oracle (sun) dependencies, and install everything to the /opt/ directory (i.e.the proper location). I simply accept oracle's prompts and complete pycharm's final installation prompts (e.g. accept license, trial period etc.)
Pycharm
sudo add-apt-repository ppa:webupd8team/java -y && sudo apt-get update && sudo apt-get install oracle-java7-set-default -y && sudo apt-get install oracle-java7-installer -y && wget "http://download.jetbrains.com/python/pycharm-professional-3.0.2.tar.gz" && sudo mkdir /opt/Pycharm && sudo cp pycharm-professional-3.0.2.tar.gz /opt/Pycharm/ && cd /opt/Pycharm/ && sudo tar xvfz pycharm-professional-3.0.2.tar.gz && cd pycharm-3.0.2/bin && sudo sh pycharm.sh
Step 2:
This single command will download, extract, move, compile, and install 3.3.0, with all necessary prior dependencies, and place python3.3.0 in the /opt/ directory (the proper location).
Python3.3.0
sudo apt-get install build-essential libbz2-dev bzip2 zlib1g-dev sqlite3 libsqlite3-dev -y && wget http://python.org/ftp/python/3.3.0/Python-3.3.0.tgz && tar xvfz Python-3.3.0.tgz && cd Python-3.3.0 && ./configure --prefix=/opt/python3.3.0 && make && sudo make install
Step 3:
This single command will download, extract, move, compile, and install 3.2.5, with all necessary dependencies, and place python3.2.5 in the /opt/ directory.
Python3.2.5
wget http://www.python.org/ftp/python/3.2.5/Python-3.2.5.tgz && tar xvfz Python-3.2.5.tgz && cd Python-3.2.5 && ./configure --prefix=/opt/python3.2.5 && make && sudo make install
We now have pycharm and two side-by-side installations of python3.3.0 and python3.2.5 that are built from source, installed in the /opt/directory, and will not interfere with the system's python2.x.x interpretor or its dependencies/packages. Good so far as this is a very clean setup... Now comes the final hurdle.
If I (or you) “sudo apt-get install python3-dev” from this point, including a few other commands to setup and activate a virtualenv of python3.x.x, everything appears to work. Meaning you can setup multiple Python3.x.x virtualenv's and run them with pycharm, eclipse or from a terminal windows as either virtualenv's or non-virtualenv's. Pycharm makes it stupidly easy to manage virtually any configuration you want with its built-in virtualenv manager. The problem though is that doing “sudo apt-get install python3-dev” defeats the whole purpose of keeping python3.x.x as separate installations and runs the risk of 1) breaking python2.x.x packages, 2) installs pip packages meant for python3.x.x. into python2.x.x directories, 3) limits the ability of the user to only python3.2 and lower because you have to point whatever virtualenv you're using to the interpreter that came with running “sudo apt-get install python3-dev”, 4) a plethora of other problems scattered throughout forums I have investigated this this week in trying to figure this all out. Therefore “sudo apt-get install python3-dev” or any other apt-get of python3.x.x is not a solution as it leads to too many issues.
At this point I have a master version of a virtual box image setup with all the above steps completed in which I keep cloning and retrying to get the compiled interpretorls from /opt/ to function without doing a “sudo apt-get python3.xxx”. The 'key problem' indicated in screen shot is this issue. Nothing I do seems to allow me to point it to /opt/python3.xx/bin/pythonX interpretor whether using an IDE like pycharm, eclipse or by terminal. As soon as I run “sudo apt-get python3.xxx” it will work – but of course inherit all the other nightmare that people scream about in forums when they go down that route. Any help is greatly appreciated...
screenshot http://www.pasteall.org/pic/show.php?id=65653
Every configuration I have tried in getting the interpretor's that were compiled from source fails to allow those python3.x.x installations to function as virtualenv's and thus use package managers like pip either in a terminal window or with pycharm/eclipse. I have tried installing to home directories, changing permissions in /opt/, making system links, practically everything - everything that doesn't involve a “sudo apt-get install python3.xxxx”...This post (https://askubuntu.com/questions/406756/how-to-install-python-3-x-x-properly#406762), at step two, works but only if you revert to doing a “sudo apt-get install python3”.
What you're looking for is pyenv. It will manage your python installations, and allow you to install new versions of python without hampering other installations, it will work fine Pycharm, and will not hamper other python installations. Its done completely in bash, so it does not have python as a prerequisite installation.
I have finally figured out what I was doing wrong. I was not reading the make report and fixing additional dependencies before installing. The main problem was including dependencies for _ssl which is required for pip to work with python3.
I now have my "ultimate python setup"

Resources