Is it possible to install perl to /usr/local/bin without full sudo permissions namely only sudo apt install ... being allowed.

I have a DVD with a software, using /usr/local/bin/perl in shebang, variables, paths etc. Yet on my machine perl is in /usr/bin .

I am not admin on my machine. I asked IT to to create copy or link to perl file ( sudo ln -s /usr/bin/perl /usr/local/bin/perl) yet it might take time. Is there other way? I have no admin/sudo permissions but allowed to install soft using standard package manager apt .

Perl 5.22 but close version would probably do, Ubuntu 16.04

Update 1. As recommended in answers I run a replace on a copy of the soft. I though installed and used designated text replacement command rpl. Still curios are there other solution e.g. is it possible to compile perl into .deb package that I can installs into desired folder with apt install.

Update 2. IT helpdesk created links for me, can run scripts now.

  • 1
    Can you get them to sudo ln -s /usr/bin/perl /usr/local/bin/perl? Can you copy the scripts and edit them? `sed -i~ -e 's%#!/usr/local/bin/perl %#!/usr/bin/perl %' is what I'd try.
    – waltinator
    May 3, 2019 at 2:43
  • Thanks, Tried with rpl. Did not help much (may be due other issues)
    – Se Bo
    May 3, 2019 at 11:16

1 Answer 1


You can build Perl from source, then placing them to /usr/local/bin.

  1. Download perl tarball file from their website, unpack it.

    wget https://www.cpan.org/src/5.0/perl-5.22.0.tar.gz
    tar -xvzf perl-5.22.0.tar.gz
    cd perl-5.22.0/
  2. Proceed to installation through make.

    ./Configure -des -Dprefix=/usr/local
    make test
    sudo make install

This will install Perl version 5.22.0 to directory /usr/local/bin, which you can call the executable as /usr/local/bin/perl.

:~$ /usr/local/bin/perl --version

This is perl 5, version 22, subversion 0 (v5.22.0) built for x86_64-linux

Copyright 1987-2015, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Although the most logical way would be replacing the shebang line to exactly /usr/bin/perl, you can do so by.

find /path/to/script -name '*.pl' | xargs perl -pi -e 's{^#!/usr/local/bin/perl}{#!/usr/bin/perl}'

Will change #!/usr/local/bin/perl#!/usr/bin/perl.

  • Even better: replace the shebang line with #!/usr/bin/env perl. Then it will always work.
    – PerlDuck
    May 3, 2019 at 7:31
  • I do not have sudo over make install, only apt install
    – Se Bo
    May 3, 2019 at 18:38
  • #!/usr/bin/env perl does not always work, not with every OS over there
    – Se Bo
    May 3, 2019 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .