Posts

DevopsDevops 👉 AnsibleDevops 👉 AWSDevops 👉 AWS DevOpsDevops 👉 AWS 👉 Continuous IntegrationDevops 👉 AWS 👉 DockerDevops 👉 AWS 👉 KubernetesDevops 👉 AWS 👉 TerraformDevops 👉 AzureDevops 👉 Azure 👉 Continuous DeploymentDevops 👉 Azure 👉 DockerDevops 👉 Azure 👉 KubernetesDevops 👉 Continuous Integration/Continuous Deployment(CI/CD)Devops 👉 GitDevops 👉 Google Cloud Ptatform (GCP)Devops 👉 JenkinsDevops 👉 JiraDevops 👉 KubernetesDevops 👉 OpenshiftDevOps 👉 SDETDevOps 👉 Selenium

a DevOps Engineer daily activities :-Writes code/software. In fact, he is a proper software engineerBuilds tools. Does the painful things, as often and frequently as possible.Participates in the on-call rotationInfrastructure design.Scaling systems (any system or subsystem - networking, applications, load balancers).Maintenance like rebooting that frail vhost with a memory leak that no one’s bothered to fix or take ownership ofMonitoringVirtualizationAgile/kanban/whatever development methodology. It’s not so much that agile is “right.” It’s just the most efficient way to complete a work queue (taking into account interruptions and blockers). A good DevOps engineer has strong opinions about this!Software release cycles and management. In fact, you might even see “development methodology” and software release cycles as the same thing.Automation. Automation. Automation.Designing a branch/release strategy for the provided SCM (git, Mercurial, svn, etc). Which you do have.Metrics / reporting. Goes hand-in-hand with monitoring, although they are different.Optimization / tuning. Of applications, tools, services, hardware…anything.Load and performance testing and benchmarking, including performance testing of highly complex systems. And you know the difference between load testing and performance testing.Cloud. Okay, you don’t really have to have cloud experience, but it can fundamentally change the way you think about complex systems. No one in a colo facility devised the notion of “immutable infrastructure.”Configuration management. Or not. You have an opinion about it. (You’ve surely heard of Puppet, Chef, Ansible, etc. Yes?)Security. At every layer.Load balancing / proxying / replicating. (Of services, systems, components and processes.)Command-line fu. A DevOps engineer is familiar with tools at his disposal for debugging, diagnosing and fixing issues on one or many servers, quickly. You know how pipes work, and you can count how many records contained some phrase in a log file with ease, for example.Package management.CI/CIT/CD — continuous integration, continuous integration testing, and continuous deployment. This is the closest thing to the real meaning of “DevOps” that a Systems Engineer will do.Databases. All of them. SQL, NoSQL, whatever. Distributed ones, too!Solid systems expertise. We’re talking about the networking stack, how hard disks work, how filesystems work, how system memory works, how CPU’s work, and how all these things come together. This is the traditional “operations” expertise you’ve heard about.

DevOps ToolsCI Framework - Jenkins, Bamboo, Hudson, TeamCityBuild automation - Maven, Gradle, AntDeploy - CircleCiIssue and project tracking - JIRA, CA Agile Central, Team Foundation Server, HPE Agile ManagerContinuous delivery - Chef, PuppetTest Management - QMetry Test Manager, HPE Quality Center Enterprise, ApTestTest Automation - QMetry Automation Studio, Selenium, AppiumRepository management - Artifactory, DockerCode coverage - JaCoCo, Atlassian Clover, SonarQube, CoberturaBehavior Driven Development - jbehave, CucumberApplication performance monitoring - AppDynamicsApplication security testing - HPE FortifyCloud management - Open StackMobile Device clouds - Perfecto, Sauce LabsMonitoring - Dynatrace, Nagios, MonitVersion control - GitConfig - Consul.ioFeature Flags & Lifecycle Management - LaunchDarkly

