While working with various cloud providers in my software engineering role at DLT Labs, I came across a very useful technique, which we can leverage to run commands or scripts on Amazon Web Services (AWS) virtual machines — EC2 instances — without requiring SSH access and without allowing any port access.
I will be using a service called AWS System Manager to achieve this.
AWS System Manager (SSM) is one of the many popular AWS services which help you easily run remote commands or scripts on one or more EC2 machines.
In this blog, I’m going to share how we can do this using AWS SDK NodeJS.
During code implementation, our goal will be to execute the following commands on EC2 machine by using AWS SSM:
Additionally, we will learn how to see the command status and corresponding logs on the application server.
The readers are expected to have some knowledge about Amazon AWS, example, they should know about IAM roles, IAM users, and how to attach roles to EC2 Instances. Apart from that I will be using NodeJS tech stack. Details of both have been described below:
>> The code implementation will take place in the following stages:
All set, let’s begin with the actual code implementation.
Dig Command Line Options and Examples
Here is the frequently used command line options and example’s of dig command.
1. Basic Dig Command
A basic dig command accept domain name as command line parameter and prints Address record.
2. Query With Specific DNS Server
The default dig command queries to dns server configured on your system. For example, the Linux systems keep default DNS entry in /etc/resolv.conf.
3. Print Short Answer
Use +short command line option to print result in short form. This is basically useful with the shell scripting and other automation tasks.
4. Print Detailed but Specific Result
Use +noall with +answer to print detailed information but specific. This will print only answer section including few more details as a result.
#linux commands #command #dig #dig command #useful examples #linux
mv Command Examples
Below is the basic mv command examples on Linux terminal.
#linux commands #command #mv #useful example #mv command #linux
The cp command (which stands for a copy) is one of the commonly used commands on Linux and other UNIX-like operating systems, for copying files and directories. In this guide, we will show how to force the cp command to overwrite a copy operation without confirmation in Linux.
Related Article: 10 SCP Commands to Transfer Files/Folders in Linux
Usually, when you run a cp command, it overwrites the destination file(s) or directory as shown.
## cp bin/git_pull_frontend.sh test/git_pull_frontend.sh
To run cp in interactive mode so that it prompts you before overwriting an existing file or directory, use the
-i flag as shown.
## cp -i bin/git_pull_frontend.sh project1/git_pull_frontend.sh
By default, modern Linux distributions especially those in the Red Hat Enterprise Linux (RHEL) family come with an alias for the cp command which makes a user run the cp command in interactive mode. This may not be the case on Debian and Ubuntu derivatives.
To check all your default aliases, run the alias command as shown.
#linux commands #cp command examples #linux tricks #linux
Screen is a terminal program in Linux which allows us to use a virtual (VT100 terminal) as full-screen window manager which multiplexes an open physical terminal between multiple processes, which are typically, interactive shells. It allows us to access multiple terminal sessions within a single terminal or a remote terminal session. It is most useful when addressing multiple Linux shell commands on the command line, as well as separating commands from the shell that started the commands.
Screen also allows a user to initiate a command from one terminal, disconnect from that terminal, and then reconnect from a different location to that same terminal, while using a different terminal without having to restart the command. This simply lets a user better control multiple and separate command windows.
Screen also lets multiple remote computers connect to the same screen session at once. This allows multiple users to connect to the same screen session allowing a second user to follow along with another administrator working on a server.
#tutorials #attach #cli #command line #detach #key bindings #logging #multiplex #multiuser #multiuser mode #remote access #remote management #remote session #remote terminal #screen #screen logging #screen session #screenlog #screens #scrollback #shell #terminal #terminal session #terminal window #tty #vt100