🐧Essential Linux Commands + Interactive Challenge

Noureldin Ehab | Creeper.exe
5 min readJan 23, 2022

WhoAmI

Hey I am Nour, I am a Second Year Software Engineering student who is interested in cyber security especially red teaming, I am an “IBM Cyber Security Student Community” Leader where we learn cyber security together, also I am an AWS Community Builder and a CTF player (Try Hack Me)

I wrote a blog about how to learn Linux you can check it out from here this is gonna be the commands I use regularly

Commands

First press CTRL + ALT + T on your keyboard to start the terminal

echo (Print)

  • Used for displaying lines of text or string it is commonly used in shell scripts
  • Syntax:
    echo {string/text}
  • EX:
    echo i love linux
    output: i love linux

cd (Move Between Folders)

  • Used to change the current working directory (move between folders)
  • Stands for Change Directory
  • Syntax:
    cd {FileName}
    cd ..
    (to get out from the folder)
  • EX:
    cd file1
    output: subfile1

ls (List Files)

  • Used to list files. “ls” on its own lists all files in the current directory except for hidden files.
  • Stands for list
  • Syntax:
    ls
  • EX:
    ls
    output: file1 file2 file3
  • ls -a is used to list hidden files
  • EX:
    ls -a
    output: file1 file2 file3 HiddenFile1 HiddenFile2

pwd (Shows your Location)

  • Used to show in which directory (folder) are you in
  • Stands for Print Working Directory
  • Syntax:
    pwd
  • EX:
    pwd
    output: /home/kali

mv (Move)

  • Used to move files
  • Stands for move
  • Syntax:
    mv {filename}{desired_location}
    mv -f {filename}{desired_location}

    - f is for force move by overwriting destination file without prompt
  • EX:
    mv file1 /home/kali/Desktop

cp (Copy)

  • Used to copy files
  • Stands for copy
  • Syntax:
    cp {filename} {desired_location}

and you can check this blog for more information about the copy command

rm (Delete)

  • Used to delete files/folders
  • Stands for remove
  • Syntax:
    rm{filename}
    rm -rf {foldername}

grep (Search for Text Inside Files)

  • Used to Search for text inside files
  • Syntax:
    grep {text}{filename}

My friend Rahul Bhichher wrote a very cool blog about it you can check it out

find (Search for Folders)

  • Used to search for folders
  • Syntax:
    find{filename}
  • EX:
    find file1
    output: /home/kali/Desktop/

whoami (Shows Username)

  • Used to show which user you are logged in with

clear (Clear Terminal)

  • Used to Clear the terminal from everything

cat (Show File Content)

  • Used to show the content of a file
  • Syntax:
    cat{filename}
  • EX:
    cat HelloWorld.tx
    output: HelloWorld

mkdir (Create File)

  • Used to make new folders
  • Stands for make directory
  • Syntax:
    mkdir{filename}
  • EX:
    mkdir HelloWorld

less (View one page)

  • Used to read the contents of a text file one page(one screen) at a time. It has faster access because if the file is large it doesn’t access the complete file, but accesses it page by page

and now let's talk about the most important command EVERRRRR

man (Command Manual)

  • Used to view the command manual
  • some commands have -h flag which is the same as man
  • Syntax:
    man {command name}
    {command name}-h
  • EX:
    man pwd
    output:

Bonus Commands

git clone (Download files from Github)

  • Used to clone a repository into a newly created directory
  • Syntax:
    git clone{repo link}

ifconfig (Network Interface)

  • Used to configure, or view the configuration of, a network interface
  • Stands for interface configuration

I recommend reading about commands like kill, cut, ping, corn, traceroute, get, useradd.

and remember Linux is more than just a terminal now let's talk about wildcards

Wild Cards

A wildcard in Linux is a symbol or a set of symbols that stands in for other characters. It can be used to substitute for any other character or characters in a string. For example, you can use a wildcard to get a list of all files in a directory that begin with the letter N

you can read more about wild cards from this awesome blog

💻Keyboard Shortcuts

  • CTRL + ALT + T ➡ Open Terminal
  • CTRL + U ➡ Cut to cursor
  • CTRL + K ➡ Cut to the end of line
  • CTRL + Y ➡ Paste text
  • CTRL + E ➡ Move to end of line
  • CTRL + A ➡ Move to the beginning
  • ALT + F ➡ Jump to next space
  • ALT + b ➡ Jump back to previous space
  • ALT + Backspace ➡ Delete the previous word
  • CTRL + W ➡ Cut word behind the cursor
  • Shift + Insert ➡ Paste the text into terminal

🏆Final Challenge

What do you need?

  1. Linux
  2. Read the blog again and take notes
  3. Excitement

That's all you need

The Challenge

The goal is to find the flag it looks similar to this nour{ThisIsNotTheFlag} and then submit it here

Note: You are only allowed to use the Terminal only

  • Create a file with the name test
  • Change the name of the file to “WeLoveLinux”
  • Open the “WeLoveLinux” file
  • Download the challenge Github Repo
  • Unzip the file
  • Read the files and follow the hints to find the final flag
  • Delete all the files

Submit Answer here

Bonus

  • Install Python3 / Make sure it is up to date
  • Create a Hello.py file
  • Open the file with nano
  • Write print("I Love Linux")
  • Save the file
  • Change the file permissions (Read about chmod command)
  • Run Hello.py

Extra Resources

Cmd Challenge

Try answering this one hehe (hint: reread the basic commands section)

Cmd challenge is an interactive website that has challenges that will make you practice a lot of commands

Try Hack Me (Free Rooms)

🟣Linux Fundamentals Part 1
🟣Linux Fundamentals Part 2
🟣Linux Fundamentals Part 3
🟣The Find Command
🟣Linux Strength Training
🟣Linux Modules
🟣Ninja Skills

Newsletter

I will be sharing my learning journey, cyber security news, new CVEs and study resources, and more, feel free to subscribe 😊 and please don’t forget to drink water 🌊

⭐I love connecting with different people so if you want to say hi, I’ll be happy to meet you more! :)

LinkedIn
Twitter

--

--