basic Linux commands terminal Fedora IC2 guide

Basic Linux commands — the ones you use every day in IC2

Basic Linux commands are the first practical skill you need in IC2. You’ve set up Fedora in VirtualBox and understood what the terminal is, now it’s time to actually use it. This article covers the commands you’ll type every single day: navigating directories, creating folders, copying and moving files, and the ones that can delete things permanently if you’re not careful.

Everything here is tested in Fedora. Open your terminal and follow along, reading without practising won’t stick.

How a terminal command works

Before the commands themselves, it’s worth understanding the structure. Every command follows the same pattern:

command  [options]  [arguments]

ls       -l         /home/sergio
↑        ↑          ↑
command  option     argument
(what)   (how)      (where/what)
  • Command — what you want to do
  • Options — flags that modify the behaviour, usually starting with - or --
  • Arguments — what you’re operating on (a file, a directory, a pattern)

Options and arguments are optional — many commands work with just the command name alone.

pwd — where am I?

pwd stands for Print Working Directory. It tells you exactly where you are in the file system right now:

pwd

Output:

/home/sergio

Use this whenever you’re lost. It’s the terminal equivalent of “you are here” on a map.

ls — what’s here?

ls lists the contents of a directory — files and folders:

ls                  # list current directory
ls /home/sergio     # list a specific directory
ls -l               # long format — shows permissions, size, date
ls -a               # show hidden files (files starting with .)
ls -la              # long format + hidden files (most useful combo)
ls -lh              # long format with human-readable sizes (KB, MB)

Output of ls -l:

total 24
drwxr-xr-x. 3 sergio sergio 4096 Jun  7 10:23 GCID
drwxr-xr-x. 2 sergio sergio 4096 Jun  5 14:11 Documents
-rw-r--r--. 1 sergio sergio  512 Jun  7 09:45 notes.txt

The columns are: permissions, links, owner, group, size (bytes), date, name. The d at the start means directory, - means file.

cd — move between directories

cd stands for Change Directory. This is the command you’ll use most, it’s how you navigate the file system:

cd GCID                    # enter GCID folder (relative path)
cd /home/sergio/GCID       # same thing (absolute path)
cd ..                      # go up one level
cd ../..                   # go up two levels
cd ~                       # go to home directory from anywhere
cd -                       # go back to previous directory
cd                         # also goes to home directory

The most common workflow:

pwd                        # check where you are
ls                         # see what's here
cd GCID                    # enter a folder
ls                         # see what's inside
cd FP1                     # go deeper
pwd                        # confirm where you are now

mkdir — create directories

mkdir creates new directories:

mkdir Lab1                  # create Lab1 in current directory
mkdir -p GCID/FP1/Lab1      # create the full path at once
                             # -p creates parent dirs if they don't exist
mkdir Lab1 Lab2 Lab3        # create multiple at once

The -p flag is very useful — without it, mkdir GCID/FP1/Lab1 fails if GCID or FP1 don’t already exist.

mkdir -p ~/GCID/IC2/Labs
mkdir -p ~/GCID/IC2/Notes
mkdir -p ~/GCID/IC2/Assignments

Create this once at the start of the semester, it saves confusion later.

touch — create empty files

touch creates an empty file or updates the timestamp of an existing one:

touch hello.c              # create empty hello.c file
touch main.c utils.c       # create multiple files at once

In IC2 you’ll use this to create your .c files before opening them in gedit.

cat — display file contents

cat prints the contents of a file directly in the terminal:

cat hello.c                # show the file contents
cat file1.c file2.c        # show multiple files concatenated

For long files use less instead, it lets you scroll:

less hello.c               # scroll with arrows, press q to quit

cp — copy files and directories

cp copies files:

cp hello.c hello_backup.c              # copy file to new name
cp hello.c ~/GCID/IC2/Labs/           # copy to a different directory
cp -r Lab1 Lab1_backup                 # copy a directory (-r = recursive)
cp *.c ~/GCID/IC2/Labs/               # copy all .c files

The -r flag is essential when copying directories, without it cp refuses to copy a folder.

mv — move or rename

mv moves files and directories, or renames them:

mv hello.c main.c                      # rename hello.c to main.c
mv main.c ~/GCID/IC2/Labs/            # move to a different directory
mv Lab1 Labs/Lab1                      # move a directory
mv *.c ../                             # move all .c files up one level

Unlike cp, mv doesn’t need -r for directories, it works on everything.

rm — delete (careful — no recycle bin)

