Next: , Previous: , Up: Top   [Contents][Index]

3 Short introduction how to use TRAMP

TRAMP extends the Emacs file name syntax by a remote component. A remote file name looks always like /method:user@host:/path/to/file.

You can use remote files exactly like ordinary files, that means you could open a file or directory by C-x C-f /method:user@host:/path/to/file RET, edit the file, and save it. You can also mix local files and remote files in file operations with two arguments, like copy-file or rename-file. And finally, you can run even processes on a remote host, when the buffer you call the process from has a remote default-directory.

3.1 File name syntax

Remote file names are prepended by the method, user and host parts. All of them, and also the local file name part, are optional, in case of a missing part a default value is assumed. The default value for an empty local file name part is the remote user’s home directory. The shortest remote file name is /-::, therefore. The ‘-’ notation for the default method is used for syntactical reasons, Default Method.

The method part describes the connection method used to reach the remote host, see below.

The user part is the user name for accessing the remote host. For the smb method, this could also require a domain name, in this case it is written as user%domain.

The host part must be a host name which could be resolved on your local host. It could be a short host name, a fully qualified domain name, an IPv4 or IPv6 address, File name syntax. Some connection methods support also a notation of the port to be used, in this case it is written as host#port.

3.2 Using ssh and plink

If your local host runs an SSH client, and the remote host runs an SSH server, the simplest remote file name is /ssh:user@host:/path/to/file. The remote file name /ssh:: opens a remote connection to yourself on the local host, and is taken often for testing TRAMP.

On MS Windows, PuTTY is often used as SSH client. Its plink method can be used there to open a connection to a remote host running an ssh server: /plink:user@host:/path/to/file.

3.3 Using su, sudo and sg

Sometimes, it is necessary to work on your local host under different permissions. For this, you could use the su or sudo connection method. Both methods use ‘root’ as default user name and the return value of (system-name) as default host name. Therefore, it is convenient to open a file as /sudo::/path/to/file.

The method sg stands for “switch group”; the changed group must be used here as user name. The default host name is the same.

3.4 Combining ssh or plink with su or sudo

If the su or sudo option shall be performed on another host, it could be comnbined with a leading ssh or plink option. That means, TRAMP connects first to the other host with non-administrative credentials, and changes to administrative credentials on that host afterwards. In a simple case, the syntax looks like /ssh:user@host|sudo::/path/to/file. See Ad-hoc multi-hops.

3.5 Using sudoedit

The sudoedit method is similar to the sudo method. However, it is a different implementation: it does not keep an open session running in the background. This is for security reasons; on the backside this method is less performant than the sudo method, it is restricted to the ‘localhost’ only, and it does not support external processes.

3.6 Using smbclient

In order to access a remote MS Windows host or Samba server, the smbclient client is used. The remote file name syntax is /smb:user%domain@host:/path/to/file. The first part of the local file name is the share exported by the remote host, ‘path’ in this example.

3.7 Using GVFS-based methods

On systems, which have installed GVFS (the GNOME Virtual File System), its offered methods could be used by TRAMP. Examples are /sftp:user@host:/path/to/file, /afp:user@host:/path/to/file (accessing Apple’s AFP file system), /dav:user@host:/path/to/file and /davs:user@host:/path/to/file (for WebDAV shares).

3.8 Using GNOME Online Accounts based methods

GVFS-based methods include also GNOME Online Accounts, which support the Files service. These are the Google Drive file system, and the OwnCloud/NextCloud file system. The file name syntax is here always / (‘’ stands here for your Google Drive account), or /nextcloud:user@host#8081:/path/to/file (‘8081’ stands for the port number) for OwnCloud/NextCloud files.

3.9 Using Android

An Android device, which is connected via USB to your local host, can be accessed via the adb command. No user or host name is needed. The file name syntax is /adb::/path/to/file.

3.10 Using rclone

A convenient way to access system storages is the rclone program. If you have configured a storage in rclone under a name ‘storage’ (for example), you could access it via the remote file name syntax /rclone:storage:/path/to/file. User names are not needed.

Next: , Previous: , Up: Top   [Contents][Index]