While you can use the cd
command to navigate into folders and files, sometimes you may want to view the content of a file or a folder graphically without going through the hassle 😤 of using your GUI tools.
Today I will show you how to do that 😎. Hi, I'm Martins Ngene, A Software Engineer. I'm happy to bring you this information 🤓
So, getting started I presume you are at the home directoy in your terminal. Let's say johndoe@johndoe-HP-EliteBook-8460xx:~$
and you want to take a look at the package.json file of a project deeply nested in your projects folder located in your Desktop folder ~/Desktop/projects/blog/package.json
All you need to do is use the xdg-open
command which is installed by default in Ubuntu 22.04. You can also use it in Ubuntu 18.04, 20.04 or install it if its not available using
sudo apt-get install xdg-utils
. If you encounter any issues maybe you use a different distro, you can refer to this Stack exchange post.
Using the xdg-open
command
To use the command simply type the code below in your terminal and adjust path url to the file/folder you wish to open:
johndoe@johndoe-HP-EliteBook-8460xx:~$ xdg-open ~/Desktop/projects/blog/package.json
This opens the package.json file in your default text editor.
To open a folder:
johndoe@johndoe-HP-EliteBook-8460xx:~$ xdg-open ~/Desktop/projects/blog
This opens the blog folder with your default file manager.
An Alternative
Maybe for some reason the above tool doesn't work for your distro, you can always use an alternative.
The command below will perform the same operation:
gnome-open ~/Desktop/projects/blog
or
gio-open ~/Desktop/projects/blog
if you use a more recent
version of ubuntu.
You can download this tool using sudo apt-get install libgnome2-0
in your terminal.
I hope this helps you and feel free to share your thoughts and/or contributions in the comment section 🤗
We can connect on LinkedIn. Follow me here for more contents on proramming and software engineering.
Top comments (0)