pwd → print working directory
cd dir → change directory
cd .. or cd ../../
ls → list all files and folders in the current working directory
ls -l → long listing format (shows permissions, owner, size, and timestamp)
ls -r → reverse the order of the output
ls -lr → long listing format in reverse order
ls -t → sort by modification time (newest first)
ls -la → list all files including hidden ones (. files) in long format
ls -s → display file size in blocks
ls -lR | grep .json → recursively list all files and filter .json files using grep
ls *js → list all files ending with js in the current directory
- ✅ You can combine these flags like
ls -ltr to customise the output
mkdir folderName → creates a new folder
touch index.js → creates a new file
cat new.txt → prints the content of the file
cat > new.txt → to write content to the file
cat >> new.txt → to append the content to the file
vi filename.xyz → vim is a text editor inside your terminal. It's used to edit files directly from the command line.
i → to enter insert mode
ESC → followed by :wq! to save and exit from the vim terminal or just :q! to exit without saving
mv file/folder loc → used to move one file or folder to another folder
mv index.js prac.js → we can also use the mv command to rename a file
cp file loc → used to copy one file to another folder
cp -r folder loc → used to copy one folder to another folder, the r here refers to copy recursively
rm new.txt → to remove a file
rm -r myFolder → to remove an entire folder recursively
echo →
chmod → is used to change the permissions of a file
node → to run JS in terminal
clear or cmd + k → to clear the terminal
node filename.js → to run JS files
npm → Node Package Manager