AnsibleAnsible is a quite simple software provisioning, configuration management and application deployment tool, which ensures faster time-to-market for your applications. Whether you are a one-man company or an enterprise, you can automate orchestration, cloud provisioning, computing machines deployment and other tasks. I like Ansible because it is not as complex as Puppet or Chef, but speeds up productivity just as well.Ansible playbooks are written in YAML, which is one of the easiest data-serialization languages for creating configuration files.It’s fast, performs all its functions over SSH and doesn't require agent installation. -It allows you to create groups of servers, describe how these should be configured and what actions should be performed on these machines.JenkinsA lot of DevOps engineers call Jenkins the best CI/CD tool available in the market, since it’s incredibly useful. Jenkins is an automation server that is written in Java and is used to report changes, conduct live testing and distribute code across multiple machines. As Jenkins has a built-in GUI and over 1,000 plugins to support building and testing your application, it is considered a really powerful, yet easy to use tool. Thanks to these plugins, Jenkins integrates well with practically every other instrument in the continuous integration and continuous delivery toolchain.Easy to install and a lot of support available from the community.1,000+ plugins are available and easy to create your own, if needed.It can be used to publish results and send email notifications.DockerDocker is a software containerization platform that allows DevOps to build, ship, and run distributed processes within containers. This gives developers the ability to create predictable environments that are isolated from the rest of the applications and can be run anywhere. Containers are isolated but share the same OS kernel. This way you get to use hardware resources more efficiently compared to virtual machines.Each container can hold a single process, like a web server or database management system. You can create a cluster of containers distributed across different nodes to have your application up and running in both load balancing and high availability modes. Containers can communicate on a private network, as you most likely want to keep some of your application parts private for security purposes. Simply expose your web server to the Internet and you are good to go.What I like most is that you can install Docker on your computer to run containers locally to make some ad-hoc software tests without installing its dependencies globally. When you are done, you simply terminate your Docker container and your computer is as clean as new.Build once, run anywhere! You can package an application from your laptop and run it unmodified on any public/private cloud or bare metal server.Containers are lightweight and fast.Docker Hub offers many official and community-built public Docker images.Separating different components of a large application into containers have security benefits: if one container is compromised, others remain unaffected.KubernetesWhile Docker allows developers to build, ship and run applications in containers easily, Kubernetes makes running containers in a cluster as easy as ever. You can automatically deploy, scale, monitor and manage your cloud-native application with Kubernetes. It is a powerful orchestrator that allows you to manage communication between containerized components, known as pods, and coordinate them as a cluster.Kubernetes has now become the heart of a microservices application. The ecosystem around it is expanding by the minute with the Cloud Native Computing Foundation ensuring its future success. There are now many additional observability, networking, and distributed data storage services that complement Kubernetes in building a loosely coupled distributed system that is resilient, manageable and observable.Open-source orchestrator.Easy container management.Horizontal autoscaling — If you get high loads, you can replicate your pods and balance the load across them to avoid downtime.Self-healing, Automated Rollouts and Rollbacks — If something goes wrong, you can automatically replace, restart, reschedule your containers or rollout/rollback to the desired state of the containerized application.Service Discovery — Kubernetes uses unique IP addresses and can put a set of containers behind a single DNS name. This allows you easily track and identify your across the cluster.RabbitMQRabbitMQ is a great messaging and queuing tool that you can use for applications that runs on most operating systems. Managing queues, exchanges and routing with it is a breeze. Even if you have an elaborate configuration to be built, it’s relatively easy to do so, since the tool is really well-documented. You can stream a lot of different high-performance processes and avoid system crashes through a friendly user interface. It's a durable and robust messaging broker that is worth your attention. As RabbitMQ developers like to say, it’s "messaging that just works."Guaranteed message delivery.Push work into background processes, freeing your web server up to handle more users.Scale the most frequently used parts of your system, without having to scale everything.Handling everything with ease even if it seems to be a huge crash.

1. Explain briefly about your project. 2. In which area you are well verse? 3. What is branching strategies? What is difference between release and feature branch? 4. What is code cut for deployment in master branch? 5. How to code will be add from feature branch to release branch? 6. Explain different job available in Jenkins. 7. How to create CI and CD pipeline? Explain stages in pipeline. 8. How master-slave configuration set-up and how to use in pipeline? 9. What is Maven and which version you are using in project? 10. What are Maven dependencies and how to manage those? 11. What are different goals in Maven lifecycle? 12. What is code coverage and which tool you use to validate code coverage? 13. Are you using any build artifactory? 14. What is build artifactory and why use artfifactory? 15. Which application and webserver used in your project? 16. Explain docker architecture. Difference between docker and K8S. 17. Explain image layers and dangling images. 18. How you monitor application logs and which tool you used? 19. How can SSH in container and troubleshoot the issue? 20. Are you aware about docker networking? If yes, then explain. 21. Apart from above Application and webserver which you are aware? 22. What is Ansible architecture and how to set-up password based authentication? 23. What is your approach to deploy war file using ansible? List down the steps. 24. How to configure the Jenkins with ansible? 25. Can we use Kubernetes without Ansible? If yes, then how? 26. What mean by roles, task and handlers in Ansible? Give me example of ansible playbook. 27. If you want to deploy any war file in production what are your approach(pre-requisite) ? 28. How to manage Jenkins administration based on user profile. 29. What are different securities level option in AWS? 30. What are fundamental pillars of AWS architecture? 31. What is SG and ACL? Are those same or different? 32. Which lib use for python with aws? 33. Which types of instances you used in your project? What is disaster recovery plan for the project? 34. What mean by SSL certificate? Why to use it? 35. Have you experience in to configure SSL certificates? If yes, please explain the process.

What is the relation between Hudson and Jenkins? Hudson was the earlier name of current Jenkins. After some issues were faced, the project name was changed from Hudson to Jenkins. What are the advantages of Jenkins? Advantage of using Jenkins 1. Bug tracking is easy at an early stage in a development environment. 2. Provides a very large number of plugin support. 3. Iterative improvement to the code, code is basically divided into small sprints. 4. Build failures are cached at integration stage. 5. For each code commit change an automatic build report notification gets generated. 6. To notify developers about build report success or failure, it can be integrated with LDAP mail server. 7. Achieves continuous integration agile development and test-driven development environment. 8. With simple steps, maven release projects can also be automated. Which SCM tools does Jenkins support? Source code management tools supported by Jenkins are below: 1. AccuRev 2. CVS 3. Subversion 4. Git 5. Mercurial 6. Perforce 7. Clearcase 8. RTC and many more What is Ansible? Ansible is a software configuration management tool to deploy an application using SSH without any downtime. It is also used for management and configuration of software applications. Ansible is developed in Python language. How can you set up Jenkins jobs? Steps to set up Jenkins job as follows: Select new item from the menu. After that enter a name for the job (it can be anything) and select a free-style job. Then click OK to create a new job in Jenkins dashboard. The next page enables you to configure your job, and it‘s done.

Write a shell script to print only prime numbers? 1. prime.sh 2. echo ―1‖ 3. i=3 4. j=300 5. flag=0 6. tem=2 7. echo ―1‖while [ $i -ne $j ] 8. do 9. temp=`echo $i` 10. while [ $temp -ne $tem ] 11. do 12. temp=`expr $temp – 1` 13. n=`expr $i % $temp` 14. if [ $n -eq 0 -a $flag -eq 0 ] 15. then 16. flag=1 17. fi 18. done 19. if [ $flag -eq 0 ] 20. then 21. echo $i 22. else 23. flag=0 24. fi 25. i=`expr $i + 1` 26. done

