Skip to content

Commit

Permalink
day 17 plus edits to day 16
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelCade committed Jan 16, 2022
1 parent 5ef17eb commit a046e15
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 15 deletions.
Binary file added Days/Images/Day17_Linux1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Days/Images/Day17_Linux8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 13 additions & 14 deletions Days/day16.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## Managing your Linux System, Filesystem & Storage

So far we have had a brief overview of Linux and DevOps and then we got our lab environment set up using vagant [(Day 14)](Day14.md), we then touched on a small portion of commands that will be in your daily toolkit when in the terminal and getting things done [(Day 15)](Day15.md).
So far we have had a brief overview of Linux and DevOps and then we got our lab environment set up using vagant [(Day 14)](Day14.md), we then touched on a small portion of commands that will be in your daily toolkit when in the terminal and getting things done [(Day 15)](Day15.md).

Here we are going to look into three key areas of looking after your Linux systems with updates, installing software, understanding what system folders are used for and we will also take a look at storage.

## Managing Ubuntu & Software

The first thing we are going to look at is how we update our operating system. Most of you will be familiar with this process in a Windows OS and macOS, this looks slightly different on a Linux desktop and server.
The first thing we are going to look at is how we update our operating system. Most of you will be familiar with this process in a Windows OS and macOS, this looks slightly different on a Linux desktop and server.

We are going to be looking at the apt package manager, this is what we are going to use on our Ubuntu VM for updates and software installation.
We are going to be looking at the apt package manager, this is what we are going to use on our Ubuntu VM for updates and software installation.

Generally, at least on dev workstations I run this command to make sure that I have the latest available updates from the central repositories, before any software installation.
Generally, at least on dev workstations, I run this command to make sure that I have the latest available updates from the central repositories, before any software installation.

`sudo apt-get update`

Expand Down Expand Up @@ -40,7 +40,7 @@ If we want to remove that or any of our software installations we can also do th

There are third party repositories that we can also add to our system, the ones we have access to out of the box are the Ubuntu default repositories.

If for example we wanted to install vagrant on our Ubuntu VM we would not be able to right now and you can see this below on the first command issued. We then add the key to trust the HashiCorp repository, then add the repository to our system.
If for example, we wanted to install vagrant on our Ubuntu VM we would not be able to right now and you can see this below on the first command issued. We then add the key to trust the HashiCorp repository, then add the repository to our system.

![](Images/Day16_Linux6.png)

