Getting started with terminal


If you’ve been trying to avoid using the dreaded Linux terminal, you’ve really been missing out! Learn about getting started with Terminal the easy way.

Don’t be put off of Linux by reading this either, you can use Linux every day without using the terminal if you want, just make sure you choose a beginner-friendly version like Linux Mint if you want to avoid ever having to use the terminal. You can see more on our post: Which version of Linux is best?

Open your terminal (Konsole) and try the following:

Update & Upgrade:

sudo apt update && sudo apt upgrade -y

Getting started with terminal: Basic Commands

sudo – superuser do (run as root – unrestricted access)

cd – select folder (directory)

ls – list files and folders (directories)

mv – move file (or rename if same location)

cp – copy file

mkdir – make folder (directory)

rm – remove (delete)

rmdir – remove folder (directory)

touch – create file

nano – text editor (if installed)

whoami – show your username

su – switch user

reboot – restart device

exit – exit session (closes terminal window or session)

Getting started with terminal: Useful Commands

df -h

Shows you how much disk space is used and is free.

sudo apt install synaptic

Installs the Synaptic Package Manager, it’s a helpful tool for managing software on your computer. It lets you easily find and install new programs, remove ones you no longer need, and keep everything up to date.

rm -rf /foldername/*

Deletes all files and folders within the “foldername” directory. The -r tells it to be recursive which just means to keep going on everything inside the folder and within sub-directories, the f tells it to use force so it will ignore warnings and keep going, and the * indicates everything within the folder rather than anything specific (that’s a wildcard)

mkdir ~/Documents/linuxmadeeasy

Creates a folder called linuxmadeeasy within your documents folder (directory)

Go to your Documents folder using:

cd ~/Documents

To list what’s inside your Documents folder, use:

ls -l

You should see the linuxmadeeasy folder that we created!

To delete it, use:

rmdir linuxmadeeasy

If you want to make sure it’s deleted, use ls -l again.

Navigating the filesystem

It’s important you know how to navigate around your Linux in terminal, then any time you need to do something you’ll most likely search online anyway and if you know how to find your way around inside your Linux and the basics, it will be the easiest way for you to learn rather than me explaining every single command like others tend to do.

You already know cd from above, so let’s say you want to navigate right to the very start of your filesystem:

cd /

Now try:

ls -l

You should see the usual folders found in the root filesystem of Linux such as run, root, proc, dev, boot and etc.

Let’s say you want to browse the etc folder, use:

cd etc/

Now if you want use ls -l again to see what folders are inside the etc folder you’re in, or we can proceed into the apt folder within the etc folder using:

cd ./apt

Again, use ls -l to check the contents of apt, then you can use the following command to go back to the upper folder (etc):

cd ..

You can also use similar to the command above to switch to other folders within a completely different folder quickly

e.g. you’re in etc/apt and you want to go to etc/ssh – you don’t need to go back to etc first and then into ssh, you can go directly using the following:

cd ../ssh

you can also chain it so if you wanted to go to a folder called test which is in a folder called example which is within the ssh folder, you would use:

cd ../ssh/example/test

One . means go forward

Two .. means go back

~ means the start of your home folder (directory)

If you ever need to find out where you currently are, use:

pwd

Getting started with terminal: Create, Edit & Delete

I want to show you how to create a basic file, edit it with the nano editor, show the contents of the file in the terminal and then delete the file.

First, go to your home Documents folder:

cd ~/Documents

Now, create a file called linuxmadeeasy.txt

touch linuxmadeeasy.txt

Open the file in nano:

nano linuxmadeeasy.txt

Enter some text content into the new file:

My secret stuff

Save and exit using CTRL + X and then when prompted “Save modified buffer?” type y and press enter.

Now you should be back in your normal terminal, try:

cat linuxmadeeasy.txt

It should show you “My secret stuff” or whatever you entered inside the file. Now we can delete the file:

rm linuxmadeeasy.txt

Double check that it’s been deleted with ls -l

ls -l

That’s it! I hope this helps you get started with Linux commands, I tried not to overcomplicate things and only show you the basics to get you started in a way that you can browse your Linux files and do basic tasks.

I’m trying to make the website an easy copy-and-paste guide rather than tutorials because I understand most people don’t want to learn Linux or programming in-depth and I want to help make Linux practical and accessible to everyone.

However, if you really want to dive into it and start learning about the Linux terminal in-depth, you can start here:

https://www.freecodecamp.org/news/the-linux-commands-handbook/

https://opensource.com/article/21/8/linux-terminal

https://www.geeksforgeeks.org/linux-commands-cheat-sheet/