I am writing a script (Ubuntu) to perform:
sudo apt-get update
followed by installation of some libs. My question is :
**is there a way to check the requirement of performing apt-get update? Because running update takes some time. **
It seems not possible. However, I thought perhaps someone know a trick.
Related
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.
I had taken a course on a training site that first suggested using sudo apt-get install docker.io or docker-io. The instructor then explained that this is an old method. So, then, without mentioning removing that version, he says to add a repo and use sudo apt-get update followed by sudo apt-get install docker lxc-docker. I saw the errors when I tried to see if it was running after this and to pull an image, not in that order - I mean I wouldn't try to pull if it wasn't running.
Anyway, I cannot seem to get it to start. I got this error instead
Job for docker.service failed because the control process exited with error code. I setup a full gist to show the complete output.
First I should note, that I do have docker installed in /usr/bin/docker and while I don't see a lxc-docker there are files in there that seem to relate to docker and start with lxc.
The gist is at: https://gist.github.com/BruceMWhealton/0c6b84062b013d500089c5e22bf10462
Any advice would be greatly appreciated.
Thanks,
Bruce
The installation on Ubuntu docs have steps for this. Basically, add the current apt source:
deb https://apt.dockerproject.org/repo ubuntu-xenial main
Then update the cache and remove the old package:
sudo apt-get upgrade
sudo apt-get purge lxc-docker
Then you should be able to install the latest version - check with docker version and it will be (as of today) 1.12.1.
Sorry, very new to server stuff, but very curious. Why run apt-get update when building a container?
My guess would be that it's for security purposes, if that the case than that'll answer the question.
apt-get update ensures all package sources and dependencies are at their latest version, it does not update existing packages that have been installed. It's recommended that you always run apt-get update prior to running an apt-get install this is so when the apt-get install is run, the latest version of the package should be used.
RUN apt-get update -q -y && apt-get install -q -y <your-program>
(the -q -y flags just mean that the apt process will run quietly without asking you for confirmations as this would cause the Docker process to fail)
First, lets make a distinction between apt-get update and apt-get upgrade. The update is to get the latest package index. This is so that you don't run into errors for outdated or redacted packages when doing a apt-get install.
The upgrade is actually going through an upgrading packages. It usually also requires a preceding update to have the updated package index. This might be done if there are package or security concerns of already installed packages.
You usually see an update a lot in builds because the base image may have a fairly out of date package index and just doing an apt-get install can fail.
The upgrade would be less common. But could still be done if you want to ensure the latest packages are installed.
I want to keep my system (and all installed packages) "always" on the latest version and therefore I'm thinking about creating special user for auto-updates. This user would get a cron-job which performs sudo apt-get update -y && sudo apt-get upgrade -y once a week.
Since this should be done automatically I'd like to edit the /etc/sudoers file (with sudo visudo of course) so that this user never gets a password prompt for these two commands.
However the only solution I found so far is to disable the password prompt only for apt-get but not for specific sub commands.
Since I want to keep it as safe as possible I'd need a way to ONLY allow update & upgrade, no other sub-commands of apt-get.
And yes, I'd also disable the execution of any other command via sudo, just to be on the safe side.
Is there any way to achieve this or is the only way to allow the execution of apt-get without password prompts (thus also allowing apt-get install)?
I'm using the Debian based distro Raspbian.
Thanks for any help!
Make a script wrapper for apt-get update and apt-get upgrade, something like this:
#!/bin/sh
apt-get update $#
and allow it in sudoers with NOPASSWD.
But need to say that I'm not really sure that it's impossible to execute some shell command using apt-get update or apt-get upgrade, so not sure that allowing to run them as root for a non-root user is secure enough.
I noticed that apt-get purge doesn't always clean every trace of an installation.
As a concrete example, I'm trying to remove mailman (installed by apt-get install mailman).
Now, I tried to remove every(!) trace of this installation by apt-get purge mailman.
find / -name '*mailman*' reveals that there is still some stuff from mailman around:
/run/mailman
/var/cache/apt/archives/mailman_1%3a2.1.16-2_amd64.deb
/var/spool/postfix/private/mailman
/usr/share/bash-completion/completions/mailmanctl
/usr/share/locale-langpack/en_GB/LC_MESSAGES/mailman.mo
/usr/share/locale-langpack/en_AU/LC_MESSAGES/mailman.mo
Also, the installation created an additional user "list" and a group "list" that I'm quite sure wasn't there before.
So, I was wondering how thorough apt-get purge is? In other words, in what way might apt-get install X; apt-get purge X; change my system? And are there more thorough methods?
When building a package, the files generated by the build process are registered. When you uninstall a package, these files will be removed (remove keeps config files, purge removes them, too).
If a program itself generates files, the package manager usually doesn't know about this, and won't touch these files.
Also, third party addons, suggested packages or dependencies may create files which do not belong to the removed/purged package, even if they don't make any sense without it.
To find out to which package a file belongs, use apt-file:
apt-file search /path/to/file
You may need to install apt-file and update its database:
sudo apt-get install apt-file && sudo apt-file update
You can use
apt-get --purge remove PACKAGE instead of apt-get purge
apt-get --purge remove mailman
AND this will remove the dependencies
sudo apt-get autoremove mailman