LinuxBasicsbeginner

Linux Commands List for Beginners with Examples

A Linux command guide with a cheat sheet, file examples, DevOps commands and practice tasks for beginners.

Published
TL;DR – Quick Answer

Start with Linux commands such as pwd, ls, cd, mkdir, cp, mv, cat and grep. Then learn permissions, processes, networks and logs. Practise in a separate folder and check the path before you remove anything.

On This Page

Linux commands are text instructions that let you work with files, programs and servers. Start with pwd, ls, cd, mkdir, cp, mv and cat. This guide explains each group with examples you can try in a practice folder.

A shell is the program that reads your command. Bash is a common shell on Linux. The terminal is the window where you type. Most examples here also work in Windows Subsystem for Linux.

Linux commands cheat sheet

Task Command
Show current folder pwd
List files ls -la
Change folder cd folder
Make a folder mkdir folder
Create an empty file touch file.txt
Show a file cat file.txt
Copy a file cp old.txt new.txt
Move or rename mv old.txt new.txt
Remove a file rm file.txt
Find text grep "word" file.txt
Change permissions chmod 644 file.txt
See processes ps aux
See disk space df -h
Get help man ls or ls --help

A command often has three parts:

ls -l /var/log

ls is the command. -l is an option that changes how it works. /var/log is the argument, or the thing it works on. Linux file names are normally case-sensitive, so Notes.txt and notes.txt are different.

Move around and work with files

Make a safe practice folder:

mkdir -p "$HOME/linux-practice"
cd "$HOME/linux-practice"
pwd

$HOME is your home folder. mkdir -p makes the folder if it does not exist. The output path depends on your user name.

These path signs save typing:

Sign Meaning
/ Start of the Linux file system
. Current folder
.. Parent folder
~ Your home folder
- with cd Previous folder

Create, view, copy and rename a file:

printf "Java\nSQL\nLinux\n" > skills.txt
cat skills.txt
cp skills.txt backup.txt
mv backup.txt skills-copy.txt
ls

The two commands that print text give:

Java
SQL
Linux
skills-copy.txt
skills.txt

> writes output to a file and replaces old content. Use >> to add to the end.

View command Best for
cat file A short file
less file A long file; press q to leave
head -n 5 file First five lines
tail -n 5 file Last five lines
tail -f file New log lines as they arrive

Common mistake: rm does not usually send a file to a recycle bin. Check with pwd and ls before removing it. Do not run rm -rf with a path you do not fully understand.

Search, pipes and text

Make a small log:

cat > app.log <<'EOF'
INFO server started
ERROR database timeout
INFO user signed in
ERROR database timeout
WARN disk almost full
EOF

Find errors with line numbers:

grep -n "ERROR" app.log

Output:

2:ERROR database timeout
4:ERROR database timeout

Count them with grep -c "ERROR" app.log, which prints 2. Use grep -i to ignore letter case and grep -r "word" folder to search a folder.

A pipe, written |, sends one command's output to the next:

cut -d' ' -f1 app.log | sort | uniq -c

Output, with spaces at the left:

      2 ERROR
      2 INFO
      1 WARN

cut takes the first word, sort puts equal words together and uniq -c counts them. Sort first because uniq joins only neighbouring equal lines.

Useful text commands:

Command Purpose
wc -l app.log Count lines
sort file Sort lines
cut -d',' -f2 data.csv Show the second simple CSV field
sed 's/ERROR/Error/' app.log Print text with a replacement
awk '{print $1}' app.log Print the first field
find . -name "*.txt" Find files by name

Quote "*.txt" in find. Otherwise the shell may replace the star with file names before find sees it.

File permissions and users

Run this in a Linux home folder:

touch report.txt
chmod 640 report.txt
ls -l report.txt

The permissions start with -rw-r-----. Read them in groups of three after the first character:

Who Letters Number Access
Owner rw- 6 Read and write
Group r-- 4 Read
Others --- 0 None

Read is 4, write is 2 and execute is 1. Add the numbers: 4 + 2 = 6. A script with mode 755 lets its owner read, write and run it. Others can read and run it.

chmod changes permissions. chown changes the owner, and often needs administrator rights. whoami shows your user name. id shows your user and groups.

sudo command runs one command with extra rights if you are allowed to use it. Do not add sudo only because a command failed. Read the error first.

Interview note: Mode 777 gives everyone full access. It may make an error disappear, but it can let the wrong user change a file. Give only the access needed.

Processes, memory and disk