rm deletes files permanently. There is no recycle bin in the Linux terminal, once it’s gone, it’s gone:

rm test.c                  # delete a file — permanent
rm -i test.c               # asks for confirmation before deleting
rm file1.c file2.c         # delete multiple files
rm -r OldLab               # delete a directory and everything inside
rm -ri OldLab              # delete directory with confirmation for each file

⚠️ The two most dangerous commands in Linux:

rm -rf /                   # deletes the entire file system — never type this
rm -rf *                   # deletes everything in current directory — be careful

The -f flag means “force”, it skips confirmations and keeps going even on errors. Never use -rf unless you’re completely sure of what you’re deleting and where you are.

Golden rule before rm: always run ls first to see exactly what’s in the directory. Then delete.

man and –help — your documentation

You don’t need to memorise every option of every command. The manual is built in:

man ls                     # full manual for ls (press q to quit)
ls --help                  # shorter quick reference
man cp
man rm

man opens the full manual page, use the arrow keys to scroll and q to exit. --help gives a shorter summary directly in the terminal.

Useful keyboard shortcuts

These save a lot of time:

Tab          # autocomplete — press once to complete, twice to see options
↑ / ↓        # navigate through command history
Ctrl + C     # cancel running command / infinite loop
Ctrl + L     # clear the terminal screen (same as clear)
Ctrl + A     # move cursor to start of line
Ctrl + E     # move cursor to end of line
!!           # repeat the last command
!ls          # repeat the last command that started with ls

Tab completion is one of the most useful features, type the first few letters of a file or command and press Tab. If there’s only one match it completes. If there are multiple matches press Tab twice to see all options.

Common mistakes — and how to avoid them

Case sensitivity

ls Documents     # works
ls documents     # error — Linux is case sensitive
cd GCID          # works
cd gcid          # error

Linux filenames are case sensitive. File.c, file.c and FILE.c are three completely different files.

Spaces in filenames

mkdir IC2 Labs               # creates TWO directories: IC2 and Labs
mkdir "IC2 Labs"             # creates ONE directory: IC2 Labs
mkdir IC2_Labs               # better — use underscores instead

Spaces in filenames cause constant problems in the terminal. Use underscores or hyphens instead.

Deleting when you meant to move

# You want to move files to Labs/ but are in the wrong directory
rm *.c               # oops — deleted instead of moved

Always check pwd before running rm. Always.

A real IC2 workflow

Here’s a typical sequence for starting a new lab:

# 1. Check where you are
pwd
# /home/sergio

# 2. Go to your IC2 folder
cd ~/GCID/IC2/Labs

# 3. Create folder for new lab
mkdir Lab3_pointers
cd Lab3_pointers

# 4. Create your source file
touch main.c

# 5. Open in gedit to write the code
gedit main.c &
# The & runs gedit in the background so the terminal stays available

# 6. Compile
gcc main.c -o main

# 7. Run
./main

# 8. If something goes wrong, check the error and edit
gedit main.c &
gcc main.c -o main
./main

That sequence, create, edit, compile, run, fix, is the IC2 workflow for every lab.

Summary — commands to memorise

# NAVIGATION
pwd                    # where am I?
ls                     # what's here?
ls -la                 # detailed + hidden files
cd folder              # enter folder
cd ..                  # go up one level
cd ~                   # go home from anywhere
cd -                   # go back to previous location

# CREATE
mkdir folder           # create directory
mkdir -p a/b/c         # create full path
touch file.c           # create empty file

# VIEW
cat file.c             # show file contents
less file.c            # scroll through long files (q to quit)

# COPY AND MOVE
cp file.c copy.c       # copy file
cp -r folder/ backup/  # copy directory
mv file.c new_name.c   # rename
mv file.c ~/GCID/      # move to directory

# DELETE — careful, no undo
rm file.c              # delete file
rm -i file.c           # delete with confirmation
rm -r folder/          # delete directory
rm -ri folder/         # delete directory with confirmation

# HELP
man command            # full manual (q to quit)
command --help         # quick reference

# SHORTCUTS
Tab    → autocomplete
↑ ↓    → command history
Ctrl+C → cancel
Ctrl+L → clear screen

# GOLDEN RULES
# 1. pwd before rm — know where you are
# 2. ls before rm — know what you're deleting
# 3. -i flag on rm — ask for confirmation
# 4. No spaces in filenames — use _ or - instead
# 5. Linux is case sensitive — Documents ≠ documents

In the next article we practice these commands with real exercises you can do directly in your Fedora terminal.

Similar Posts

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *