Skip to content

Looking around#

Get logged into your Ubuntu VM as your normal user and type this: pwd. This means "present working directory", and I get this:

1
2
michael@develop:~$ pwd
/home/michael

Note

Notice the little ~ just before the $? That's the tilde, and it means "home". It means you're exactly in your home directory.

So we're in /home/michael. All Linux filesystems follow this pattern /<path>. There's a path known as the root of the file system, or just "root" (not to be confused with the root user) that's simply: /. We can go there right now: cd / and now I get pwd:

1
2
michael@develop:/$ pwd
/

So now we're at the root of the file system, but what's here? Type this: ls

1
2
3
michael@develop:/$ ls
bin   cdrom  etc   lib    lib64   lost+found  mnt  proc  run   snap  swap.img  tmp  var
boot  dev    home  lib32  libx32  media       opt  root  sbin  srv   sys       usr

Interesting! These are all directories, but it's not possible to tell from looking at them here. Let's make it a little easier by using a command-line flag to the ls to not only "list" the items top-to-bottom, but also get a lot more information: ls -l

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
michael@develop:/$ ls -l
total 4030536
lrwxrwxrwx   1 root root          7 Jul 31  2020 bin -> usr/bin
drwxr-xr-x   4 root root       4096 Mar 18 02:08 boot
drwxr-xr-x   2 root root       4096 Mar 18 01:57 cdrom
drwxr-xr-x  19 root root       4080 Mar 18 07:22 dev
drwxr-xr-x  94 root root       4096 Mar 18 08:44 etc
drwxr-xr-x   4 root root       4096 Mar 18 08:01 home
lrwxrwxrwx   1 root root          7 Jul 31  2020 lib -> usr/lib
lrwxrwxrwx   1 root root          9 Jul 31  2020 lib32 -> usr/lib32
lrwxrwxrwx   1 root root          9 Jul 31  2020 lib64 -> usr/lib64
lrwxrwxrwx   1 root root         10 Jul 31  2020 libx32 -> usr/libx32
drwx------   2 root root      16384 Mar 18 01:56 lost+found
drwxr-xr-x   2 root root       4096 Jul 31  2020 media
drwxr-xr-x   2 root root       4096 Jul 31  2020 mnt
drwxr-xr-x   2 root root       4096 Jul 31  2020 opt
dr-xr-xr-x 154 root root          0 Mar 18  2022 proc
drwx------   4 root root       4096 Mar 18 07:22 root
drwxr-xr-x  25 root root        780 Mar 18 08:55 run
lrwxrwxrwx   1 root root          8 Jul 31  2020 sbin -> usr/sbin
drwxr-xr-x   6 root root       4096 Mar 18 07:22 snap
drwxr-xr-x   2 root root       4096 Jul 31  2020 srv
-rw-------   1 root root 4127195136 Mar 18 01:58 swap.img
dr-xr-xr-x  13 root root          0 Mar 18 07:22 sys
drwxrwxrwt  11 root root       4096 Mar 18 07:53 tmp
drwxr-xr-x  14 root root       4096 Jul 31  2020 usr
drwxr-xr-x  13 root root       4096 Jul 31  2020 var

That's a lot of information. We're going to cover everything in the first column - the drwxr-xr-x like stuff - in the next section, but let's briefly go over what we're seeing here.

Each row above, each item, is split into column, from left or right. We'll look at each column below.

Permissions#

The drwxr-xr-x, for example, is the permissions. This tells use who can do what to the item in the list. Again, we'll cover this in the next section.

Notice the d at the front of some (most) of the items? That means directory and that's how we know the item on the very far right, the last item, is a directory and not a file (or anything else.)

The second column is the number of links to the specific file or directory. This isn't important at this point in time.

The Owner and Group#

The third and fourth columns are the owner of the file/directory and the group that it also belongs to.

Size#

The fifth column is the size of the object. In my list I have:

1
-rw-------   1 root root 4127195136 Mar 18 01:58 swap.img

Which is a SWAP file. Nothing to worry about, but how BIG is it? That's a big number! Can we make it more readable?

Try this: ls -lh swap.img

1
2
michael@develop:/$ ls -lh swap.img
-rw------- 1 root root 3.9G Mar 18 01:58 swap.img

I did two things here: I added the -h flag to my ls command to further modify the behaviour of the command, and I added the filename at the end, swap.img. If I didn't include the filename, I would get all the files, but I want to know how big this particular file is and now I know: 3.9G which translate to 3.9GB or 3.9 gigabytes.

Date and Time#

The sixth, seventh, and eighth columns are the month, day and time the file was last modified or changed. If it's a directory, it's the same information but it tells the last time a file inside the directory was modified (not the directory itself.)

Name#

And finally we have the name of the file. We've just looked at one, swap.img, but there are many in the list.