DEV Community

Jatin Jain Saraf
Jatin Jain Saraf

Posted on • Originally published at insight.jatinjainsaraf.com on

Linux Terminal Basics Commands:

Linux Terminal Basics Commands:

File and Directory Commands: ls: List files and directories. Syntax: ls [options] [directory] cd: Change directory. Syntax: cd [directory]…


Linux Terminal Basics Commands:

File and Directory Commands:

ls
: List files and directories. Syntax: ls [options] [directory]

cd: Change directory. Syntax: cd [directory]

pwd: Print working directory. Syntax: pwd

mkdir: Create a new directory. Syntax: mkdir [directory]

cp: Copy files or directories. Syntax: cp [options] source destination

mv: Move or rename files/directories. Syntax: mv [options] source destination

rm: Remove/delete files or directories. Syntax: rm [options] file

File Manipulation:

cat
: Concatenate and display the content of files. Syntax: cat [file]

nano Text editors to create or edit files. Syntax (nano): nano [file]_

Vim_
: Text editors to create or edit files.Syntax (vim): vim [file]

touch: Create an empty file or update timestamp. Syntax: touch [file]

System Information:

uname
-a: Display system information. Syntax: uname -a

df -h: Show disk space usage. Syntax: df -h

free -h: Display RAM usage. Syntax: free -h

t_op or htop_: Display running processes. Syntax: top or htop

Debian/Ubuntu:

sudo apt update: Update package lists. Syntax: sudo apt update

sudo apt upgrade: Upgrade installed packages. Syntax: sudo apt upgrade

sudo apt install : Install a new package. Syntax: sudo apt install [package]

Red Hat/Fedora:

sudo yum update: Update packages. Syntax: sudo yum update

sudo yum install: Install a new package. Syntax: sudo yum install [package]

Node.js

node -v: Check Node.js version. Syntax: node -v

npm -v: Check npm version. Syntax: npm -v

npm init: Initialize a new Node.js project. Syntax: npm init

node app.js: Run a Node.js script. Syntax: node [script]

NPM:

npm install : Install a Node.js package.Syntax: npm install [package]

npm install -g : Install a global package.Syntax: npm install -g [package]

npm start: Start the application (as defined in package.json).Syntax: npm start

npm test: Run tests.Syntax: npm test

npm run :</em></strong> Run a custom script.<strong><em>Syntax</em></strong>: npm run [script]</p> </blockquote> <h3> <a name="mongodb-commands" href="#mongodb-commands" class="anchor"> </a> <strong><em>MongoDB Commands:</em></strong> </h3> <blockquote> <p><strong><em>MongoDB Service:<br><br> Sudo service mongod start:</em></strong> Start MongoDB service. <strong><em>Syntax</em></strong>: sudo service mongod start<br><br> <strong><em>sudo service mongod stop:</em></strong> Stop MongoDB service.<strong><em>Syntax</em></strong>: sudo service mongod stop<br><br> <strong><em>sudo service mongod restart:</em></strong> Restart MongoDB service. <strong><em>Syntax</em></strong>: sudo service mongod restart</p> <p><strong><em>Mongo Shell:<br><br> mongo:</em></strong> Open the MongoDB shell. <strong><em>Syntax</em></strong>: mongo<br><br> <strong><em>show dbs:</em></strong> Show available databases.<strong><em>Syntax</em></strong>: show dbs<br><br> <strong><em>use <database>:</em></strong> Switch to a specific database.<strong><em>Syntax</em></strong>: use [database]<br><br> <strong><em>db.<collection>.find():</em></strong> Retrieve documents from a collection. <strong><em>Syntax</em></strong>: db.[collection].find()</p> </blockquote> <h3> <a name="git-commands" href="#git-commands" class="anchor"> </a> <strong><em>Git Commands:</em></strong> </h3> <blockquote> <p><strong><em>Repository Management:<br><br> git init:</em></strong> Initialize a new Git repository. <strong><em>Syntax</em></strong>: git init<br><br> <strong><em>git clone <repository>:</em></strong> Clone a repository. <strong><em>Syntax</em></strong>: git clone [repository]<br><br> <strong><em>git add .:</em></strong> Stage all changes for commit.<strong><em>Syntax</em></strong>: git add .<br><br> <strong><em>git commit -m “message”:</em></strong> Commit changes with a message. <strong><em>Syntax</em></strong>: git commit -m “message”</p> <p><strong><em>Branching:<br><br> git branch:</em></strong> List branches.<strong><em>Syntax</em></strong>: git branch<br><br> <strong><em>git checkout <branch>:</em></strong> Switch to a different branch.<strong><em>Syntax</em></strong>: git checkout [branch]<br><br> <strong><em>git merge <branch>:</em></strong> Merge a branch into the current branch.<strong><em>Syntax</em></strong>: git merge [branch]</p> <p><strong><em>Remote Repositories:<br><br> git remote add origin <repository>:</em></strong> Add a remote repository. <strong><em>Syntax</em></strong>: git remote add origin [repository]<br><br> <strong><em>git push -u origin <branch>:</em></strong> Push changes to a remote repository.<strong><em>Syntax</em></strong>: git push -u origin [branch]<br><br> <strong><em>git pull origin <branch>:</em></strong> Pull changes from a remote repository.<strong><em>Syntax</em></strong>: git pull origin [branch]</p> </blockquote> <h3> <a name="docker-commands" href="#docker-commands" class="anchor"> </a> <strong><em>Docker Commands:</em></strong> </h3> <blockquote> <p><strong><em>Container Management:<br><br> docker build -t <image-name>:</em></strong> Build a Docker image. <strong><em>Syntax</em></strong>: docker build -t [image-name]<br><br> <strong><em>docker run -p <host-port>:</em></strong> <container-port> <image>: Run a Docker container. <strong><em>Syntax</em></strong>: docker run -p [host-port]:[container-port] [image]<br><br> <strong><em>docker ps:</em></strong> List running containers.<strong><em>Syntax</em></strong>: docker ps<br><br> <strong><em>docker stop <container-id>:</em></strong> Stop a running container. <strong><em>Syntax</em></strong>: docker stop [container-id]</p> <p><strong><em>Image and Registry:<br><br> docker images:</em></strong> List Docker images.<strong><em>Syntax</em></strong>: docker images<br><br> <strong><em>docker rmi <image-id>:</em></strong> Remove a Docker image.<strong><em>Syntax</em></strong>: docker rmi [image-id]<br><br> <strong><em>docker push <image>:</em></strong> Push an image to a Docker registry. <strong><em>Syntax</em></strong>: docker push [image]</p> </blockquote> <p>By Jatin Jain Saraf on December 20, 2023.</p>

Top comments (0)