How can you define particular space to the file This feature is generally used to give the swap space to the server. Let‘s say in below machine I have to create swap space of 1GB then, dd if=/dev/zero of=/swapfile1 bs=1G count=1 What is the concept of sudo in Linux? Sudo(superuser do) is a utility for UNIX- and Linux-based systems that provides an efficient way to give specific users permission to use specific system commands at the root (most powerful) level of the system. What is a Jenkins Pipeline? Jenkins Pipeline (or simply ―Pipeline‖) is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins. How to stop and restart the Docker container? To stop the container: docker stop container ID Now to restart the Docker container: docker restart container ID What platforms does Docker run on? Docker runs on only Linux and Cloud platforms: 1. Ubuntu 12.04 LTS+ 2. Fedora 20+ 3. RHEL 6.5+ 4. CentOS 6+ 5. Gentoo 6. ArchLinux 7. openSUSE 12.3+ 8. CRUX 3.0+ 9. Amazon EC2 10. Google Compute Engine 11. Microsoft Azure 12. Rackspace Note that Docker does not run on Windows or Mac for production as there is no support, yes you can use it for testing purpose even in windows What are the tools used for docker networking? For docker networking we generally use kubernetes and docker swarm. What is docker compose? Let‘s say you want to run multiple docker containers, at that time you have to create the docker- compose file and type the command docker-compose up. It will run all the containers mentioned in docker compose file. What is Scrum? Scrum is basically used to divide your complex software and product development task into smaller chunks, using iterations and incremental practises. Each iteration is of two weeks. Scrum consists of three roles: Product owner, scrum master and Team

What does the commit object contain? Commit object contain the following components: It contains a set of files, representing the state of a project at a given point of time reference to parent commit objects An SHAI name, a 40-character string that uniquely identifies the commit object (also called as hash). Explain the difference between git pull and git fetch? Git pull command basically pulls any new changes or commits from a branch from your central repository and updates your target branch in your local repository. Git fetch is also used for the same purpose, but it‘s slightly different from Git pull. When you trigger a git fetch, it pulls all new commits from the desired branch and stores it in a new branch in your local repository. If we want to reflect these changes in your target branch, git fetch must be followed with a git merge. Our target branch will only be updated after merging the target branch and fetched branch. Just to make it easy for us, remember the equation below: Git pull = git fetch + git merge How do we know in Git if a branch has already been merged into master? git branch –merged The above command lists the branches that have been merged into the current branch. git branch –no-merged This command lists the branches that have not been merged. What is „Staging Area‟ or „Index‟ in GIT? Before committing a file, it must be formatted and reviewed in an intermediate area known as ‗Staging Area‘ or ‗Indexing Area‘. #git add What is Git Stash? Let‘s say you‘ve been working on part of your project, things are in a messy state and you want to switch branches for some time to work on something else. The problem is, you don‘t want to commit your half-done work just, so you can get back to this point later. The answer to this issue is Git stash. Git Stashing takes your working directory, that is, your modified tracked files and staged changes and saves it on a stack of unfinished changes that you can reapply at any time. What is Git stash drop? Git ‗stash drop‘ command is basically used to remove the stashed item. It will basically remove the last added stash item by default, and it can also remove a specific item if you include it as an argument. I have provided an example below: If you want to remove any particular stash item from the list of stashed items you can use the below commands:

Mention the key aspects or principle behind DevOps? The key aspects or principle behind DevOps are: 1. Infrastructure as a Code 2. Continuous Integration 3. Continuous Deployment 4. Automation 5. Continuous Monitoring 6. Security

List out some of the popular tools for DevOps?  Git  Jenkins  Gitlab  Ansible  Puppet  Docker  Kubernetes  Helm-Charts  Terraform  Promethious  ELK (Elasticsearch, Logstash, Kibana)

What is DevOps? By the name DevOps, it‘s very clear that it‘s a collaboration of Development as well as Operations. But one should know that DevOps is not a tool, or a software or framework, DevOps is a Combination of Tools which helps for the automation of whole infrastructure. DevOps is basically and implementation of Agile methodology on Development side as well as Operations side.

Why do we need DevOps? To fulfil the need of delivering more and faster and better applications to meet more and more demands of users, we need DevOps. DevOps helps deployment to happen really fast compared to any other traditional tools.

devops interview questions

BITWISE OPERATOR def xorProblem(n, arr, q, queries): result=[] for i in queries: l=arr[(i[0]-1):i[1]] result.append(subsegment(l)) return result def subsegment(arr): res=[] res=arr l=[arr[i:j] for i in range(len(arr)) for j in range(i+1,len(arr)+1)] #------------------------------------------------> def BitOperation(m): l=[] for i in range(len(m)-1): l.append(m[i]^m[i+1]) if len(l)==1: res.append(l[0]) elif len(l)!=1 and len(m)>1: BitOperation(l) #-------------------------------------------------------> for i in l: BitOperation(i) return max(res) print(xorProblem(6,[1, 2, 4, 8, 16, 32] , 3,[ [1, 3],[2, 5],[1,6] ]))