Expand All @@ -50,17 +50,16 @@ Once we have the HashiCorp repository added we can go ahead and run `sudo apt in

There are so many options when it comes to software installation, different options for package managers, built into Ubuntu we could also use snaps for our software installations.

Hopefully this gives you a feel about how to manage your OS and software installations on Linux.
Hopefully, this gives you a feel about how to manage your OS and software installations on Linux.

## File System Explained

Linux is made up of configuration files, if you want to change anything then you change these configuration files.

On Windows you have C: drive and that is what we consider the root. On linux we have `/` this is where we are going to find the important folders on our Linux system.
On Windows, you have C: drive and that is what we consider the root. On Linux we have `/` this is where we are going to find the important folders on our Linux system.

![](Images/Day16_Linux8.png)


- `/bin` - Short for binary, the bin folder is where our binaries that your system needs, executables and tools will mostly be found here.

![](Images/Day16_Linux9.png)
Expand All @@ -81,7 +80,7 @@ On Windows you have C: drive and that is what we consider the root. On linux we

![](Images/Day16_Linux13.png)

- `/lib` - We mentioned that `/bin` is where our binaries and executables live, `/lib` is where you will find the shared libaries for those.
- `/lib` - We mentioned that `/bin` is where our binaries and executables live, `/lib` is where you will find the shared libraries for those.

![](Images/Day16_Linux14.png)

Expand Down Expand Up @@ -109,7 +108,7 @@ On Windows you have C: drive and that is what we consider the root. On linux we

![](Images/Day16_Linux20.png)

- `/sbin` - Sudo bin, similar to the bin folder but these tools are intended for elevated super user priveleges on the system.
- `/sbin` - Sudo bin, similar to the bin folder but these tools are intended for elevated superuser privileges on the system.

![](Images/Day16_Linux21.png)

Expand All @@ -133,7 +132,7 @@ When we come to a Linux system or any system we might want to know the available

![](Images/Day16_Linux25.png)

- `df` gives us a little more detail about those partitions, total, used and available. You can parse other flags here I generally use `df -h` gives us a human output of the data.
- `df` gives us a little more detail about those partitions, total, used and available. You can parse other flags here I generally use `df -h` to give us a human output of the data.

![](Images/Day16_Linux26.png)

Expand All @@ -143,7 +142,7 @@ We would then need to mount our newly formatted disk so that it was useable. We

It is also possible that you will need to unmount storage from your system safely vs just pulling it from the configuration. We can do this with `sudo umount /dev/sdb`

If you did not want to unmount that disk and you were going to be using this disk for a database or some other persistent use case then you want it to be there when you reboot your system. For this to happen we need to add this disk to our `/etc/fstab` configuration file for it to persist, if you don't it won't be useable when the machine reboots and you would manually have to go through the above process. The data will still be there on the disk but it wont auto mount unless you add the configuration to this file.
If you did not want to unmount that disk and you were going to be using this disk for a database or some other persistent use case then you want it to be there when you reboot your system. For this to happen we need to add this disk to our `/etc/fstab` configuration file for it to persist, if you don't it won't be useable when the machine reboots and you would manually have to go through the above process. The data will still be there on the disk but it won't automount unless you add the configuration to this file.

Once you have edited the `fstab` configuration file you can check your workings with `sudo mount -a` if no errors then your changes will now be persistent across restarts.

Expand All @@ -152,6 +151,6 @@ We will cover how you would edit a file using a text editor in a future session.
## Resources

- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
- [Linux for hackers (don't worry you don't need to be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)

See you on [Day17](Day17.md)
See you on [Day17](Day17.md)
79 changes: 79 additions & 0 deletions Days/day17.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

## Text Editors - nano vs vim

The majority of your Linux systems are going to be servers and these are not going to have a GUI. I also mentioned in the last session that Linux is mostly made up of configuration files, to make changes you are going to need to be able to edit those configuration files to change anything on the system.

There are lots of options out there but I think we should cover probably the two most common terminal text editors. I have used both of these editors and for me, I find `nano` the easy button when it comes to quick changes but `vim` has such a broad set of capabilities.

### nano

- Not available on every system.
- Great for getting started.

If you run `nano 90DaysOfDevOps.txt` we will create a new file with nothing in, from here we can add our text and we have our instructions below for what we want to do with that file.

![](Images/Day17_Linux1.png)

We can now use `control x + enter` and then run `ls` you can now see our new text file.

![](Images/Day17_Linux2.png)

We can now run `cat` against that file to read our file. We can then use that same `nano 90DaysOfDevOps.txt` to add additional text or modify your file.

For me, nano is super easy when it comes to getting small changes done on configuration files.

### vim

Possibly the most common text editor around? A sibling of the UNIX text editor vi from 1976 we get a lot of functionality with vim.

- Pretty much supported on every single Linux distribution.
- Incredibly powerful! You can likely find a full 7-hour course just covering vim.

We can jump into vim with the `vim` command or if we want to edit our new txt file we could run `vim 90DaysOfDevOps.txt` but you are going to first see the lack of help menus at the bottom.

The first question might be "How do I exit vim?" that is going to be `escape` and if we have not made any changes then it will be `:q`

![](Images/Day17_Linux3.png)

You start in `normal` mode, there are other modes `command, normal, visual, insert` , if we want to add the text we will need to switch from `normal` to `insert` we need to press `i` if you have added some text and would like to save these changes then you would hit escape and then `:wq`

![](Images/Day17_Linux4.png)

![](Images/Day17_Linux5.png)

You can confirm this with the `cat` command to check you have saved those changes.

There is some cool fast functionality with vim that allows you to do menial tasks very quickly if you know the shortcuts which is a lecture in itself. Let's say we have added a list of repeated words and we now need to change that, maybe it's a configuration file and we repeat a network name and now this has changed and we quickly want to change this. I am using the word day for this example.

![](Images/Day17_Linux6.png)

Now we want to replace that word with 90DaysOfDevOps, we can do this by hitting `esc` and typing `:%s/Day/90DaysOfDevOps`

![](Images/Day17_Linux7.png)

The outcome when you hit enter is that the word day is then replaced with 90DaysOfDevOps.

![](Images/Day17_Linux8.png)

Copy and Paste was a big eye-opener for me. Copy is not copy it is yank. we can copy using `yy` on our keyboard in normal mode. `p` paste on the same line, `P` paste on a new line.

You can also delete these lines by choosing the number of lines you wish to delete followed by `dd`

There is also likely a time you will need to search a file, now we can use `grep` as mentioned in a previous session but we can also use vim. we can use `/word` and this will find the first match, to navigate through to the next you will use the `n` key and so on.

For vim this is not even touching the surface, the biggest advice I can give is to get hands-on and use vim wherever possible.

A common interview question is what is your favourite text editor in Linux and I would make sure you have at least this knowledge of both so you can answer, it is fine to say nano because it's simple. At least you show competence in understanding what a text editor is. But get hands-on with them to be more proficient.

Another pointer to navigate around in vim we can use `H,J,K,L` as well as our arrow keys.

## Resources

- [Vim in 100 Seconds](https://www.youtube.com/watch?v=-txKSRn0qeA)
- [Vim tutorial](https://www.youtube.com/watch?v=IiwGbcd8S7I)


- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need to be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)

See you on [Day17](Day17.md)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This will not cover all things DevOps but it will cover the areas that I feel wi
- [ ] 🐧 14 > [The Big Picture - DevOps and Linux](Days/day14.md)
- [ ] 🐧 15 > [Linux Commands for DevOps (Actually everyone)](Days/day15.md)
- [ ] 🐧 16 > [Managing your Linux System, Filesystem & Storage](Days/day16.md)
- [ ] 🐧 17 > [](Days/day17.md)
- [ ] 🐧 17 > [Text Editors - nano vs vim](Days/day17.md)
- [ ] 🐧 18 > [](Days/day18.md)
- [ ] 🐧 19 > [](Days/day19.md)
- [ ] 🐧 20 > [](Days/day20.md)
Expand Down

0 comments on commit a046e15

Please sign in to comment.