Skip to content
← Back to Community
How to use Bash: The basics
Profile icon

How to use bash

Learning how to use the command line, is in my opinion, a life skill, as is driving.

BASH is the Bourne Again SHell, the default command-line interpreter for most unixes

If you have to fall back on your initramfs (recovery mode for experts), you'll get bash.

So, let's jump into bash!

Bash basics

Most commands in bash are a verb and a noun.

What does this mean?

Commands take to form do_something to something.

For example, cd ~ or mkdir foo (More on those later).

First, before beginning the class, we need to know what a filesystem is.

In Windows, you have something like

C:\Windowsaefvhba'ifvbai;['brf aosgna dhonasd fohnads h']

In Linux, you have:

bin boot desktopfs-pkgs.txt dev etc home lib lib64 lost+found mnt opt proc root rootfs-pkgs.txt run sbin srv sys tmp usr var

and each of these has subfolders.

Everything in Linux starts at the root (/)

To reference something in the bin directory (folder), you do /bin/item

For example: /bin/ls.

Let's break this down.

We start at the root /.

Then we go into bin, and then ls.

As you see, the Linux filesystem is very organised.

Now, onto commands!

Filesystem operations

Now, one more thing. All Linux commands have a mnemonic.

Let's start with moving between directories.

The command for this is cd (change directory).

Let's move to the root. (cd /)

As you can see, the verb is cd, and the noun is /.

Your prompt (The stuff before where you type) should change from something like this:
*****-laptop :: ~ ‹master*› »

to something like this:
*****-laptop :: / ».

This means that you have moved.

Now, some commands don't take verbs. These usually give you data.

Here's an example: pwd.

Pwd stands for Print Working Directory, and it tells you where you are.

If you run pwd, you get /, meaning you are at the root.

Now, you can move places, and see where you are, but how can you see what's around you?

That's where LIst saves the day.

This is a command that has three parts:

  • A verb (ls)
  • 0 or more options
  • a noun

What's an option, you say?

They are passed using one hyphen.

Some need two, but that's for later.

Please run ls.
You should see something like above bin boot ....

Now, let's pass some options.

Run ls with the option a (all).

The syntax is ls -a.

This will show you all hidden files.

You should see . and .. be shown in your terminal.

These directories have special meanings.

. means your current location. (pwd is the same)

.. means a directory one higher.

If you run cd /bin, pwd, and cd .., you are up a directory, in the root.

Creating, moving, copying, and deleting files.

Now that we can move, let's look at how to create files and do stuff with them.

To create, use touch filename.

run cd (With no args), and run touch clap.

If you compare a ls before and after, you'll see that clap appeared.

Now, I hear you ask, how can I make a directory? That's not a file!

Well, yes, it is, but ignore that.

You make a directory with mkdir dirname (make dir)

Lets make the dir foo (mkdir foo)

Now, let's copy (cp) clap into foo. (cp clap foo)

Let's now remove clap (rm clap).

You can do the same thing with mv clap foo.

I'm sorry, but I'm going to have to make this multipart because so much content.

Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon
Profile icon

lol windows

Profile icon


  • lol
  • mdr
    vasy a plus