If you are a new developer, you probably use a nice GUI (Graphical User Interface) to code. It's easy. But when you start doing real work—like backend systems, deployment, or CI/CD—you will need to use the Terminal.
Using the terminal and Bash commands is a skill you must have.
This article is for new developers who are not used to the command line.
Commands You Should Know
Basics & File Management
pwd
,ls
,cd
,touch
,mkdir
,rm
,cat
,less
,head
,tail
,echo
Searching & Editing
grep
,find
,nano
Managing Git
git clone
,git status
,git log
Processing Text
awk
,sed
,jq
Calling APIs & Basic Networking
curl
,ping
,wget
,netstat
,lsof
1 Basics and File Management
pwd
– Where am I?
This command shows you the path of the folder you are in right now.
bashpwd
It will display something like this:
/Users/yourname/projects/myapp
ls
– What's in here?
This lists all the files and folders in your current directory.
bashls # A short list of files and folders. ls -lah # A detailed list of all files.
-l
gives you more details (like size and date).-a
shows all files, even hidden ones (those starting with a dot.
).-h
makes file sizes easy to read (like KB or MB).
cd
– Change folder
Use this to move between folders.
bashcd bash_cmd_learn # Go into the 'bash_cmd_learn' folder. cd .. # Go back up to the parent folder. cd - # Go back to the last folder you were in.
touch
– Create an empty file
This creates a new, empty file.
bashtouch rean.txt # Creates a new file named rean.txt.
If the file already exists, this command just updates its timestamp.
mkdir
– Make a new folder
bashmkdir logs # Creates a new folder named 'logs'. mkdir -p data/db # Creates 'data' folder and then 'db' folder inside it.
The -p
option is useful. It creates the parent folder if it's not there.
rm
– Remove a file or folder
bashrm rean.txt # Deletes the file rean.txt. rm -rf logs/ # Deletes the 'logs' folder and everything inside it.
-r
means recursive, so it deletes the whole folder.-f
means force, so it doesn't ask you for confirmation.
Be very careful with
rm -rf
. It deletes everything forever and does not ask you. There is no undo.
cat
– Read a whole file
This command prints the entire content of a file to the screen. Good for small files.
bashcat README.md
less
– Read a file page by page
If a file is very long, use less
. It lets you scroll up and down.
bashless 2000_log_file.log
Press
q
to exit.
head
and tail
– See the start or end of a file
Sometimes you only need to see the first few lines or the last few lines.
bashhead app.js # Shows the first 10 lines. tail app.js # Shows the last 10 lines.
echo
– Print text
This command prints text or the value of a variable.
bashecho "Hello, Developer" echo $HOME # Shows the path to your home directory.
You can also use it to write text to a file.
bashecho "PORT=8080" > .env # Creates a file named .env with this text. echo "DEBUG=true" >> .env # Adds a new line to the end of .env.
>
overwrites the file.>>
adds to the end of the file.
2. Searching & Editing
grep
– Find text inside files
This is one of the most useful commands. It searches for a pattern of text.
bash# Search for any usage of async functions in JS files. grep "async function" *.js # Search for all lines that import modules (ES6 style). grep "^import" *.js
find
– Find files or folders
Use this to find files by name, type, or size.
bash# Find all JavaScript files in the src/ directory and its subdirectories. find ./src -name "*.js" # Find all test files that end with .test.js. find . -type f -name "*.test.js"
nano
– The simple editor
nano
is a very easy-to-use editor for beginners allow you edit the files in the terminal.
bashnano index.js
This opens config.yaml
for you to edit.
- Press
Ctrl + O
to save your changes. - Press
Ctrl + X
to exit.
3. Basic Git Commands
You will use Git every day. Here are the most common commands.
git status
- See what files have changed.git add <file>
- Prepare a file to be saved.git commit -m "Your message"
- Save your changes with a message.git log --oneline
- See a short history of all your saves.git pull
- Get the latest changes from the server.git push
- Send your saved changes to the server.git clone <url>
- Copy a project from a server to your computer.
4. Processing Text
awk
– Get a specific column of text
Imagine you have a log file where data is separated by spaces. awk
can pull out just the columns you want.
bash# From a Node.js server log, print the first column (the timestamp). awk '{print $1}' server.log # Print the IP address if it's the third column. awk '{print $3}' server.log
sed
– Find and replace text
sed
is for finding and replacing text in a stream or file.
bash# Replace 'development' with 'production' in a .env file. # This only prints the result; it doesn't change the file. sed 's/development/production/g' .env # To update the file in-place, use the -i flag. sed -i 's/development/production/g' .env
jq
– Work with JSON
If you work with APIs or config files like package.json
, jq
is a powerful tool for handling JSON.
bash# Pretty-print package.json cat package.json | jq '.' # Get the value of the "name" field in package.json cat package.json | jq '.name' # Get all dependency names from package.json cat package.json | jq '.dependencies | keys[]'
5. Network Commands You Should Know
ping
– Is the server online?
Use ping
to check if you can reach a server.
bashping google.com # Ping 4 times and then stop. ping -c 4 google.com
If it works, you’ll see replies with response times (e.g., 64 bytes from ... time=23.4 ms
). If it’s not , you’ll get errors like Request timed out
or Destination Host Unreachable
.
curl
– Talk to APIs
curl
is a great tool for testing APIs from the command line.
bash# Send a GET request to a health check endpoint. curl http://localhost:8080/health # Send a POST request with JSON data. curl -X POST http://localhost:8080/users \ -H "Content-Type: application/json" \ -d '{"name": "new dev"}'
wget
– Download files
Use wget
to download a file from a URL.
bashwget https://example.com/some-file.zip
lsof
and netstat
– What's using that port?
If you get an error like "port already in use," these commands can help.
bash# Show me what program is using port 8080. lsof -i :8080
This will show you the command and PID using the port. You can then use kill
to stop it if you need to.
You don't need to remember all these commands at once. The best way to learn is to start using them for your real projects.
Start with simple things: moving between folders, editing a config file, checking logs, or running your app.
Once you are comfortable, you will see that the command line is a powerful tool. You can build your own scripts for testing, deploying, and monitoring your work. And that is a very important skill for a developer.