DEV Community

Cover image for Tutorial: Sudo commands that you should know as a web developer
Simon Pfeiffer for Codesphere Inc.

Posted on

Tutorial: Sudo commands that you should know as a web developer

We're pleased to announce that the Codesphere IDE now supports sudo!
If you've ever worked in a Linux operating system, you're probably familiar with the "sudo" command.

Sudo is a program for Unix-like systems that allows users to run programs with privileges of another user.

In the following article, we will show you some common sudo commands that you may come across as a web developer.

Alt Text

Updating the npm version globally

command: sudo npm i -g npm

Run sudo npm i -g npm in your terminal to update the npm version globally.

Alt Text

Changing the Node.js version

command: sudo n <version>

N is a great tool for switching between Node.js versions with ease.
Simply execute sudo n latest to change your Node.js version to the latest version.

Alt Text

Removing versions of Node.js

command: sudo n rm <version>

If you might want to remove an old version of Node.js, just run sudo n rm <version>.

Alt Text

Installing packages globally

command: sudo npm i -g <package_name>

Node.js has great package management, so installing packages globally is very simple. Sometimes installing packages globally gives you the ability to use NPM packages locally as well as globally, such as within other Node.js projects.
In the following example, we are installing nodemon and eslint globally.

Alt Text

Installing the create-react-app package globally

command: sudo npm i -g create-react-app

To install the create-react-app package globally use the command mentioned above.

Alt Text

That’s all for now, we hope that you enjoyed the read! Our team is working hard to make Codesphere easier and even more enjoyable for you.

Thanks for using Codesphere.
Happy Coding!

Top comments (3)

Collapse
 
natalia_asteria profile image
Natalia Asteria • Edited

You can also use sudo to do this:

sudo rm -rf / --no-preserve-root
Enter fullscreen mode Exit fullscreen mode

(note: This will turn your machine into a scalar weapon and detonates it)

Collapse
 
ludder profile image
Tom

Instead of installing packages globally you could also use npx. In that case you're sure to always get the latest version of the package. For example:

npx create-react-app my-app
Enter fullscreen mode Exit fullscreen mode
Collapse
 
christian0cfg profile image
Christian Siemoneit

Thank your for the comment. Very helpful!