Basic Linux Commands Explained: grep, sed, awk, cp, find & More
Linux commands are instructions you type into a terminal to control your system, manage files, search text, and automate tasks. The most essential Linux commands include cd, cp, find, grep, sed, awk, echo, alias, and history. Every DevOps engineer, sysadmin, and ethical hacker relies on these Linux commands daily to navigate systems and process data.
- grep searches text; sed edits text in-place; awk processes structured data column by column.
- cp copies files and directories; find locates them by name, size, or age.
- alias lets you create shortcuts for long commands you type constantly in the bash shell.
- These Linux commands appear in DevOps, support, and cybersecurity interviews at companies like Infosys, TCS, and Wipro.
- The man command is your built-in documentation; use it before searching the internet.
What Are the Linux Commands You Actually Need to Know?
There are hundreds of Linux commands, but a working vocabulary of about a dozen covers 90% of real tasks. The trick is grouping them by what they do, not memorising an alphabetical list. Think in four buckets: move around the system, find things, transform text, and customise your shell. Understanding what the Linux commands are in each category is the fastest path to terminal confidence.
According to the Stack Overflow Developer Survey 2023, Linux is the most commonly used operating system among professional developers globally, with over 53% of respondents working on it. In India, demand for Linux skills in job postings on Naukri.com grew by over 40% between 2021 and 2023, driven by the DevOps hiring boom in cities like Bengaluru, Hyderabad, and Pune. Knowing what the Linux commands are is no longer optional for IT roles in Indian product and service companies alike.
Navigation and File Management Commands
cd changes your current directory. cd /var/log takes you straight to the system logs folder. Use cd .. to go one level up and cd ~ to jump back to your home directory instantly. These are the Linux commands you will type dozens of times every working day.
cp copies files and folders. The basic syntax is cp source destination. To copy a directory and everything inside it, add the -r flag: cp -r /home/user/project /backup/project. That single flag is the most common thing beginners forget. If you are preparing for a support or DevOps interview, expect a question on it.
find locates files based on criteria. find /etc -name "*.conf" -mtime -7 finds all config files modified in the last seven days. It is indispensable for auditing servers or tracking down rogue log files eating disk space. Among all Linux commands for sysadmins, find is one of the most powerful.
which tells you where an installed program lives. which python3 returns something like /usr/bin/python3. It is a fast sanity check when you are troubleshooting path issues in the Linux terminal.
Searching and Filtering with grep
grep stands for Global Regular Expression Print. It scans a file or stream and prints every line matching a pattern. grep "error" /var/log/syslog is probably the most-typed of all Linux commands in any sysadmin’s day.
Add -i to make the search case-insensitive, -r to search recursively through directories, and -n to show line numbers. A practical combo: grep -rn "password" /var/www/html/ scans an entire web directory for hardcoded credentials. That is also an exercise you will find in Kali Linux beginner labs.
Text Transformation: sed vs awk vs grep Compared
This is where a lot of beginners get confused, so let us settle it quickly. grep finds lines. sed edits them. awk processes them as structured data with fields and columns. They are complementary Linux commands, not interchangeable tools.
Using sed for In-Place Editing
sed (Stream Editor) applies text transformations to a file or stream without opening it in a text editor. The most common use is find-and-replace: sed -i 's/old_text/new_text/g' config.txt replaces every occurrence of “old_text” with “new_text” directly in the file. The -i flag means in-place and the g flag means global (all occurrences, not just the first).
When to use it: any time you need to update a value across a config file during deployment, for example swapping a staging URL for a production URL in a settings file. This is one of the Linux commands that appears most frequently in CI/CD pipeline scripts.
Using awk for Structured Data
awk treats each line as a record and splits it into fields by whitespace (or a delimiter you define). awk '{print $1, $3}' access.log prints the first and third column from an Apache access log, which typically means the IP address and the HTTP status code.
A more targeted example: awk -F: '{print $1}' /etc/passwd uses the colon as a delimiter and prints just the usernames from the passwd file. When to use it: log analysis, report generation, or any task where data comes in clean columns. Among Linux commands for data processing, awk is the most versatile.
The practical difference: if you are grepping for a pattern, use grep. If you are replacing a string, use sed. If you are pulling specific fields from structured output, use awk. All three Linux commands can be piped together, and that is where the real power comes from.
| Command | Primary Use | Example | Typical Interview Context |
|---|---|---|---|
| grep | Search for patterns in text | grep -rn "error" /var/log/ |
Log analysis, security audits |
| sed | Find and replace text in files | sed -i 's/dev/prod/g' app.conf |
Config management, CI/CD pipelines |
| awk | Process structured/columnar data | awk '{print $1}' access.log |
Log parsing, reporting scripts |
| cp | Copy files and directories | cp -r /src /backup |
Backup tasks, deployment steps |
| find | Locate files by attributes | find / -name "*.sh" -type f |
Sysadmin troubleshooting |
| alias | Create command shortcuts | alias ll='ls -la' |
Shell customisation, dotfiles |
| echo | Print text or variable values | echo $PATH |
Script debugging, env setup |
| history | View recent command history | history | grep ssh |
Troubleshooting, audit trails |
Shell Customisation: alias, history, echo and man Pages
Once you know the core Linux commands, the next step is making your terminal work faster for you. That is where alias, history, and echo come in. These bash commands save real time across a working day.
How to Create an Alias in Linux
An alias is a shortcut for a longer command. To create a temporary alias, type alias ll='ls -la' in your terminal. Now typing ll runs the full ls -la command. It lasts only for the current session.
To make it permanent, add the alias line to your ~/.bashrc or ~/.zshrc file, then run source ~/.bashrc to reload it. A practical example that saves real time: alias gs='git status' or alias update='sudo apt update && sudo apt upgrade -y'. DevOps engineers at Indian product companies in Bengaluru and Pune routinely maintain alias libraries as part of their dotfiles setup. These are among the Linux commands that separate efficient engineers from slow ones.
Using history and echo
history shows your recent command history. history | grep ssh filters it to show only SSH-related Linux commands you have run, which is useful for reconstructing what you did during a troubleshooting session. To clear the history entirely, run history -c followed by history -w to write the cleared state to the history file.
echo prints text to the terminal or to a file. echo "Hello World" is the traditional first command, but it is genuinely useful for debugging scripts: echo $PATH shows your current PATH variable, and echo "export VAR=value" >> ~/.bashrc appends an environment variable to your config without opening an editor.
Why man Pages Matter
The man command opens the manual page for any command. man grep gives you the full documentation, including every flag and its explanation. According to the Linux Foundation Open Source Jobs Report 2023, 68% of hiring managers rate comfort with command-line documentation as a key indicator of a candidate’s practical Linux ability. Knowing how to read a man page signals experience, not just memorisation of Linux commands.
For anyone aiming to become a DevOps engineer, these shell skills are foundational. The Red Hat State of Enterprise Open Source Report 2023 found that Linux expertise ranks among the top three skills requested in DevOps job descriptions globally, with India being one of the fastest-growing markets for such roles, particularly in Bengaluru, Hyderabad, Chennai, and Pune.
Practice these Linux commands in a real environment, not just by reading about them. Set up a free Ubuntu VM on VirtualBox, or use a browser-based terminal like the one at 3.0 University’s labs. Repetition in a live shell is the only thing that makes these commands stick.
Frequently Asked Questions
What are the most used Linux commands?
The most used Linux commands include cd, ls, cp, mv, rm, grep, find, echo, chmod, and sudo. These cover navigation, file management, text search, and permissions. The Linux Foundation notes these commands appear in virtually every beginner and intermediate Linux certification exam, including the LPIC-1 and CompTIA Linux+ syllabi. If you want to become a DevOps engineer, mastering these is your starting point.
What is the grep command used for?
grep searches through files or command output and prints every line that matches a pattern you specify. It supports plain text and regular expressions. You will use this Linux command to filter log files, find config values, and search codebases. For example, grep -i "failed" /var/log/auth.log pulls every failed login attempt from the authentication log.
What is the difference between awk and sed?
sed is a stream editor best suited for find-and-replace operations on text files. awk is a full pattern-scanning language that treats each line as a record with fields, making it ideal for structured data like CSV files or log columns. Use sed to substitute strings and awk to extract or compute values from specific columns. Both are essential Linux commands for shell scripting.
How do you create an alias in Linux?
Type alias shortname='full command' in the terminal for a session-only alias. To make it permanent, add the same line to your ~/.bashrc or ~/.zshrc file and run source ~/.bashrc. For example, alias cls='clear' lets you type cls instead of clear, just like in Windows Command Prompt. This is one of the Linux commands that immediately improves your daily workflow.
How do you clear command history in Linux?
Run history -c to clear the in-memory history for the current session, then history -w to overwrite the history file on disk with the now-empty list. You can also delete the file directly with rm ~/.bash_history. This is relevant in security contexts where sensitive Linux commands, like passwords typed accidentally, should not persist in logs.
Which Linux commands are asked in DevOps interviews in India?
In DevOps interviews at Indian companies like Infosys, TCS, Wipro, and startups in Bengaluru and Hyderabad, the most commonly tested Linux commands include grep, sed, awk, find, cp, chmod, ps, and netstat. Interviewers typically ask candidates to write one-liners combining these commands with pipes. Reviewing the DevOps interview questions resource will show you exactly how these appear in technical rounds.
Start practising these Linux commands in a live environment at 3.0 University, where the courses are built around hands-on labs, not slide decks. If you want to go deeper into terminal skills for security work, the Kali Linux beginner command guide is a solid next read. For career-focused preparation, the DevOps interview questions resource covers exactly how these Linux commands show up in technical rounds.
Last updated: July 2026. Reviewed by the 3University editorial team.


