Linux ssh file manager

The ultimate guide to manage your files via SSH

Learning how to manage files in SSH is quite easy. Commands are simple; only a simple click is needed to run and execute.

The ultimate guide to manage your files via SSH

List of content you will read in this article:

Unsecure networks, poor connection, and slow internet have caused many problems for network administrators, website owners, etc. when managing their files remotely. Imagine transferring your website files from one server to the other. It’s almost impossible over an internet connection. It’ll take years to transfer, not to mention how insecure it would be.

This is when SSH comes in handy. Two servers (computers) can easily connect through SSH over an open network. It’ll create strong encryption that lets people transfer and manage files remotely by running commands. At first, using this protocol might be daunting; however, after a while, you’ll learn everything about SSH file management and its practical use.

This article will cover how to manage files in SSH and what commands to use. Keep reading to find out more.

What is SSH protocol?

If you are a beginner, let’s see this protocol before we learn how to manage files in SSH (Secure Shell). If you are not a beginner, feel free to scroll down to find your answers more quickly.

In simple words, SSH is a network protocol that makes an unsecured network safe to use. How? Well, it can create a secure, encrypted channel on any network you want to make it invulnerable to possible attacks. However, unlike other third-party FTP apps, SSH only operates within the command line. So. to take advantage of this protocol, use Command Prompt if your operating system is Windows. For Mac and Linux systems Terminal will do.

In Mac and Linux, SSH is a native feature you can use immediately. However, if you have Windows 10, you may need third-party apps, such as Putty, to use this feature.

How to manage files in SSH

Although you can execute countless commands in SSH, here, we’ll only lay out SSH file manager commands. Whether you want to list, create, move, edit, or delete files and folders or want to learn how to manage your archives, we’ve got you covered.

Читайте также:  Лучший консольный браузер linux

First things first! Follow these steps to access the SSH terminal or command prompt:

  1. Login to your hosting
  2. Launch SSH terminal or Command Prompt
  3. Copy your password and username
  4. Paste them on the terminal

Now, you are logged in. Based on what action you want to perform, use the below commands.

How to list and open files and folders

If you want to list all files and folders, use the ls command. It will show you all files and folders available in the root directory. Now, to change the directory and get into one of the listed folders, write the cd command, then add the folder or file name.

For example, imagine after executing the ls command, you’ll see the below list:

If you want to get to the “Gdjoslld” folder, write the following command:

After getting into “Gdjoslld,” write the ls command again to see all files and folders in Gdjoslld. Repeat the steps until you reach the file or folder you want.

How to create a folder

To learn how to manage files in SSH, you must first create folders within the command line. mkdir is used for creating folders. For example, if you want to create a folder named “Folder 1” in SSH, paste the below command:

To check whether your folder has been successfully created or not, use the ls command to see the list. Do you want to get into the folder? Easy! Run the cd Folder 1 command.

Pro tip

If you want to see where you are or ensure you are in the right folder, use the PWD command.

How to create a file

The SSH command line for creating files is:

Write the name and extension in front of the command based on what type of file you want to create, whether it’s a PHP or txt file. For instance, if you want to create File1.php, run the following command:

To see whether your file has been successfully created or not, run the ls command.

How to rename a file or folder

The mv command is used for renaming files and folders. However, the command line is slightly different depending on whether you rename a file or folder. Suppose you are renaming text-file.php to newfile.php. Use:

mv text-file.php newfile.php

So basically, you are following this structure: mv old-file-name new-file-name

It’s the same for folders without the extension part:

mv myfolder renamedfolder

By executing this command, myfolder will be renamed to renamedfolder

How to move a file

Now, you almost know how to manage files in SSH. Let’s learn a few more tricks. Moving a file to another folder has the same command as renaming files and folders. The command syntax is:

For example, if you want to move “newfile.php” to “My-folder,” run the following command:

Then use “ls” to list folders and files, run the cd My-folder command to get into My-folder, and use ls again to see whether newfile.php has been successfully moved or not.

Читайте также:  Linux which desktop manager

Moving multiple files at once

