Building Bash Muscle (3)

List the files that contains “linux” in their file name. Also ignore the case.

$ ll | grep -i linux

By the way, ll is an alias. Type the following command to see what it really is.

$ type ll

The output shows the following.

ll is aliased to `ls -alF'

Some basic stuff but always nailing the basics is very important in not only software engineering but in anything.

Building Bash Muscle (2)

I’ve been writing quite a bit of PowerShell code. The huge difference between PowerShell and Bash is that when executing a command, PowerShell returns collections of objects not just texts. That said, I still need to build my Bash muscle because Bash is useful after all in Linux world.

Today, I’m going to see what process is listening to which port on the local machine. It’s really critical to know this when you are troubleshooting a service that’s having a problem. Execute the following command.

$ sudo netstat -tlup

-t means –tcp. -u means –udp. -l means –listening and -p means –program. Let me show you the actual screenshot of the result.

As you can see, it lists all the processes (programs) that are listening on the machine. If you grep this result, you will be able to narrow down the result more to find the process that’s listening to certain port. Let’s see what’s up with ssh.

$ netstat -tulp | grep ssh

It’s listening the port “ssh”. Well, ssh usually listens to the port 22 so translate that in your head. I wonder if there is a way to actually show 22… I don’t know right now.

When something is not working, the first thing you should do is if a process is even listening to the expected port. This command will help you troubleshoot any service that may be serving people.

CentOS 8 Installation

I downloaded CentOS 8 and I’ve installed the minimal install on my ESXi. There are some changes from CentOS 7 installation but there weren’t anything that got me confused.

I will paste some screenshot so that you get some feel for what to expect with CentOS 8 installation screen.

Initial screen
Selection
Software Selection. “Server with GUI” is the default option, so if you want to create a server, make sure to select Minimal Install.
Set at least root password here
This is something we never saw in CentOS 7. Just accept the license and move on.

Recap

There is nothing too special in CentOS 8 installation. Just make sure what you want to install in Software Selection before you “Begin Installation.”

I will cover these things later but nmtui, yum, systemctl, hostnamectl are still available. Restarting network got me kind of confused because you have to systemctl restart NetworkManager in CentOS 8. Otherwise, it’s been pretty much the same so far.

bash muscle (1)

I should build my bash muscle. I’m going to do just that gradually here.

What if I wanted to find files that contain certain text in them? Let’s try the command below.

$ grep -rl 'test' | grep groovy

-r (–recursive) means “Read all files under each directory, recursively. Follow all symbolic links, unlike -r” is what’s in man page for grep.

-l (–files-with-matches) “Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match.

The | grep groovy part filters the files that contains groovy in the file name.

By running the command, you would get a result like the following.

docker/master/initial-setup.groovy

And the file certainly contains the text “test” in it.

This command is kind of like Find in Files in Windows but it’s better with grep capability. Definitely a command to remember.

What’s taking up the space?

There was a case where one of my CentOS servers running out of space at the root which is mapped to /dev/sda5. I didn’t think I was using it much but the df -h was telling me otherwise. So here is what I did.

$ cd /
$ sudo du -h --max-depth=1

The command shows which directory is taking up how much space in human readable format. Thanks to that, I figured out what the problem was. 🙂

Netflix’s (no) DevOps -> Culture

I just watched the entire video of “How Netflix Thinks of DevOps” twice. It’s amazing to hear about the world class company’s system architecture and its culture. There is a lot to learn not only about its technology but their mindset and culture.

The part that I was most inspired about was the culture part. So many companies and recruiters are only interested in the number of years of experience and how many years of experience you have on certain technology. Don’t get me wrong. Experience is very important and as a person who has 21 years of experience, I have learned so much through my experience.

What I’m saying is quite often we engineers are not asked about the mindset and culture we bring to the company. I think the culture and mindset is very important. Extremely important. What I feel the most important thing is is the person someone you think you can work with and be able to contribute to your organization? When a company or recruiter asks me “how do you rate yourself with PowerShell out of 10?”, it really turns me off. Such a shallow way of gauging an engineer’s skill set. Isn’t it time when we are asked different kind of questions in hiring process?

As much as having technical knowledge is important, having the right mindset is critically important as an engineer.

After I published this article, I thought of definition of DevOps.

DevOps should not really be a job title. It’s a set of tools, automated processes, mindset and culture that helps move code from development to QA to staging to production systems as fast as possible with quality and values to customers. Agree?

PowerShell $profile and mklink

I have an issue with PowerShell as I have VS Code on my Windows machine. When I’m using a regular PowerShell console, it uses one profile and when I’m on VS Code’s PowerShell console in Terminal, it uses different profile. I don’t want to have to manage both. I want to be able to consolidate to one.

When you are in regular PowerShell console, if you type $profile and hit enter, you will get a path like the following.

C:\Users\amaterasu48\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

When you do the same in VS Code’s PowerShell terminal, you get something like this.

C:\Users\amaterasu48\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1

Microsoft.PowerShell_profile.ps1 but Microsoft.VSCode_profile.ps1 does not exist. So I thought I would create a symlink. Here what you can do. cd into the directory first and execute the following command as an administartor.

 mklink Microsoft.VSCode_profile.ps1 Microsoft.PowerShell_profile.ps1

It creates a symlink like the image below.

This way, both regular PowerShell console and VS Code PowerShell console share the same profile.

I read somewhere that you could change the value of $profile but I choose to just create a symlink. That may be another option to consolidate the two or more PowerShell profile files into one.