[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how disable apt downloads w/o sudo



On Mon, Sep 12, 2022 at 04:44:36PM +0000, jindam, vani wrote:
> On 12 September 2022 1:04:51 PM UTC, Greg Wooledge <greg@wooledge.org> wrote:
> >Well, *I* don't understand your issue yet.  Can you please explain it in
> >more detail?
> >
> >Are you trying to stop other users on your system from doing this, or are
> >you trying to stop *yourself* from doing this?
> 
> i am concerned about *myself*

OK.

> >Is your concern the use of bandwidth?  
> 
> yes
> 
> >Is a disk being filled up and
> >running out of space?  Something else?
> 
> frankly, if the downloaded files cant 
> be used, its *definitely* wastage 
> of space

A downloaded .deb file can be used.  Just become root and install it.  Or
move it to /var/cache/apt/archives, so that it'll be used next time you
do "apt install ..." as root.

Nothing is being wasted here, if you actually did want to download it.

> >Are you *only* concerned about the "apt" command (and maybe apt-get), or
> >is the concern broader? 
> 
> yes
> i use only apt

Since you're only trying to prevent personal accidents, you could also
just set up a shell function.

apt() {
  if [[ $1 = download ]]; then
    echo "Do this as root instead." >&2
    return 1
  fi
  command apt "$@"
}

Something along those lines would prevent you from accidentally running
"apt download ..." as yourself.

Having never used an "apt download" command in my entire life, I'm not
sure exactly what your work flow is, but anyway, here are two answers.


Reply to: