List of most used linux commands for various purposes

I have found some time to sit together and make a list of most used linux commands by me on a personal basis. I’m sharing the same over here (this in no way intends to be a complete list or reference list, so please don’t feel offensive). I hope you can find the same useful:

System Information

dmesg (boot message)
dmesg | less (view line by line)

sudo lshw (complete hardware info about computer!)
uname -a (server info)
cat /etc/*release (OS)
df -hT (mounted file systems)
mount -l (lists all mounted filesystems)
env | sort (environmental variables)Read More »

Understand what Azure ARM templates are

The infrastructure for an application is typically made up of many components – a server to execute and respond to all calls, a storage mechanism to handle all I/O (input/output) , some kind of networking mechanism and finally off course, your application. Your application may be a standalone application with or without any database support and with or without any 3rd party integration services. You don’t generally want to see these components as separate entities or you may be (depending upon your background in Information Technology Sector) .

Generally, if you are a consumer, all you are concerned about is to consume how services available by a particular piece of the application. Read More »

Error: The term ‘Save-AzureRMProfile’ is not recognized as the name of a cmdlet, function, script file, or operable program

If you have recently installed Azure PowerShell module on one of the machines and then trying to login using Select-AzureRMProfile, you are likely to receive below error:

Save-AzureRMProfile : The term ‘Save-AzureRMProfile’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try againAt line:3 char:2+  Save-AzureRMProfile -Path “C:\$SubscriptionName.json”+  ~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : ObjectNotFound: (Save-AzureRMProfile:String) [], CommandNotFoundException    + FullyQualifiedErrorId : CommandNotFoundException

I checked the list of cmdlets and it was gone.Read More »

Running PowerShell Core in a docker container

PowerShell core is the edition of PowerShell built on top of .NET Core. It is sometimes simplified to “CoreCLR”, though it technically includes CoreFX as well.

PowerShell Core is cross-platform, available on Windows, macOS, and Linux, thanks to the cross-platform nature of .NET Core. On PowerShell Core, $PSVersionTable.PSEdition is set to Core.

Do note that  while PowerShell Core 6.0 is cross-platform, there is also a PowerShell Core 5.0/5.1 released exclusively as part of Nano Server. In this blog post, we’ll learn how to run PowerShell core in a docker container.Read More »

Navigate to current user’s path in PowerShell

I guess everyone knows that you can find current logged-in user’s profile path using variable $env:USERPROFILE, which is one of the built in environmental variables in PowerShell. However, you can also choose to navigate to current user’s profile path using ‘~’ (without single quotes). So for an example would be:

PS data [07/11/2017 09:58:00]> pwd

Path
----
C:\data

PS data [07/11/2017 09:58:01]> cd ~
PS mogoyal[07/11/2017 09:58:05]> pwd

Path
----
C:\Users\mogoyal

However, unlike $env:userprofile, you can not use this in write-host to print out the value of the path.

Remove images from Docker Images

You can remove an image using its short or long ID, its tag, or its digest in the Docker. For this we have to use the command:

docker rmi [OPTIONS] IMAGE [IMAGE...]

Where Options are:
-f, –force Force removal of the image
–help Print usage
–no-prune Do not delete untagged parents

Let’s see how this works. You cannot delete an image if it has been used to spawn containers or child images based on it. You would likely see an error message which resembles following:

Error response from daemon: conflict: unable to remove repository reference “mogo/ubuntu:telnet” (must force) – container 4888c45aa31c is using its referenced image a955c52ec9ec

OrRead More »

Change directory to store containers and images in Docker

As discussed in one of the previous posts, docker is more focused on ease of use and not so much on the disk space efficiency out of the box. However, it is our responsibility to maintain adequate free space on hard disk and also do some kind of standardization. DevOps is not only about automation but it is also about standardization of process thereby removing any gotchas or discrepancy in the configuration. For example, we may like to store docker images in a separate directory that may be located on a mounted device storage or some other easy to navigate configuration.

By default, docker store containers and images in /var/lib/docker by default:

Default directory for containers and images in Docker
Default directory for containers and images in Docker

Read More »