What happens when I use stop command without any args? - linux

I just accidentally typed stop instead of exit in a bash script. When I execute it my Xubuntu went to the login screen and when I logged in, everything was closed and it was like I just started the computer.
I then went to my Ubuntu on a virtual box and executed stop in the terminal. Then some windows was closed and some frames around other windows disappeared.
I'm a Linux noob but when I looked at the stop command info it looks like you need to have an argument to use the stop command.
Is this just a bug or is this supposed to happen? If it's supposed, then I'm really curious of whats happening. My guessing is that it will try to kill all ongoing processes.
I'm new here so I hope this it not a stupid question and its really hard to google on a common word like stop :/

man stop should tell you what it does. E.G. http://manpages.ubuntu.com/manpages/precise/en/man8/stop.8.html
I think it should tell you it needs an argument for a name of a job to stop.
However it appears from what you describe that it's stopping the X11 window manager?

Related

Autostart GUI application with LXDE session

There's quite a bit of information out there on this topic, but for some reason I just can't get it to work. This is on a raspberry pi running the 'DietPi' flavor over the raspian distro, and is perhaps what separates my question from the others.
So I have a GUI application that I wish to launch at boot, after the LXDE session has begun. So I have utilized the following file here:
/etc/xdg/lxsession/LXDE/autostart
and added the line:
#/myapplication
This works, however, it launches multiple instances of this program, and the first one always crashes. This creates problems because there's some competition for resources (IO, files, etc). So what I did was create script file, /myapplication-autostart.sh instead like so:
if pgrep "myapplication" > /dev/null
then
echo "my application is already running"
else
/myapplication
fi
and then changed /etc/xdg/lxsession/LXDE/autostart to #/myapplication-autostart.sh. Now what I find is the program launches once, but the instance crashes. It crashes when it attempts to create a window (opencv imshow). This is strange because the program will also run headless if an X-session is not available, but for some reason it crashes and I do not know where to check why.
Also, to test it wasn't an issue with the script file, I commented everything out except the /myapplication and I have found the script file runs in a continuous loop and every time I close the application it opens back up. I'm not sure why this is either.
I've tried adding a sleep delay in the script and it does not help. For whatever reason, it seems the LXDE autostart script is ran at least 3 times when booting the pi and the circumstances around the first cause the program to crash. Does anybody understand this sequence and behavior of calling this autostart script?
It is also possible to use the XDG standard Autostart - which is independent of the used desktop environment - by placing desktop files at
$XDG_CONFIG_HOME/autostart (by default ~/.config/autostart)
or for system-wide autostarts at $XDG_CONFIG_DIRS/autostart (by default /etc/xdg/autostart).
Such a .desktop-file could look like:
[Desktop Entry]
Type=Application
Version=1.0
Name=JDownloader
Exec=/usr/local/bin/my-application.sh
Categories=Utilities
The specification of desktop-files can be found at freedesktop.org.
Here was the final solution...
/etc/xdg/lxsession/LXDE/autostart added the line:
/myapplication-autostart.sh
and /myapplication-autostart.sh was changed to:
#!/bin/bash
if pgrep "myapplication" > /dev/null
then
echo "my application is already running"
else
if [[ "$DISPLAY" = ":0" ]]
then
/myapplication
fi
fi
I had to write the display variable to file in combination with the errors to file to discover the issue. At login 2 X sessions were created, display ":1" and display ":0", in that sequence. Display ":1" crashed because, although not headless, it was not initialized to a particular resolution and there was some resizing code in my program. Display ":0" was the actual display on the HDMI out and the one I wanted. Really, the conditional check to see if the application isn't necessary but I left it in there to be safe. I could have also left the # on the LXDE autostart file but it got annoying in the cases I wanted to close the application because it'd keep re-opening. Possibly I'll put it back later.
Thanks for the help!
First, some comments about opening several instances of the program: when you use "#" at the beginning of the line on the startup file (ex.: #/myapplication), this requests your system to try to launch the program, but if the program fails to open correctly, then the system will try to open it multiple times until it opens correctly -- if you remove "#" from the line beginning, then the system will only try to open the program once.
Now, to find out why the program is failing, I advise you to add
2> /file/log
to the end of every command on your script. Doing so would append any error message to a log (/file/log), and analyzing those error messages would be key to find out why the program is misbehaving.
One important note: if your program needs root privileges to run, then it will fail when called via /etc/xdg/lxsession/LXDE/autostart, as this method calls programs without elevated permissions.
This is an old thread but I was having problems getting autostart to start all the tasks listed. After many days I concluded there were one or more "invisible" characters that autostart didn't like. So I deleted the lines for the tasks that didn't start and retyped them. That solved the problem!
I think I corrupted the lines because I was editing some of the lines on my Windows computer. It was likely inserting CR with LF or some other stuff. I WILL NEVER EDIT TEXT FOR LINUX USING WINDOWS!
Maybe someone else will hit this problem and this may help them. I don't know where else to put this information.

Running a program in linux (debian) on startup

I would like to point out that I tried A LOT of different tutorials from the internet but they don't seem to work...
Adding stuff to init.d, rc.local etc. for some reason it doesn't work.
I'm really desperate to get this done, but I'm a total noob when it comes to linux.
when I type in "matchbox-keyboard" it runs just fine and as intended.
That's literally all I want, but I'd like to run it every time so when I turn my raspberry pi on, I won't have to connect a keyboard and a mouse to initialize on-screen keyboard.
Is there a simple way to get this done, something like dropping the program into autostart folder in windows?
I have no experience with linux at all, I don't know how to write scrips and all that stuff and all I want is to run this "matchbox-keyboard" after every reboot...
Please help me, I'm really desperate and I can't figure it out. Spent all day doing it and still nothing...
The simplest way is to drop in a new cronjob (a cronjob is a task that is scheduled to run at a particular time):
crontab -e
This allows you to edit your cron file. Instead of putting in a time, use #reboot. So you should have a new line in your cronjob file that looks like this:
#reboot matchbox-keyboard
The cronjobs run in a different environment from your login environment, so you may need to use the full path to the program. I'm also not familiar with the matchbox-keyboard program, but it looks like it will run fine since it can run as a background process.
Maybe you have gnome-tweaks installed?
apt list gnome-tweaks
Listing... Done
gnome-tweaks/stable,now 3.30.2-1 all [installed,automatic]
It has a graphical Startup Applications function that allows you to select application icons and start them at LOGIN time. I use it to start my favorite text editor.
Starting things like an Apache server (e.g. XAMPP) at BOOT time is a whole new ball game. I used this link as a starting point.

How to reenter Linux process after closing putty

I'm new to Linux.Yesterday I wrote some Python codes,now I'm using Linux to execute my codes,it may take a few hours. As my Linux is not native,it's a remote server,I use putty to connect to it.
Now ,I want to close putty and go to sleep.But I don't know how to find my process again and reenter it after I wake up and start putty.And also,I wrote some code to print progress rate,next time when I find the process,can I see the print info again?
Run screen, start your programm and close the connection. After logging in again, use screen -r to resume your session.
Alternatively nohup will do the trick.
screen is the best built-in tool that's always available for that, although it gets a bit weird around keyboard shortcuts, some of which sometimes don't work the way you want exactly.
I've found tmux to be much better in terms of usability.
Alternatively. take a look at mosh, which is trying to replace ssh. It's a mobile shell tool from MIT that supports intermittent connectivity, lots of praise there.

Cannot enter long commands in terminal

I am using putty (0.64.0.0 2015) to access the terminal on an AIX server. Normally typing long commands works just fine but somehow something weird happened and when I type long commands Linux cursor goes back on the same line even behind the 'bash' word.
In order to explain the problem I have a picture. Just to explain in the picture I start with capital 'ABC' then '1-10' and then small 'abc' and then repeat this sequence to simulate a long command.
Can anybody please explain why this is happening (it has also happened before) and how to solve it without restarting putty? Does it have to do with a buffer of some kind since the command runs just fine it is only that it looks like this in the picture.
It looks like your shell is no longer aware of its terminal's dimensions. Perhaps you've resized the PuTTY window after logging in?
Sometimes resize will fix such issues.

Bash Console commands (Codeship console): how to exit from current "inputs"

Excuse me for the imprecisions in the question but I don't know how it is called what I'm trying.
In the CodeShip documentation is stated that I can pass to the SSH CodeShip debug build some commands using their command line application.
So, I should do something like cs setup-commands and I'm prompted with this:
rof#railsonfire_unique_string_sfivbe8bwucb9:~$ cs setup-commands
Your setup commands:
phpenv local 5.6
phpenv local 5.6
In Your setup commands: I put my commands but then, how can I "execute" them?
The second phpenv local 5.6 line is wrote by the command-line application. I think is something to signal the command were taken, but the behavior is ever the same: I remain "blocked" in the command setup-commands. After setting setup-commands I have to set also test-commands but all the things I write are taken by Your setup commands:.
How can I "submit and exit" the command setup-commands to then launch test-commands and set those other commands?
I think this is something related to Bash, but I don't know what it is...
And I don't know which is the correct terminology.
Can someone help me with this? So I will can also update my question to be more precise. Thank you.
Not sure about your case, but usually the input is considered finished, when th input file (in your case stdin) is closed.
Try to press Ctrl+D, it should end your input (and so signal the program hat you stopped typing for this session)

Resources