Did you know you can simply drag and drop files and folders in terminal to print their absolute path? No? No problem! This quick tip will teach you how to quickly paste the actual path of a file or a folder in Terminal by drag and drop in Linux and Unix-like systems.
Let us say, you want to run an executable script stored somewhere in your Linux system. You can do it from command line in three ways. Move the script to your $PATH, so you can run it directly using its name. Secondly, just go to the location where you saved the script and run it. Thirdly, you can run it from anywhere by specifying its absolute path, something like
For instance, I was testing Sysmon program yesterday. At present, I launch it every time using its full path like this –
python sysmon/src/sysmon.py. It is just an example. You might often have to type the absolute path of a file or folder in the Terminal for any reason. Instead of typing the whole path manually each time, you can simply use the built-in drag and drop mechanism to print the full path of a file or folder in Terminal as shown below.
Drag And Drop Files And Folders In Terminal To Print Their Absolute Path
To print the absolute path of a file or folder in the Terminal, just drag and drop them inside the Terminal window. The full path of the dragged will instantly appear.
Print absolute path of a file by drag and drop:
Print absolute path of a folder by drag and drop:
Here is a short visual demo.
It’s quite handy, isn’t? No need to type the long path over and over. Just drag and drop the files or folders to paste their absolute path instantly in the Terminal. Hope it was useful to you too.