tag:blogger.com,1999:blog-12159320808458326652024-03-16T06:39:11.937+05:30Cloud VedasAll about Cloud ComputingSaurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.comBlogger155125tag:blogger.com,1999:blog-1215932080845832665.post-3224961995514563092023-07-01T05:47:00.001+05:302023-07-01T15:07:15.685+05:30Python: difference between list and tuple with examples<p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">Lists and tuples both are used to store data in a sequence in Python. Lists are enclosed in square brackets <code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: var(--tw-prose-code); font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; font-weight: 600;">[ ]</code>, whereas tuples are enclosed in parentheses <code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: var(--tw-prose-code); font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; font-weight: 600;">( )</code>.</p><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">Here is an example of creating a list in Python:</p><pre style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; line-height: 1.71429; margin-bottom: 0px; margin-top: 0px; overflow-x: auto; padding: 0px;"><div class="bg-black rounded-md mb-4" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: rgba(0,0,0,var(--tw-bg-opacity)); border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; margin-bottom: 1rem;"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-text-opacity: 1; --tw-translate-x: 0; --tw-translate-y: 0; align-items: center; background-color: rgba(52,53,65,var(--tw-bg-opacity)); border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; display: flex; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 0.75rem; justify-content: space-between; line-height: 1rem; padding: 0.5rem 1rem; position: relative;"><button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; appearance: button; background-image: none; border-color: rgb(217, 217, 227); border-style: solid; border-width: 0px; cursor: pointer; display: flex; font-family: inherit; font-size: 12px; font-weight: inherit; gap: 0.5rem; line-height: inherit; margin: 0px 0px 0px auto; padding: 0px;"><br /></button></div><div class="p-4 overflow-y-auto" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-css" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background: none; border-radius: 0.3em; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: inherit; font-size: inherit; font-weight: inherit; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0.1em; tab-size: 4; white-space: normal; word-break: normal; word-spacing: normal;"><span style="color: white;">cv_list = <span class="hljs-selector-attr" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;">[1, 2, 3, 4, 5]</span></span>
</code></div></div></pre><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">And here is an example of creating a tuple in Python:</p><pre style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; line-height: 1.71429; margin-bottom: 0px; margin-top: 0px; overflow-x: auto; padding: 0px;"><div class="bg-black rounded-md mb-4" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: rgba(0,0,0,var(--tw-bg-opacity)); border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; margin-bottom: 1rem;"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-text-opacity: 1; --tw-translate-x: 0; --tw-translate-y: 0; align-items: center; background-color: rgba(52,53,65,var(--tw-bg-opacity)); border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; display: flex; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 0.75rem; justify-content: space-between; line-height: 1rem; padding: 0.5rem 1rem; position: relative;"><span style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"><br /></span><button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; appearance: button; background-image: none; border-color: rgb(217, 217, 227); border-style: solid; border-width: 0px; cursor: pointer; display: flex; font-family: inherit; font-size: 12px; font-weight: inherit; gap: 0.5rem; line-height: inherit; margin: 0px 0px 0px auto; padding: 0px;"><svg class="h-4 w-4" fill="none" height="1em" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewbox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect height="4" rx="1" ry="1" width="8" x="8" y="2"></rect></svg><br /></button></div><div class="p-4 overflow-y-auto" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-makefile" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background: none; border-radius: 0.3em; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: inherit; font-size: inherit; font-weight: inherit; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0.1em; tab-size: 4; white-space: normal; word-break: normal; word-spacing: normal;"><span style="color: white;">cv_tuple = (1, 2, 3, 4, 5)
</span></code></div></div></pre><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">To access elements in a list or tuple, you use indexing and slicing. The first element in a list or tuple has an index of 0.</p><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">Here is an example of indexing in a list:</p><pre style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; line-height: 1.71429; margin-bottom: 0px; margin-top: 0px; overflow-x: auto; padding: 0px;"><div class="bg-black rounded-md mb-4" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: rgba(0,0,0,var(--tw-bg-opacity)); border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; margin-bottom: 1rem;"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-text-opacity: 1; --tw-translate-x: 0; --tw-translate-y: 0; align-items: center; background-color: rgba(52,53,65,var(--tw-bg-opacity)); border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: rgba(217,217,227,var(--tw-text-opacity)); display: flex; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 0.75rem; justify-content: space-between; line-height: 1rem; padding: 0.5rem 1rem; position: relative;"><span style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"><span style="color: white;"><br /></span></span><button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; appearance: button; background-image: none; border-color: rgb(217, 217, 227); border-style: solid; border-width: 0px; cursor: pointer; display: flex; font-family: inherit; font-size: 12px; font-weight: inherit; gap: 0.5rem; line-height: inherit; margin: 0px 0px 0px auto; padding: 0px;"><svg class="h-4 w-4" fill="none" height="1em" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewbox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><span style="color: white;"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect height="4" rx="1" ry="1" width="8" x="8" y="2"></rect></span></svg><span style="color: white;"><br /></span></button></div><div class="p-4 overflow-y-auto" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-bash" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background: none; border-radius: 0.3em; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: inherit; font-size: inherit; font-weight: inherit; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0.1em; tab-size: 4; white-space: normal; word-break: normal; word-spacing: normal;"><span style="color: white;"><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;">print</span>(cv_list[0]) <span class="hljs-comment" color="rgba(255, 255, 255, 0.5)" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"># Output: 1</span></span>
</code></div></div></pre><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">And here is an example of indexing in a tuple:</p><pre style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; line-height: 1.71429; margin-bottom: 0px; margin-top: 0px; overflow-x: auto; padding: 0px;"><div class="bg-black rounded-md mb-4" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: rgba(0,0,0,var(--tw-bg-opacity)); border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; margin-bottom: 1rem;"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-text-opacity: 1; --tw-translate-x: 0; --tw-translate-y: 0; align-items: center; background-color: rgba(52,53,65,var(--tw-bg-opacity)); border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: rgba(217,217,227,var(--tw-text-opacity)); display: flex; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 0.75rem; justify-content: space-between; line-height: 1rem; padding: 0.5rem 1rem; position: relative;"><span style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"><span style="color: white;"><br /></span></span><button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; appearance: button; background-image: none; border-color: rgb(217, 217, 227); border-style: solid; border-width: 0px; cursor: pointer; display: flex; font-family: inherit; font-size: 12px; font-weight: inherit; gap: 0.5rem; line-height: inherit; margin: 0px 0px 0px auto; padding: 0px;"><svg class="h-4 w-4" fill="none" height="1em" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewbox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><span style="color: white;"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect height="4" rx="1" ry="1" width="8" x="8" y="2"></rect></span></svg><span style="color: white;"><br /></span></button></div><div class="p-4 overflow-y-auto" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-bash" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background: none; border-radius: 0.3em; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: inherit; font-size: inherit; font-weight: inherit; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0.1em; tab-size: 4; white-space: normal; word-break: normal; word-spacing: normal;"><span style="color: white;"><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;">print</span>(cv_tuple[0]) <span class="hljs-comment" color="rgba(255, 255, 255, 0.5)" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"># Output: 1</span></span>
</code></div></div></pre><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">You can also slice a list or tuple to access a range of elements. To slice a list or tuple, you specify the start index and end index separated by a colon <code style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: var(--tw-prose-code); font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; font-weight: 600;">:</code>.</p><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">Here is an example of slicing a list:</p><pre style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; line-height: 1.71429; margin-bottom: 0px; margin-top: 0px; overflow-x: auto; padding: 0px;"><div class="bg-black rounded-md mb-4" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: rgba(0,0,0,var(--tw-bg-opacity)); border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; margin-bottom: 1rem;"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-text-opacity: 1; --tw-translate-x: 0; --tw-translate-y: 0; align-items: center; background-color: rgba(52,53,65,var(--tw-bg-opacity)); border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; display: flex; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 0.75rem; justify-content: space-between; line-height: 1rem; padding: 0.5rem 1rem; position: relative;"><span style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"><br /></span><button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; appearance: button; background-image: none; border-color: rgb(217, 217, 227); border-style: solid; border-width: 0px; cursor: pointer; display: flex; font-family: inherit; font-size: 12px; font-weight: inherit; gap: 0.5rem; line-height: inherit; margin: 0px 0px 0px auto; padding: 0px;"><svg class="h-4 w-4" fill="none" height="1em" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor" viewbox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect height="4" rx="1" ry="1" width="8" x="8" y="2"></rect></svg><br /></button></div><div class="p-4 overflow-y-auto" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-bash" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background: none; border-radius: 0.3em; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: inherit; font-size: inherit; font-weight: inherit; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0.1em; tab-size: 4; white-space: normal; word-break: normal; word-spacing: normal;"><span style="color: white;"><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;">print</span>(cv_list[1:3]) <span class="hljs-comment" color="rgba(255, 255, 255, 0.5)" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"># Output: [2, 3]</span></span>
</code></div></div></pre><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px; white-space: pre-wrap;">And here is an example of slicing a tuple:</p><pre style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: "Söhne Mono", Monaco, "Andale Mono", "Ubuntu Mono", monospace; font-size: 0.875em; line-height: 1.71429; margin-bottom: 0px; margin-top: 0px; overflow-x: auto; padding: 0px;"><div class="bg-black rounded-md mb-4" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: rgba(0,0,0,var(--tw-bg-opacity)); border-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; margin-bottom: 1rem;"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md" style="--tw-bg-opacity: 1; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-text-opacity: 1; --tw-translate-x: 0; --tw-translate-y: 0; align-items: center; background-color: rgba(52,53,65,var(--tw-bg-opacity)); border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; display: flex; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 0.75rem; justify-content: space-between; line-height: 1rem; padding: 0.5rem 1rem; position: relative;"><span style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"><br /></span></div><div class="p-4 overflow-y-auto" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; overflow-y: auto; padding: 1rem;"><code class="!whitespace-pre hljs language-bash" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background: none; border-radius: 0.3em; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; font-family: inherit; font-size: inherit; font-weight: inherit; hyphens: none; line-height: 1.5; overflow-wrap: normal; padding: 0.1em; tab-size: 4; white-space: normal; word-break: normal; word-spacing: normal;"><span style="color: white;"><span class="hljs-built_in" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;">print</span>(cv_tuple[1:3]) <span class="hljs-comment" color="rgba(255, 255, 255, 0.5)" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(217, 217, 227); box-sizing: border-box;"># Output: (2, 3)</span></span>
</code></div></div></pre><p style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 transparent; --tw-rotate: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-shadow-colored: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-skew-x: 0; --tw-skew-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; background-color: #f7f7f8; border: 0px solid rgb(217, 217, 227); box-sizing: border-box; color: #374151; font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; margin: 1.25em 0px 0px; white-space: pre-wrap;">In summary, lists and tuples are both useful data structures in Python, but they have some fundamental differences. Lists are mutable, while tuples are immutable. Lists are used when you need to add, remove, or change elements, while tuples are used when you need to store a collection of elements that won't change. Understanding the differences between these two data structures will help you make the right choice for your program.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-29456591868804445292021-10-21T15:33:00.014+05:302021-11-06T05:25:19.235+05:30How to prepare for Certified Kubernetes Administrator exam<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjFnDKxLOlypza7XX5V4_7gQcDpLobXQ6IaKQGQd0Wpa0AD7eK0pUGiBhkJNIxNg7RpXn98MNUH7PQzKqcig_Dp_J6rN8zXY55HfkmPdib043u5_SGU7A2hkMWVYtYwWw_CVrSp3QiUgqTReYUjUMnq4wgSKdr6J7Www_O5z6v8mACDaP5uAQCHPPujXw=s600" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="Certified Kubernetes Administrator exam preparation" border="0" data-original-height="600" data-original-width="600" height="200" src="https://blogger.googleusercontent.com/img/a/AVvXsEjFnDKxLOlypza7XX5V4_7gQcDpLobXQ6IaKQGQd0Wpa0AD7eK0pUGiBhkJNIxNg7RpXn98MNUH7PQzKqcig_Dp_J6rN8zXY55HfkmPdib043u5_SGU7A2hkMWVYtYwWw_CVrSp3QiUgqTReYUjUMnq4wgSKdr6J7Www_O5z6v8mACDaP5uAQCHPPujXw=w200-h200" title="Certified Kubernetes Administrator badge" width="200" /></a></div><br />Hello everyone I have recently cleared the Certified Kubernetes Administrator (CKA) exam by Cloud Native Computing Foundation (CNCF), in collaboration with The Linux Foundation.<p></p><p>In this blog I will share the strategy I used to prepare for the exam and the important tips you should remember while you are actually giving the exam.</p><p>My CKA exam was on Kubernetes 1.22 version which is the latest exam version as of 21-Oct-21. You can see broad level domains tested in this exam <a href="https://www.cncf.io/certification/cka/" target="_blank">here</a> .</p><span><a name='more'></a></span><p><br /></p><p>CKA is bit different from many other professional exams of like AWS, Azure or GCP etc. CKA is lab based practical exam, so you are given tasks related to Kubernetes and you have to practically perform them during the exam. This can be little overwhelming if you are preparing for such an exam format for the first time but it's actually fun once you get the hang of it. I have earlier given <a href="https://www.cloudvedas.com/2017/06/how-to-prepare-for-ex210-rhcsa-in-red.html" target="_blank">Redhat Openstack exam</a> which is also lab based so I had some idea about the exam format.</p><p>I have more than 2 years of professional experience working on Kubernetes so I was quite familiar with it's terminologies and way of working. But exam covers lot of different topics which you may not be using in your office stack. So, you have to learn about them too.</p><p>While preparing for the exam I used the Udemy course <a href="https://click.linksynergy.com/link?id=ejY07iaMgRc&offerid=507388.2301254&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fcertified-kubernetes-administrator-with-practice-tests%2F" target="_blank">Certified Kubernetes Administrator (CKA) with Practice Tests</a> which covers all the major topics. They have hands-on labs which are very useful for practice and give you almost exam like environment. They have special labs for <b>jsonpath</b> practice which are helpful. Other than this I also used the <a href="https://killer.sh/" target="_blank">Killer.sh</a> simulator, you get 2 free attempts of this simulator when you book your CKA exam. Though the simulator is bit hard in comparison to the actual exam but it's good to keep you grounded and helps you prepare for the worst.</p><p>Basically for CKA you need to know about below topics:</p><p>1) <b>Kubernetes</b> (Obviously 😃 ) </p><p>2) <b>Linux </b>: You should know how to get around Linux like changing directories, creating files etc. And knowing commands like grep, awk, sed can be really handy to get the desired result from the huge jsons outputs.</p><p>3) <b>Container run time</b> : Earlier <b>docker</b> was the main run time for Kubernetes but Kubernetese now is not restricted to only docker. While practicing in exam simulator of Killer.sh I noticed the simulator was updated to <b>containerd</b> and this stumbled me during the last phase of preparation as I was not familiar with it's commands. But later while looking for it I realized that the containerd command are easy and not very different form docker commands. You can learn more about <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/crictl/" target="_blank">containerd commands in Kubernetes docs</a>. So while going in exam I'll suggest you practice for both docker and containerd commands in case you have to do some debugging.</p><p>4) <b>Fetching json outputs</b> : Get yourself familiarized with jsonpath, custom-columns and sort-by commands which are in <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#bash" target="_blank">kubectl cheat sheet</a> accessible during exam. These are very helpful in getting relevant details from json output. Saves you from creating complex awk, grep, sed commands or you can use them in conjunction with jsonpath if you know what you are doing.</p><p>5) <b>vi/vim Editor</b> : Get yourself accustomed with vi/vim editors. This is very important as you will have to edit yaml or json files frequently and doing it in the exam notepad is not very friendly always. </p><p><b>Tips for the exam :</b></p><p>1) The <a href="https://docs.linuxfoundation.org/tc-docs/certification/tips-cka-and-ckad" target="_blank">main tips from CNCF</a> anyways should be kept in mind.</p><p>2) You get 15-20 questions in exam. </p><p>3) Don't waste your time on tricky questions. I spent my first 20 minutes on the first question itself which got me in a tight situation. My suggestion is to flag the one's you find tricky and move to others. There are many easy questions also in the exam so my personal advise is to tackle the easier one's first and later go back to the flagged questions.</p><p>4) You are allowed to open only one tab other than your exam tab. So you should bookmark some important pages to avoid wasting time searching for them. Bookmarks I used were <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#bash" target="_blank">kubectl cheat sheet</a> , <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands" target="_blank">kubectl command reference</a> , <a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/" target="_blank">JSONPath support</a> and <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#claims-as-volumes" target="_blank">Persistent Volume</a> .</p><p><b>Conclusion:</b></p><p>The CKA exam is not very tough but it does test all your skills on kubernetes. Time management is critical for this exam as you can easily end most of your time on few tricky questions so be careful about it. Overall I think if you have done good practice and know your way around the Kubernetes docs you should be able to clear it easily.</p><p>Do let me know in comment section if you have any feedback for this post or any further queries. I'll be glad to help you.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-31989539334993603612021-08-29T11:03:00.002+05:302021-08-31T05:01:40.120+05:30Solved : How to zip directories in Linux<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHS46tTVVUV370hPjTDnlX_HQY4CXtCXFHTN4URV8klpRWzTx_41zoCFuGF64GOYSXEn-nb-aJlbIW4AEo-3op0SvX0RoOtVjNt6szFcct8XETFpDSmWeSmQqXHHp2WRS6xVxSS15feSEb/s873/linux+zip+and+unzip+directories+and+files.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="493" data-original-width="873" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHS46tTVVUV370hPjTDnlX_HQY4CXtCXFHTN4URV8klpRWzTx_41zoCFuGF64GOYSXEn-nb-aJlbIW4AEo-3op0SvX0RoOtVjNt6szFcct8XETFpDSmWeSmQqXHHp2WRS6xVxSS15feSEb/s320/linux+zip+and+unzip+directories+and+files.JPG" width="320" /></a></div><br />In this post we will see how you can use <b>zip</b> command in Linux to compress directories and files and <b>unzip</b> them. <b>zip</b> is also very useful if you have to further uncompress the files on windows machine as by default windows allows you to open zip files without installing any extra program.<p></p><p>First let's install zip. Below we will show installation instruction for both Ubuntu and Redhat linux/CentOS.</p><p><b>Ubuntu</b> :</p><p>Update the package repo:</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# sudo apt-get update</span></p><p>Now let's install zip and unzip packages:</p><p><span style="background-color: #f3f3f3;">sudo apt-get install zip unzip -y</span></p><p><br /></p><p><b>RHEL/CentOS:</b></p><p>Update the package repo:</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# sudo yum makecache</span></p><p>Install the zip and unzip packages</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# sudo yum install zip unzip</span></p><p><br /></p><p>Once the zip and unzip packages are installed we can now see their usage.</p><p>The basic syntax of the zip command is below:</p><p><span style="background-color: #f3f3f3;">zip -r <output_file>.zip <dir1> <dir2> ... <dirn></span></p><p>Let's see some examples :</p><p>We will zip three directories</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# zip -r finaldir.zip dir1 dir2 dir3</span></p><p><span style="background-color: #f3f3f3;"> adding: dir1/ (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir1/test11 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir1/test13 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir1/tet12 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir2/ (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir2/test21 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir2/test22 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir2/test23 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir3/ (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir3/test31 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir3/test32 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;"> adding: dir3/test33 (stored 0%)</span></p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~#</span></p><p>When we list the contents we can see our zipped file finaldir.zip .</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# ls -lrth</span></p><p><span style="background-color: #f3f3f3;">total 4.0K</span></p><p><span style="background-color: #f3f3f3;">drwxr-xr-x 1 root root 4.0K Aug 29 13:54 dir1</span></p><p><span style="background-color: #f3f3f3;">drwxr-xr-x 1 root root 4.0K Aug 29 13:54 dir2</span></p><p><span style="background-color: #f3f3f3;">drwxr-xr-x 1 root root 4.0K Aug 29 13:54 dir3</span></p><p><span style="background-color: #f3f3f3;">-rw-r--r-- 1 root root 1.8K Aug 29 13:55 finaldir.zip</span></p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~#</span></p><p><br /></p><p>You can also zip all the directories in the present working directory using this simple bash script.</p><p><span style="background-color: #f3f3f3;">for dir in $(ls -d */); do zip script_archive.zip $dir; done </span></p><p><br /></p><p><b>View contents of a zip file</b> </p><p>If you want to see the contents of a zip file without unzipping it you can use either <b>vi</b> or <b>vim</b> .</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# vim finaldir.zip</span></p><p>or</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~# vi finaldir.zip</span></p><p>With the above commands you can easily see the list of files and directories inside the zip.</p><p><br /></p><p><b>unzip</b></p><p>Now let's see how you can unzip a file. Be careful when you are unzipping a file with out any extra options as it will overwrite the existing contents if same name exist. Best is to unzip the file in a different directory and then copy the required files and directories as needed in the destination folder.</p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~/unziptest# unzip finaldir.zip</span></p><p><span style="background-color: #f3f3f3;">Archive: finaldir.zip</span></p><p><span style="background-color: #f3f3f3;"> creating: dir1/</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir1/test11</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir1/test13</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir1/tet12</span></p><p><span style="background-color: #f3f3f3;"> creating: dir2/</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir2/test21</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir2/test22</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir2/test23</span></p><p><span style="background-color: #f3f3f3;"> creating: dir3/</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir3/test31</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir3/test32</span></p><p><span style="background-color: #f3f3f3;"> extracting: dir3/test33</span></p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~/unziptest# ls</span></p><p><span style="background-color: #f3f3f3;">dir1 dir2 dir3 finaldir.zip</span></p><p><span style="background-color: #f3f3f3;">root@CloudVedas:~/unziptest#</span></p><p>If you want to see other useful options on unzip you can use below command</p><p><span style="background-color: #f3f3f3;">unzip -hh</span></p><p>So above we have seen how you can use zip and unzip in Linux. zip is a good utility for smaller files and directories but if you need better compression you should use tar.gz. Check out our post on <a href="https://www.cloudvedas.com/2021/06/most-useful-tar-command-examples.html" target="_blank">most useful tar command examples</a> if you want to know more about tar.gz and tar.bz2 or other compression methods in Linux.</p><p>If you want to transfer this file out of the Linux server check our post on <a href="https://www.cloudvedas.com/2020/10/how-to-transfer-files-to-ec2-instance.html" target="_blank">how to transfer files to and from linux</a> .</p><p>Do let us know in comments section if you have any query or suggestion about this post.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-85786335961393290012021-08-20T04:26:00.004+05:302021-08-30T15:59:55.573+05:30Solved : Unable to locate package error in Ubuntu<p style="text-align: left;"><span style="background-color: white;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="background-color: white;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5wDZfnjBO5Qz0BD1QjC41SP0RokrH8jk9S6iVXBGSPT7V82HF5b3XTzVFvfCMky_Ekry723ZjA1mmsq7rAaZCX6qKUdxI1W-flCwE7XOnBDuhiWPd5sWAAhUNuhuGampDzrBMPggily9T/s862/error-ubuntu.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="Unable to locate package ubuntu" border="0" data-original-height="328" data-original-width="862" height="122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5wDZfnjBO5Qz0BD1QjC41SP0RokrH8jk9S6iVXBGSPT7V82HF5b3XTzVFvfCMky_Ekry723ZjA1mmsq7rAaZCX6qKUdxI1W-flCwE7XOnBDuhiWPd5sWAAhUNuhuGampDzrBMPggily9T/w320-h122/error-ubuntu.png" width="320" /></a></span></div><span style="background-color: white;"><br />During installation of a package in ubuntu you may get an error </span><b>Unable to locate package . </b><p></p><p style="text-align: left;"><span style="background-color: white;">In this post we will show you how you can fix that error and continue with your installation. </span></p><p style="text-align: left;"><span style="background-color: white;">Below is a sample error I got while installing vagrant. But, the solution discussed below is common for any package installation in ubuntu.</span></p><p style="text-align: left;"><span style="background-color: white;"><br /></span></p><p style="text-align: left;"><span style="background-color: #eeeeee;">root@cloudvedas:~# apt install vagrant<br />Reading package lists... Done<br />Building dependency tree<br />Reading state information... Done<br />E: Unable to locate package vagrant</span></p><p style="text-align: left;"><span style="background-color: white;">To resolve this issue you have to update your apt repo. You can simply do this by running below command as root user or use sudo .</span></p><p style="text-align: left;"><span style="background-color: white;"><br /></span></p><p><span style="background-color: #eeeeee;">root@cloudvedas:~# apt update</span></p><p><span style="background-color: #eeeeee;">or</span></p><p><span style="background-color: #eeeeee;">user@cloudvedas:~# sudo apt update</span></p><p><span style="background-color: white;"><br /></span></p><p><span style="background-color: white;">Once the apt update is successfully completed you can try the installation once more.</span></p><p><span style="background-color: #eeeeee;"><br /></span></p><p><span style="background-color: #eeeeee;">root@cloudvedas:~# apt install vagrant</span></p><p><span style="background-color: #eeeeee;">or</span></p><p><span style="background-color: #eeeeee;">user@cloudvedas:~# sudo apt install vagrant</span></p><p><span style="background-color: #eeeeee;"><br /></span></p><p><span style="background-color: white;"><br /></span></p><p><span style="background-color: white;">It should work now.</span></p><p>Do let us know in the comment section if you are still facing any issue after following the above steps.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-67143167977702644532021-08-07T11:05:00.011+05:302021-08-31T04:47:54.862+05:30Solved : How to zip and unzip files in Python<p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbKsgbzwrA5MBhyFAq1On-GQd7OaEZiqUx_HX6TkYXOzlrf5m0vW3g9FumLWs0_C3WZ6vzOzaC7SSa0t0MmuZBrRk4Z9pZ_L5lMuLK-Aghn4-1SYh_2eNrEDQ0rUg9Cp7fgO7oYSC0eMBJ/s872/python+zipfile+shutil.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="489" data-original-width="872" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbKsgbzwrA5MBhyFAq1On-GQd7OaEZiqUx_HX6TkYXOzlrf5m0vW3g9FumLWs0_C3WZ6vzOzaC7SSa0t0MmuZBrRk4Z9pZ_L5lMuLK-Aghn4-1SYh_2eNrEDQ0rUg9Cp7fgO7oYSC0eMBJ/s320/python+zipfile+shutil.JPG" width="320" /></a></div><br />In this post we will see how to zip and unzip files in python using two modules <b>zipfile</b> and <b>shutil</b> .<p></p><p>You can execute below commands in Jupyter notebook or IDE like Pycharm.</p><p>Note: If you are looking for <a href="https://docs.python.org/3.3/library/functions.html#zip" target="_blank">python zip() function check here</a>.</p><p><b>Create a zip using zipfile</b></p><p>First we will use a python module called <b>zipfile</b> to create a zip file containing multiple files.</p><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: grey;">#import required modules<br /></span><span style="color: #cc7832;">import </span>zipfile<br /><br /><span style="color: grey;">#Let's create a zip file first by giving it a name<br /></span>new_zip = zipfile.ZipFile(<span style="color: #6a8759;">'zip_file.zip'</span><span style="color: #cc7832;">,</span><span style="color: #6a8759;">'w'</span>)
<br /><span style="color: grey;">#Add two files which we want to zip<br /></span>new_zip.write(<span style="color: #6a8759;">"abc.txt"</span><span style="color: #cc7832;">,</span><span style="color: #aa4926;">compress_type</span>=zipfile.ZIP_DEFLATED)<br />new_zip.write(<span style="color: #6a8759;">"fileloop.py"</span><span style="color: #cc7832;">,</span><span style="color: #aa4926;">compress_type</span>=zipfile.ZIP_DEFLATED)<br /><br /><span style="color: grey;">#Close the zip file<br /></span>new_zip.close()</pre><p>So, with the above steps we have created a zip file called <b>zip_file.zip </b>. Now let's try to extract those files in a directory.</p><p><b>Unzip using zipfile</b> </p><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: grey;">#import required modules<br /></span><span style="color: #cc7832;">import </span>zipfile<br /><br /><span style="color: grey;">#First open the file in read mode<br /></span>unzip_files = zipfile.ZipFile(<span style="color: #6a8759;">'zip_file.zip'</span><span style="color: #cc7832;">,</span><span style="color: #6a8759;">'r'</span>)<br /><br /><span style="color: grey;">#Now we will unzip and put those files in a directory called extracted_dir<br /></span>unzip_files.extractall(<span style="color: #6a8759;">"extracted_dir"</span>)</pre><p>Great! so now our files are extracted in a directory called <b>extracted_dir </b>.</p><p><br /></p><p>Let's try doing the same using other python module called <b>shutil</b> . </p><p><b>Create a zip using shutil</b></p><p>First we will zip a directory.</p><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: grey;">#import required modules<br /></span><span style="color: #cc7832;">import </span>shutil<br /><span style="color: #cc7832;">import </span>os<br /><br /><span style="color: grey;">#Give name of your final zipped file. .zip extension will be added automatically.<br /></span>output_file = <span style="color: #6a8759;">'zip_file_new'<br /></span><span style="color: #6a8759;"><br /></span><span style="color: grey;"># Give the name of directory which you want to zip.<br /></span><span style="color: grey;"># If you are in same location as the directory you can simply give it's name or<br /></span><span style="color: grey;"># else give full path of directory.<br /></span><span style="color: grey;"># Check your current directory using this command<br /></span><span style="color: #8888c6;">print</span>(os.getcwd())<br /><br /><span style="color: grey;">#full path of directory to be zipped<br /></span>zip_dir = <span style="color: #6a8759;">'E:\Software\Python\CloudVedas\extracted_dir'<br /></span><span style="color: #6a8759;"><br /></span><span style="color: grey;">#Create a zip archive<br /></span>shutil.make_archive(output_file<span style="color: #cc7832;">,</span><span style="color: #6a8759;">'zip'</span><span style="color: #cc7832;">,</span>zip_dir)</pre><p>Note: If your folder name has <b>n</b> in it at the start e.g. <b>new_extracted_dir</b> in that case you will have to escape it using extra "\" since <b>\n</b> will be treated as new line by python so in that case file path should be mentioned as 'E:\Software\Python\CloudVedas<b>\\new_extracted_dir</b>'</p><p>So, above we have created a zip file called <b>zip_file_new.zip </b>. </p><p><br /></p><p><b>Unzip using shutil</b></p><p>Now let's unzip the file zip_file_new.zip we have created earlier .</p><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: grey;">#import required modules<br /></span><span style="color: #cc7832;">import </span>shutil<br /><br /><span style="color: grey;">#zipped file full path<br /></span>zipped_file = <span style="color: #6a8759;">'E:\Software\Python\CloudVedas\zip_file_new.zip'<br /></span><span style="color: #6a8759;"><br /></span><span style="color: grey;">#full path of directory to where the zipped files will be extracted<br /></span>extracted_shutil_dir = <span style="color: #6a8759;">'E:\Software\Python\CloudVedas\extracted_dir_new'<br /></span><span style="color: #6a8759;"><br /></span><span style="color: grey;">#extract the files<br /></span>shutil.unpack_archive(zipped_file<span style="color: #cc7832;">,</span>extracted_shutil_dir<span style="color: #cc7832;">,</span><span style="color: #6a8759;">'zip'</span>)<br /></pre><p>Above steps has extracted all the files from our zip and put them in a directory called <b>extracted_dir_new</b> .</p><p>In this post we have seen two methods of zipping and unzipping files in python. Do let us know in comments section if you have any query or feedback.</p><p>If you want to extract an archive in linux shell you can check our post on <a href="https://www.cloudvedas.com/2021/06/most-useful-tar-command-examples.html" target="_blank">how archive or unarchive using tar command</a>.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-57446126745358319292021-06-19T08:39:00.012+05:302021-08-30T15:58:54.573+05:30Most useful Tar command examples <p></p><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1qK6o29vcCvZfs9ngH0Tj9ZZyC6sJEOC_o_TZLBjSJI8BhL-fTKuFfRYevy4KexNr3Yaq7DSH6LDx2siNJ4oGW9BnaYtA9RGvfboeW8-A_f3JiCj5eYyYP-jZHOaJLRvp1mbKaz4MoiKO/s811/Linux+tar+command+examples.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="346" data-original-width="811" height="137" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1qK6o29vcCvZfs9ngH0Tj9ZZyC6sJEOC_o_TZLBjSJI8BhL-fTKuFfRYevy4KexNr3Yaq7DSH6LDx2siNJ4oGW9BnaYtA9RGvfboeW8-A_f3JiCj5eYyYP-jZHOaJLRvp1mbKaz4MoiKO/s320/Linux+tar+command+examples.JPG" width="320" /></a></div><br />In this post we will see how to use the <b>tar </b>command to compress and uncompress your files and directories. Many softwares are distributed by compressing them using <b>tar</b> so the examples below will guide you how you can uncompress or open such files. This command is also very useful when you have to archive or share huge directories or files. <p></p><p><b>Create a tar </b></p><p>In the below example we have a directory called cloudvedas which has multiple files. Let's tar this directory. With -v option you can see what all files it is adding in the tar ball.</p><div>-<b>c:</b> Create an archive.<br /><b>-v:</b> Verbose output shows you all the files being archived.<br /><b>-f: </b>Allows you to specify the filename of the archive.</div><div><br /></div><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -cvf cloudvedas.tar cloudvedas<br />cloudvedas/<br />cloudvedas/cv1.sh<br />cloudvedas/cv2.sh<br />cloudvedas/cv3<br />cloudvedas/cv4<br />cloudvedas/cv5.py</span></blockquote></div><div>So now we can see we have our tar file.</div><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#ls -lrth<br />total 12K<br />drwxr-xr-x 1 sagu sagu 4.0K Jun 16 08:19 cloudvedas<br />-rw-r--r-- 1 sagu sagu 10K Jun 16 08:20 cloudvedas.tar<br />cvterm#</span></blockquote><p><br /></p><p><b>List or View contents of a tar</b></p><p>Now if you want to check all the files which are in the tar ball without doing untar/opening/uncompressing you can check it as below</p><p></p><blockquote><div style="text-align: left;"><span style="background-color: #d9d2e9;"> cvterm#tar --list -f cloudvedas.tar<br /></span><span style="background-color: #d9d2e9;">cloudvedas/<br /></span><span style="background-color: #d9d2e9;">cloudvedas/cv1.sh<br /></span><span style="background-color: #d9d2e9;">cloudvedas/cv2.sh<br /></span><span style="background-color: #d9d2e9;">cloudvedas/cv3<br /></span><span style="background-color: #d9d2e9;">cloudvedas/cv4<br /></span><span style="background-color: #d9d2e9;">cloudvedas/cv5.py<br /></span><span style="background-color: #d9d2e9;">cvterm#</span></div></blockquote><p> Another way to see the contents of a tar ball without untar is using -tvf option like below. This will show the permissions also.</p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tar<br />drwxr-xr-x sagu/sagu 0 2021-06-16 08:19 cloudvedas/<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv1.sh<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv2.sh<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv3<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv4<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv5.py<br />cvterm#</span></blockquote><p><b>Create tar.gz or .tgz which is tar and gzip in single command.</b></p><div style="text-align: left;"><p>Now let's try to gzip the directory along with tar in a single command. We will do this with option -<b>z</b> .</p><p><b>-z:</b> Compress the archive with gzip.<br /></p><div style="text-align: left;"><b style="background-color: #d9d2e9;"></b><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -cvzf cloudvedas.tar.gz cloudvedas<br /></span></blockquote><div style="text-align: left;"><br />We can see below a .tar.gz is created cloudvedas.tar.gz </div><p style="text-align: left;"><span style="background-color: #d9d2e9;"><b></b></span></p><blockquote><span style="background-color: #d9d2e9;"><b><br /></b>cvterm#ls -lrth<br />total 8.0K<br />drwxr-xr-x 1 sagu sagu 4.0K Jun 17 19:34 cloudvedas<br />-rw-r--r-- 1 sagu sagu 5.5K Jun 17 19:34 cloudvedas.tar.gz<br />cvterm#</span></blockquote><b></b><p></p><blockquote><span style="background-color: #d9d2e9;"><b></b></span></blockquote><p>We can also create .tgz which is same as .tar.gz </p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -cvzf cloudvedas.tgz cloudvedas</span><br /><p style="text-align: left;"><span style="background-color: #d9d2e9;">cvterm#ls -lrth<br />total 16K<br />drwxr-xr-x 1 sagu sagu 4.0K Jun 17 19:34 cloudvedas<br />-rw-r--r-- 1 sagu sagu 5.5K Jun 17 19:34 cloudvedas.tar.gz<br />-rw-r--r-- 1 sagu sagu 5.5K Jun 17 19:36 cloudvedas.tgz<br />cvterm#</span></p></blockquote></div><p><b>Create a</b> <span face="Muli, sans-serif" style="background-color: white; color: #3a3a3a; font-weight: 700;"> </span><span face="Muli, sans-serif" style="background-color: white; color: #3a3a3a; font-weight: 700;">tar.bz2 or tbz or tb2</span></p><p><span face="Muli, sans-serif" style="background-color: white; color: #3a3a3a;">The </span><span face="Muli, sans-serif" style="background-color: white; color: #3a3a3a; font-weight: 700;">tar.bz2 or tbz or tb2</span><span face="Muli, sans-serif" style="background-color: white; color: #3a3a3a;"> creates a file which is more compressed as compared to <b>gz</b> but these 3 extensions takes more time to compress and uncompress. If you see the file size listed below you can see clear difference.</span></p><p><span face="Muli, sans-serif" style="background-color: white; color: #3a3a3a;"><br /></span></p><p style="text-align: left;"><span style="background-color: white;"><span face="Muli, sans-serif" style="color: #3a3a3a;"></span></span></p><blockquote><p style="text-align: left;"><span style="background-color: #d9d2e9;"><span face="Muli, sans-serif" style="color: #3a3a3a;">cvterm#tar -cvjf cloudvedas.tar.tb2 cloudvedas</span></span></p><p style="text-align: left;"><span style="background-color: #d9d2e9;"><span face="Muli, sans-serif" style="color: #3a3a3a;">or</span></span></p><p style="text-align: left;"><span style="background-color: #d9d2e9;"><span face="Muli, sans-serif" style="color: #3a3a3a;">cvterm#tar -cvjf cloudvedas.tar.tbz cloudvedas</span></span></p><p style="text-align: left;"><span style="background-color: #d9d2e9;"><span face="Muli, sans-serif" style="color: #3a3a3a;">or</span></span></p><div style="text-align: left;"><p style="text-align: left;"><span style="background-color: #d9d2e9;"><span face="Muli, sans-serif" style="color: #3a3a3a;">cvterm#tar -cvjf cloudvedas.tar.bz2 cloudvedas</span></span></p><div><span style="background-color: #d9d2e9;">cvterm#ls -lrth</span></div><div><span style="background-color: #d9d2e9;">total 5.1M</span></div><div><span style="background-color: #d9d2e9;">drwxr-xr-x 1 sagu sagu 4.0K Jun 17 19:34 cloudvedas</span></div><div><span style="background-color: #d9d2e9;">-rw-r--r-- 1 sagu sagu 5.5K Jun 17 19:34 cloudvedas.tar.gz</span></div><div><span style="background-color: #d9d2e9;">-rw-r--r-- 1 sagu sagu 5.5K Jun 17 19:36 cloudvedas.tgz</span></div><div><span style="background-color: #d9d2e9;">-rw-r--r-- 1 sagu sagu 332 Jun 17 19:37 cloudvedas.tar.tb2</span></div><div><span style="background-color: #d9d2e9;">-rw-r--r-- 1 sagu sagu 332 Jun 17 19:38 cloudvedas.tar.tbz</span></div><div><span style="background-color: #d9d2e9;">-rw-r--r-- 1 sagu sagu 332 Jun 17 19:38 cloudvedas.tar.bz2</span></div><div><span style="background-color: #d9d2e9;">-rw-r--r-- 1 sagu sagu 5.1M Jun 17 19:44 cloudvedas.tar</span></div><div><span style="background-color: #d9d2e9;">cvterm#</span></div></div><p style="text-align: left;"><span face="Muli, sans-serif" style="color: #3a3a3a;"><b><span style="background-color: #d9d2e9;"></span></b></span></p><p style="text-align: left;"><br /></p></blockquote><p><b>List / View</b> the contents of <b>.tar.gz .tgz .tar.bz2 .tar.tbz .tar.tb2</b></p><p>You can simply view the contents of all these file types by same option of<b> -tvf</b></p><div><b></b></div><blockquote><div><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tar.gz</span></div><div><span style="background-color: #d9d2e9;"><br /></span></div><div><span style="background-color: #d9d2e9;">or <br /><br /></span></div><div><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tgz<br /><br /></span></div><div><span style="background-color: #d9d2e9;">or</span></div><div><span style="background-color: #d9d2e9;"><br /></span></div><div><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tar.tbz<br /><br /></span></div><div><span style="background-color: #d9d2e9;">or</span></div><div><span style="background-color: #d9d2e9;"><br /></span></div><div><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tar.bz2<br /><br /></span></div><div><span style="background-color: #d9d2e9;">or</span></div><div><span style="background-color: #d9d2e9;"><br /></span></div><div><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tar.tb2</span></div></blockquote><p><br /></p><p><b>Extract or Untar a file</b></p><p>To untar a file in the current directory do below</p><p><b>-f:</b> It tells tar the name and path of the compressed file.<br /><b>-x:</b> Extract the files.<br /><b>-v:</b> Verbose output shows you all the files being extracted.</p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar</span> </blockquote><div style="text-align: left;"><br /></div><p>To untar a file in a <b>different directory </b>use option <b>-C</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar -C /var/tmp/newdir <br />cvterm#pwd<br />/var/tmp/newdir<br />cvterm#ls<br />cloudvedas<br />cvterm#</span></blockquote></div><p>Now let's <b>extract single file</b> from tar</p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar cloudvedas/file5.txt</span></blockquote><p><b>Uncompress and untar .tar.gz or .tgz</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar.gz<br />or<br />cvterm#tar -xvf cloudvedas.tgz </span></blockquote></div><p><b>Uncompress and untar single file .tar.gz or .tgz</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;"><br />cvterm#tar -zxvf cloudvedas.tar.gz cloudvedas/file4.txt<br />cloudvedas/file4.txt<br />cvterm#tar -zxvf cloudvedas.tgz cloudvedas/file5.txt<br />cloudvedas/file5.txt</span></blockquote></div><p></p><p><b>Uncompress and untar .tar.gz or .tgz in a different directory</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar.gz -C /home/sagu/newdir/<br />or<br />cvterm#tar -xvf cloudvedas.tgz -C /home/sagu/newdir/</span></blockquote></div><p><b>Uncompress and untar tar.bz2, tar.tbz, tar.tb2</b> </p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar.bz2<br />or<br />cvterm#tar -xvf cloudvedas.tar.tbz<br />or<br />cvterm#tar -xvf cloudvedas.tar.tb2</span></blockquote></div><p><b>Extract multiple files from .tar</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar "cloudvedas/file.txt" "cloudvedas/file2.txt"<br />cloudvedas/file.txt<br />cloudvedas/file2.txt</span></blockquote></div><p><b>Extract multiple files from tar.gz .tgz using -z option</b></p><p><b>-z:</b> Decompress the archive using gzip</p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -zxvf cloudvedas.tar.gz "cloudvedas/file3.txt" "cloudvedas/file4.txt"<br />or<br />cvterm#tar -zxvf cloudvedas.tgz "cloudvedas/file3.txt" "cloudvedas/file4.txt"</span></blockquote></div><p><b>Extract multiple files from tar.bz2, tar.tbz, tar.tb2 using -j option</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -jxvf cloudvedas.tar.bz2 "cloudvedas/file5.txt" "cloudvedas/cv1.sh"<br />or<br />cvterm#tar -jxvf cloudvedas.tbz "cloudvedas/file5.txt" "cloudvedas/cv1.sh"<br />or<br />cvterm#tar -jxvf cloudvedas.tar.tb2 "cloudvedas/file5.txt" "cloudvedas/cv1.sh"</span></blockquote></div><p><b>Extract group of files using --wildcard option</b></p><p><b>.tar</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -xvf cloudvedas.tar --wildcards '*.sh'</span></blockquote></div><p><b>.tar.gz .tgz using -z option</b></p><p></p><blockquote><div style="text-align: left;"><span style="background-color: #d9d2e9;">cvterm#tar -zxvf cloudvedas.tar.gz --wildcards '*.sh'<br /></span><span style="background-color: #d9d2e9;">cvterm#tar -zxvf cloudvedas.tgz --wildcards '*.sh'</span></div></blockquote><p></p><p><b>tar.bz2, tar.tbz, tar.tb2 using -j option</b></p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -jxvf cloudvedas.tar.bz2 --wildcards '*.txt'<br />cvterm#tar -jxvf cloudvedas.tar.tbz --wildcards '*.txt'<br />cvterm#tar -jxvf cloudvedas.tar.tb2 --wildcards '*.txt'</span></blockquote></div><p><b>Add a new file or directory in .tar archive using -r option</b></p><div style="text-align: left;"><blockquote><span><span style="background-color: #d9d2e9;">cvterm#tar -rvf cloudvedas.tar cvnew1.sh </span></span> ##Adding a file<span><br /><span style="background-color: #d9d2e9;">cvterm#tar -rvf cloudvedas.tar newdir1</span></span> ## Adding dir</blockquote></div><p>Check below that now we have new file and dir added in our .tar</p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedas.tar<br />drwxr-xr-x sagu/sagu 0 2021-06-17 19:34 cloudvedas/<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv1.sh<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv2.sh<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv3<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv4<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv5.py<br />drwxr-xr-x sagu/sagu 0 2021-06-17 19:17 cloudvedas/cvdir1/<br />drwxr-xr-x sagu/sagu 0 2021-06-17 19:17 cloudvedas/cvdir2/<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:33 cloudvedas/file.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file2.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file3.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file4.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file5.txt<br /><b>-rw-r--r-- sagu/sagu 0 2021-06-18 19:27 cvnew1.sh<br />drwxr-xr-x sagu/sagu 0 2021-06-18 19:26 newdir1/</b><br />cvterm#</span></blockquote></div><p>Note: You cannot add files or dir to <b>tar.gz, .tgz, </b><b>tar.bz2, tar.tbz, tar.tb2 </b>archives</p><p><b>Exclude specific file or directories while creating a tar</b></p><p></p><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -cf cloudvedasexclude.tar --exclude='cloudvedas/cvdir1' --exclude='cloudvedas/file2.txt' cloudvedas</span></blockquote><p></p><p>As we can see below the file and directory we excluded are not in the tar.</p><div style="text-align: left;"><blockquote><span style="background-color: #d9d2e9;">cvterm#tar -tvf cloudvedasexclude.tar<br />drwxr-xr-x sagu/sagu 0 2021-06-18 19:25 cloudvedas/<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv1.sh<br />-rw-r--r-- sagu/sagu 0 2021-06-16 08:19 cloudvedas/cv2.sh<br />drwxr-xr-x sagu/sagu 0 2021-06-17 19:17 cloudvedas/cvdir2/<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:33 cloudvedas/file.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file3.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file4.txt<br />-rw-r--r-- sagu/sagu 1048576 2021-06-17 19:34 cloudvedas/file5.txt<br />cvterm#</span></blockquote><p><br /></p><p>Above we have seen some examples of frequently used tar command options. You can also use tar command to convert your vmware ova files to ovf . Check this post on <a href="https://www.cloudvedas.com/2017/09/solved-three-options-to-convert-ova-to.html" target="_blank">how to convert ova to ovf</a> using tar.</p><p>There are lot more options in tar that you can see using <b>tar --help </b>in your terminal<b>. </b>Do let us know in the comment section if you want us to add any other examples.</p></div></div><div style="text-align: left;"><b></b></div></div><p style="text-align: left;"></p><b></b></div><p></p></div></div><p></p></div>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-50322115390913707112021-06-16T04:15:00.006+05:302021-08-08T10:02:19.917+05:30Steps to create docker containers in your laptop<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzoZ2BG1odRxqYcbkoN4Q3yfI6CQHyCzMXjkyJH6FmFXPxVNYqfvHOCAFB-of0UD_wiN6R8kl78FTRADj9vBJbMTkx60Gy-BK3zq7qUwQel1TCGItquhTEbUhnSUHy5lZ0b-Syxu9yVjM/s750/docker+windows.jpg" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="422" data-original-width="750" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqzoZ2BG1odRxqYcbkoN4Q3yfI6CQHyCzMXjkyJH6FmFXPxVNYqfvHOCAFB-of0UD_wiN6R8kl78FTRADj9vBJbMTkx60Gy-BK3zq7qUwQel1TCGItquhTEbUhnSUHy5lZ0b-Syxu9yVjM/w200-h113/docker+windows.jpg" width="200" /></a></div><br />In this post we will see how to create a docker container of ubuntu on your windows laptop.<div><br />
<h3 style="text-align: left;">
Pre-requisites:-</h3>
I am using “Docker for Windows” software to run dockers on my Windows 10 laptop. You can get “Docker for Windows” by clicking on this <a href="https://docs.docker.com/docker-for-windows/install/#download-docker-for-windows" rel="noopener noreferrer" target="_blank">link</a> .<br />
If you have Windows 7 download <a href="https://docs.docker.com/toolbox/toolbox_install_windows/" rel="noopener noreferrer" target="_blank">Docker Toolbox for Windows</a> with <a href="https://www.virtualbox.org/" rel="noopener noreferrer" target="_blank">Virtualbox</a>.<br />
<strong><br /></strong><div><strong>Ubuntu docker creation</strong><br />
Once you are done with docker installation let’s move ahead.<br />
<ul>
<li>In the windows command prompt or in “Docker Quickstart Terminal” execute below command. By default it will pull the latest image of ubuntu container available in repository.</li>
</ul>
<pre><blockquote><span style="background-color: #d9d2e9;">C:\CloudVedas>docker run ubuntu</span></blockquote></pre>
<ul>
<li>If you need specific version of Ubuntu you can mention the version name in command. Like below we are pulling Ubuntu 14.04 version. You can check all the available versions <a href="https://hub.docker.com/_/ubuntu/" rel="noopener noreferrer" target="_blank">here</a> .</li>
</ul>
<div><span style="background-color: #d9d2e9;"></span></div><blockquote><div><span style="background-color: #d9d2e9;">
C:\CloudVedas> docker run ubuntu:14.04</span></div>
<div>
<div><span style="background-color: #d9d2e9;">
Unable to find image 'ubuntu:14.04' locally</span></div>
<div><span style="background-color: #d9d2e9;">
14.04: Pulling from library/ubuntu</span></div>
<div><span style="background-color: #d9d2e9;">
2e6e20c8e2e6: Pulling fs layer</span></div>
<div><span style="background-color: #d9d2e9;">
30bb187ac3fc: Pulling fs layer</span></div>
</div>
<div>
</div></blockquote><div><br /></div>
<br />
<ul>
<li>Now let’s see the image we have downloaded .</li>
</ul>
<div>
<div><span style="background-color: #d9d2e9;"></span></div><blockquote><div><span style="background-color: #d9d2e9;">
C:\CloudVedas> docker image ls</span></div>
<div><span style="background-color: #d9d2e9;">
REPOSITORY TAG IMAGE ID CREATED SIZE</span></div>
<div><span style="background-color: #d9d2e9;">
ubuntu 14.04 6e4f1fe62ff1 4 months ago 197MB</span></div></blockquote><div><span style="background-color: #d9d2e9;"></span></div>
</div>
<div>
<br /></div>
<br />
<ul>
<li>Let’s create a container with that image using the image id. Here we are using -t and -d option so that the container keeps on running in detached mode and we can login to it.</li>
</ul>
<div>
<div></div><blockquote><div><span style="background-color: #d9d2e9;">
C:\CloudVedas>docker run -t -d 6e4f1fe62ff1</span></div>
<div><span style="background-color: #d9d2e9;">
a8dee68d78026adb830edb04391af00ec8b7e1033e711fc640a1489ca54adc0a</span></div></blockquote><div></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<br />
<ul>
<li>List the running containers using “docker container ls”</li>
</ul><blockquote><span style="background-color: #d9d2e9;">
C:\CloudVedas>docker container ls<br />
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES<br />
a8dee68d7802 6e4f1fe62ff1 "/bin/bash" About a minute ago Up About a minute eager_johnson</span></blockquote><br />
<div>
<br /></div>
<br />
We can see our container is created 5 minutes ago and is up. You can also identify the container using the container id. Note that the container ID is same as the first 12 digits of the string we got when we executed docker run in last step.<br />
<ul>
<li>Let’s get inside our container and check it.</li>
</ul>
<div><blockquote><span style="background-color: #d9d2e9;">
C:\CloudVedas>docker exec -it a8dee68d7802 /bin/bash</span></blockquote></div>
<div>
<br /></div>
<br />
Once you are inside the Ubuntu container you can explore it. Let’s check the OS version.<br />
<pre><blockquote><span style="background-color: #d9d2e9;">root@a8dee68d7802:/# more /etc/os-release
NAME="Ubuntu"
VERSION="14.04.6 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.6 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
root@a8dee68d7802:/#</span></blockquote></pre>
<ul>
<li>If you don’t see your container up, it may have stopped automatically. To check all the containers which are/were running, execute command</li>
</ul>
<pre><blockquote><span style="background-color: #d9d2e9;">C:\CloudVedas>docker ps -a</span></blockquote></pre>
<pre></pre>
You can also create your own customized container image which you can use to deploy more containers in your environment. Refer this post on <a href="https://www.cloudvedas.com/2017/06/solved-how-to-create-image-of-docker.html" rel="noopener noreferrer" target="_blank">how to create a container image</a>. If instead of Docker hub you are using AWS ECR, check the post on <a href="https://www.cloudvedas.com/2019/07/aws-ecr-how-to-push-or-pull-docker-image.html" target="_blank">how to push/pull image to/from AWS ECR</a>. <div><br /></div><div>If you want to try next level on docker you can user dockerfile or docker-compose files to install your application. Like in our other post we cover <a href="https://www.cloudvedas.com/2017/06/how-to-use-wordpress-in-docker.html" target="_blank">how you can install wordpress in docker</a>.</div><div><br />
Hope this post helped you. Do let us know if you have any query or you get stuck in any installation step. </div></div></div>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-25084361969245242632020-12-30T06:15:00.007+05:302021-08-08T10:02:44.921+05:30How to become a Google Cloud Certified Professional Cloud Architect<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5oK4IMXunrIveM6a7vInznm573N08JNNZgnmqlLNfU3tL6hE2_Ez4d3ugCZDhUeWj8IqqwHWribDh_pe7NjJBytzUk08gykGkHu8Ubp2v9UVYhIKC1ADo7igGbqRjZI3j5c6GL8iKuUny/s320/Google_Cloud_Certificates_Badges-320x320.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="320" data-original-width="320" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5oK4IMXunrIveM6a7vInznm573N08JNNZgnmqlLNfU3tL6hE2_Ez4d3ugCZDhUeWj8IqqwHWribDh_pe7NjJBytzUk08gykGkHu8Ubp2v9UVYhIKC1ADo7igGbqRjZI3j5c6GL8iKuUny/w200-h200/Google_Cloud_Certificates_Badges-320x320.png" width="200" /></a></div><br />In this post I'll be giving tips on how to prepare for <a href="https://cloud.google.com/certification/cloud-architect" target="_blank">Google Cloud Certified Professional Cloud Architect</a> exam. This will also be helpful for people who are currently working on other cloud platforms like AWS or Azure and looking for broadening their skills to Google Cloud Platform (GCP).<p></p><p>As many of you who are following this blog knows that I am already working on AWS and Azure. About a couple of years back we got heavily into Kubernetes. Being a curious techie when I started digging further about Kubernetes, I found that it was initially designed by Google. One thing led to another and I ended up exploring more about google cloud. In parallel, we started getting traction on multi-cloud strategy and GCP is also considered a good option with many features which are helpful for both startups and big Enterprises.</p><p>So, I decided to get more knowledge and expertise on Google Cloud. When I compared AWS with GCP I felt that most of the technologies are similar but obviously with different naming convention and some technical setting differences. Thus, if you have worked on AWS it won't be very difficult to grasp the Google Cloud as well. But even if you don't have background in other clouds then also learning about google cloud is not very difficult, you just need to spend extra time on the basics.</p><p>If, you are from AWS background you can get a good <a href="https://cloud.google.com/docs/compare/aws#service_comparisons" target="_blank">comparison of AWS and GCP services here</a> and that's what I did as a starting point.</p><p>Next I went through the Udemy course <a href="https://click.linksynergy.com/link?id=ejY07iaMgRc&offerid=507388.2827592&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fgoogle-cloud-specialization%2F" target="_blank">Google Cloud (GCP) 2020: Zero to Cloud Architect</a>. This course covers the GCP services in detail starting from basics. So, it is useful even for someone who is starting from scratch.</p><p>Since our company is a partner of Google so, I supplemented my preparation by enrolling in the <a href="https://cloud.google.com/training/cloud-infrastructure#cloud-architect-learning-path" target="_blank">online training labs of QWIKLABS</a>. These labs are really helpful in getting you good hands-on practice on the various GCP services.</p><p>AWS background folks will find that the GCP services are not very different but it still has some differences for e.g. in AWS a subnet is restricted to an AZ but in GCP the subnet can span to multiple AZs in a region. You have to keep these subtle differences in mind when designing in GCP.</p><p>If we talk specifically about the certification exam it mainly focuses on below topics:-</p><p></p><ul style="text-align: left;"><li>Managing and provisioning cloud infrastructure.</li><li>Designing and planning a cloud solution which is scalable, resilient and cost effective.</li><li>Security strengthening using IAM, Firewall, Security Groups etc.</li><li>Analyzing and Monitoring the application behavior using GCP Operations Suite.</li><li>Managing HA and DR.</li></ul><div>The exam is in multiple choice questions format. You will also get 2-3 case studies and you have to select an answer which is most suitable considering the scenario mentioned in case study. </div><div><br /></div><div>You can choose to appear for an exam at the test center or go for an <a href="https://support.google.com/cloud-certification/answer/9907748?hl=en" target="_blank">online proctored exam</a> from home. Considering the Corona situation I appeared for an online proctored exam. You just have to follow the guidelines mentioned in the link I have shared above and with good internet connection it is pretty easy to appear for the exam from home.</div><div><br /></div><div>Overall I found the exam to be very engaging covering wide ranging of topics.</div><div><br /></div><div>If you have any queries regarding the exam preparation or GCP in general please post them in the comment section below. </div><div><br /></div><p></p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-21409894067520949592020-10-02T21:31:00.010+05:302021-08-15T10:22:00.171+05:30How to transfer files to and from EC2 instance<p><span style="font-family: verdana;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDslrtNjJH5QctFKszFpDFvLQkS-Pgn3UZEie1R_eWaRciN5GhAozpHa_K9kZKBCzLf3vNdFEuXvmX0PD9SSqIXCj7RXp-iuX90IgwQfPmMT-ANIlq9WMgyJLuSHUgSnr3TIEuWRyI8-q5/s1280/EC2sftp.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDslrtNjJH5QctFKszFpDFvLQkS-Pgn3UZEie1R_eWaRciN5GhAozpHa_K9kZKBCzLf3vNdFEuXvmX0PD9SSqIXCj7RXp-iuX90IgwQfPmMT-ANIlq9WMgyJLuSHUgSnr3TIEuWRyI8-q5/s320/EC2sftp.jpg" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: verdana;">In our <a href="https://www.cloudvedas.com/2017/07/solved-using-filezilla-for-transferring.html" target="_blank">earlier post</a> we showed how you can use Filezilla a GUI based solution to transfer files to an EC2 instance. But, in many companies installation of third party software like Filezilla is not allowed. </span><p></p><p><span style="font-family: verdana;">So, in this post we will show you how you can transfer files to and from an EC2 linux instance using our old trustworthy friend <b>SFTP</b>. </span></p><p><span style="font-family: verdana;">For those who don't know about sftp let us give you a gist of what it is.</span></p><p><span style="font-family: verdana;">SFTP is <b style="background-color: white; color: #202122;">SSH File Transfer Protocol</b><span style="background-color: white; color: #202122;"> (also </span><b style="background-color: white; color: #202122;">Secure File Transfer Protocol</b><span style="background-color: white; color: #202122;">, or </span><b style="background-color: white; color: #202122;">SFTP</b><span style="background-color: white; color: #202122;">) thus it works on same port 22 as ssh. It's secure in comparison to <b>ftp </b>which works on port 21 and nowadays blocked because of security reasons. sftp is generally pre-installed on most linux versions including Amazon Linux.</span></span></p><p><span style="font-family: verdana;"><span style="background-color: white; color: #202122;">Also, </span><span style="color: #202122;">if you compare it with SCP , which supports only file transfers, the SFTP allows you to perform a range of operations on remote files and resume file transfers.</span></span></p><p><span style="font-family: verdana;"><span style="background-color: white; color: #202122;">If you want to know more about SFTP please look at this <a href="https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol" target="_blank">sftp wiki page</a>. </span> </span></p><p><span style="font-family: verdana;">Now let's see how we can use <b>sftp</b> to transfer files.</span></p><p><span style="font-family: verdana;">Pre-requisite for this are only two things </span><span style="font-family: verdana;">both of which are pretty much standard requirement to access your EC2 linux instances.</span></p><p><span style="font-family: verdana;">1) ssh .pem key which you configured when you built the remote server where you want to connect.</span></p><p><span style="font-family: verdana;">2) Port 22 should be open to access the remote server. (</span><span style="font-family: verdana;">In case you want to know if a port is open on a remote linux/unix server by CLI without using telnet </span><a href="https://www.cloudvedas.com/2018/08/solved-check-without-telnet-if-port-is.html" style="font-family: verdana;" target="_blank">check this post</a> .<span style="font-family: verdana;">)</span></p><p><span style="font-family: verdana;">Once you have checked that you have fulfilled the pre-requisites let's move to the next step.</span></p><p><span style="font-family: verdana;">Open your shell terminal, it can be GIT Bash installed on you local windows desktop or Linux shell terminal.</span></p><p><span style="font-family: verdana;">Inside the terminal you need to execute below command</span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp -o IdentityFile=identity_file ec2-user@10.xxx.xxx.xxx</span></p><p><span style="font-family: verdana;">where identity_file is you .pem key .</span></p><p><span style="font-family: verdana;">Your actual command will look like</span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp -o IdentityFile=cloudvedas.pem ec2-user@192.168.0.10</span></p><p><span style="font-family: verdana;">Let's check our directory in remote server</span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp>pwd</span></p><p><span style="background-color: #cccccc; font-family: verdana;">Remote working directory: /home/ec2-user</span></p><p><span style="font-family: verdana;">Let's go to /tmp</span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp> cd /tmp</span></p><p><span style="font-family: verdana;">Let's transfer a file <b>from local machine to the remote server</b></span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp> PUT test123-file.sh</span></p><p><span style="font-family: verdana;">Now if you want to transfer a file <b>from remote server to local machine </b></span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp> GET remote123-file.sh</span></p><p><span style="font-family: verdana;">Note: </span><b style="font-family: verdana;">PUT</b><span style="font-family: verdana;"> and </span><b style="font-family: verdana;">GET</b><span style="font-family: verdana;"> commands are case sensitive and will work in uppercase only.</span></p><p><span style="font-family: verdana;">If you forgot what was the home directory on your local machine you can check that from sftp prompt</span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp>lpwd</span></p><p><span style="background-color: #cccccc; font-family: verdana;">Local working directory: /home/cloudvedas</span></p><p><span style="font-family: verdana;">If you want to change the directory in your local machine do this</span></p><p><span style="background-color: #cccccc; font-family: verdana;">sftp>lcd /tmp</span></p><p><span style="font-family: verdana;">Hope this simple tutorial is helpful for you. Do let us know in comments section if you have any queries or to share what methods you use to transfer file to EC2 instances.</span></p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-17824569932226336832020-06-15T15:39:00.003+05:302021-08-03T04:02:58.656+05:30AWS Subnet Calculator<div><span style="color: #222222;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixjXlZ661DWGg3isqDRXFiHunFNCS2i60nK1U2RRswN_ysO-f4wv8AdVVc93eBHxuXWpwTBLQmg6CQekJ_wahBTo6k_xN7tvWp76lOG58FUVPgNVZ1cjmtKS2Zi_t-a7g8rLDUdh2VOAvd/s1280/awssubnet.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixjXlZ661DWGg3isqDRXFiHunFNCS2i60nK1U2RRswN_ysO-f4wv8AdVVc93eBHxuXWpwTBLQmg6CQekJ_wahBTo6k_xN7tvWp76lOG58FUVPgNVZ1cjmtKS2Zi_t-a7g8rLDUdh2VOAvd/s320/awssubnet.jpg" width="320" /></a></div><br />This is a simple calculator to let you know how many IPv4 IPs you will get when you create a Subnet in AWS. </span></div> <span style="color: #222222;"><br />
</span><div><span style="color: #222222;">AWS allows subnet mask only between /16 to /28 . Few IPs in each subnet are reserved for AWS internal usage . </span></div> <span style="color: #222222;"><br />
To calculate for e.g. in subnet 10.0.0.0/24 subnet mask is 24 so, enter 24 below to get available IPs in this subnet . </span><div><html> <br />
<body>
<p>Enter Subnet Mask <input id="subnetmask" max="28" min="16" name="subnetmask" type="number" /></p>
<button onclick="myFunction()">Calculate IPs</button>
<p id="demo"></p>
<script>
function myFunction() {
var netmask = subnetmask.value;
if (netmask < 16 || netmask > 28) {
document.getElementById("demo").innerHTML = "Please enter a value between 16 and 28";
}
else {
document.getElementById("demo").innerHTML = (Math.pow(2, (32 - netmask)) - 5) + " IPs will be available in this AWS subnet. ";
}
}
</script>
</body>
</html>
<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />
Disclaimer: Please note that this is not an offical AWS calculator. Please visit <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html" target="_blank">AWS VPC</a> for more details.</div>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-41665050268300789732020-06-02T05:29:00.008+05:302021-07-02T16:38:58.863+05:30AWS Security and Compliance Crash Course<div><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">In this post we will provide you gist of the AWS security and compliance model.</font></span></div><font color="#222222" face="verdana" style="background-color: white;"><span face="arial, helvetica, sans-serif"><b><div><span face="arial, helvetica, sans-serif"><b><br /></b></span></div>Shared Security Model</b></span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif">AWS is responsible for securing the underlying infra. While customer is responsible for anything you put on the cloud or connect to the cloud.</span></font><div><font color="#222222" face="verdana" style="background-color: white;"><br /></font></div><div><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-lEJzDiUxb1UEhDUFMi-MPpO3mPizfaKEzoOfMXJk4GVmX2V7aM-FF7NZZ7H0KW_7sp8VkzJIwkbV_Jg0KqkZdSg3Qh9tc6IoHgRtKYKsmL6z-Fjlx3bB8uqgAgpX6cHe1kZKDw9M67pK/" style="margin-left: 1em; margin-right: 1em;"><font color="#222222" face="verdana" style="background-color: white;"><img border="0" data-original-height="664" data-original-width="1212" height="219" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-lEJzDiUxb1UEhDUFMi-MPpO3mPizfaKEzoOfMXJk4GVmX2V7aM-FF7NZZ7H0KW_7sp8VkzJIwkbV_Jg0KqkZdSg3Qh9tc6IoHgRtKYKsmL6z-Fjlx3bB8uqgAgpX6cHe1kZKDw9M67pK/w400-h219/Shared_Responsibility_Model_V2.jpg" width="400" /></font></a></div><font color="#222222" face="verdana" style="background-color: white;"><font face="arial, helvetica, sans-serif"><br /></font>
<br />
<span face="arial, helvetica, sans-serif">Amazon is responsible for the security config of it's product that are considered managed services e.g. dynamoDB, Amazon RDS, Amazon redshift, Amazon workspaces, Amazon EMR.</span><br />
<br />
<span face="arial, helvetica, sans-serif"><b>IAAS</b> :- Amazon EC2 and Amazon VPC are completely under customer's control and thus customer has to take steps to make them secure and compliant.</span><br />
<br />
<span face="arial, helvetica, sans-serif"><b>Storage decommissioning</b> :-</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif">AWS uses the technique detailed in DoD 5220.22-M and NIST 800-88 to destroy data as part of decommissioning process.</span></font></div><div><font><font color="#222222" face="verdana" style="background-color: white;"><br /></font></font></div><div><font><font color="#222222" face="verdana" style="background-color: white;"><br /></font></font></div><div><h3 style="text-align: left;"><font color="#222222" face="verdana" size="3" style="background-color: white;">AWS Services to secure the cloud </font></h3><div><ul style="text-align: left;"><li><font color="#222222" face="verdana" style="background-color: white;"><b>AWS Config</b> :- Manage configuration history and change notifications to enable security.</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>AWS Service catalog</b> :- Catalog allows you to centrally manage commonly-deployed IT services thus enabling users to deploy approved IT services in your organization.</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>AWS Guard Duty</b>:- Offers threat detection and continuous monitoring and malicious behaviors in your AWS accounts.</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>AWS CloudHSM</b> :- Protect your encryption keys with hardware security modules (HSM).</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>Server-side Encryption</b> :- If you prefer S3 to manage encryption process for you.</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>AWS IAM</b> :- Secure access through IAM Users, Groups and Roles. IAM roles can be mapped to AD groups also.</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>Amazon Macie </b>:- Use Machine learning to automatically discover and protect sensitive data.</font></li><li><font color="#222222" face="verdana" style="background-color: white;"><b>AWS CloudTrail</b> :- Records all API calls to your AWS account either programmatically or through console. </font></li></ul></div><div><font color="#222222" face="verdana" style="background-color: white;"> </font></div><div><font color="#222222" face="verdana" style="background-color: white;"><b>AWS Artifact</b> :- To get details of all the AWS compliance reports from third-party auditors.</font></div><span style="background-color: white; color: #222222; font-family: verdana;"><font>
<br />
<span face="arial, helvetica, sans-serif"><b>Network security</b></span><br />
<span face="arial, helvetica, sans-serif"><br /><ul style="text-align: left;"><li><span face="arial, helvetica, sans-serif">You can connect to AWS access point via http or https using SSL.</span></li><li><span face="arial, helvetica, sans-serif"><b>AWS DirectConnect</b> :- Private connectivity between yours and AWS datacenter.</span></li><li><span face="arial, helvetica, sans-serif">For customer who require additional security amazon provides Amazon VPC which provide private subnet within AWS cloud and the ability to use an IPsec VPN(Virtual private network) device to provide an encrypted tunnel between the amazon vpc and your data center.</span></li><li><span face="arial, helvetica, sans-serif"><b>Amazon corporate network segregation</b>:- Logically the amazon prod network is segregated from amazon corporate network by means of a complex set of network security/segregation devices.</span></li></ul></span></font><font>
<br />
<span face="arial, helvetica, sans-serif"><b>Network Monitoring and Protection</b></span><br />
<br />
<span face="arial, helvetica, sans-serif">Amazon protects from different type of attacks:-</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif"><b>DDoS</b>:- A Denial of Service (DoS) attack is a malicious attempt to affect the availability of a targeted system, such as a website or application, to legitimate end users. Typically, attackers generate large volumes of packets or requests ultimately overwhelming the target system. In case of a Distributed Denial of Service (DDoS) attack, and the attacker uses multiple compromised or controlled sources to generate the attack.</span><br />
<br />
<span face="arial, helvetica, sans-serif"><b>Man in the Middle attacks(MITM)</b> :- In cryptography and computer security, a man-in-the-middle attack (often abbreviated MitM, MiM attack, MitMA or the same using all capital letters) is an attack where the attacker secretly relays and possibly alters the communication between two parties who believe they are directly communicating with each other.</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif"><b>IP spoofing</b> :- IP Spoofing is a technique used to gain unauthorized access to machines, whereby an attacker illicitly impersonate another machine by manipulating IP packets. IP Spoofing involves modifying the packet header with a forged (spoofed) source IP address, a checksum, and the order value.</span><br />
<br />
<span face="arial, helvetica, sans-serif"><b>Port Scanning</b> :- Port scanner is an application designed to probe a server or host for open ports. This is often used by administrators to verify security policies of their networks and by attackers to identify services running on a host and exploit vulnerabilities.</span><br />
<br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif"><b>AWS credentials types:-</b></span><br />
<br />
</font></span><ul>
<li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">password</font></span></li>
<li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">Multi factor authentication (MFA)</font></span></li><li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">AWS Microsoft AD </font></span></li><li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">IAM roles</font></span></li>
<li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">access keys</font></span></li>
<li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">key pairs</font></span></li>
<li><span face="arial, helvetica, sans-serif" style="color: #222222;"><font face="verdana" style="background-color: white;">X.509 certificates:- X.509 are only used to sign SOAP-based requests . You can have AWS create a x.509 certificate and a private key that you can download, or you can upload your own certificate by using the security credentials page.</font></span></li></ul><div><font color="#222222" face="verdana" style="background-color: white;"><br /></font></div><h3 style="text-align: left;"><font color="#222222" face="verdana" size="3" style="background-color: white;"><b>Automation</b> :-</font></h3><div><font color="#222222" face="verdana" style="background-color: white;">Amazon Inspector :- It's an automated security assessment service. It can be very helpful in finding vulnerabilities on OS and suggesting the patches.</font></div><div><font color="#222222" face="verdana" style="background-color: white;"><br /></font></div><div><font color="#222222" face="verdana" style="background-color: white;"><br /></font></div><font color="#222222" face="verdana" style="background-color: white;">
Source: <a href="https://aws.amazon.com/">https://aws.amazon.com/</a></font><ul>
</ul>
</div>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-11378882098264101672020-05-17T16:33:00.001+05:302021-08-03T04:06:04.575+05:30AWS DynamoDB Cheat Sheet<span style="background-color: white;"><span face="arial, helvetica, sans-serif" style="color: #222222;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLib0X3R3AhvuTsgfYUScSyjJ_iFeu2Js4yJ3rHKiL2tk_fnI4RZzTYB61Dj-rxcfY-5FH0HgGrK6TEULiOu2Nfu4BEWQE1WC527jLos3-Mc5L8WlkZFzS9QcI3tvEbnYvLerdU1f6vtSk/s800/dynamodb.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="400" data-original-width="800" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLib0X3R3AhvuTsgfYUScSyjJ_iFeu2Js4yJ3rHKiL2tk_fnI4RZzTYB61Dj-rxcfY-5FH0HgGrK6TEULiOu2Nfu4BEWQE1WC527jLos3-Mc5L8WlkZFzS9QcI3tvEbnYvLerdU1f6vtSk/s320/dynamodb.jpg" width="320" /></a></div><br />DynamoDB is fast and flexible noSQL DB service for all application that need consistent single digit millisecond latency at any scale. It is a fully managed DB and support both document and key value data models.It is great for IoT, mobile/web gaming, and many other apps.</span></span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Quick facts of dynamodb</span><br />
<ul>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Stored on SSD storage</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Spread across 3 geo distinct Ds.</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Eventual consistent reads:- Consistency across all copies is usually reached within a sec. Repeating a read after short time should return the updated data.(Best Read perf)</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Strongly consistent reads:- It returns a result that reflects all writes that received successful response prior to the read.</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;"><b>Table</b></span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Items(Like row of data in a table)</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Attributes(Like column of data in a table)</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Here everything between brackets {} is Item and 1587, Alan etc. are attributes.</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">{</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">"ID" : 1587,</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">"Name" : "Alan"</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">"Phone": "555-5555"</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">}</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Two types of primary keys available:-</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Single Attribute(Think unique ID)</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Partition Key (Hash Key) composed of one attribute.</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Composite(Think unique ID and date Range)</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Partition key and Sort key (hash & Range) composed of 2 attributes</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Partition key</span><br />
<ul>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Dynamodb uses the partition key 's value as input to an internal hash function. The output from the hash function determines the partition(this is simply the physical location in which the data is stored)</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">No two items in a table can have the same partition key value.</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Partition Key and Sort Key</span><br />
<ul>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Dynamodb uses the partition key 's value as input to an internal hash function. The output from the hash function determines the partition(this is simply the physical location in which the data is stored)</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Two items in a table can have the same partition key , but they must have a different sort key.</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">All items with the same partition key are sorted together , in sorted order by sorted key value</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Local secondary index</span><br />
<ul>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">It has the same partition key but different sort key</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Can only be created when creating a table. they cannot be removed or modified later.</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Global secondary index:</span><br />
<ul>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">It has different partition key and different sort key.</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Can be created at table creation or added later.</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">DynamoDB streams</span><br />
<ul>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">If a new item is added to the table, the stream captures an image of the entire item, including all of its attributes</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">If an item is updated, the stream captures the before and after image of any attributes that were modified in the item.</span></li>
<li><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">If an item is deleted from the table, the stream captures an image of an entire item before it was deleted.</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Query:-</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">A query operations find items in a table using only primary key attribute values. You must provide a partition attribute name and a distinct value to search for. </span><span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">You can optionally provide a sort key attribute name and value, and use a comparison operator to refine search results.</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">By default, a query returns all of the data attributes for the items with specified primary key(s) however you can use the ProjectionExpression parameter so that the query only returns some of the attributes, rather than all of them.</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Query results are always sorted by the sort key. If the data type of the sort key is a number the results are returned in numeric order. Otherwise, the results are returned in order of ascii character code values. By default the sort order is ascending. To reverse the order set the ScanIndexForward parameter to false.</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">By default is eventually consistent but can be changed to strongly consistent.</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">SCAN:-</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">A Scan operation examines every item in the table. By default, a scan returns all of the data attributes of every item however you can use the ProjectionExpression parameter so that the scan only returns some of the attributes, rather than all of them.</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;"><br /></span>
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Hope you find this quick glance of DynamoDB useful. Do let us know in comments if you have any query or suggestion.</span><br />
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;"><br /></span>
<span face="arial, helvetica, sans-serif" style="background-color: white; color: #222222;">Today we also want to share with you a good news that our blog is now included by Feedspot in the list of <a href="https://blog.feedspot.com/aws_blogs/" target="_blank">AWS Top 10 blogs</a> . We would like to thank you all for your help and support in achieving this.</span>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-63704252185300779962020-05-10T12:32:00.004+05:302021-07-02T16:38:07.525+05:30AWS certification exam cheat sheetsAWS certification exams grill you on vast topics and lot of services. In this post we have consolidated major services and topics of different exams so that you can access them from a single location.<br />
<div>
<br />
Below links will give you better info on which topics and services are important for each exam and how to best prepare for them.</div>
<div>
<br /></div>
<div>
<a href="https://www.cloudvedas.com/2017/07/which-aws-certification-is-suitable-for.html" target="_blank">Which AWS certification is suitable for me?</a><br />
<div>
<br /></div>
<a href="https://www.cloudvedas.com/2018/04/how-to-prepare-for-aws-certified.html" target="_blank">How to prepare for AWS Certified Developer - Associate</a><br />
<div>
<br /></div>
<a href="https://www.cloudvedas.com/2018/05/how-to-prepare-for-aws-certified-sysops.html" target="_blank">How to prepare for AWS Certified SysOps Administrator – Associate</a><br />
<div>
<br /></div>
<a href="https://www.cloudvedas.com/2017/06/how-to-become-aws-certified-solution.html" target="_blank">How to prepare for AWS Certified Solutions Architect - Associate</a><br />
<div>
<br /></div>
<a href="https://www.cloudvedas.com/2017/11/how-to-prepare-for-aws-certified.html" target="_blank">
How to prepare for AWS Certified Solutions Architect - Professional</a><br />
<br />
Once decided on which certification you want to pursue you can take a quick look of services in these cheat sheets for each service.<br />
<b><br /></b>
<br />
<h3>
<b><span style="font-size: medium;">Services</span></b></h3>
<a name='more'></a><ul>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;"><b>Amazon API gateway</b></span></li>
</ul>
<span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">It's a fully managed service that makes it easy for developer to publish, maintain, monitor and secure APIs at any scale. With few click you can create an API that acts as front door for applications to access data, business logic, or functionality from your back-end services, such as applications running on EC2, AWS lambda or any web application.</span><br />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">What can API gateway do?</span><br />
<ul>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Expose HTTPS endpointns to define a RESTful API</span></li>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Serverlessly connect to services like lambda and dynamoDB</span></li>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Send each API endpoint to a different target</span></li>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Scale effortlessly</span></li>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Track and control usage by API key</span></li>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Throttle requests to prevent attacks</span></li>
<li><span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">Connect to cloudwatch to log all requests to monitoring</span></li>
</ul>
<br style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;" />
<span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">What is API caching?</span><br />
<span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;">You can enable API caching in API gateway to cache your endpoint's responses . With caching, you can reduce the number of calls made to your endpoint and also improve the latency of the requests to your API.When you enable caching for a stage, API gateway caches responses from your endpoint for a specified TTL period in seconds. API gateway then responds to the requests by looking up the endpoint response from the cache instead of making a request to your endpoint.</span><br />
<span style="background-color: white; color: #222222; font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<a href="https://www.cloudvedas.com/2017/06/aws-crash-course-vpc.html" target="_blank"></a><ul><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-vpc.html" target="_blank"></a>
<li><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-vpc.html" target="_blank"></a><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-vpc.html" target="_blank">VPC Cheat sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-ec2.html" target="_blank">EC2 Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/06/difference-between-classic-and.html" target="_blank">ELB Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-s3.html" target="_blank">S3 Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-elastic-beanstalk.html" target="_blank">Elastic Beanstalk Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/08/aws-crash-course-emr.html" target="_blank">EMR Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/07/aws-crash-course-redshift.html" target="_blank">Redshift Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/07/aws-crash-course-sqs.html" target="_blank">SQS Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/07/aws-crash-course-rds.html" target="_blank">RDS Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-ebs.html" target="_blank">EBS Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2017/06/aws-crash-course-route-53.html" target="_blank">Route 53 Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2020/05/readyaws-dynamodb-cheat-sheet.html" target="_blank">AWS DynamoDB Cheat Sheet</a></li>
</ul>
<ul>
<li><a href="https://www.cloudvedas.com/2020/06/aws-security-and-compliance-crash-course.html" target="_blank">AWS Security and Compliance</a></li>
</ul>
<ul>
<li><b style="background-color: white; color: #222222; font-family: arial, helvetica, sans-serif;">Cloud Front</b></li>
</ul>
<br />
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<ul>
</ul>
<span style="background-color: white; color: #222222;"><br style="font-family: Arial, Helvetica, sans-serif;" /><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Edge Location </b>:- this is the location where content will be cached. This is separate to an availabilty zone in aws region</span><br style="font-family: Arial, Helvetica, sans-serif;" /><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Origin</b> :- This is the origin of the file that the cdn will distribute . This can either be S3 bucket, an EC2 instance, elastic load balancer or route 53.</span><br style="font-family: Arial, Helvetica, sans-serif;" /><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Distribution</b> :- this is the name given the CDN which consists of a collection of edge locations.</span></span><br />
<span style="background-color: white; color: #222222;"><br style="font-family: Arial, Helvetica, sans-serif;" /><b><span style="font-family: "arial" , "helvetica" , sans-serif;">Two type of distributions</span></b></span><br />
<span style="background-color: white; color: #222222;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Web distribution :</b>- Typically used for websites</span><br style="font-family: Arial, Helvetica, sans-serif;" /><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>RTMP(real time messaging protocol) :</b>- Used for media streaming</span></span><br />
<ul>
<li><span style="background-color: white; color: #222222;"><span style="background-color: white; color: #222222;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Edge location are not just read only you can write to them too.(i.e. put object on them)</span></span></span></li>
<li><span style="background-color: white; color: #222222;"><span style="background-color: white; color: #222222;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Object are cached for the life of the TTL (Time to Live) - TTL is define by you for an object in cloud front - cdn</span></span></span></li>
<li><span style="background-color: white; color: #222222;"><span style="background-color: white; color: #222222;"><span style="font-family: "arial" , "helvetica" , sans-serif;">You can clear cached objects before TTL expires, but you will be charged</span></span></span></li>
<li><span style="background-color: white; color: #222222;"><span style="background-color: white; color: #222222;"><span style="font-family: "arial" , "helvetica" , sans-serif;">You can have multiple origins in same distribution</span></span></span></li>
<li><span style="background-color: white; color: #222222;"><span style="font-family: "arial" , "helvetica" , sans-serif;">TTL is defined in seconds</span></span></li>
</ul>
<br />
<h3>
<b><span style="font-size: medium;">Exam Questions</span></b></h3>
<div>
<b><br /></b>
Below are links of some sample exam questions to test your preparation.<br />
<br />
<a href="https://www.cloudvedas.com/2017/07/aws-sample-exam-questions-part-1.html" target="_blank">AWS Sample Exam Questions</a><br />
<br />
<br />
<b>Sources</b><br />
<br />
<a href="https://docs.aws.amazon.com/index.html?nc2=h_ql_doc_do" target="_blank">AWS Documentation</a><br />
<br /></div>
</div>
Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-19020158671710193172020-05-02T07:26:00.000+05:302020-05-03T15:49:20.609+05:30Solved: How to use nmtui and nmcli tool to configure network in RedhatLinuxIn this post we will see how to use nmtui for network management. This can be a very useful tool for starters in Redhat Linux 7.<br />
<ul>
<li>Login to your server using <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html" rel="noopener noreferrer" target="_blank">putty</a> and execute command “nmtui” to invoke the interface. If your machine is not in network you can login via console and follow the same steps mentioned below.</li>
<li>If you don’t have the nmtui tool installed, you can install it using yum (Note: If you don’t want to install a new package in your server you can use nmcli for network configuration. Refer the post for <a href="https://www.cloudvedas.com/2017/09/solved-how-to-use-nmcli-for-adding-new.html" rel="noopener noreferrer" target="_blank">how to configure network with nmcli</a> )</li>
</ul>
<pre>[root@cloudvedas ~]# yum install NetworkManager-tui</pre>
<pre>[root@cloudvedas ~]# nmtui</pre>
<ul>
<li>Once you get the interface you can navigate using Arrow keys , Tab key and make selection using “enter” key. So, using arrow key select “Edit a connection” and press enter.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-7vWx1gnawNSay9TLuJUJK_OIi4dA9zYtzOOsNcUXTGiRtnbqczXNC1Nc1ziDQz0p9Pq9qe7ANW_Yw6Z9CBY06x-7EXNUpgYnuXhEE6rW9FZ44TcPhSzoAA5MnMf5hskunBQyIujXevNo/s1600/nmtui-edit-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="377" data-original-width="387" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-7vWx1gnawNSay9TLuJUJK_OIi4dA9zYtzOOsNcUXTGiRtnbqczXNC1Nc1ziDQz0p9Pq9qe7ANW_Yw6Z9CBY06x-7EXNUpgYnuXhEE6rW9FZ44TcPhSzoAA5MnMf5hskunBQyIujXevNo/s320/nmtui-edit-1.png" width="320" /></a></div>
<div>
<br /></div>
<br />
<ul>
<li>We have two network interfaces enp0s8 and enp0s3 . Today we will be configuring enp0s3. As enps0s8 is already configured and in use. So once highlighted enp0s3 go to “Add” and press enter.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXaubAb9n2pHPMwhyphenhyphenzDsaQOjjoEHPY4oqcakxbX7AIrfgUqy-BGMdV5mDe6ukzYGaIM9ys17L8WRLRunGG8hTuXlkxA3r4hmn_Ws5u1BIAnp0-fbAsp2bMho4r0r4U-N9iN41wmqplEIpj/s1600/enp0s3-select-3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="694" data-original-width="348" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXaubAb9n2pHPMwhyphenhyphenzDsaQOjjoEHPY4oqcakxbX7AIrfgUqy-BGMdV5mDe6ukzYGaIM9ys17L8WRLRunGG8hTuXlkxA3r4hmn_Ws5u1BIAnp0-fbAsp2bMho4r0r4U-N9iN41wmqplEIpj/s320/enp0s3-select-3.png" width="160" /></a></div>
<div>
<br /></div>
<br />
<ul>
<li>Select the type of connection. For this tutorial we are selecting “Ethernet”.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkZPqlAkdcUKqaPF8teaxduHGcEthRatT-vaPDLF3lEuomJPl5RT8oxHmmkig4JpOYNGC0qKQrluksE9T6SS-_gCw3kslv2G5f3zp6DxeODhVnmzXLxGfyeqAPNb8mHRagKPhckjP8_FXc/s1600/nmtui-ethernet-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="215" data-original-width="508" height="135" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkZPqlAkdcUKqaPF8teaxduHGcEthRatT-vaPDLF3lEuomJPl5RT8oxHmmkig4JpOYNGC0qKQrluksE9T6SS-_gCw3kslv2G5f3zp6DxeODhVnmzXLxGfyeqAPNb8mHRagKPhckjP8_FXc/s320/nmtui-ethernet-2.png" width="320" /></a></div>
<div>
<br /></div>
<br />
<ul>
<li>Once in “Edit connection” section enter “Profile name” , “Device”. If you want static IP select “Manual” for IPv4 and select “Show”.</li>
</ul>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<img border="0" data-original-height="303" data-original-width="600" height="161" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNywNcXclRN6Fqnu8Cae2ARLiBskw-TXiqfz5RAA01qfzBPGiZf4Bt033KUnxZrthttLyyNA3jzfWe4tnsvOZFAKWmo85sYCQTHA8wzWfs-lkOiOzHEjtPnihlRUmDeu71kWvlG9FzHVJq/s320/edit-connection-4.png" width="320" /></div>
<div>
<br /></div>
<div>
<br /></div>
<br />
<ul>
<li>Once you select “Show” enter your IP detail with subnet id. Here subnet id is /24 or 255.255.255.0 . Also enter gateway. If you want to use DNS enter DNS server details else leave it blank and select OK.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilctGssKyjnT6AX8uEf4JkIP0fCCjfLoGqwsUgVHYj5jcbbYLAdtiudreGJHDsYX5weOCt3FMnE3LKkXazRYBHROa6IJOL0NfVCjc8bFF_osVN3o4Z06sfGD1NEtjz1fNqVnXqieLKZRwM/s1600/add-ip-5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="436" data-original-width="609" height="229" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilctGssKyjnT6AX8uEf4JkIP0fCCjfLoGqwsUgVHYj5jcbbYLAdtiudreGJHDsYX5weOCt3FMnE3LKkXazRYBHROa6IJOL0NfVCjc8bFF_osVN3o4Z06sfGD1NEtjz1fNqVnXqieLKZRwM/s320/add-ip-5.png" width="320" /></a></div>
<div>
<br /></div>
<br />
<ul>
<li>Once the IP configuration is done select “OK” again. Now you can see the new connection that you have created. Select “Quit” to come out.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<img border="0" data-original-height="677" data-original-width="288" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUqLjZ8QZFbq3Q0X5ZnmKWXdQuPl1MYyhPcpyjTOW8VZ-e1CnEWz3n3xU-wDIQWHruHJWcknXl1QgPeky26ERblt5zogtbvaMDujAGLP-i-aY07eSjcUODyeIgq3g0CldyUicBQ0ocj6iK/s320/new-connection-added-6.png" width="136" /></div>
<div>
<br /></div>
<br />
<ul>
<li>Now let’s activate the connection. Execute “nmtui” in putty or console again and select “Activate a connection” and press Enter.</li>
</ul>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<img border="0" data-original-height="214" data-original-width="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi13GMKITkDo-NuAbLNQZK9vsfToulUNRpu9jEHpCFg4gJZErMiTIuYgzKRS8WsfeiEUGJi-8_DYab4UhGq0zMkrnfE0E9a2MzOm_IJokXCGJenA4cs_Ko4DUR8oYZ9Ok8rU8Ge30u2uUS5/s1600/activate-connection-7.png" /></div>
<div>
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<ul>
<li>Navigate with arrow key select the interface and then move right and Press enter on “Activate”. This will activate your interface as in image below.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ1hyaVmeGxJU3Nkf0o-3yBrsk9mt0oXptYgVT3OqJAlGsV3T94tcKMEguC-B5UvtWXCzjNiZJzvGzi9ZsN5wgLBFjw_V75T79fqrrLzwpC9s5pWbwxPtl5yV2586zA1imjmmzbxHusKj8/s1600/activate-connection-8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="252" data-original-width="337" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ1hyaVmeGxJU3Nkf0o-3yBrsk9mt0oXptYgVT3OqJAlGsV3T94tcKMEguC-B5UvtWXCzjNiZJzvGzi9ZsN5wgLBFjw_V75T79fqrrLzwpC9s5pWbwxPtl5yV2586zA1imjmmzbxHusKj8/s320/activate-connection-8.png" width="320" /></a></div>
<div>
<br /></div>
<ul>
<li>Check if the new IP is configured.</li>
</ul>
<div class="separator" style="clear: both; text-align: left;">
<img border="0" data-original-height="209" data-original-width="721" height="92" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbtmSFLldTSWBhE0f_cY0y9MirsEWZPPQZalT1FeYP2XuBItZsqHPVKPg7QeD3qc_rERrx6NsGgoPhw-XIqPr3LHtevJpfKHqvwr1QafvfJCOQpwiqlX4eTnfkRmlHSDcxF-1CAtgVQvME/s320/ip-show-9.png" width="320" /></div>
<div>
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<ul>
<li>Also let’s check in “nmcli” about the new connection.</li>
</ul>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgywJIcF4jm4OuzRBIjBnx5vwYcrVgTAu6iWAoQzctNRFodPG8m2qaVAKZS6ZhUmlwoBHNT_MtAo-soRJKvt9MubkBfCCCDz019_0jyYsN25JLmBQp8vMMW7BF-v9VKS9rbttSkEQd5QKpg/s1600/nmcli-show-10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="99" data-original-width="609" height="52" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgywJIcF4jm4OuzRBIjBnx5vwYcrVgTAu6iWAoQzctNRFodPG8m2qaVAKZS6ZhUmlwoBHNT_MtAo-soRJKvt9MubkBfCCCDz019_0jyYsN25JLmBQp8vMMW7BF-v9VKS9rbttSkEQd5QKpg/s320/nmcli-show-10.png" width="320" /></a></div>
<div>
<br /></div>
If you want to change hostname refer this post on <a href="https://www.cloudvedas.com/2017/09/solved-how-to-change-hostname-using.html" rel="noopener noreferrer" target="_blank">how to change hostname with nmtui or nmcli</a> .<br />
Hope this post is helpful. Do let me know if you have any query.Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-26253294951798220392020-04-16T06:59:00.000+05:302020-04-18T06:16:29.322+05:30Solved: How to cap or limit memory usage of a docker containerIn this post we will see how we can cap or restrict the maximum amount of memory the container can use.<br />
Let’s first see the current usage of container id ec6ed4af7c34 with “docker stats”.<br />
<pre>docker stats ec6ed4af7c34</pre>
In the below image we can see the current limit of the container is 300MiB<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoFoxE78eD30ThBx0IvHnykZ6cdwyT75OQOVnPPQ3OueIcZmHoLddo27CT-xckSBxvnsP7tea3lbMcSSeYcfiUTkkB-YiT42Eef6mSVwXPuTF857BEN3qav7oMPv8eTZ6mwo1Zk7Xtp33D/s1600/Docker+Pre-memory+cap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="116" data-original-width="536" height="69" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoFoxE78eD30ThBx0IvHnykZ6cdwyT75OQOVnPPQ3OueIcZmHoLddo27CT-xckSBxvnsP7tea3lbMcSSeYcfiUTkkB-YiT42Eef6mSVwXPuTF857BEN3qav7oMPv8eTZ6mwo1Zk7Xtp33D/s320/Docker+Pre-memory+cap.png" width="320" /></a></div>
<br />
<br />
<br />
Now let’s change this limit to 200MiB of a running container.<br />
<pre>docker container update -m 200m ec6ed4af7c34</pre>
Now when we look at “docker stats” we can see in the image below the new limit on the container.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtxkdYcHVlcgdfcb2_xIx1IRr671KJJ8LJhmkNA_4Hne_QFMq29crYs2AmHC2G2w013fm2JqByPZ0jclzpCv2A06w9an6UyH8-Wu21AJmNImNh6z0lPvWblZYBXdj3dIhnsN2ZFV4917m8/s1600/Docker+post-memory+cap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="96" data-original-width="566" height="54" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtxkdYcHVlcgdfcb2_xIx1IRr671KJJ8LJhmkNA_4Hne_QFMq29crYs2AmHC2G2w013fm2JqByPZ0jclzpCv2A06w9an6UyH8-Wu21AJmNImNh6z0lPvWblZYBXdj3dIhnsN2ZFV4917m8/s320/Docker+post-memory+cap.png" width="320" /></a></div>
<br />
If you want to set the memory limit at the time of launching the container itself do it as<br />
<pre>docker run -exec -it -m 200m image-name /bin/bash</pre>
<strong>Compose file version 3</strong><br />
If you want to restrict the usage from the compose file itself you can follow below example, the redis service is constrained to use no more than 50M of memory and 0.50 (50%) of available processing time (CPU), and has 20M of memory and 0.25 CPU time reserved (as always available to it).<br />
<br />
<pre lang="none" style="background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; color: #24292e; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; line-height: 1.45; margin-bottom: 16px; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background: initial; border-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 11.9px; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">version: '3'
services:
redis:
image: redis:alpine
deploy:
resources:
limits:
cpus: '0.50'
memory: 50M
reservations:
cpus: '0.10'
memory: 20M</code></pre>
<br />
Hope this post is helpful to you. Do let me know if you have any query.Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-88973858687745660652019-07-27T17:54:00.005+05:302024-03-13T06:40:33.496+05:30AWS ECR : How to push or pull docker imageHello everyone!<br />
In this post we will see how to push a docker image to your AWS ECR and how to pull image from it.<br />
<strong>Pre-requisites:-</strong><br />
<ul>
<li>Skip this step if you already have docker on your machine. I am using “<a href="https://docs.docker.com/docker-for-windows/install/#download-docker-for-windows" rel="noopener noreferrer" target="_blank">Docker for Windows</a>” software to run dockers on my Windows 10 laptop.</li>
</ul>
If you have Windows 7 download <a href="https://docs.docker.com/toolbox/toolbox_install_windows/" rel="noopener noreferrer" target="_blank">Docker Toolbox for Windows</a> with <a href="https://www.virtualbox.org/" rel="noopener noreferrer" target="_blank">Virtualbox</a>.<br />
<ul>
<li>Get <a href="https://aws.amazon.com/cli/" rel="noopener noreferrer" target="_blank">AWS CLI</a>.</li>
<li>Create AWS IAM user from AWS console which has permission to put and delete images. You can refer sample policy below.</li>
</ul>
<pre>{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "ecr:*",
"Resource": "*"
}
]
}</pre>
Once you are done with pre-requisites let's move forward.<br />
1) Open powershell in windows or command prompt in linux. Below I'll be running command on windows powershell. But the AWS CLI command on linux are similar.<br />
In powershell check that you have docker running. It should give you an output like below.<br />
<pre>PS C:\CloudVedas> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
55f016be65aa hello-world "/hello" 2 hours ago Exited (0) 2 hours ago gifted_hamilton
PS C:\CloudVedas></pre>
2) Configure AWS CLI by entering the access key and secret key of the IAM user.<br />
<pre>PS C:\CloudVedas> aws configure
AWS Access Key ID [****************A37B]:
AWS Secret Access Key [****************W3w3]:
Default region name [ap-southeast-2]:
Default output format [None]:
PS C:\CloudVedas></pre>
3) Check if your IAM user is able to describe ECR.<br />
<pre>PS C:\CloudVedas> aws ecr describe-repositories
{
"repositories": []
}
PS C:\CloudVedas></pre>
4) Let's create an ECR repository now. You can skip this step if you already have repo.<br />
<pre>PS C:\CloudVedas> aws ecr create-repository --repository-name cloudvedas
{
"repository": {
"repositoryArn": "arn:aws:ecr:ap-southeast-2:123456789123:repository/cloudvedas",
"registryId": "123456789123",
"repositoryName": "cloudvedas",
"repositoryUri": "123456789123.dkr.ecr.ap-southeast-2.amazonaws.com/cloudvedas",
"createdAt": 1564224171.0
}
}
PS C:\CloudVedas></pre>
5) Next we will authenticate the Docker client to the Amazon ECR registry to which we intend to push our image. You will get a long <strong>docker login</strong> token as below.<br />
<pre>PS C:\CloudVedas> aws ecr get-login-password --region ap-southeast-2</pre><pre><br /></pre><pre><span style="font-family: arial;">6) Enter below the long token that you will receive in response of above command.</span></pre><pre>docker login -u AWS -p <b><token></b> https://123456789123.dkr.ecr.ap-southeast-2.amazonaws.com</pre><pre>Login Succeeded</pre>You will see "Login Succeeded" message once you are logged in successfully. Continue to Step 7 if you want to <strong>push image</strong>. Skip to step 10 if you want to <strong>pull image</strong> from ECR.<br />
<strong>Push Image</strong><br />
7) Tag your image with the Amazon ECR registry, repository, and optional image tag name combination to use.<br />
<pre>PS C:\CloudVedas> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 6 months ago 1.84kB
PS C:\CloudVedas>
PS C:\CloudVedas> docker tag fce289e99eb9 123456789123.dkr.ecr.ap-southeast-2.amazonaws.com/cloudvedas
PS C:\CloudVedas> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
123456789123.dkr.ecr.ap-southeast-2.amazonaws.com/cloudvedas latest fce289e99eb9 6 months ago 1.84kB
hello-world latest fce289e99eb9 6 months ago 1.84kB
PS C:\CloudVedas></pre>
8) Next let's push the image.<br />
<pre>PS C:\CloudVedas> docker push 123456789123.dkr.ecr.ap-southeast-2.amazonaws.com/cloudvedas
The push refers to repository [123456789123.dkr.ecr.ap-southeast-2.amazonaws.com/cloudvedas]
af0b15c8625b: Pushed
latest: digest: sha256:92c7f9c92844bb49837dur49vnbvm7c2a7949e40f8ea90c8b3bc396879d95e899a size: 524
PS C:\CloudVedas></pre>
9) We just now pushed the image. Let's check our image in ECR.<br />
<pre>PS C:\CloudVedas> aws ecr describe-images --repository-name cloudvedas
{
"imageDetails": [
{
"registryId": "123456789123",
"repositoryName": "cloudvedas",
"imageDigest": "sha256:92c7f9c92844bb49837dur49vnbvm7c2a7949e40f8ea90c8b3bc396879d95e899a",
"imageTags": [
"latest"
],
"imageSizeInBytes": 2487,
"imagePushedAt": 1564224404.0
}
]
}
PS C:\CloudVedas></pre>
Great ! We can see our image in ECR and it has a tag "latest".<br />
<strong>Pull Image</strong><br />
10) If you want to pull the image you have to follow same instruction till step 6, after that just execute below command.<br />
<pre>PS C:\CloudVedas> docker pull 123456789123.dkr.ecr.ap-southeast-2.amazonaws.com/cloudvedas:latest</pre>
Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com2tag:blogger.com,1999:blog-1215932080845832665.post-53763014321280517382019-06-23T13:51:00.000+05:302020-05-15T18:32:16.855+05:30Solved: How to lock Terraform provider versionWhile working with terraform you would have noticed that every time you execute a <em>terraform plan </em>it will download the latest version of terraform available for that provider.<br />
While this is good if you are testing as you get the latest features but, it can create trouble in production if a buggy version gets deployed. So, it is always recommended that you lock down the version of provider. In this post we will show you how to do that.<br />
It’s really very simple to lock down the provider version. You just have to add a snippet like below in your main.tf file .<br />
<br />
<div>
<pre></pre>
<pre><pre class="highlight hcl" style="background-color: #f8f8f8; border-radius: 4px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: dejavu-sans-mono-web, monospace; font-size: 0.844rem; line-height: 1.63em; margin-bottom: 16px; overflow-wrap: break-word; overflow: auto; padding: 20px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; font-family: dejavu-sans-mono-web, monospace; font-size: 0.844rem; line-height: 1.63em; overflow-wrap: normal; padding: 0px;"><span class="n" style="box-sizing: border-box;">provider</span> <span class="s2" style="box-sizing: border-box;">"aws"</span> <span class="p" style="box-sizing: border-box;">{</span>
version="<=2.6.0"
<span class="n" style="box-sizing: border-box;">region</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="s2" style="box-sizing: border-box;">"us-east-1"</span>
<span class="p" style="box-sizing: border-box;">}</span></code></pre>
</pre>
<pre></pre>
</div>
In the above example we have specified that version 2.6.0 or older can be used.<br />
The <code>version</code> argument value may either be a single explicit version or a version constraint string. Constraint strings use the following syntax to specify a <em>range</em> of versions that are acceptable:<br />
>= 2.4.0: version 2.4.0 or newer<br />
<= 2.4.0: version 2.4.0 or older<br />
~> 2.4.0: any non-beta version >= 2.4.0 and < 2.5.0, e.g. 2.4.X<br />
~> 2.4: any non-beta version >= 2.4.0 and < 3.0.0, e.g. 2.X.Y<br />
>= 2.0.0, <= 3.0.0: any version between 2.0.0 and 3.0.0 inclusive<br />
Give it a try and let us know if you have any query or suggestion.Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-86759770155492971982019-06-09T06:44:00.000+05:302020-05-10T10:27:50.987+05:30Solved: How to configure Terraform backend on AWS S3Terraform is a very useful tool for IaaS. As you would have already known that it create a .<em>tfstate</em> file to save the status of infra. If you are doing testing you can save the .<em>tfstate</em> locally on your laptop. But, if you are working in prod environment with team then it's best that you save the .<em>tfstate</em> remotely so that it's secure and can be used by other team members.<br />
Here we will show you two ways of configuring AWS S3 as backend to save the .<em>tfstate</em> file.<br />
<ol>
<li>First way of configuring .<em>tfstate</em> is that you define it in the main.tf file. You will just have to add a snippet like below in your main.tf file.</li>
</ol>
<div>
<pre>terraform {
backend "s3" {
bucket="cloudvedas-test123"
key="cloudvedas-test-s3.tfstate"
region="us-east-1"
}
}
</pre>
Here we have defined following things.<br />
<strong>bucket</strong> = The S3 bucket in which the .<em>tfstate</em> should be saved<br />
<strong>key</strong> = The name of the .<em>tfstate</em> file<br />
<strong>region</strong> = The region in which S3 backend bucket exists.<br />
<strong>2 </strong>Another way of specifying the S3 backend is that you define it when you initialize the terraform using the <em>init</em> command. This can be useful when you want to invoke the terraform from a jenkins file.</div>
<ul>
<li>Here is an example that you can execute in <strong>windows command prompt</strong>. This will do the same thing as we did in first example.</li>
</ul>
<pre>terraform init -no-color -reconfigure -force-copy -backend-config="region="us-east-1"" \</pre>
<pre>-backend-config="bucket="cloudvedas-test123"" -backend-config="key="cloudvedas-test1-win-s3.tfstate""</pre>
<ul>
<li>If you want to execute from a <strong>linux shell</strong> use below syntax.</li>
</ul>
<pre> terraform init -no-color -reconfigure -force-copy \
-backend-config="region=us-east-1" \
-backend-config="bucket=cloudvedas-test123" \
-backend-config="key=cloudvedas-test-s3.tfstate"</pre>
Give it a try and let us know in comments section if you have any query or suggestion.Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-59121317717078484622019-02-02T15:35:00.000+05:302020-04-12T07:53:35.168+05:30Solved RDS : Access denied; you need the SUPER privilege for thisoperation<p><b>Access denied; you need the SUPER privilege for this operation</b></p><p>You may get this error while trying to set values for RDS AURORA MySQL from the command line. It can be setting for long running queries or slow queries or many others.</p><p>If, you are sure you are trying to execute these changes using the master user then you can’t set these from command line.</p><p>For RDS Aurora you will have to make these changes through Parameter groups of DB and Cluster.</p><ul><li> To make the change, login to your <a href="https://console.aws.amazon.com/rds" target="_blank" rel="noopener noreferrer">AWS RDS console</a>.</li><li>On the left side panel click on Parameter Groups and select the group associated with your RDS Cluster and node.</li><li>Make changes in the parameter groups.</li><li>Once you have saved the changes in parameter group it will start applying to your RDS cluster.</li></ul><p>Some parameter changes will require reboot of your cluster while others can be done without reboot. You will see <em><strong>pending-reboot</strong></em> in your cluster if it needs reboot to change the parameter. For more details about parameter groups refer this <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithParamGroups.html" target="_blank" rel="noopener noreferrer">AWS doc</a>.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-62355154480835452372019-01-30T20:51:00.000+05:302020-05-06T08:56:44.670+05:30Solved : How to redirect non-www blogger custom domain to www with SSL<span style="font-family: inherit;">If you have added a custom domain to your blogger blog you may have noticed that when you access your domain like </span><i style="font-family: inherit;">www.example.com</i><span style="font-family: inherit;"> it works fine but if you try to access the naked domain like </span><i style="font-family: inherit;">example.com</i><span style="font-family: inherit;">(notice no www) it fails or gives SSL error. In this post we will show you how to fix this.</span><br />
<span style="font-family: inherit;"></span><br />
<a name='more'></a><span style="font-family: inherit;">Before we proceed further ensure that you have followed all steps mentioned in google support page to <a href="https://support.google.com/blogger/answer/1233387?hl=en" target="_blank">setup a custom domain</a>. </span>If you are still facing issues check below settings:-<br />
<b><span style="font-family: inherit;"><br /></span></b>
<b><span style="font-family: inherit;">Setting 1</span></b><br />
<b><span style="font-family: inherit;"><br /></span></b>
<span style="font-family: inherit;">If your website is not accessible at all on <i>example.com</i> URL you will get an error like check your internet connection or DNS error.</span><br />
<br />
For this login to your your domain provider's website like GoDaddy or BigRock and go to DNS management> Forwarding section. There you will have to add a subdomain redirection like below we did in GoDaddy website.<br />
<br />
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNdic1MHTjvxLAQ0090aYPdngwE3gV5NKUbUidW2A5QgsOwXBKMlQYTbdKNYMtMAbDnYTnZW0fADfPZu5pLMHrCtaqp4k1esBSM1Ms3sJu0Zi3di_hGEthDidaR2sUmylStymkBVMgwtid/s1600/Subdomainforwarding.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="487" data-original-width="381" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNdic1MHTjvxLAQ0090aYPdngwE3gV5NKUbUidW2A5QgsOwXBKMlQYTbdKNYMtMAbDnYTnZW0fADfPZu5pLMHrCtaqp4k1esBSM1Ms3sJu0Zi3di_hGEthDidaR2sUmylStymkBVMgwtid/s320/Subdomainforwarding.png" width="250" /></a></div>
<br />
<br />
<span style="font-family: inherit;"></span><br />
After you save this go to setting 2 of adding google IPs in your DNS provider website if you have not done that already during initial custom domain setup of blog. Else wait for 30 minutes and try to access your site on naked domain like example.com . If you are getting SSL error ensure that IP setting is done properly as described in Setting 2 below.<br />
<span style="font-family: inherit;"><br /></span>
<b>Setting 2</b><br />
<br />
Another issue that you may face is that when you try to access <i>example.com</i> you may get an SSL error while it works fine for <i>www.example.com</i> .<br />
<br />
<span style="font-family: inherit;">In this case you will have to login to your </span>your domain provider's website like GoDaddy or BigRock and <span style="font-family: inherit;">add </span>four DNS A-records which point to Google IPs . Check example below and latest IPs can be found on <a href="https://support.google.com/blogger/answer/1233387?hl=en" target="_blank">blogger support site</a>.<br />
<br />
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHbBYMfKV5aQWxmX4lhVwUqlFhNAn9sPoAc_bJBCP5BXc7GNnUKRDYykkPzOZ5OfJ-5SB87e6XNAyt3k-D8gl_kb7oLMvLal0HZF8DM4YZkPATb-GYJt3q-3UTZl-hK11MmRd3w-PG_myt/s1600/Arecord.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="221" data-original-width="814" height="105" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHbBYMfKV5aQWxmX4lhVwUqlFhNAn9sPoAc_bJBCP5BXc7GNnUKRDYykkPzOZ5OfJ-5SB87e6XNAyt3k-D8gl_kb7oLMvLal0HZF8DM4YZkPATb-GYJt3q-3UTZl-hK11MmRd3w-PG_myt/s400/Arecord.png" width="400" /></a></div>
<br />
Once you have saved this setting wait for 30 minutes, after that you should be able to reach the site on non-www domain like example.com without SSL error. To check that your domain is redirecting correctly now go to <a href="https://developers.google.com/speed/pagespeed/insights/" target="_blank">PageSpeed Insights</a> and analyze both domains <i>example.com</i> and <i>www.example.com</i>.<br />
<br />
<b>Setting 3</b><br />
<b><br /></b>
If you are still facing error login to your blogger blog and go to Settings > Basic . There in "Blog Address" section click on Edit and ensure that you have check marked on box which says "Redirect <i>example.com</i> to <i>www.example.com</i>" .<br />
<br />
That's all folks. Hope this helped you. Let's us know in comment section below if you have any query.<br />
<br />Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-80082448019256923062018-12-10T19:46:00.001+05:302020-06-15T04:03:10.467+05:30Review of 70-532 Developing Microsoft Azure Solutions Certification preparation course by Scott DuffyIn our earlier post we have described steps about how you can prepare for <a href="https://www.cloudvedas.com/review-of-70-534-architecting-microsoft-azure-solutions-certification-course-on-udemy-by-scott-duffy/" rel="noopener noreferrer" target="_blank">Architecting Microsoft Azure Solutions Certification</a>. But, if you have just started your journey in Azure than it will be a good idea to start with the Azure developer certification which is 70-532 Developing Microsoft Azure Solutions .<br />
<span style="font-size: inherit;">If you are an absolute beginner you can start with </span><a href="https://azure.microsoft.com/en-in/free/" rel="noopener noreferrer" style="font-size: inherit;" target="_blank">free Azure account</a><span style="font-size: inherit;">. It will help give a good understanding of Azure. But, be careful while using the resources because as we get free hand access to resources, we tend to spin up lot of instances and forget them running. This may end up with a huge bill. Best practice is that you </span><a href="https://docs.microsoft.com/en-us/azure/billing/billing-set-up-alerts" rel="noopener noreferrer" style="font-size: inherit;" target="_blank">setup a billing alert</a><span style="font-size: inherit;"> to avoid any shocks at month end.</span><br />
To further hone your skills you can either go for Azure classroom training or go for online courses. The classroom training will cost you from USD 800 to USD 2000. While the online courses can cost you from USD 10 to USD 300, depending on which course you choose.<br />
As mentioned in the last post since my experience with online courses was good as it give you good foundation, so I prefer to go the online way.<br />
When I started my search for a suitable course I zeroed in on <a href="https://click.linksynergy.com/link?id=ejY07iaMgRc&offerid=358574.802574&type=2&murl=https%3A%2F%2Fwww.udemy.com%2F70532-azure%2F" rel="noopener noreferrer" target="_blank">70-532 or renamed AZ-203 Developing Microsoft Azure Solutions Certification</a> course by Scott Duffy on Udemy.<br />
Scott himself is a certified architect and got a rich industry experience. Going through the course content I found that it covered almost all exam topics. Also Scott keeps on updating the content as the syllabus changes. And if you buy from Udemy you get free life time access to the course so I went with this one.<br />
As of Dec-18 the course contents 10 hours of video and a practice test. Also, you get lifetime free access to the course on Udemy.<br />
It’s a good idea to follow all the labs with the instructor and once you get confidence redo the labs independently. Don’t forget to complete the practice quizzes to check your knowledge.<br />
You can also supplement your preparation with <a href="https://click.linksynergy.com/link?id=ejY07iaMgRc&offerid=507388.1454922&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fdeveloping-microsoft-azure-solutions-70-532-practice-tests%2F" rel="noopener noreferrer" target="_blank">practice Tests for 70-532 Developing MS Azure Solutions</a> .Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-37362350212161155452018-12-01T08:28:00.000+05:302020-04-19T05:48:42.961+05:30Solved : How to simply install python pip on windows?The latest version of python is shipped with pip. But, if you are using older version of python 2(<2.7.9) or python 3(<3.4) and still need pip on windows please follow the instruction below.<br />
If pip is not installed or the path is not set correctly you will get an error like below while invoking it in windows command prompt.<br />
<pre>pip install sklearn'pip' is not recognized as an internal or external command,operable program or batch file.</pre>
<strong>Here are the steps to get pip in your windows box.</strong><br />
<ul>
<li>Download <code><a href="https://bootstrap.pypa.io/get-pip.py" rel="nofollow noreferrer">get-pip.py</a></code> . Copy and paste the contents of the link in a notepad and save it as get-pip.py, remember not in .txt format but .py format.</li>
<li>Next install it.</li>
</ul>
<pre class="lang-py prettyprint prettyprinted"><code><span class="pln">python get</span><span class="pun">-</span><span class="pln">pip</span><span class="pun">.</span><span class="pln">py</span></code></pre>
<ul>
<li>Find the recently installed pip.exe in your machine. It’s generally in C:\Python27\Scripts or similar folder depending on the python version you installed. You can set the path variable in windows using these instructions.</li>
</ul>
– Search for “Advanced System Settings” in your windows machine.<br />– Click on the tab “Advanced”. In it click on Environment Variables.<br />– In the new window click on System Variables. Select “Path” and click on “Edit”.<br />– Click on new and enter C:\Python27\Scripts\ in the space.<br />– Finally click ok to all windows and re-open command prompt.<br />
<ul>
<li>If you have followed the instructions correctly you will now be able to install packages using pip.</li>
</ul>
<pre>pip install sklearn</pre>
That’s all you need to install pip in windows.<br />
Tip:- Some people make mistake of executing pip from Python interpreter and get the below error.<br />
<br />
<pre>>>> pip install sklearn</pre>
<pre>File "<stdin>", line 1</pre>
<pre>pip install sklearn^SyntaxError: invalid syntax</pre>
<pre>>>></pre>
<br />
But, from the above tutorial you now know that pip is installed and executed from command prompt and not from the interpreter.<br />
Hope you find this simple tutorial useful. Let us know in comment section if you face any issue.Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-12691931366975533782018-08-23T16:40:00.000+05:302020-04-12T07:56:38.132+05:30Solved : How to check disk usage in windows like Linux<p>Identifying the files or directories which are hogging space in your windows machine can be very difficult specially if you have hidden files or they are in nested directories.</p><p>If you have worked on Linux you will know it has a very useful command du -sh. When i work on windows I really miss the Linux command which is very handy.</p><p>Thankfully you can find a utility at sysinternals on microsoft site which do the same job as du command in linux.</p><p>The name of utility is simply “du” and you can download it from <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/du" target="_blank" rel="noopener noreferrer">here</a> .</p><p>Once you download the utility you just have unzip it and no installation needed.</p><p>After that open the command prompt as admin user and go to the directory where you have unzipped the “du” and execute it as below to find the usage of any directory.</p><pre>du -l 1 "C:\Program Files\Microsoft SQL Server"</pre><p>It will show you usage of even the hidden files. The usage is shown in KB.</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-17764036486398808772018-08-01T17:03:00.000+05:302020-04-17T10:48:42.962+05:30Solved : Check without telnet if port is open on remote host - LinuxEarlier many system admins were using telnet to check if a port is open on remote machine. But, because of security concerns telnet is now not recommended to be installed on most linux boxes.<br />
But hey we still need to check the remote port. This is part of normal troubleshooting in a linux admin’s life.<br />
So, instead of using telnet you can use <strong>nc. netcat or nc </strong>is a simple tool which is generally installed by default in linux distributions or you can install it with instructions below.<br />
<strong style="font-size: inherit;">Ubuntu</strong><br />
<pre>$ sudo apt-get update<span style="font-size: 1rem;">$ sudo apt-get install netcat</span></pre>
<strong>Redhat or CentOS</strong><br />
<pre>yum install nc.x86_64</pre>
<strong>Amazon Linux</strong><br />
<pre> sudo yum install nc</pre>
Once you are done with installation simply run it as below:-<br />
<pre>nc -z 100.4.78.39 22</pre>
<pre>
</pre>
<pre>Connection to 100.4.78.39 22 port [tcp/ldaps] succeeded!</pre>
<pre>
</pre>
Here we can see that port 22 is open on remote server.<br />
Tip :- If you want to check the same from <strong>windows</strong> machine, follow this post on <a href="https://www.cloudvedas.com/2017/12/solved-how-to-check-remote-port-status.html" rel="noopener noreferrer" target="_blank">How to check remote port status in windows without telnet</a>.<br />
nc is a swiss knife kind of tool. It comes with very useful options. You can explore the below options also.<br />
<table border="1" cellpadding="5" cellspacing="0" class="src"><tbody>
<tr><th width="25%">Tag</th><th>Description</th></tr>
<tr valign="top"><td>–<b>4</b></td><td>Forces <b>nc</b> to use IPv4 addresses only.</td></tr>
<tr valign="top"><td>–<b>6</b></td><td>Forces <b>nc</b> to use IPv6 addresses only.</td></tr>
<tr valign="top"><td>–<b>D</b></td><td>Enable debugging on the socket.</td></tr>
<tr valign="top"><td>–<b>d</b></td><td>Do not attempt to read from stdin.</td></tr>
<tr valign="top"><td>–<b>h</b></td><td>Prints out <b>nc</b> help.</td></tr>
<tr valign="top"><td colspan="2">–<b>i</b> <i>interval</i></td></tr>
<tr><td></td><td>Specifies a delay time interval between lines of text sent and received. Also causes a delay time between connections to multiple ports.</td></tr>
<tr valign="top"><td>–<b>k</b></td><td>Forces <b>nc</b> to stay listening for another connection after its current connection is completed. It is an error to use this option without the –<b>l</b> option.</td></tr>
<tr valign="top"><td>–<b>l</b></td><td>Used to specify that <b>nc</b> should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the –<b>p</b> , –<b>s</b> , or –<b>z</b> options. Additionally, any timeouts specified with the –<b>w</b> option are ignored.</td></tr>
<tr valign="top"><td>–<b>n</b></td><td>Do not do any DNS or service lookups on any specified addresses, hostnames or ports.</td></tr>
<tr valign="top"><td colspan="2">–<b>p</b> <i>source_port</i></td></tr>
<tr><td></td><td>Specifies the source port <b>nc</b> should use, subject to privilege restrictions and availability. It is an error to use this option in conjunction with the –<b>l</b> option.</td></tr>
<tr valign="top"><td>–<b>r</b></td><td>Specifies that source and/or destination ports should be chosen randomly instead of sequentially within a range or in the order that the system assigns them.</td></tr>
<tr valign="top"><td>–<b>S</b></td><td>Enables the RFC 2385 TCP MD5 signature option.</td></tr>
<tr valign="top"><td colspan="2">–<b>s</b> <i>source_ip_address</i></td></tr>
<tr><td></td><td>Specifies the IP of the interface which is used to send the packets. It is an error to use this option in conjunction with the –<b>l</b> option.</td></tr>
<tr valign="top"><td colspan="2">–<b>T</b> <i>ToS</i></td></tr>
<tr><td></td><td>Specifies IP Type of Service (ToS) for the connection. Valid values are the tokens “lowdelay”, “throughput”, “reliability”, or an 8-bit hexadecimal value preceded by “0x”.</td></tr>
<tr valign="top"><td>–<b>t</b></td><td>Causes <b>nc</b> to send RFC 854 DON’T and WON’T responses to RFC 854 DO and WILL requests. This makes it possible to use <b>nc</b> to script telnet sessions.</td></tr>
<tr valign="top"><td>–<b>U</b></td><td>Specifies to use Unix Domain Sockets.</td></tr>
<tr valign="top"><td>–<b>u</b></td><td>Use UDP instead of the default option of TCP.</td></tr>
<tr valign="top"><td>–<b>v</b></td><td>Have <b>nc</b> give more verbose output.</td></tr>
<tr valign="top"><td colspan="2">–<b>w</b> <i>timeout</i></td></tr>
<tr><td></td><td>If a connection and stdin are idle for more than <i>timeout</i> seconds, then the connection is silently closed. The –<b>w</b> flag has no effect on the –<b>l</b> option, i.e. <b>nc</b> will listen forever for a connection, with or without the –<b>w</b> flag. The default is no timeout.</td></tr>
<tr valign="top"><td colspan="2">–<b>X</b> <i>proxy_version</i></td></tr>
<tr><td></td><td>Requests that <b>nc</b> should use the specified protocol when talking to the proxy server. Supported protocols are “4” (SOCKS v.4), “5” (SOCKS v.5) and “connect” (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.</td></tr>
<tr valign="top"><td colspan="2">–<b>x</b> <i>proxy_address[:</i> <i>port]</i></td></tr>
<tr><td></td><td>Requests that <b>nc</b> should connect to <i>hostname</i> using a proxy at <i>proxy_address</i> and <i>port</i>. If <i>port</i> is not specified, the well-known port for the proxy protocol is used (1080 for SOCKS, 3128 for HTTPS).</td></tr>
<tr valign="top"><td>–<b>z</b></td><td>Specifies that <b>nc</b> should just scan for listening daemons, without sending any data to them. It is an error to use this option in conjunction with the –<b>l</b> option.</td></tr>
</tbody></table>
Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0tag:blogger.com,1999:blog-1215932080845832665.post-73180294033053197852018-07-20T06:43:00.000+05:302020-04-12T07:58:50.089+05:30Real shell scripting interview questions<p>Q What is Shell?</p><p>Ans: Shell is a command interpreter, which interprets the command which the user gives to the kernel. It can also be defined as an interface between a user and operating system.</p><p>Q How to debug the problems encountered in shell script/program?</p><p>Ans: Two options<br />1) Execute the script as “sh -x script.sh”<br />2) Put “set -x” in the script</p><p>Q Which is the symbol used for comments in bash shell scripting ?<br />Ans:</p><p>#</p><p>Q What is the difference between = and ==?</p><p>Ans:</p><p>= -> It is used for assigning value to the variable.</p><p>== -> It is used for string comparison.</p><p>Q How to get 4th element from each line of a file ?</p><p>Ans:</p><pre>awk '{print $4}'</pre><p>Q What needs to be done before you can execute a shell script?</p><p>Ans:<br />You need to make the shell script executable using the chmod command.</p><p>This chmod command makes the shell script file “file1” executable for the user (owner) only:<br />$ chmod u+x file1</p><p>Below syntax makes it executable for all (everyone):</p><p>$ chmod a+x file1</p><p>Q How to pass argument to a script ?<br />Ans:</p><p>./script argument</p><p>Q How do you terminate an if statement?</p><p>Ans: Using “fi” . Check example below.</p><p>Q Give an example of if else statement<br />Ans:</p><pre>#Testfile.sh script to test if the file exists#!/bin/kshcvfile=$1if [ -f $cvfile ]thenecho "$cvfile exists"else"$cvfile does not exists"fiexit 0</pre><p>So you will execute the script as “./Testfile.sh file1” .</p><p>Q How to check if a directory exists?</p><p>Ans:</p><pre>if [ -d $mydir ] thenecho "Directory exists"fi</pre><p>Q How to calculate number of passed arguments ?</p><p>Ans:</p><pre>$#</pre><p>Q How to check if previous command run successful ?</p><p>Ans:</p><pre>echo $?</pre><p>If exit code is 0 it means command ran successfully</p><p>Q How to get last line from a file ?</p><p>Ans:</p><pre>tail -1</pre><p>Q How to redirect stdout and stderr streams to log.txt file from inside the script ?<br />Ans:</p><p>Add “exec >log.txt 2>&1” put this as the first command in the script</p><p>Q How to remove blank lines from a file?</p><p>Ans :</p><pre>grep -v '^</pre><p>Q Write a command to find all the files modified in less than 3 days and print the record count of each?</p><p>find . –mtime -3 –exec wc –l {} \;</p><p>Q How to find a process name from process ID?</p><p>ps -p PID</p><pre> testcv.txt > testcv2.txt</pre><p>Q Write a command to find all the files modified in less than 3 days and print the record count of each?</p><p>find . –mtime -3 –exec wc –l {} \;</p><p>Q How to find a process name from process ID?</p><p>ps -p PID</p>Saurabh Guptahttp://www.blogger.com/profile/02878420502158851553noreply@blogger.com0