{"id":1619,"date":"2023-10-13T17:42:11","date_gmt":"2023-10-13T12:12:11","guid":{"rendered":"https:\/\/www.veeble.org\/kb\/?p=1619"},"modified":"2025-03-26T10:00:35","modified_gmt":"2025-03-26T04:30:35","slug":"creating-editing-file-via-ssh","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/creating-editing-file-via-ssh\/","title":{"rendered":"How to Create, Edit, Delete File via SSH?"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"489\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-scaled.jpg\" alt=\"file ssh\" class=\"wp-image-6809\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-scaled.jpg 2560w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-300x57.jpg 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1024x196.jpg 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-768x147.jpg 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1536x294.jpg 1536w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-2048x391.jpg 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/figure>\n\n\n<h4 class=\"wp-block-heading\" id=\"introduction\">Introduction<\/h4>\n\n\n<p>Hello! \ud83d\ude80 If you find yourself needing to create or edit a file on a remote server, using <a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Shell\" target=\"_blank\" rel=\"noopener\">SSH<\/a> (Secure Shell) is a fabulous way to do it securely. This guide will lead you on a journey through creating and editing files remotely, ensuring that even beginners can get a grasp of it.<\/p>\n\n\n\n<p><em>Before embarking on this SSH journey, ensure you\u2019re equipped with some fundamental insights into basic Linux commands, which will be pivotal for navigating through our guide &#8211; you can brush up on these essentials with this handy <a href=\"https:\/\/www.veeble.org\/kb\/linux-commands-gist\/\" target=\"_blank\" rel=\"noopener\">Linux Commands Gist<\/a>!&#8221;<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"section-1-preparing-to-ssh-into-your-server\">Section 1: Preparing to SSH into Your Server<\/h4>\n\n<h5 class=\"wp-block-heading\" id=\"11-understand-ssh\">1.1. Understand SSH<\/h5>\n\n\n<p>SSH allows you to access and control a remote server. In simple terms, it\u2019s like having a chat with your distant server securely!<\/p>\n\n\n<h5 class=\"wp-block-heading\" id=\"12-acquiring-the-credentials\">1.2. Acquiring the Credentials<\/h5>\n\n\n<p>To chat (connect) with your server, you\u2019ll need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>IP Address<\/strong>: A unique address to identify your server.<\/li>\n\n\n\n<li><strong>Username<\/strong>: Your server account name.<\/li>\n\n\n\n<li><strong>Password<\/strong>: Your secret key to enter the server.<\/li>\n<\/ul>\n\n\n<h5 class=\"wp-block-heading\" id=\"13-using-an-ssh-client\">1.3. Using an SSH Client<\/h5>\n\n\n<p>Utilize software like <a href=\"https:\/\/www.putty.org\/\" target=\"_blank\" rel=\"noopener\">Putty<\/a> (Windows), <a href=\"https:\/\/support.apple.com\/en-in\/guide\/terminal\/welcome\/mac\" target=\"_blank\" rel=\"noopener\">Terminal<\/a> (Mac), or <a href=\"https:\/\/www.gnu.org\/software\/bash\/\" target=\"_blank\" rel=\"noopener\">Shell<\/a> (Linux) to initiate the conversation!<\/p>\n\n\n\n<p><em>Now, with our credentials and SSH client ready, let\u2019s establish our connection and dive into file management!<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"section-2-establishing-the-ssh-connection\">Section 2: Establishing the SSH Connection<\/h4>\n\n<h5 class=\"wp-block-heading\" id=\"21-connecting-to-the-server\">2.1. Connecting to the Server<\/h5>\n\n\n<p>Input this simple command, replacing the placeholders with your details:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">ssh [username]@[IP address]<\/pre>\n\n\n\n<p>When prompted, enter your password.<\/p>\n\n\n<h5 class=\"wp-block-heading\" id=\"22-navigating-directories\">2.2. Navigating Directories<\/h5>\n\n\n<p>Use these friendly commands:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ls<\/code>: To see your files.<\/li>\n\n\n\n<li><code>cd [directory name]<\/code>: To move into a directory.<\/li>\n\n\n\n<li><code>cd ..<\/code>: To step back to the previous directory.<\/li>\n<\/ul>\n\n\n\n<p><em>Now that you&#8217;re connected and can move around, let\u2019s create a new file!<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"section-3-creating-a-file-with-ssh\">Section 3: Creating a File with SSH<\/h4>\n\n<h5 class=\"wp-block-heading\" id=\"31-utilizing-touch\">3.1. Utilizing Touch<\/h5>\n\n\n<p>The <code>touch<\/code> command swiftly creates a new, empty file. Simply:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">touch [filename]<\/pre>\n\n\n<h5 class=\"wp-block-heading\" id=\"32-using-nano-vi-or-vim\">3.2. Using Nano, Vi, or Vim<\/h5>\n\n\n<p>Pick an editor of your choice: <a href=\"https:\/\/www.nano-editor.org\/\" target=\"_blank\" rel=\"noopener\">nano<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Vi\" target=\"_blank\" rel=\"noopener\">vi<\/a>, or <a href=\"https:\/\/www.vim.org\/\" target=\"_blank\" rel=\"noopener\">vim<\/a>, and create a file by typing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">nano [filename]<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">vi [filename]<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">vim [filename]<\/pre>\n\n\n\n<p><em>The file is created! \ud83c\udf89 Let&#8217;s explore how to add content to it.<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"section-4-editing-a-file-via-ssh\">Section 4: Editing a File via SSH<\/h4>\n\n<h5 class=\"wp-block-heading\" id=\"41-basic-text-editing\">4.1. <strong>Basic Text Editing<\/strong><\/h5>\n\n\n<p>After creating a file using an editor, simply start typing to add content. For structured editing:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nano: Use arrow keys to navigate.<\/li>\n\n\n\n<li>Vi\/Vim: Press <code>i<\/code> for insert mode. Use arrow keys to navigate.<\/li>\n<\/ul>\n\n\n<h5 class=\"wp-block-heading\" id=\"42-saving-and-exiting\">4.2. <strong>Saving and Exiting<\/strong><\/h5>\n\n\n<p>After editing:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In Nano: Press <code>CTRL + X<\/code>, then <code>Y<\/code> to confirm, and <code>Enter<\/code> to exit.<\/li>\n\n\n\n<li>In Vi\/Vim: Press <code>Esc<\/code>, type <code>:wq<\/code>, and hit <code>Enter<\/code>.<\/li>\n<\/ul>\n\n\n<h5 class=\"wp-block-heading\" id=\"43-deleting-a-file\">4.3. <strong>Deleting a File<\/strong><\/h5>\n\n\n<p>In case you wish to remove a file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-small-font-size\">rm [filename]<\/pre>\n\n\n\n<p><em>With these file management skills, you\u2019re now empowered to manage files smoothly via SSH!<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"section-5-troubleshooting-common-issues\">Section 5: Troubleshooting Common Issues<\/h4>\n\n<h5 class=\"wp-block-heading\" id=\"51-connection-issues\">5.1. <strong>Connection Issues<\/strong><\/h5>\n\n\n<p>Ensure IP, username, and password are correct. Check your internet and server status.<\/p>\n\n\n<h5 class=\"wp-block-heading\" id=\"52-permission-denied\">5.2. <strong>Permission Denied<\/strong><\/h5>\n\n\n<p>If you see this, it might be that your user doesn\u2019t have the right access. Use <code><a href=\"https:\/\/www.veeble.org\/kb\/disabling-root-login-and-creating-a-sudo-user-for-strengthening-vps-security\/\" target=\"_blank\" rel=\"noopener\">sudo<\/a><\/code> for superuser privileges or consult your admin.<\/p>\n\n\n<h5 class=\"wp-block-heading\" id=\"53-lost-changes\">5.3. <strong>Lost Changes<\/strong><\/h5>\n\n\n<p>If changes are lost, ensure you\u2019re saving correctly and back up important data regularly.<\/p>\n\n\n\n<p>Transition Note: Troubleshooting can be a lifesaver when in a pinch, but always remember to act carefully to avoid issues in the first place!<\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h4>\n\n\n<p>Managing files via SSH might seem like a journey full of cryptic commands at first, but with practice, it becomes a walk in the park! \ud83c\udf33 Remember: Connect, Navigate, Create, Edit, and always Save. Happy SSH-ing, and may your files always be in order! \ud83d\udc69\u200d\ud83d\udcbb\ud83d\ude80<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Ensure you adhere to best practices and prioritize security (like using secure passwords and possibly, <a href=\"https:\/\/www.digitalocean.com\/docs\/ssh\/create-ssh-keys\/\" target=\"_blank\" rel=\"noopener\">SSH keys<\/a> for authentication) while dealing with servers and SSH. Always keep learning and exploring more advanced functionalities as you become comfortable with the basics!<\/pre>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-aeb24c3e wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Reliable Hosting Solutions<\/h3><p class=\"uagb-cta__desc\">Trust in our dependable cPanel hosting. We provide a stable and secure environment for your website, ensuring minimal downtime. Enjoy peace of mind with our expert support.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/cpanel-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Explore cPanel Plans<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Also Read:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-veeble-hosting wp-block-embed-veeble-hosting\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"tI3M1sz0RT\"><a href=\"https:\/\/www.veeble.com\/kb\/ssh-login-without-password\/\">SSH login without password<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;SSH login without password&#8221; &#8212; Veeble Hosting\" src=\"https:\/\/www.veeble.com\/kb\/ssh-login-without-password\/embed\/#?secret=N2kfMu0sz1#?secret=tI3M1sz0RT\" data-secret=\"tI3M1sz0RT\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Hello! \ud83d\ude80 If you find yourself needing to create or edit a file on a remote server, using SSH (Secure Shell) is a [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":8308,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1619","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1.jpg",1366,768,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1-768x432.jpg",768,432,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1.jpg",1366,768,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2023\/10\/How-to-Create-Edit-Delete-File-via-SSH-1.jpg",1366,768,false]},"uagb_author_info":{"display_name":"Adrian Antony","author_link":"https:\/\/www.veeble.com\/kb\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"Introduction Hello! \ud83d\ude80 If you find yourself needing to create or edit a file on a remote server, using SSH (Secure Shell) is a [&hellip;]","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=1619"}],"version-history":[{"count":16,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1619\/revisions"}],"predecessor-version":[{"id":8174,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/1619\/revisions\/8174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/8308"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=1619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=1619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=1619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}