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.