I was wondering if anybody knew a command that would allow me to open a Nautilus (if that's the right name for the Ubuntu graphic/window explorer) window from the command line at the current directory that the user is at.
So, if I open a command line, and type:
cd /home/myUser/some/long/path/to/a/directoryThen, I'd like to be able to issue some command:
nautilus open-sesameAnd have a graphic window opened to /home/myUser/some/long/path/to/a/directory. Is this even possible?
6 Answers
You can type in the terminal:
cd /home/myUser/some/long/path/to/a/directoryand then:
nautilus .The above command will open nautilus in the folder /home/myUser/some/long/path/to/a/directory (the period is the current directory)
Or in the Terminal just type:
nautilus /home/myUser/some/long/path/to/a/directory 3 You can also do gnome-open .. gnome-open is similar to open on Mac which tries to open the file using the best matching application. By default, gnome-open . on Ubuntu will open the current directory in Nautilus.
There is an open command in Ubuntu as well but it does not work in this case.
In order to avoid nasty warnings in my terminal I use nohup. To have it detached from my terminal I'm adding & at the end of my command. I also use the -w flag to open in a new window.
nohup nautilus -w . &Note that, nohup will create a file with warnings.
You can send that to /dev/null like this:
nohup nautilus -w . > /dev/null &EDIT:
If you don't want to type all of this all everytime you want to open nautilus, you can make a function and place it in your .bashrc or into a file that is sourced when you open your console.
open() { nohup nautilus -w $1 > /dev/null 2>&1 &
}You could then use :
$ open path/to/open/I would prefer that over an alias as mentioned here since it allows you to specify the path to open in nautilus.
1You should use xdg-open . (or xdg-open <path>) which is way more generic.
To open nautilus from terminal.
nautilus .
To open nautilus in the background and still use the terminal.
nohup nautilus . > /dev/null 2>&1 &
You can also make that an alias.
alias open='nohup nautilus . > /dev/null 2>&1 &'
You can also add that alias to .bash_aliases, to have it persistent.
echo "alias open='nohup nautilus . > /dev/null 2>&1 &'" >> .bash_aliases
So now, after restarting the terminal, you can just type open.
I'm running Ubuntu 18.04.4 LTS and I also experienced problems with some of the popular solutions above. What is currently working for me is:
nautilus -w $(pwd)This method does not require additional installs, creating files, error handling, etc, and so appears to be the simplest.
I hope it helps!