GREP Command Search for the given string in a single file The basic usage of grep command is to search for a specific string in the specified file as shown below. Syntax: grep "literal_string" filename $ grep "this" demo_file this line is the 1st lower case line in this file. Two lines above this line is empty. And this is the last line. 2. Checking for the given string in multiple files. Syntax: grep "string" FILE_PATTERN This is also a basic usage of grep command. For this example, let us copy the demo_file to demo_file1. The grep output will also include the file name in front of the line that matched the specific pattern as shown below. When the Linux shell sees the meta character, it does the expansion and gives all the files as input to grep. $ cp demo_file demo_file1 $ grep "this" demo_* demo_file:this line is the 1st lower case line in this file. demo_file:Two lines above this line is empty. demo_file:And this is the last line. demo_file1:this line is the 1st lower case line in this file. demo_file1:Two lines above this line is empty. demo_file1:And this is the last line. 3. Case insensitive search using grep -i Syntax: grep -i "string" FILE This is also a basic usage of the grep. This searches for the given string/pattern case insensitively. So it matches all the words such as “the”, “THE” and “The” case insensitively as shown below. $ grep -i "the" demo_file THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file. This Line Has All Its First Character Of The Word With Upper Case. And this is the last line. 4. Match regular expression in files Syntax: grep "REGEX" filename This is a very powerful feature, if you can use use regular expression effectively. In the following example, it searches for all the pattern that starts with “lines” and ends with “empty” with anything in-between. i.e To search “lines[anything in-between]empty” in the demo_file. $ grep "lines.*empty" demo_file Two lines above this line is empty. From documentation of grep: A regular expression may be followed by one of several repetition operators: • ? The preceding item is optional and matched at most once. • * The preceding item will be matched zero or more times. • + The preceding item will be matched one or more times. • {n} The preceding item is matched exactly n times. • {n,} The preceding item is matched n or more times. • {,m} The preceding item is matched at most m times. • {n,m} The preceding item is matched at least n times, but not more than m times. 5. Checking for full words, not for sub-strings using grep -w If you want to search for a word, and to avoid it to match the substrings use -w option. Just doing out a normal search will show out all the lines. The following example is the regular grep where it is searching for “is”. When you search for “is”, without any option it will show out “is”, “his”, “this” and everything which has the substring “is”. $ grep -i "is" demo_file THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file. This Line Has All Its First Character Of The Word With Upper Case. Two lines above this line is empty. And this is the last line. The following example is the WORD grep where it is searching only for the word “is”. Please note that this output does not contain the line “This Line Has All Its First Character Of The Word With Upper Case”, even though “is” is there in the “This”, as the following is looking only for the word “is” and not for “this”. $ grep -iw "is" demo_file THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE. this line is the 1st lower case line in this file. Two lines above this line is empty. And this is the last line. 6. Displaying lines before/after/around the match using grep -A, -B and -C When doing a grep on a huge file, it may be useful to see some lines after the match. You might feel handy if grep can show you not only the matching lines but also the lines after/before/around the match. Please create the following demo_text file for this example. $ cat demo_text 4. Vim Word Navigation You may want to do several navigation in relation to the words, such as: * e - go to the end of the current word. * E - go to the end of the current WORD. * b - go to the previous (before) word. * B - go to the previous (before) WORD. * w - go to the next word. * W - go to the next WORD. WORD - WORD consists of a sequence of non-blank characters, separated with white space. word - word consists of a sequence of letters, digits and underscores. Example to show the difference between WORD and word * 192.168.1.1 - single WORD * 192.168.1.1 - seven words. 6.1 Display N lines after match -A is the option which prints the specified N lines after the match as shown below. Syntax: grep -A "string" FILENAME The following example prints the matched line, along with the 3 lines after it. $ grep -A 3 -i "example" demo_text Example to show the difference between WORD and word * 192.168.1.1 - single WORD * 192.168.1.1 - seven words. 6.2 Display N lines before match -B is the option which prints the specified N lines before the match. Syntax: grep -B "string" FILENAME When you had option to show the N lines after match, you have the -B option for the opposite. $ grep -B 2 "single WORD" demo_text Example to show the difference between WORD and word * 192.168.1.1 - single WORD 6.3 Display N lines around match -C is the option which prints the specified N lines before the match. In some occasion you might want the match to be appeared with the lines from both the side. This options shows N lines in both the side(before & after) of match. $ grep -C 2 "Example" demo_text word - word consists of a sequence of letters, digits and underscores. Example to show the difference between WORD and word * 192.168.1.1 - single WORD 7. Highlighting the search using GREP_OPTIONS As grep prints out lines from the file by the pattern / string you had given, if you wanted it to highlight which part matches the line, then you need to follow the following way. When you do the following export you will get the highlighting of the matched searches. In the following example, it will highlight all the this when you set the GREP_OPTIONS environment variable as shown below. $ export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8' $ grep this demo_file this line is the 1st lower case line in this file. Two lines above this line is empty. And this is the last line. 8. Searching in all files recursively using grep -r When you want to search in all the files under the current directory and its sub directory. -r option is the one which you need to use. The following example will look for the string “ramesh” in all the files in the current directory and all it’s subdirectory. $ grep -r "ramesh" * 9. Invert match using grep -v You had different options to show the lines matched, to show the lines before match, and to show the lines after match, and to highlight match. So definitely You’d also want the option -v to do invert match. When you want to display the lines which does not matches the given string/pattern, use the option -v as shown below. This example will display all the lines that did not match the word “go”. $ grep -v "go" demo_text 4. Vim Word Navigation You may want to do several navigation in relation to the words, such as: WORD - WORD consists of a sequence of non-blank characters, separated with white space. word - word consists of a sequence of letters, digits and underscores. Example to show the difference between WORD and word * 192.168.1.1 - single WORD * 192.168.1.1 - seven words. 10. display the lines which does not matches all the given pattern. Syntax: grep -v -e "pattern" -e "pattern" $ cat test-file.txt a b c d $ grep -v -e "a" -e "b" -e "c" test-file.txt d 11. Counting the number of matches using grep -c When you want to count that how many lines matches the given pattern/string, then use the option -c. Syntax: grep -c "pattern" filename $ grep -c "go" demo_text 6 When you want do find out how many lines matches the pattern $ grep -c this demo_file 3 When you want do find out how many lines that does not match the pattern $ grep -v -c this demo_file 4 12. Display only the file names which matches the given pattern using grep -l If you want the grep to show out only the file names which matched the given pattern, use the -l (lower-case L) option. When you give multiple files to the grep as input, it displays the names of file which contains the text that matches the pattern, will be very handy when you try to find some notes in your whole directory structure. $ grep -l this demo_* demo_file demo_file1 13. Show only the matched string By default grep will show the line which matches the given pattern/string, but if you want the grep to show out only the matched string of the pattern then use the -o option. It might not be that much useful when you give the string straight forward. But it becomes very useful when you give a regex pattern and trying to see what it matches as $ grep -o "is.*line" demo_file is line is the 1st lower case line is line is is the last line 14. Show the position of match in the line When you want grep to show the position where it matches the pattern in the file, use the following options as Syntax: grep -o -b "pattern" file $ cat temp-file.txt 12345 12345 $ grep -o -b "3" temp-file.txt 2:3 8:3 Note: The output of the grep command above is not the position in the line, it is byte offset of the whole file. 15. Show line number while displaying the output using grep -n To show the line number of file with the line matched. It does 1-based line numbering for each file. Use -n option to utilize this feature. $ grep -n "go" demo_text 5: * e - go to the end of the current word. 6: * E - go to the end of the current WORD. 7: * b - go to the previous (before) word. 8: * B - go to the previous (before) WORD. 9: * w - go to the next word. 10: * W - go to the next WORD. Cut Command in Unix ( Linux) Examples Cut command in unix (or linux) is used to select sections of text from each line of files. You can use the cut command to select fields or columns from a line by specifying a delimiter or you can select a portion of text by specifying the range or characters. Basically the cut command slices a line and extracts the text. Unix Cut Command Example We will see the usage of cut command by considering the below text file as an example > cat file.txt unix or linux os is unix good os is linux good os 1. Write a unix/linux cut command to print characters by position? The cut command can be used to print characters in a line by specifying the position of the characters. To print the characters in a line, use the -c option in cut command cut -c4 file.txt x u l The above cut command prints the fourth character in each line of the file. You can print more than one character at a time by specifying the character positions in a comma separated list as shown in the below example cut -c4,6 file.txt xo ui ln This command prints the fourth and sixth character in each line. 2.Write a unix/linux cut command to print characters by range? You can print a range of characters in a line by specifying the start and end position of the characters. cut -c4-7 file.txt x or unix linu The above cut command prints the characters from fourth position to the seventh position in each line. To print the first six characters in a line, omit the start position and specify only the end position. cut -c-6 file.txt unix o is uni is lin To print the characters from tenth position to the end, specify only the start position and omit the end position. cut -c10- file.txt inux os ood os good os If you omit the start and end positions, then the cut command prints the entire line. cut -c- file.txt 3.Write a unix/linux cut command to print the fields using the delimiter? You can use the cut command just as awk command to extract the fields in a file using a delimiter. The -d option in cut command can be used to specify the delimiter and -f option is used to specify the field position. cut -d' ' -f2 file.txt or unix linux This command prints the second field in each line by treating the space as delimiter. You can print more than one field by specifying the position of the fields in a comma delimited list. cut -d' ' -f2,3 file.txt or linux unix good linux good The above command prints the second and third field in each line. Note: If the delimiter you specified is not exists in the line, then the cut command prints the entire line. To suppress these lines use the -s option in cut command. 4. Write a unix/linux cut command to display range of fields? You can print a range of fields by specifying the start and end position. cut -d' ' -f1-3 file.txt The above command prints the first, second and third fields. To print the first three fields, you can ignore the start position and specify only the end position. cut -d' ' -f-3 file.txt To print the fields from second fields to last field, you can omit the last field position. cut -d' ' -f2- file.txt 5. Write a unix/linux cut command to display the first field from /etc/passwd file? The /etc/passwd is a delimited file and the delimiter is a colon (:). The cut command to display the first field in /etc/passwd file is cut -d':' -f1 /etc/passwd 6. The input file contains the below text > cat filenames.txt logfile.dat sum.pl add_int.sh Using the cut command extract the portion after the dot. First reverse the text in each line and then apply the command on it. rev filenames.txt | cut -d'.' -f1 Sed Command in Unix and Linux Examples Sed is a Stream Editor used for modifying the files in unix (or linux). Whenever you want to make changes to the file automatically, sed comes in handy to do this. Most people never learn its power; they just simply use sed to replace text. You can do many things apart from replacing text with sed. Here I will describe the features of sed with examples. Consider the below text file as an input. >cat file.txt unix is great os. unix is opensource. unix is free os. learn operating system. unixlinux which one you choose. Sed Command Examples 1. Replacing or substituting string Sed command is mostly used to replace the text in a file. The below simple sed command replaces the word "unix" with "linux" in the file. >sed 's/unix/linux/' file.txt linux is great os. unix is opensource. unix is free os. learn operating system. linuxlinux which one you choose. Here the "s" specifies the substitution operation. The "/" are delimiters. The "unix" is the search pattern and the "linux" is the replacement string. By default, the sed command replaces the first occurrence of the pattern in each line and it won't replace the second, third...occurrence in the line. 2. Replacing the nth occurrence of a pattern in a line. Use the /1, /2 etc flags to replace the first, second occurrence of a pattern in a line. The below command replaces the second occurrence of the word "unix" with "linux" in a line. >sed 's/unix/linux/2' file.txt unix is great os. linux is opensource. unix is free os. learn operating system. unixlinux which one you choose. 3. Replacing all the occurrence of the pattern in a line. The substitute flag /g (global replacement) specifies the sed command to replace all the occurrences of the string in the line. >sed 's/unix/linux/g' file.txt linux is great os. linux is opensource. linux is free os. learn operating system. linuxlinux which one you choose. 4. Replacing from nth occurrence to all occurrences in a line. Use the combination of /1, /2 etc and /g to replace all the patterns from the nth occurrence of a pattern in a line. The following sed command replaces the third, fourth, fifth... "unix" word with "linux" word in a line. >sed 's/unix/linux/3g' file.txt unix is great os. unix is opensource. linux is free os. learn operating system. unixlinux which one you choose. 5. Changing the slash (/) delimiter You can use any delimiter other than the slash. As an example if you want to change the web url to another url as >sed 's/http:\/\//www/' file.txt In this case the url consists the delimiter character which we used. In that case you have to escape the slash with backslash character, otherwise the substitution won't work. Using too many backslashes makes the sed command look awkward. In this case we can change the delimiter to another character as shown in the below example. >sed 's_http://_www_' file.txt >sed 's|http://|www|' file.txt 6. Using & as the matched string There might be cases where you want to search for the pattern and replace that pattern by adding some extra characters to it. In such cases & comes in handy. The & represents the matched string. >sed 's/unix/{&}/' file.txt {unix} is great os. unix is opensource. unix is free os. learn operating system. {unix}linux which one you choose. >sed 's/unix/{&&}/' file.txt {unixunix} is great os. unix is opensource. unix is free os. learn operating system. {unixunix}linux which one you choose. 7. Using \1,\2 and so on to \9 The first pair of parenthesis specified in the pattern represents the \1, the second represents the \2 and so on. The \1,\2 can be used in the replacement string to make changes to the source string. As an example, if you want to replace the word "unix" in a line with twice as the word like "unixunix" use the sed command as below. >sed 's/\(unix\)/\1\1/' file.txt unixunix is great os. unix is opensource. unix is free os. learn operating system. unixunixlinux which one you choose. The parenthesis needs to be escaped with the backslash character. Another example is if you want to switch the words "unixlinux" as "linuxunix", the sed command is >sed 's/\(unix\)\(linux\)/\2\1/' file.txt unix is great os. unix is opensource. unix is free os. learn operating system. linuxunix which one you choose. Another example is switching the first three characters in a line >sed 's/^\(.\)\(.\)\(.\)/\3\2\1/' file.txt inux is great os. unix is opensource. unix is free os. aelrn operating system. inuxlinux which one you choose. 8. Duplicating the replaced line with /p flag The /p print flag prints the replaced line twice on the terminal. If a line does not have the search pattern and is not replaced, then the /p prints that line only once. >sed 's/unix/linux/p' file.txt linux is great os. unix is opensource. unix is free os. linux is great os. unix is opensource. unix is free os. learn operating system. linuxlinux which one you choose. linuxlinux which one you choose. 9. Printing only the replaced lines Use the -n option along with the /p print flag to display only the replaced lines. Here the -n option suppresses the duplicate rows generated by the /p flag and prints the replaced lines only one time. >sed -n 's/unix/linux/p' file.txt linux is great os. unix is opensource. unix is free os. linuxlinux which one you choose. If you use -n alone without /p, then the sed does not print anything. 10. Running multiple sed commands. You can run multiple sed commands by piping the output of one sed command as input to another sed command. >sed 's/unix/linux/' file.txt| sed 's/os/system/' linux is great system. unix is opensource. unix is free os. learn operating system. linuxlinux which one you chosysteme. Sed provides -e option to run multiple sed commands in a single sed command. The above output can be achieved in a single sed command as shown below. >sed -e 's/unix/linux/' -e 's/os/system/' file.txt linux is great system. unix is opensource. unix is free os. learn operating system. linuxlinux which one you chosysteme. 11. Replacing string on a specific line number. You can restrict the sed command to replace the string on a specific line number. An example is >sed '3 s/unix/linux/' file.txt unix is great os. unix is opensource. unix is free os. learn operating system. linuxlinux which one you choose. The above sed command replaces the string only on the third line. 12. Replacing string on a range of lines. You can specify a range of line numbers to the sed command for replacing a string. >sed '1,3 s/unix/linux/' file.txt linux is great os. unix is opensource. unix is free os. learn operating system. linuxlinux which one you choose. Here the sed command replaces the lines with range from 1 to 3. Another example is >sed '2,$ s/unix/linux/' file.txt linux is great os. unix is opensource. unix is free os. learn operating system. linuxlinux which one you choose. Here $ indicates the last line in the file. So the sed command replaces the text from second line to last line in the file. 13. Replace on a lines which matches a pattern. You can specify a pattern to the sed command to match in a line. If the pattern match occurs, then only the sed command looks for the string to be replaced and if it finds, then the sed command replaces the string. >sed '/linux/ s/unix/centos/' file.txt unix is great os. unix is opensource. unix is free os. learn operating system. centoslinux which one you choose. Here the sed command first looks for the lines which has the pattern "linux" and then replaces the word "unix" with "centos". 14. Deleting lines. You can delete the lines a file by specifying the line number or a range or numbers. >sed '2 d' file.txt >sed '5,$ d' file.txt 15. Duplicating lines You can make the sed command to print each line of a file two times. >sed 'p' file.txt 16. Sed as grep command You can make sed command to work as similar to grep command. >grep 'unix' file.txt >sed -n '/unix/ p' file.txt Here the sed command looks for the pattern "unix" in each line of a file and prints those lines that has the pattern. You can also make the sed command to work as grep -v, just by using the reversing the sed with NOT (!). >grep -v 'unix' file.txt >sed -n '/unix/ !p' file.txt The ! here inverts the pattern match. 17. Add a line after a match. The sed command can add a new line after a pattern match is found. The "a" command to sed tells it to add a new line after a match is found. >sed '/unix/ a "Add a new line"' file.txt unix is great os. unix is opensource. unix is free os. "Add a new line" learn operating system. unixlinux which one you choose. "Add a new line" 18. Add a line before a match The sed command can add a new line before a pattern match is found. The "i" command to sed tells it to add a new line before a match is found. >sed '/unix/ i "Add a new line"' file.txt "Add a new line" unix is great os. unix is opensource. unix is free os. learn operating system. "Add a new line" unixlinux which one you choose. 19. Change a line The sed command can be used to replace an entire line with a new line. The "c" command to sed tells it to change the line. >sed '/unix/ c "Change line"' file.txt "Change line" learn operating system. "Change line" 20. Transform like tr command The sed command can be used to convert the lower case letters to upper case letters by using the transform "y" option. >sed 'y/ul/UL/' file.txt Unix is great os. Unix is opensoUrce. Unix is free os. Learn operating system. UnixLinUx which one yoU choose. Here the sed command transforms the alphabets "ul" into their uppercase format "UL" . Display timestamp using HISTTIMEFORMAT Typically when you type history from command line, it displays the command# and the command. For auditing purpose, it may be beneficial to display the timepstamp along with the command as shown below. # export HISTTIMEFORMAT='%F %T ' # history | more 1 2008-08-05 19:02:39 service network restart 2 2008-08-05 19:02:39 exit 3 2008-08-05 19:02:39 id 4 2008-08-05 19:02:39 cat /etc/redhat-release 2. Search the history using Control+R I strongly believe, this may be your most frequently used feature of history. When you’ve already executed a very long command, you can simply search history using a keyword and re-execute the same command without having to type it fully. Press Control+R and type the keyword. In the following example, I searched for red, which displayed the previous command “cat /etc/redhat-release” in the history that contained the word red. # [Press Ctrl+R from the command prompt, which will display the reverse-i-search prompt] (reverse-i-search)`red': cat /etc/redhat-release [Note: Press enter when you see your command, which will execute the command from the history] # cat /etc/redhat-release Fedora release 9 (Sulphur) Sometimes you want to edit a command from history before executing it. For e.g. you can search for httpd, which will display service httpd stop from the command history, select this command and change the stop to start and re-execute it again as shown below. # [Press Ctrl+R from the command prompt, which will display the reverse-i-search prompt] (reverse-i-search)`httpd': service httpd stop [Note: Press either left arrow or right arrow key when you see your command, which will display the command for you to edit, before executing it] # service httpd start 3. Repeat previous command quickly using 4 different methods Sometime you may end up repeating the previous commands for various reasons. Following are the 4 different ways to repeat the last executed command. 1. Use the up arrow to view the previous command and press enter to execute it. 2. Type !! and press enter from the command line 3. Type !-1 and press enter from the command line. 4. Press Control+P will display the previous command, press enter to execute it 4. Execute a specific command from history In the following example, If you want to repeat the command #4, you can do !4 as shown below. # history | more 1 service network restart 2 exit 3 id 4 cat /etc/redhat-release # !4 cat /etc/redhat-release Fedora release 9 (Sulphur) 5. Execute previous command that starts with a specific word Type ! followed by the starting few letters of the command that you would like to re-execute. In the following example, typing !ps and enter, executed the previous command starting with ps, which is ‘ps aux | grep yp’. # !ps ps aux | grep yp root 16947 0.0 0.1 36516 1264 ? Sl 13:10 0:00 ypbind root 17503 0.0 0.0 4124 740 pts/0 S+ 19:19 0:00 grep yp 6. Control the total number of lines in the history using HISTSIZE Append the following two lines to the .bash_profile and relogin to the bash shell again to see the change. In this example, only 450 command will be stored in the bash history. # vi ~/.bash_profile HISTSIZE=450 HISTFILESIZE=450 7. Change the history file name using HISTFILE By default, history is stored in ~/.bash_history file. Add the following line to the .bash_profile and relogin to the bash shell, to store the history command in .commandline_warrior file instead of .bash_history file. I’m yet to figure out a practical use for this. I can see this getting used when you want to track commands executed from different terminals using different history file name. # vi ~/.bash_profile HISTFILE=/root/.commandline_warrior If you have a good reason to change the name of the history file, please share it with me, as I’m interested in finding out how you are using this feature. 8. Eliminate the continuous repeated entry from history using HISTCONTROL In the following example pwd was typed three times, when you do history, you can see all the 3 continuous occurrences of it. To eliminate duplicates, set HISTCONTROL to ignoredups as shown below. # pwd # pwd # pwd # history | tail -4 44 pwd 45 pwd 46 pwd [Note that there are three pwd commands in history, after executing pwd 3 times as shown above] 47 history | tail -4 # export HISTCONTROL=ignoredups # pwd # pwd # pwd # history | tail -3 56 export HISTCONTROL=ignoredups 57 pwd [Note that there is only one pwd command in the history, even after executing pwd 3 times as shown above] 58 history | tail -4 9. Erase duplicates across the whole history using HISTCONTROL The ignoredups shown above removes duplicates only if they are consecutive commands. To eliminate duplicates across the whole history, set the HISTCONTROL to erasedups as shown below. # export HISTCONTROL=erasedups # pwd # service httpd stop # history | tail -3 38 pwd 39 service httpd stop 40 history | tail -3 # ls -ltr # service httpd stop # history | tail -6 35 export HISTCONTROL=erasedups 36 pwd 37 history | tail -3 38 ls -ltr 39 service httpd stop [Note that the previous service httpd stop after pwd got erased] 40 history | tail -6 10. Force history not to remember a particular command using HISTCONTROL When you execute a command, you can instruct history to ignore the command by setting HISTCONTROL to ignorespace AND typing a space in front of the command as shown below. I can see lot of junior sysadmins getting excited about this, as they can hide a command from the history. It is good to understand how ignorespace works. But, as a best practice, don’t hide purposefully anything from history. # export HISTCONTROL=ignorespace # ls -ltr # pwd # service httpd stop [Note that there is a space at the beginning of service, to ignore this command from history] # history | tail -3 67 ls -ltr 68 pwd 69 history | tail -3 11. Clear all the previous history using option -c Sometime you may want to clear all the previous history, but want to keep the history moving forward. # history -c 12. Subtitute words from history commands When you are searching through history, you may want to execute a different command but use the same parameter from the command that you’ve just searched. In the example below, the !!:$ next to the vi command gets the argument from the previous command to the current command. # ls anaconda-ks.cfg anaconda-ks.cfg # vi !!:$ vi anaconda-ks.cfg In the example below, the !^ next to the vi command gets the first argument from the previous command (i.e cp command) to the current command (i.e vi command). # cp anaconda-ks.cfg anaconda-ks.cfg.bak anaconda-ks.cfg # vi !^ vi anaconda-ks.cfg 13. Substitute a specific argument for a specific command. In the example below, !cp:2 searches for the previous command in history that starts with cp and takes the second argument of cp and substitutes it for the ls -l command as shown below. # cp ~/longname.txt /really/a/very/long/path/long-filename.txt # ls -l !cp:2 ls -l /really/a/very/long/path/long-filename.txt In the example below, !cp:$ searches for the previous command in history that starts with cp and takes the last argument (in this case, which is also the second argument as shown above) of cp and substitutes it for the ls -l command as shown below. # ls -l !cp:$ ls -l /really/a/very/long/path/long-filename.txt 14. Disable the usage of history using HISTSIZE If you want to disable history all together and don’t want bash shell to remember the commands you’ve typed, set the HISTSIZE to 0 as shown below. # export HISTSIZE=0 # history # [Note that history did not display anything] 15. Ignore specific commands from the history using HISTIGNORE Sometimes you may not want to clutter your history with basic commands such as pwd and ls. Use HISTIGNORE to specify all the commands that you want to ignore from the history. Please note that adding ls to the HISTIGNORE ignores only ls and not ls -l. So, you have to provide the exact command that you would like to ignore from the history. # export HISTIGNORE="pwd:ls:ls -ltr:" # pwd # ls # ls -ltr # service httpd stop # history | tail -3 79 export HISTIGNORE="pwd:ls:ls -ltr:" 80 service httpd stop 81 history [Note that history did not record pwd, ls and ls -ltr] Sed Command in Unix and Linux Examples Sed is a Stream Editor used for modifying the files in unix (or linux). Whenever you want to make changes to the file automatically, sed comes in handy to do this. Most people never learn its power; they just simply use sed to replace text. You can do many things apart from replacing text with sed. Here I will describe the features of sed with examples. Consider the below text file as an input. >cat file.txt unix is great os. unix is opensource. unix is free os. learn operating system. unixlinux which one you choose.