Command What it shows or does
ps aux Running processes
top Live CPU and memory; press q to leave
kill 1234 Asks process 1234 to stop
kill -9 1234 Forces it to stop
free -h Memory use on Linux
df -h Free space by file system
du -sh folder Space used by one folder
uptime Running time and load

Try normal kill first, so a program can close its files. Use -9 only when it does not stop. Check the process ID before either command.

Run a program in the background by adding &:

sleep 30 &
jobs
kill %1

%1 refers to job 1 in this shell. The job number may differ if you already have other jobs, so use the number from jobs.

Linux commands for DevOps and servers

DevOps work often means finding why a service failed. These commands are for a server you are allowed to use:

Task Command
Open a remote shell ssh user@server
Copy to a server scp app.jar user@server:/tmp/
See IP addresses ip addr
See listening ports ss -tulpn
Check a web response curl -I https://example.com
Check a service systemctl status nginx
Restart a service sudo systemctl restart nginx
Follow service logs journalctl -u nginx -f
Pack a folder tar -czf app.tar.gz app/
Extract it tar -xzf app.tar.gz

systemctl works on systems that use systemd. Package commands also depend on the Linux type:

  • Ubuntu or Debian: sudo apt update, then sudo apt install nginx.
  • Fedora or Red Hat based systems: sudo dnf install nginx.

Here is a safe order when a website is down: check its response with curl, see the service status, read recent logs, check its port, then check disk and memory. Restarting first may hide the clue you need.

Pro tip: Before you run a command found online, look up each option with man or --help. Be extra careful with a command that uses sudo, deletes data or pipes a downloaded file into a shell.

Linux commands practice with a small script

Use the log you made earlier. Create count-errors.sh:

#!/usr/bin/env bash
set -u

file="${1:-app.log}"
if [[ ! -f "$file" ]]; then
  echo "File not found: $file" >&2
  exit 1
fi

total=$(wc -l < "$file")
errors=$(grep -c "ERROR" "$file" || true)
echo "Lines: $total"
echo "Errors: $errors"

Run it:

bash count-errors.sh app.log

Output:

Lines: 5
Errors: 2

The first argument becomes the file name. If you give no argument, the script uses app.log. Quotes protect file names with spaces. exit 1 tells the caller that the script failed.

Do these Linux commands practice tasks without looking above:

  1. Make a folder named reports with three text files.
  2. Copy one file and give the copy a new name.
  3. Find all lines with "timeout" in your log.
  4. Show only the last two log lines.
  5. Count the number of INFO lines.
  6. Find files with the .txt ending.
  7. Make a file readable by its owner and group, but nobody else.
  8. Show which process uses the most CPU.

Check each result with a different command. For example, use ls -l to check a permission change.

Linux commands practice online and at home

You can practise Linux commands online without changing your main computer:

Option Good for
Linux Survival First file and folder commands
OverTheWire Bandit Solving small shell puzzles over SSH
Killercoda Short Linux and DevOps labs
WSL on Windows Daily practice beside Windows tools
Virtual machine A full Linux system you can reset

Online labs may have time limits or need an account. Check their current rules. Never use commands from a hacking lab on a system without permission.

A useful first week is simple: files on days 1 and 2, text on days 3 and 4, permissions on day 5, processes on day 6, and the script on day 7. Keep your own Linux commands list with one example and one safe check for each command.

Once the terminal feels normal, learn Git commands. Then follow the DevOps engineer roadmap, learn Docker basics, or test yourself with DevOps interview questions. If your goal is cloud work, see the cloud engineer roadmap.

Frequently Asked Questions

Which Linux commands should a beginner learn first?
Start with pwd, ls, cd, mkdir, cp, mv, cat, less and grep. These let you move around and work with text files.
Can I practise Linux commands on Windows?
Yes. You can use Windows Subsystem for Linux or a virtual machine. An online lab is another choice if you do not want to install Linux.
What is the difference between a terminal and a shell?
A terminal is the window where you type and see text. A shell, such as Bash, reads and runs your commands.
What does chmod 755 mean?
The owner can read, write and execute the file. The group and other users can read and execute it, but cannot write to it.
How do I stop a running command?
Press Ctrl+C to stop most commands running in the terminal. For another process, check its ID and use kill. Use kill -9 only if a normal stop does not work.
Siva Prasad Galaba
Founder, CodeBegun · Staff Engineer

Founder of CodeBegun. 15+ years building Java systems at companies like Crunchyroll. Teaches Java, Spring Boot and system design the way the industry actually works, and mentors students through projects, mock interviews and placement preparation.

Technically reviewed by CodeBegun Technical TeamLast reviewed 3 December 2026 LinkedIn
Chat with us