I installed the 'preupg' command using:
yum -y install redhat-upgrade-tool preupgrade-assistant-contents
And I want to run the following command:
preupg
It asks if I want to continue, but I am using docker and cant say yes or no so it exits. Is there a way to silence this command?
I have tried -f and -q
To run the "preupg" tool without user interaction use
preupg --force
this will not ask for permissions and assume yes for every question.
As the preupg man page says
--force
Suppress user interaction.
Related
I'm starting my coding journey and I have set up the Ubuntu terminal(WSL2). I followed this guide my cousin gave me and it included some directions to install PostgreSQL. I thought it would be a good idea to get it ahead of time, but now it's turning into a nightmare. I installed it and followed the directions to make it automatically connect to the server on the Ubuntu terminal start-up. Long story short, it makes the terminal take awhile to start-up, puts my terminal in some weird directory, and I won't even be using it, so we decided to get rid of it. We tried everything and finally decided to just uninstall it. Now on start-up, it's still trying to connect to the server or whatever. I tried running the code to make it automatically start-up again in case it might just toggle it on and off, but now it's attempting to connect three times on open. Please see the directions I used below as well as what my terminal is showing on start-up. Also, when I try commands to end it or whatever, it can't do it because postgresql can't be found (because I uninstalled it). Any thoughts?
Directions:
In a few weeks, we'll talk about SQL and Databases and you'll need something called PostgreSQL, an open-source robust and production-ready database.
Let's install it now.
sudo apt install -y postgresql postgresql-contrib libpq-dev build-essential
sudo /etc/init.d/postgresql start
sudo -u postgres psql --command "CREATE ROLE `whoami` LOGIN createdb;"
You can configure PostgreSQL to autostart, so you don't have to execute sudo /etc/init.d/postgresql start each time you open a new terminal:
sudo echo "`whoami` ALL=NOPASSWD:/etc/init.d/postgresql start" | sudo tee /etc/sudoers.d/postgresql
sudo chmod 440 /etc/sudoers.d/postgresql
echo "sudo /etc/init.d/postgresql start" >> ~/.zshrc
Error Code:
sudo: /etc/init.d/postgresql: command not found
sudo: /etc/init.d/postgresql: command not found
sudo: /etc/init.d/postgresql: command not found
➜ /home
Just remove the offending line from .zshrc.
Let me add that the Linux emulation of Windows cannot be used for serious work with a database, as it does not implement the vital system call fsync to persist data. Any operating system crash will result in data corruption.
There are ways to automatically answer -y in bash commands for example like
RUN apt-get install -y nodejs
but I'm having this case I want to run
dpkg --install someDebianpackage.deb && apt install --assume-yes --fix-broken
It actually answers y for the immediate prompt given by it but in the later stage it asks me to configure geographic are with answer 6
and after that again I want to answer the command with 20 for the city corresponding to timezone
and then again with answer 31 and then 1 as same as above for different questions.
What I want to know is to run this command as single command in a non-interactive way. ( I'm hoping to make a docker file and put the above command along with some other commands that can be chained with && in a RUN Command for example like
RUN apt-get update && apt-get install sudo && "the above command along with their answers" && "some other command"
I would highly appreciate some guidance over this
Technically, you can auto-answer prompts with a tool like expect. However, that's usually much more difficult than getting the program to stop asking you questions.
I'm not sure why apt is asking for your timezone, but I suspect that you're pulling in the tzdata package somehow, which wants to configure your timezone. To avoid these questions, you should set the frontend to non-interactive:
To run dpkg (behind other tools like Apt) without interactive
dialogue, you can set one environment variable as
DEBIAN_FRONTEND=noninteractive
(Source.)
In a Dockerfile, you can set an environment variable like this:
ENV DEBIAN_FRONTEND=noninteractive
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 am using CentOS 6.3.
How can I ignore or write 'y' when the terminal prompts a question?
For example, when I run 'yum install java-1.7.0-openjdk', it prompts me with this statement
Is this ok [y/N]:
Is there anyway I could ignore or always say yes to the question?
In the case of yum it takes an option -y that answers yes to all questions asked.
yum -y install java-1.7.0-openjdk
For other installations you can try to pipe the command yes to the process but I'm not sure it would work with every program. Try it first.
yes | yum install java-1.7.0-openjdk
Yes, you can use Spawn.
#!/usr/bin/expect -f
spawn yum install java-1.7.0-openjdk
expect "[y/N]:"
send "y\r"
interact
I'm not tested but I found "auto-terminal" here
When I install packages in linux environment I can set the automatic 'yes' option, for example
yum -y install ...
or
apt-get -y install...
Is there a way to do the same but for ".run" programs. For example as,
sudo sh a.run -y
So that whenever it asks yes/no it automatically selects yes, whenever it asks for ok/cancel it selects ok, and so on...
thanks a lot in advance!!!
No, a .run command is simply a set of commands that are going to be run by sh. A particular .run file might take a -y option but in general you can't count on it. If you need to automate some stuff, consider using Expect.