7

I am trying to follow Introduction to bash for data analysis. It has a line of commands as: open ~/.bash_profile.

The tutorial is on Mac computers, but on the comments section it says that I can also do it on Ubuntu through VirtualBox

But this command is not recognized on Ubuntu:

the command 'Open' not working on Ubuntu Terminal

Is there any alternative on Ubuntu that I can use instead of open command?

Kulfy
  • 17,696
hmd
  • 73
  • 1
    Without context of what the command is trying to do, I'd guess you could replace "open" with "Use your favorite text editor". – ubfan1 Aug 20 '20 at 15:17
  • She responds to this question in the comments section, she intends you to just use whatever text editor you want. – WU-TANG Aug 20 '20 at 17:10
  • Another difference, due to how terminals behave and what per-user files exist by default: in Ubuntu you should rarely do anything with ~/.bash_profile. Only login shells (on either OS) use it. In macOS, Terminal.app runs bash as a login shell; GUI terminals in Ubuntu and other GNU/Linux systems do not. Also, Ubuntu doesn't already have ~/.bash_profile. If you create it, bash uses it instead of ~/.profile, which in Ubuntu has nontrivial contents you probably want run. In Ubuntu, commands you want every interactive bash shell to run should go at the end of ~/.bashrc as vanadium says. – Eliah Kagan Aug 20 '20 at 17:19

3 Answers3

9

In linux, xdg-open will open a file with the associated application.

xdg-open ~/.bashrc

will open the configuration file .bashrc located in your home folder (represented here by the shortcut notation ~/ with your default text editor.

vanadium
  • 88,010
2

You can try gedit instead. I believe what you're trying to do is opening the file in a text editor.

1

From man open on macos:

The open command opens a file (or a directory or URL), just as if you had
double-clicked the file's icon. If no application name is specified, the
default application as determined via LaunchServices is used to open the
specified files.

So what that commend is doing is just opening the file in whatever the default editor is. Since ~/bash_profile is a plain text config file, you can open it directly using whatever text editor you prefer (e.g. gedit ~/bash_profile , nano ~/bash_profile, etc.).

There are also a few options for opening with an automatic default editor

  • xdg-open
  • gnome-open

My personal preference is to be more intentional with what programs I'm using. However you can try out those options and see what works, and what works best for you.