0% found this document useful (0 votes)
5 views2 pages

Linux_NodeJS_CheatSheet_Clean

This cheat sheet provides 15 essential Linux commands for freshers, including file management, process control, and Node.js app management. It outlines steps to install Node.js, create a project, and run a simple Node.js application using Express. Additionally, it includes common interview questions related to Linux and Node.js commands.

Uploaded by

ramaniyagnik06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Linux_NodeJS_CheatSheet_Clean

This cheat sheet provides 15 essential Linux commands for freshers, including file management, process control, and Node.js app management. It outlines steps to install Node.js, create a project, and run a simple Node.js application using Express. Additionally, it includes common interview questions related to Linux and Node.js commands.

Uploaded by

ramaniyagnik06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux + Node.

js Cheat Sheet for Freshers

15 Essential Linux Commands

1. pwd - Show current path

2. ls - List files and folders (use ls -l for details)

3. cd - Change directory (cd /var/www)

4. mkdir - Make directory (mkdir myapp)

5. rm - Delete files/folders (rm -rf foldername)

6. cp - Copy files (cp file1.js file2.js)

7. mv - Move/rename files (mv old.js new.js)

8. touch - Create empty file (touch app.js)

9. chmod - Change file permissions (chmod 755 start.sh)

10. chown - Change file owner (chown user:user file.js)

11. nano/vim - Edit files (nano app.js)

12. ps aux - View running processes

13. kill PID - Kill process (kill 12345)

14. pm2 - Manage Node apps (pm2 start app.js)

15. scp - Copy files to remote server (scp app.js user@ip:/home/user/)

Practice Task: Run Node.js App on Linux

1. Install Node.js using nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

source ~/.bashrc

nvm install --lts

2. Create a project:

mkdir myapp && cd myapp

npm init -y

npm install express


Linux + Node.js Cheat Sheet for Freshers

3. Create app.js:

const express = require('express');

const app = express();

app.get('/', (req, res) => res.send('Hello from Linux!'));

app.listen(3000, () => console.log('App running on port 3000'));

4. Run the app:

node app.js (then visit http://localhost:3000)

5. Use pm2 to keep it running:

npm install -g pm2

pm2 start app.js

pm2 status / pm2 logs

Common Interview Questions

Q: What does chmod 755 mean?

A: Gives owner all rights; others can read and execute.

Q: How do you keep a Node.js app running?

A: Use pm2 (pm2 start app.js).

Q: How do you view app logs?

A: pm2 logs or tail -f filename.log

Q: What command changes file permissions?

A: chmod

Q: How do you stop a stuck process?

A: Find the PID with ps aux, then use kill PID.

You might also like