Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a perl script that must write configuration file. I need to know if the script is running on Ubuntu to set some Ubuntu-specific values (basically, disable the unified bar). The script cannot require any Perl packages that may not be present on user system.

How can I check if the system is Ubuntu or some other Linux distro?

share|improve this question
up vote 3 down vote accepted

You can check contents of the /etc/lsb-release file.

share|improve this answer
Thanks, I did it this way. – Eugene Jun 22 '12 at 18:19

Alternative answer:

use Linux::Distribution qw(distribution_name);
print "Do your stuff here\n" if( distribution_name eq 'ubuntu' );
share|improve this answer

You can check the output of lsb_release without parsing the file manually or loading an external module:

# ...
my $id = `lsb_release -si`;
if($id eq "Ubuntu") {
    # set Ubuntu-specific values
# ...
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.