Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

Detecting Ubuntu and its version using NodeJS in Linux

Detecting Ubuntu and its version using NodeJS in Linux

In Linux we can detect ubuntu and its version like Ubuntu 18.04.4 LTS using Linux command “lsb_release -a | grep Description”, using nodejs child_process we can easily run Linux command and detect Linux version.

Code to detect Ubuntu and its version using Nodejs in Linux

The blow code is tested on Node JS Version : 12.4.0

/* by Sanjay Prasad */
const { exec } = require('child_process');
exec('lsb_release -a | grep Description', (err, stdout, stderr) => {
if (err) {
console.error(err)
} else {
console.log("stdout" +stdout.slice(12));
console.log(`stderr: ${stderr}`);
}
});
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Do you have any Query / Suggestion