What are the edge locations?Ans. An edge location is defined as the place where the content is used to be cached. If a user finds to access some content, then the given content will be searched in the edge location. If it is not available, then the content will be accessible from the origin location, and a copy will be stored.

What are the popular DevOps tools?Ans. The popular DevOps tools are –Chef, Puppet, Ansible, and SaltStack – Deployment and Configuration Management ToolsDocker – Containerization ToolGit – Version Control System ToolJenkins – Continuous Integration ToolNagios – Continuous Monitoring ToolSelenium – Continuous Testing Too

What are the different types of cloud services?Ans. Different types of cloud services are:Software as a Service (SaaS)Data as a Service (DaaS)Platform as a Service (PaaS)Infrastructure as a Service (IaaS)

What are the main differences between ‘horizontal’ and ‘vertical’ scales?Ans. The main differences between ‘horizontal’ and ‘vertical’ scales are –Horizontal ScaleVertical ScaleProvides new resources along with new hardware devices to support the infrastructureYou would need to increase power resources by upgrading the current machineUsed in distributed systemsUsed in virtualizationResilient to system failure Single point of failureUtilizes network callsInterprocess communicationIncreases the capacity of existing hardware or software by adding additional resourcesConnects multiple system entities, both hardware, and software such that they work as a single logical unitDifficult to implement Easy to implemen

