ubuntu Useful Commands
Update Ubuntu version
// Check Ubuntu Version
$: lsb_release -a
// Update your Current Ubuntu server to the latest:
// Step 1: This command refreshes your local list of software,
// making a note of any newer revisions and updates. If there’s a newer version
// of the kernel, the command will find it and mark it for download and
//installation.
$: sudo apt-get update
// Step 2: The “dist-upgrade” switch asks Ubuntu to handle any dependencies
// intelligently. That is, if a particular software package is dependent on
// another software package to run, this command will make sure that the second
// package is upgraded before upgrading the first one. This method is a safe way
// to upgrade your Ubuntu Linux kernel. The kernel updates accessible through
// this utility have been tested and verified to work with your version of Ubuntu.
$: sudo apt-get dist-upgrade
Install Node.js
// Install Node.js on Ubuntu
// One very convenient way to install Node.js is through a package manager of ubuntu
// Official Procedure: https://github.com/nodesource/distributions/blob/master/README.md
// Which version to select: https://nodejs.org/en/
// Step 1: check the current by default ubuntu node version
$: node -v
$: nodejs -v
// Step 2: Install Node.js 14.X LTS and npm
$: curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
$: sudo apt-get install -y nodejs
## You may also need development tools to build native addons:
sudo apt-get install gcc g++ make
// Step 3: Install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
// Yarn is a JavaScript package manager compatible with npm that helps
// you automate the process of installing, updating, configuring,
// and removing npm packages. It caches every download package and
// speeds up the installation process by parallelizing operations.
Install node.js package - Lite Web Server
// Install NPM lite Server package on the directory of the project
$ cd /ProjectDirectory
// Install the NPM lite-server
$ npm install lite-server
// Create in the project root directory a file package.json
// This is the config file used by NPM and add the following inside of it:
# Inside package.json...
"scripts": {
"dev": "lite-server"
}
// Then you can launch the lite-Server npm package
$ npm run dev
// if you run it on a server, launch it as a dedicated process:
$: nohup npm run dev >> runningwebserver.log 2>&1 &
// in runningwebserver.log -> you will have all the npm lite web server output
// You have a Local Web Server running on http://localhost:3000
// Copy on the root section of your project an index.html file
//Add "Hello World" inside of it
/Then refresh the browser page you should see your first web page
// To Stop the running lite-server, do in the CLI running windows and enter
// ctrl + C
// To specify a src base directory for your project, create a bs-config.json
// in your project's folder with the following content:
{
"port": 8000,
"files": ["./src/**/*.{html,htm,css,js}"],
"server": { "baseDir": "./src" }
}
// Then in the project directory create a folder:
$ mkdir src
$ cd src
// create an index.html file that will be the host page of the Demon
// Open the Chrome Browser and go to view/developer/Javascrip console for debugging
Git
// Copy your project git repo on your server
// To to the project directory on Ubuntu and copy your git project there:
$: git clone https://github.com/IPConvergence/TrustedDistributedOpenDataRegistry
Ubuntu CLI System useful commands
// If you have a big project to copy from server to your PC
// Create a zip of all the project folder and its content
// On Linux, gzip is unable to compress a folder, it used to compress
// a single file only. To compress a folder, you should use tar + gzip,
which is tar -z.
$: tar -zcvf outputFileName folderToCompress
// To uncompress on your local PC:
$: tar -xzvf compressfile.
Last updated