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!
Most commands in bash are a verb and a noun.
What does this mean?
Commands take to form do_something to something.
do_something to something
For example, cd ~ or mkdir foo (More on those later).
cd ~
mkdir foo
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
/bin/item
For example: /bin/ls.
/bin/ls
Let's break this down.
We start at the root /.
Then we go into bin, and then ls.
bin
ls
As you see, the Linux filesystem is very organised.
Now, onto commands!
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).
cd
Let's move to the root. (cd /)
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*› »
*****-laptop :: ~ ‹master*› »
to something like this: *****-laptop :: / ».
*****-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
Pwd stands for Print Working Directory, and it tells you where you are.
Print Working Directory
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:
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 ....
bin boot ...
Now, let's pass some options.
Run ls with the option a (all).
a
The syntax is ls -a.
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.
cd /bin
cd ..
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.
touch filename
run cd (With no args), and run touch clap.
touch clap
If you compare a ls before and after, you'll see that clap appeared.
clap
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)
mkdir dirname
Lets make the dir foo (mkdir foo)
foo
Now, let's copy (cp) clap into foo. (cp clap foo)
cp
cp clap foo
Let's now remove clap (rm clap).
rm clap
You can do the same thing with mv clap foo.
mv clap foo
I'm sorry, but I'm going to have to make this multipart because so much content.
lol windows
How to use Bash: The basics
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 ~
ormkdir foo
(More on those later).First, before beginning the class, we need to know what a filesystem is.
In Windows, you have something like
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 thenls
.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:
ls
)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 optiona
(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
, andcd ..
, 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 runtouch clap
.If you compare a
ls
before and after, you'll see thatclap
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
intofoo
. (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.
lol windows