When I first started working with Linux, the terminal looked a little intimidating.
I knew I could open folders, create files, and install applications using a graphical interface. But whenever I followed a backend development tutorial, I kept seeing commands like:
ls -la
chmod +x script.sh
ps aux
grep "ERROR" app.log
I could copy and paste them, but I didn't really understand what they did.
And that is a problem.
As a developer, you will frequently work with Linux servers, Docker containers, cloud environments, and remote machines. Most of these environments rely heavily on the command line.
So, instead of memorizing random commands, let's learn them by understanding the problems they solve.
This article covers common Linux commands used for everyday development and server management.
Environment used in this article:
- Operating system: GNU/Linux distributions.
- Shell: Bash 5.x.
- Utilities: GNU Coreutils 9.x.
- Package management: APT for Ubuntu/Debian and DNF for Fedora/RHEL.
The commands are broadly applicable to modern Linux distributions, although some options differ between GNU and other implementations.
Table of contents
- Linux essentials before commands
- Navigating the filesystem
- Creating and managing files
- Searching and inspecting data
- Getting system information
- File permissions and administrator access
- Combining commands
- Basic networking commands
- Installing software
- Archives and file types
- Getting help
- Which commands should I learn first?
- Common mistakes
- Quick recap
- Try it yourself
Linux essentials before commands
Before learning commands, let's understand a few basic terms.
Terminal, shell and command
People often use the words terminal, shell, and command line interchangeably.
But they are not exactly the same.
Terminal
A terminal is an application that provides a text-based interface through which you interact with your computer.
Instead of clicking buttons, you type commands.
Shell
A shell is a program that understands the commands you enter and executes them.
Examples include:
- Bash (Bourne Again Shell).
- Zsh (Z Shell).
- Fish (Friendly Interactive Shell).
In this article, we'll use Bash.
Command
A command is an instruction given to the shell to perform an operation.
For example:
pwd
This command asks the shell to execute pwd, which displays the current working directory.
Let's visualize the relationship.
YOU
|
| Type command
v
+-------------+
| TERMINAL |
| |
| pwd |
+-------------+
|
v
+-------------+
| SHELL |
| |
| Understands |
| the command |
+-------------+
|
v
+-------------+
| COMMAND |
| pwd |
+-------------+
|
v
+-------------+
| OUTPUT |
| /home/asha |
+-------------+
Try it yourself:
echo "Hello Linux"
Output:
Hello Linux
echo prints the provided text to the terminal.
Behind the scenes, Bash recognizes echo as a shell command and executes it with the supplied argument.
Understanding command syntax
Most Linux commands follow a simple structure:
command [options] [arguments]
Let's break this down.
- Command: The operation you want to perform.
- Options: Modify how the command behaves.
- Arguments: Tell the command what to work on.
For example:
ls -l /home/asha
Here:
-
lsis the command. -
-lis an option. -
/home/ashais the argument.
The -l option tells ls to display information in long format.
Another example:
mkdir -p projects/java
Here:
-
mkdircreates directories. -
-pcreates parent directories if they don't exist. -
projects/javais the directory path.
A few things to remember:
- Linux commands are generally case-sensitive.
-
lsandLSare different. - Options commonly start with
-or--. - You can often combine short options.
For example:
ls -la
This combines:
ls -l -a
The exact available options depend on the command.
Navigating the filesystem
The first thing you should know is how to move around the Linux filesystem.
Think of the filesystem as a hierarchy of folders and files.
/
|
+-- home
| |
| +-- asha
| |
| +-- Documents
| |
| +-- Downloads
| |
| +-- Projects
|
+-- etc
|
+-- var
|
+-- usr
|
+-- tmp
The top-level directory / is called the root directory.
All other directories and files exist somewhere underneath it.
Before trying the commands, let's create a small practice environment.
Run:
mkdir -p ~/linux-practice/project/src
mkdir -p ~/linux-practice/project/logs
cd ~/linux-practice/project
printf 'Asha\nRavi\nMeera\n' > users.txt
printf 'INFO Order created\nERROR Payment failed\nINFO Email sent\n' > app.log
touch README.md
We've created this structure:
project/
|
+-- src/
|
+-- logs/
|
+-- README.md
|
+-- app.log
|
+-- users.txt
We'll use these files throughout the article.
pwd: where am I?
Imagine opening a terminal and navigating through multiple folders.
After a while, you might forget where you currently are.
How do you find your current location?
Use pwd.
pwd stands for Print Working Directory.
It displays the absolute path of the directory in which you're currently working.
Example:
pwd
Output (example):
/home/asha/linux-practice/project
Your username and path will be different.
Why is this useful?
Before running file-related commands, it's good to know your current location.
For example, suppose you execute:
rm app.log
This attempts to delete app.log from your current directory.
If you are in the wrong directory, you might delete the wrong file.
That's why pwd is one of the most useful commands to remember.
Behind the scenes:
The shell maintains a current working directory for each process. The pwd utility displays that location.
ls: what is here?
Now that we know our current location, how do we see the files and folders inside it?
Use ls.
ls stands for List.
Example:
ls
Output:
app.log logs README.md src users.txt
We can also use different options.
1. List files in long format
ls -l
It displays additional information such as:
- Permissions.
- Owner.
- Group.
- File size.
- Last modification time.
- File or directory name.
Example output (your values will differ):
-rw-r--r-- 1 asha asha 63 Nov 26 10:00 app.log
drwxr-xr-x 2 asha asha 40 Nov 26 10:00 logs
-rw-r--r-- 1 asha asha 0 Nov 26 10:00 README.md
drwxr-xr-x 2 asha asha 40 Nov 26 10:00 src
-rw-r--r-- 1 asha asha 15 Nov 26 10:00 users.txt
2. Show hidden files
ls -a
Output (trimmed):
.
..
app.log
logs
README.md
src
users.txt
In Linux, filenames beginning with a dot (.) are treated as hidden by convention.
For example:
.env
.git
.bashrc
3. Combine both options
ls -la
This displays all entries, including hidden ones, in long format.
4. List only directory names
ls -d */
Example output:
logs/ src/
Behind the scenes:
ls reads directory entries and displays their names. Options control what information is shown and which entries are included.
cd: move between directories
Suppose you want to move from the project directory into src.
How do you do that?
Use cd.
cd stands for Change Directory.
Example:
cd src
Now check your location:
pwd
Output:
/home/asha/linux-practice/project/src
Let's understand some useful path shortcuts.
1. Move to the parent directory
cd ..
.. represents the parent directory.
If you're inside:
/home/asha/linux-practice/project/src
After cd .., you move to:
/home/asha/linux-practice/project
2. Move to your home directory
cd ~
The ~ symbol represents your home directory.
For example:
/home/asha
3. Move to the root directory
cd /
This takes you to the top-level filesystem directory.
4. Return to the previous directory
cd -
This takes you to the previous working directory.
Absolute path vs relative path
An absolute path starts from the root directory.
Example:
cd /home/asha/Documents
A relative path starts from your current directory.
Example:
cd Documents
The difference is simple:
- Absolute path: Specifies the complete location.
- Relative path: Specifies the location relative to where you currently are.
Creating and managing files
Now let's learn how to create, read, copy, move, and delete files.
These are commands you'll use almost every day.
mkdir and touch
mkdir
mkdir stands for Make Directory.
It creates a new directory.
Example:
mkdir reports
This creates:
project/
|
+-- reports/
What if the parent directory doesn't exist?
For example:
mkdir reports/2026/november
This may fail because reports/2026 doesn't exist.
Use the -p option:
mkdir -p reports/2026/november
Now all the required parent directories are created.
touch
touch creates an empty file if the file doesn't exist.
Example:
touch reports/today.txt
The command creates:
reports/
|
+-- 2026/
| |
| +-- november/
|
+-- today.txt
If the file already exists, touch normally updates its access and modification timestamps instead of clearing its contents.
Behind the scenes
These commands ask the operating system to create filesystem entries.
mkdir creates a directory, whereas touch uses the filesystem's file-creation and timestamp functionality.
cat, less, head and tail
We have created files. But how do we read their contents?
Let's use the app.log file we created earlier.
1. cat
cat is short for concatenate.
It displays file contents in the terminal.
Example:
cat app.log
Output:
INFO Order created
ERROR Payment failed
INFO Email sent
You can also combine multiple files:
cat users.txt app.log
This prints the contents of both files one after another.
Use cat when the file is small.
2. less
What if the file has thousands of lines?
Displaying everything at once can become difficult.
Use less.
less app.log
It opens the file in a pager, allowing you to scroll through its contents.
Common keys:
-
Space: Move forward one screen. -
b: Move backward one screen. -
/word: Search for a word. -
q: Quit.
The visible contents in our example are:
INFO Order created
ERROR Payment failed
INFO Email sent
3. head
What if you only want the first few lines?
Use head.
head -n 2 app.log
Output:
INFO Order created
ERROR Payment failed
By default, head displays the first 10 lines.
4. tail
What if you want the last few lines?
Use tail.
tail -n 2 app.log
Output:
ERROR Payment failed
INFO Email sent
One especially useful option is:
tail -f app.log
This continuously displays newly appended lines as they appear.
Why is this useful?
Imagine your Spring Boot application is running on a Linux server and writing logs to application.log.
You can execute:
tail -f application.log
Now you can observe new log entries as your application runs.
Press Ctrl + C to stop following the file.
cp and mv
Sometimes we need to copy or move files.
1. cp
cp stands for Copy.
It creates a copy of a file or directory.
Example:
cp users.txt users-backup.txt
Now we have:
project/
|
+-- users.txt
|
+-- users-backup.txt
To copy a directory and its contents:
cp -r src src-backup
The -r option means recursive.
It tells cp to copy the directory contents as well.
2. mv
mv stands for Move.
It moves files or directories to another location.
Example:
mv users-backup.txt logs/
Now the structure becomes:
project/
|
+-- users.txt
|
+-- logs/
|
+-- users-backup.txt
But mv is also used for renaming files.
Example:
mv users.txt customers.txt
Now the file is renamed to customers.txt.
What's the difference?
-
cp: Creates another copy. -
mv: Moves or renames the original file.
rm and rmdir
Now let's learn how to delete files and directories.
1. rm
rm stands for Remove.
Example:
rm customers.txt
This deletes the file.
You can also delete a directory and its contents using:
rm -r directory-name
The -r option means recursive.
Be careful with this command because it can delete many files at once.
2. rmdir
rmdir removes empty directories.
Example:
mkdir empty-folder
rmdir empty-folder
Both commands complete without output when successful.
What's the difference?
-
rmdir: Removes empty directories only. -
rm -r: Removes directories containing files and subdirectories as well.
Important safety note
Avoid blindly executing commands such as:
rm -rf *
The -f option forces removal without prompting for confirmation. Combined with recursive deletion, it can remove a large amount of data.
Always check your current directory using pwd before deleting anything.
Searching and inspecting data
As developers, we often work with hundreds of files and thousands of log lines.
Searching manually is not practical.
Linux provides useful commands to search and inspect information.
find: search for files
Imagine you have a project with hundreds of files.
You remember that a file named application.properties exists somewhere, but you don't know where.
Use find.
Example:
find . -name "application.properties"
Here:
-
findis the command. -
.means start searching from the current directory. -
-namefilters by filename. -
"application.properties"is the filename to find.
Another example:
find . -type f -name "*.log"
Output:
./app.log
What does -type f mean?
It tells find to search for regular files.
Some useful options:
-
-type f: Regular files. -
-type d: Directories. -
-name: Case-sensitive filename matching. -
-iname: Case-insensitive filename matching.
Example:
find . -type d -name "src"
Output:
./src
Behind the scenes
find traverses directories starting from the given path and evaluates the conditions you provide.
When an entry matches, it performs the requested action, which by default is printing the path.
grep: search inside files
find searches for filenames.
But what if you want to search for specific text inside files?
Use grep.
grep is commonly used to search text using patterns.
Let's search for the word ERROR in our log file.
grep "ERROR" app.log
Output:
ERROR Payment failed
Some useful options:
1. Show line numbers
grep -n "ERROR" app.log
Output:
2:ERROR Payment failed
2. Ignore uppercase and lowercase differences
grep -i "error" app.log
Output:
ERROR Payment failed
3. Search recursively inside directories
grep -rn "ERROR" .
This searches files under the current directory and displays matching line numbers.
4. Count matching lines
grep -c "ERROR" app.log
Output:
1
Why is this useful?
Suppose your Spring Boot application is producing thousands of log entries.
Instead of opening the file and reading everything, you can search directly:
grep -n "NullPointerException" application.log
This helps locate the lines containing the exception.
wc, sort and uniq
These commands are useful when working with text files and command output.
1. wc
wc stands for Word Count.
It can count lines, words, and bytes or characters.
Example:
wc -l users.txt
Output:
3 users.txt
Here, -l counts lines.
Other useful options:
-
-w: Count words. -
-c: Count bytes. -
-m: Count characters.
2. sort
sort arranges lines in a file.
Example:
sort users.txt
Output:
Asha
Meera
Ravi
By default, sorting is based on the current locale.
3. uniq
uniq removes adjacent duplicate lines.
Let's try an example:
printf 'java\nlinux\njava\n' | sort | uniq -c
Output:
2 java
1 linux
Here:
-
sortarranges identical lines next to one another. -
uniqidentifies and combines adjacent duplicate lines. -
-cdisplays the number of occurrences.
Notice that uniq alone does not remove every duplicate if identical lines are separated. That's why we commonly use sort before uniq.
Getting system information
When working on a Linux server, you often need to answer questions like:
- Which user am I logged in as?
- What Linux version or kernel is running?
- How much disk space is available?
- Which processes are running?
- How much memory is being used?
Let's explore the commands that help us answer these questions.
whoami, id, uname and hostname
1. whoami
Displays the username of the current effective user.
whoami
Example output:
asha
Your output will contain your username.
2. id
Displays user and group identity information.
id
Example output (your IDs and groups will differ):
uid=1000(asha) gid=1000(asha) groups=1000(asha),27(sudo)
This is useful when troubleshooting file access and permissions.
3. uname
Displays basic system information.
uname -s
Output:
Linux
To display more information:
uname -a
Example output (version and machine details will differ):
Linux my-machine 6.x.x-generic #1 SMP x86_64 GNU/Linux
The -a option displays all available system information.
4. hostname
Displays the machine's hostname.
hostname
Example output:
my-linux-server
The actual hostname depends on your machine.
ps, top and kill
Linux runs many processes in the background.
A process is a running instance of a program.
For example:
- A browser is a process.
- A Spring Boot application is a process.
- A database server is a process.
Sometimes we need to inspect or stop these processes.
1. ps
ps stands for Process Status.
It displays information about running processes.
Example:
ps -ef
This displays a detailed list of processes.
To inspect processes with a particular username:
ps -u "$USER" -f
The output depends on which processes are running on your machine.
2. top
top displays running processes and live system information.
top
It displays information such as:
- CPU usage.
- Memory usage.
- Process IDs.
- Running processes.
- Process resource consumption.
Press q to exit.
Why is this useful?
Imagine your Spring Boot application is consuming too much CPU.
You can use top to identify which process is consuming resources.
3. kill
Sometimes a process becomes unresponsive.
You may need to send it a signal to stop.
The kill command sends a signal to a process using its process ID (PID).
Example:
kill 12345
Here, 12345 is an example PID. Replace it with the actual process ID.
By default, kill sends the SIGTERM signal, which requests a graceful shutdown.
If a process refuses to stop, SIGKILL can be used as a last resort:
kill -9 12345
Unlike SIGTERM, SIGKILL cannot be caught or ignored by the process.
Don't use it as your first option because the application does not get an opportunity to shut down cleanly.
df and du
Both commands help you understand disk usage.
But they answer different questions.
1. df
df stands for Disk Free.
It displays available and used space on mounted filesystems.
Example:
df -h
The -h option displays sizes in human-readable units such as MB and GB.
Example output (values and mount points will differ):
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 20G 28G 42% /
Use this when you want to know how much disk space is available on a filesystem.
2. du
du stands for Disk Usage.
It estimates the disk space used by files and directories.
Example:
du -sh ~/linux-practice/project
Example output:
16K /home/asha/linux-practice/project
Your result will differ.
The options mean:
-
-s: Display only the total summary. -
-h: Display human-readable sizes.
You can also inspect individual directories:
du -h --max-depth=1 .
Remember the difference:
-
df: How much space is available on a filesystem? -
du: How much space is a directory or file using?
File permissions and administrator access
One important concept in Linux is file permissions.
Not every user should be allowed to read, modify, or execute every file.
For example:
- A normal user may read a public log file.
- Only an administrator may modify certain system files.
- An application script may need execute permission.
Linux provides a permission system to control these operations.
Understanding Linux permissions
Let's run:
ls -l
You may see output like:
-rw-r--r-- 1 asha asha 15 Nov 26 10:00 users.txt
Focus on the first part:
-rw-r--r--
This represents file type and permissions.
Let's break it down.
- rw- r-- r--
| | | |
| | | +-- Others
| | |
| | +-------- Group
| |
| +-------------- Owner
|
+------------------- File type
There are three permission types:
-
r: Read permission. -
w: Write permission. -
x: Execute permission.
And three permission categories:
- Owner: The user who owns the file.
- Group: Users belonging to the file's group.
- Others: Everyone else.
For example:
-rw-r--r--
Means:
- Owner can read and write.
- Group can only read.
- Others can only read.
What about a directory?
Directory permissions have slightly different meanings:
- Read (
r): List directory entries. - Write (
w): Create, delete, or rename entries, subject to other restrictions. - Execute (
x): Access or traverse the directory.
chmod: change permissions
chmod stands for Change Mode.
It changes file or directory permissions.
Let's create a simple shell script.
printf '#!/usr/bin/env bash\necho "Hello from Linux"\n' > hello.sh
Try executing it:
./hello.sh
If the file does not have execute permission, you may get an error like:
bash: ./hello.sh: Permission denied
We need to grant execute permission.
chmod u+x hello.sh
Here:
-
chmodchanges permissions. -
umeans user or owner. -
+means add permission. -
xmeans execute.
Now run:
./hello.sh
Output:
Hello from Linux
Numeric permissions
Linux also supports numeric permission values.
Each permission has a number:
- Read = 4.
- Write = 2.
- Execute = 1.
Let's understand 755.
Owner -> 7 -> 4 + 2 + 1 -> rwx
Group -> 5 -> 4 + 0 + 1 -> r-x
Others -> 5 -> 4 + 0 + 1 -> r-x
So:
chmod 755 hello.sh
gives the owner read, write, and execute permissions, while the group and others get read and execute permissions.
Another common example:
chmod 644 users.txt
This gives:
- Owner: Read and write.
- Group: Read only.
- Others: Read only.
sudo: run commands with elevated privileges
Sometimes normal users are not allowed to perform certain operations.
For example, installing system-wide software usually requires administrator privileges.
Linux commonly uses sudo to execute a command with elevated privileges.
Example:
sudo apt update
This runs the package-list update operation with administrative privileges.
You may be asked to enter your password.
Why do we need sudo?
Because modifying system-wide configuration, installing software, and managing certain services require additional permissions.
A few important points:
- Use
sudoonly when necessary. - Understand what a command does before running it with
sudo. - Avoid running unknown scripts as root.
- Do not use
sudoto fix every permission error.
Behind the scenes
Linux checks the current user's identity and permissions when an operation is requested.
sudo uses its configuration to authorize a command to run with elevated privileges.
Combining commands
One of the most powerful things about Linux is that we can combine simple commands to perform complex operations.
Instead of executing everything manually, we can connect commands together.
Pipes
A pipe is represented by:
|
It takes the standard output of one command and sends it as standard input to another command.
Let's understand with an example.
Suppose we want to count how many error lines are present in our log file.
We could first search for errors and then count the results manually.
But we can combine two commands:
grep "ERROR" app.log | wc -l
Output:
1
What's happening?
grep "ERROR" app.log
|
| Matching lines
v
wc -l
|
v
Total count
Step by step:
-
grepsearches for the wordERROR. - It prints matching lines.
- The pipe sends those lines to
wc. -
wc -lcounts the lines.
Another example:
ls -1 | sort
This lists directory entries and sorts them.
Behind the scenes
Bash connects the standard output of the first command to the standard input of the next command.
This allows small utilities to work together without requiring temporary files.
Input and output redirection
Normally, a command receives input from the keyboard and sends output to the terminal.
But sometimes we want to read input from a file or save output into a file.
This is called redirection.
1. Output redirection (>)
It writes command output into a file.
Example:
echo "Hello Linux" > message.txt
Now inspect the file:
cat message.txt
Output:
Hello Linux
Important: > overwrites the existing file contents.
2. Append output (>>)
What if we want to add content without overwriting the existing file?
Use >>.
echo "Welcome to Linux" >> message.txt
Now:
cat message.txt
Output:
Hello Linux
Welcome to Linux
3. Input redirection (<)
It takes input from a file instead of the keyboard.
Example:
wc -l < users.txt
Output:
3
Notice that the filename is not displayed because the input is redirected through standard input.
4. Error redirection (2>)
Linux has separate output streams:
- Standard input: File descriptor 0.
- Standard output: File descriptor 1.
- Standard error: File descriptor 2.
We can redirect errors separately.
Example:
ls missing-file 2> error.log
The error message is stored in error.log instead of being printed to the terminal.
This is useful when running scripts or background processes.
Command chaining and exit codes
Sometimes we want to execute multiple commands in one line.
Linux provides different operators for this.
1. Semicolon (;)
Executes commands one after another, regardless of whether the previous command succeeds.
echo "First"
echo "Second"
Equivalent chained command:
echo "First"; echo "Second"
Output:
First
Second
2. AND operator (&&)
Executes the next command only when the previous command succeeds.
mkdir demo && cd demo
If directory creation succeeds, the shell changes into it.
3. OR operator (||)
Executes the next command when the previous command fails.
mkdir demo || echo "Directory creation failed"
4. Exit status ($?)
Every command returns an exit status.
Generally:
-
0: Success. - Non-zero: Failure or another status.
Example:
false
echo $?
Output:
1
The false command returns a non-zero status.
This is especially useful when writing shell scripts and automating tasks.
Basic networking commands
Linux is widely used on servers.
So, developers often need to inspect network interfaces, test connectivity, and make HTTP requests directly from the terminal.
ip and ping
1. ip
The ip command is used to inspect and manage network configuration.
For example:
ip addr
Displays network interfaces and their IP addresses.
To inspect routing information:
ip route
The output depends on your machine's network configuration.
2. ping
ping tests whether a destination can be reached using ICMP echo requests, when permitted by the network.
Example:
ping -c 4 example.com
The -c 4 option sends four requests and stops.
The output includes:
- Destination address.
- Response time.
- Packets transmitted.
- Packets received.
- Packet loss.
A failed ping does not always mean a server is down. Some networks block ICMP traffic.
curl and wget
Both commands are commonly used to download resources over a network.
1. curl
curl transfers data using URLs and supports protocols such as HTTP and HTTPS.
Example:
curl https://example.com
This retrieves the response body from the URL and prints it to the terminal.
To inspect HTTP response headers:
curl -I https://example.com
To save the response into a file:
curl -o page.html https://example.com
2. wget
wget is commonly used to download files.
Example:
wget https://example.com
It downloads the resource into the current directory, using the URL's filename where applicable.
Why should developers know these commands?
They are useful for:
- Testing REST APIs.
- Downloading files.
- Checking HTTP response headers.
- Debugging network connectivity.
- Testing whether an endpoint is accessible.
For example, you can test a Spring Boot API without opening Postman:
curl http://localhost:8080/hello
Installing software
Linux distributions use package managers to install and manage software.
A package manager handles software packages and their dependencies.
However, different distributions use different package managers.
apt and dnf
1. APT
APT stands for Advanced Package Tool.
It is commonly used on Debian-based distributions, including Ubuntu.
Some useful commands:
Update package information:
sudo apt update
Install a package:
sudo apt install tree
Remove a package:
sudo apt remove tree
Search for a package:
apt search nginx
2. DNF
DNF is commonly used on Fedora and related RPM-based distributions.
Install a package:
sudo dnf install tree
Remove a package:
sudo dnf remove tree
Search for a package:
dnf search nginx
Which one should you use?
- Ubuntu and Debian: APT.
- Fedora: DNF.
- Other distributions: Check the package manager used by that distribution.
Do not blindly execute APT commands on Fedora or DNF commands on Ubuntu.
Archives and file types
When working with applications, we often need to package files, inspect file types, and locate executable programs.
tar, file and which
1. tar
tar is used to create and extract archive files.
For example, let's create a compressed archive of our project directory.
Move to the parent directory:
cd ~/linux-practice
Create a compressed archive:
tar -czf project-backup.tar.gz project
Let's understand the options:
-
c: Create an archive. -
z: Compress using gzip. -
f: Specify the archive filename.
To view the files inside the archive:
tar -tzf project-backup.tar.gz
Example output:
project/
project/logs/
project/README.md
project/src/
project/users.txt
project/app.log
To extract the archive:
tar -xzf project-backup.tar.gz
The x option extracts the archive.
2. file
Sometimes the filename extension does not tell us the actual file type.
The file command identifies a file by inspecting its contents.
Example:
file project/app.log
Output:
project/app.log: ASCII text
This is useful when dealing with unknown files.
3. which
which is commonly used to locate an executable through the directories listed in the PATH environment variable.
Example:
which bash
Example output:
/usr/bin/bash
A useful alternative is:
command -v bash
command -v is a shell builtin and is generally preferable when checking how the current shell resolves a command.
Getting help
You don't need to memorize every command and every option.
Linux provides built-in ways to learn about commands.
man and --help
1. man
man stands for Manual.
It displays the manual page of a command.
Example:
man ls
This opens the manual for ls.
You can read about:
- Description.
- Syntax.
- Available options.
- Examples.
- Related commands.
Press q to exit.
2. --help
Many commands provide a shorter help message through --help.
Example:
ls --help
This displays available options and basic usage information.
3. history
Want to see commands you previously executed?
Use:
history
It displays the command history available in the current shell session and history file, depending on shell configuration.
4. clear
Is your terminal full of command output?
Use:
clear
It clears the visible terminal screen.
These commands are useful because you can learn directly from your Linux environment rather than depending on tutorials for every option.
Which commands should I learn first?
We've covered a lot of commands.
But as a beginner, you don't need to memorize all of them on day one.
Start with the commands you'll use most frequently.
First priority: Navigation
-
pwd: Find your current location. -
ls: List files and directories. -
cd: Move between directories.
Second priority: File management
-
mkdir: Create directories. -
touch: Create empty files. -
cat: Display file contents. -
cp: Copy files. -
mv: Move or rename files. -
rm: Delete files.
Third priority: Searching and logs
-
find: Search for files. -
grep: Search inside files. -
head: Display the first lines. -
tail: Display the last lines. -
less: Read large files. -
wc: Count lines and words.
Fourth priority: System management
-
ps: Inspect processes. -
top: Monitor processes. -
kill: Send signals to processes. -
df: Check filesystem space. -
du: Check directory space. -
chmod: Change permissions. -
sudo: Execute authorized administrative commands.
Fifth priority: Developer productivity
-
curl: Test HTTP endpoints. -
tar: Create and extract archives. -
ssh: Connect to remote machines. -
ip: Inspect network configuration. -
man: Read command documentation.
These commands form a good foundation for working with Linux as a backend developer.
Common mistakes
Here are six mistakes beginners commonly make when using Linux commands.
Confusing absolute and relative paths:
/home/asha/projectis an absolute path, whereasprojectis relative to the current directory. Always check your location usingpwd.Ignoring case sensitivity:
README.md,Readme.md, andreadme.mdare different filenames. Type names exactly as they appear.Using rm without checking the path:
rmdoes not normally move files into a recycle bin. Check the target usingpwdandlsbefore deleting anything.Using sudo for every command: Administrative privileges should be used only when required. Understand why a command needs elevated permissions.
Assuming uniq removes every duplicate:
uniqremoves adjacent duplicate lines. Usesortbeforeuniqwhen you want to group identical lines.Ignoring command output and exit status: A command that prints nothing may have succeeded, while a non-zero exit status generally indicates failure. Check the output and use
echo $?when debugging.
Quick recap
Let's quickly revise the commands we've covered.
Navigation
-
pwd: Print current working directory. -
ls: List directory contents. -
cd: Change directory.
File and directory management
-
mkdir: Create directories. -
touch: Create empty files or update timestamps. -
cat: Display file contents. -
less: Read files interactively. -
head: Display the first lines. -
tail: Display the last lines. -
cp: Copy files. -
mv: Move or rename files. -
rm: Remove files and directories. -
rmdir: Remove empty directories.
Searching and text processing
-
find: Search for files and directories. -
grep: Search text. -
wc: Count lines, words, and bytes. -
sort: Sort lines. -
uniq: Remove adjacent duplicate lines.
System management
-
whoami: Display current effective username. -
id: Display user and group information. -
uname: Display system information. -
hostname: Display machine hostname. -
ps: Display process information. -
top: Monitor running processes. -
kill: Send signals to processes. -
df: Display filesystem space. -
du: Display directory and file usage. -
chmod: Change file permissions. -
sudo: Execute authorized commands with elevated privileges.
Networking and utilities
-
ip: Inspect network configuration. -
ping: Test network reachability using ICMP. -
curl: Transfer data using URLs. -
wget: Download resources. -
tar: Create and extract archives. -
file: Identify file types. -
which: Locate executables in PATH. -
man: Read manual pages. -
history: Display command history. -
clear: Clear the visible terminal.
Try it yourself
Practice idea:
Create a directory named linux-practice and build this structure:
linux-practice/
|
+-- backend/
| |
| +-- src/
| |
| +-- logs/
| |
| +-- application.log
|
+-- frontend/
|
+-- README.md
|
+-- users.txt
Then perform these operations:
- Navigate into the backend directory.
- Display its absolute path.
- List all files, including hidden files.
- Create a file named
application.propertiesinsidesrc. - Add some text to
application.log. - Search the log file for the word
ERROR. - Display the last two lines of the log.
- Copy
users.txttousers-backup.txt. - Change the permission of a shell script to make it executable.
- Create a compressed archive of the entire project.
Bonus experiment:
Imagine you have deployed a Spring Boot application on a Linux server.
Try answering these questions using only terminal commands:
- Which user is running the application?
- Which process is using port 8080?
- How much disk space is available?
- How can you watch application logs in real time?
- How can you find
NullPointerExceptionoccurrences in the logs? - How can you stop a process gracefully?
The goal is not to memorize commands. It's to understand what problem each command solves and become comfortable combining them.
If this helped, or if you spotted something I should fix, tell me in the comments. I'm still learning too.

Top comments (0)