What is CloudFront?Ans. Amazon CloudFront has become one of the most popular delivery networks (content delivery network, CDN) in the world, thanks to its ability to accelerate the transmission of static and dynamic web content, as .html, .css, and .js files. CloudFront works efficiently with services like AWS Shield and helps in curbing DDoS attacks. It utilizes Amazon S3, Elastic Load Balancing, or Amazon EC2 as sources for your applications and uses Lambda @ Edge to run custom code closer to and personalize customer users.

What is Amazon S3?Ans. Amazon S3 (Simple Storage Service) is object storage with a simple web service interface to store and retrieve any amount of data from anywhere on the web.

What is AWS SNS?Ans. Amazon Simple Notification Service (Amazon SNS) is a push notification service used in sending individual messages to a big group of mobile or email subscriber systems including Amazon SQS queues, AWS Lambda functions, and HTTPS endpoints. It is both application-to-application (A2A) and application-to-person (A2P) communication

What is AWS?Ans. It is among the most commonly asked AWS interview questions. There is little room to be creative – you either know or you don’t know the answer.Amazon Web Services or AWS is a set of cloud computing services and tools from Amazon. It offers over 200 comprehensive data center services globally. AWS is a cross-functional platform that offers a wide variety of services ranging from data warehousing to content delivery.

git commit -m "comit msg" and git commit -a -m " comit msg" what is the difference