Don’t worry. It’s easier than you think. Moving multiple files follows the same command with a slight change. Name all the files you want to move and add (./) before the folder’s name.

For example, to move newfile.php and text-file.txt to My-folder, run the following command:

mv newfile.php text-file.txt ./My-folder

How to copy a file

The SSH file manager command for copying a file is cp. If you want to copy text-file.php to My-folder. Follow the cp source destination command:

How to delete a file or folder

To remove a file or folder in the SSH command line, use rm:

This command will delete the text-file.php file from the folder you are in. You can use the same for removing an empty folder. However, if you want to remove a folder and all files and subfolders inside it, use the rm -r command. For example:

How to edit a file

The next command on our “how to manage files in SSH” list is vi, which is used for editing files:

  1. Run the vi text-file.php command to open the file and write the text.
  2. Press the INSERT key on your keyboard and start writing.
  3. To exit from the editor’s mode, press the ESC key.
  4. Then press the SHIFT+: keys to get back to the command line.

Then use any of these shortcut lines to finalize your editing status:

How to run a file

Running files command depends on the type of script you are running. For instance, if you want to run a PHP script, use the following command:

How to create and extract archives

The command line will differ depending on the archive file you want to extract or create. The most commonly used archive format is tar.gz. So to archive My-folder and create an archive named newarchive, use:

tar -zcf newarchive.tar.gz My-folder/

If you want to extract an archive, look at its extension first. Then follow the below commands based on each format.

  • Zip file: unzip archive.zip
  • Tar file: tar -xvf archive.tar
  • Gz file: tar -zxvf archive.tar.gz
  • Rar file: rar x archive.rar

How to search for a file or folder

The find command searches a file or folder’s name, type, or modified time. If you want to search for the exact name of a file or folder under the current folder, run:

However, if you don’t know the exact name or want to search for a part of the name, use the following:

If you only want to find related directories, use the following:

To search for by modified time, in this case, 2 days ago, run:

How to search for a text in files

If you are looking for a specific text in the content of one of your files, use the grep command. For example, to find the “database” word in “text-file.php,” run:

grep «database» text-file.php

However, if you don’t know which file contains the “database” word, use the following command to search all files under the current directory for the text:

Читайте также:  Linux on lenovo yoga 2 pro

Bottom line

As you can see, learning how to manage files in SSH is quite easy. Commands are simple, and only a simple click is needed to run and execute them. But it is worth a try, as SSH protocol will provide a secure and fast network to get your work done.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

An SSH file manager that lets you edit files like they are local

License

allanrbo/filesremote

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

  • Edit files like local:
    • Automatically download and open files in any local editor (configurable).
    • Automatically upload when changes are detected.
    • Especially useful on slow and unstable links, where FUSE+SSHFS would cause too big of a slowdown on the local system.

    This demo illustrates the automatic upload feature:

    Mac

    Windows

    Linux

    Usage: filesremote [-h] [-i ] [-pw ] [[username@]host[:port]] -h, --help displays help -i, --identity-file= selects a file from which the identity (private key) for public key authentication is read -pw, --password= password to use for authentication and sudo (WARNING: Insecure! Will appear in your shell history!) Example: filesremote example.com Example: filesremote 192.168.1.60 Example: filesremote user1@192.168.1.60:2222 Example: filesremote 2001:db8::1 Example: filesremote [2001:db8::1] Example: filesremote [2001:db8::1]:2222 

    Defaults to your local username and port 22 if unspecified.

    On first run the app will be blocked, because I do not have an Apple Developer account. From MacOS version 13, it seems that the way to unblock it is to right click and click Open in from Applications:

    Right click and click Open in from Applications

    On MacOS versions prior to 13, unblock it in this System Preferences pages:

    Security & Privacy system preferences page

    After starting the app, go to File -> Preferences and set up the path of your text editor. For example for Sublime Text on MacOS this could be:

    Optionally make aliases for easy command line usage:

    alias filesremote="open -a FilesRemote --args $@" alias filesremote_myserver="filesremote user1@192.168.1.60" 

    About

    An SSH file manager that lets you edit files like they are local

    Источник

Оцените статью
Adblock
detector