0% found this document useful (0 votes)
17 views5 pages

BASH Programming Commands

The document provides a comprehensive cheat sheet for running various programming projects from the Bash terminal, including commands for Python, Java, Node.js, Golang, and C/C++. It also includes instructions for creating and managing Python virtual environments, Bash programming commands, and VS Code terminal commands. Additionally, it outlines common situations for script automation, code execution, version control, package management, and Docker/DevOps tasks.

Uploaded by

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

BASH Programming Commands

The document provides a comprehensive cheat sheet for running various programming projects from the Bash terminal, including commands for Python, Java, Node.js, Golang, and C/C++. It also includes instructions for creating and managing Python virtual environments, Bash programming commands, and VS Code terminal commands. Additionally, it outlines common situations for script automation, code execution, version control, package management, and Docker/DevOps tasks.

Uploaded by

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

✅ Running Python, Java, and Other Projects from Bash

Language / Framework Command Description / Use Case

Python (Single File) python file.py or python3 file.py Run a Python script

Python (with Arguments) python file.py arg1 arg2 Pass arguments to script

Run installed or inbuilt Python


Python (from Module) python -m module_name
modules

Run Flask web server (after setting


Run Flask App flask run
FLASK_APP)

Run Django App python manage.py runserver Run Django development server

Python Virtual Environment


python -m venv venv Create virtual environment
(venv)

Activate venv (Linux/Mac) source venv/bin/activate Activate virtual environment

Activate virtual environment on


Activate venv (Windows) .\\venv\\Scripts\\activate
Windows

Deactivate venv deactivate Exit virtual environment

Install Requirements Install Python dependencies for


pip install -r requirements.txt
(Python) project

Java (Compile) javac Main.java Compile Java source code

Java (Run) java Main Run compiled Java class

Java (Package .jar) jar cf app.jar *.class Package compiled Java files into a JAR

Java (Run .jar) java -jar app.jar Execute JAR package

Node.js (JS) node app.js Run Node.js project

Node.js (npm) npm start Start project using npm scripts

Golang go run main.go Run Go project

C Program (Compile + Run) gcc file.c -o output && ./output Compile and run C programs

C++ Program (Compile + g++ file.cpp -o output &&


Compile and run C++ programs
Run) ./output

✅ Virtual Environment Creation: Python


Tool Command When to Use

venv (Default) python -m venv venv For isolated development environment

conda create --name myenv For Python scientific computing, ML, data
conda (if installed)
python=3.x science

Activate
source venv/bin/activate Enter venv environment
(Linux/Mac)

Activate (Windows) .\\venv\\Scripts\\activate Enter venv on Windows

Deactivate deactivate Exit environment

✅ Bash Programming Commands Cheat Sheet


Command Description Theme/Context When to Use (Situation)

Shebang to indicate script Always at the top of bash


#!/bin/bash Script Declaration
should be run in Bash scripts

Display information,
echo "text" Print text to the terminal Output
debugging, logging

Scripts requiring user


read var Get input from the user User Input
interaction

if [ condition ]; then
Conditional statements Control Flow Decision making in scripts
... fi

case <var> in ... Multi-condition Alternative to multiple if-elif-


Control Flow
esac branching else blocks

for var in list; do ... Repeating tasks on lists or


Loop over a list or range Loops
done patterns

while [ condition ]; Run while a condition is Useful for indefinite loops


Loops
do ... done true with exit conditions

function fname() Break complex tasks into


Declare a function Modularity
{ ... } reusable parts

Exit script with a status Communicate success or


exit <code> Control Flow
code failure of script execution

Logical AND / OR between


&& / ` `
commands
Command Description Theme/Context When to Use (Situation)

$(command) or Capture output of command


Command substitution Advanced Scripting
`command` into variable

source <file> or . Execute commands from Break scripts into multiple


Modularity/Reusability
<file> another file reusable parts

Extract filename from full


basename <path> Get file name from path File Handling
path

Get directory name from


dirname <path> File Handling Extract folder from full path
path

$0 $1 $2 ... Positional arguments Parameter Handling Pass arguments to the script

For handling CTRL+C


Capture signals and run
trap Error Handling interruptions, cleaning temp
cleanup commands
files

Exit script if any Fail early when something


set -e Error Handling
command fails goes wrong

Move positional When processing arguments


shift Parameter Handling
parameters to the left one by one

✅ VS Code Terminal Commands Cheat Sheet (Developer Use)


Command Description Theme/Context When to Use (Situation)

Open current
Quickly launch VS Code from
code . directory in VS VS Code Specific
terminal
Code

Open a specific Edit a specific file without


code <file> VS Code Specific
file in VS Code opening the full project

Toggle terminal
Show or hide terminal inside VS
Ctrl + \ open/close in VS VS Code Shortcut
Code
Code

Execute VS Code actions (e.g.,


Open command
Ctrl + Shift + P VS Code Shortcut install extensions, format code,
palette
etc.)

Initialize Node.js JavaScript


npm init Start a Node.js project
project Development

Install npm Package When adding a dependency to


npm install <package>
package Management your project
Command Description Theme/Context When to Use (Situation)

Python Execute Python scripts within VS


python <file>.py Run Python script
Development Code terminal

Install Python Python Install libraries required for


pip install <package>
package Development coding

Compile Java
javac <file>.java Java Development Build Java source code
program

Run Java
java <ClassName> Java Development Execute compiled Java classes
program

Show changes in Track what’s


git status Version Control
Git staged/unstaged/untracked

Add all changes


git add . Version Control Prepare files for commit
to staging area

Commit staged
git commit -m "msg" Version Control Save a snapshot of code changes
changes

Push code to Publish commits to remote


git push Version Control
GitHub repository

Basic Linux Regular directory/file operations


ls, cd, mkdir, rm File Management
commands inside VS Code terminal

Create a Python
Python For dependency isolation in
python -m venv venv virtual
Development Python projects
environment

source venv/bin/activate
Activate Python Activate isolated environment for
(Linux/Mac) Python
virtual running and testing Python
.\\venv\\Scripts\\activate Development
environment projects
(Windows)

Activate Conda
conda activate <env> environment (if Python Data Science Activate Conda environment
using Conda)

Build Docker
docker build . DevOps/Containers When containerizing applications
image

Start services
defined in Managing multi-container
docker-compose up DevOps/Containers
docker- applications
compose.yml

✅ Common Situations
Situation Bash Programming VS Code Terminal

bash script.sh, loops, VS Code: bash script.sh inside integrated


Script Automation
conditionals terminal

Depends on language
Code Execution python file.py, javac, java, node app.js
interpreter

Use git inside VS Code or VS Code Source


Version Control Use git CLI
Control UI

Package
apt, yum, brew pip, npm, conda, inside VS Code terminal
Management

Same commands executed from VS Code


Docker/DevOps docker, docker-compose
terminal

You might also like