Blog → Post


(TIP) CLI Tips
Command line tips
by @admin, june 08, 2021, 12:30pm utc

This is just a short tip to break down this command line syntax,
home:~$ (jedit the_code.py & disown); in case you run into this type of thing.
So then, let's just see what all of the "(", ")", "&" and "disown" stuff is all about.

The main part of the above command is the loading of a file (the_code.py) into a graphical (GUI) editor (jedit).
home:~$ jedit the_code.py
As you get more experienced with Linux, this is definitely something that you will want to do, as it saves you from digging through menus just to quickly run a GUI app.

This works just fine and dandy -- but it "hooks" jedit to your terminal.
Your terminal will receive any text messages put out by jedit; and closing the terminal will also close jedit as well. Worse, you can not run anything else in the terminal until jedit is closed.

All of this is true regardless of what GUI app that you run in this way.


If we add "& disown" to the command: home:~$ jedit the_code.py & disown it does the same as above, except that jedit is "detached" from the terminal. You can then close the terminal by typing exit or clicking/tapping the close button(s) at the top. jedit will continue running without the terminal.

If you do leave the terminal open; the terminal may still get a stream of messages from the disassociated application. This might be things like non-critical errors, warnings, or recommendations. So, the GUI app is still a little associated to the terminal, if only as a place to dump non-critical messages.

To most users, who might just be using the terminal to do other work; these messages can be annoying.


That brings us to wrapping the whole command in parenthesis, like so: home:~$ (jedit the_code.py & disown)
This does everything the above commands do -- but also suppresses those diagnostic messages that may get dumped to the terminal from the GUI app.

ps.
A reminder that "&&" allows you to string together CLI commands.
So,this → home:~$ jedit the_code.py & disown && exit
Runs jedit, dissociates the running jedit from the terminal AND then closes the terminal. This leaves just jedit running and loaded with the file to edit.

In a similar fashion clear && jedit first clears the terminal screen and then runs jedit.

tags: All users, Tips
Footer done in Inkscape