I want the ability to restart a xorg server via simple bash script. Something like this: #!/bin/bash exec killall X exec startx  Please, do not ask me why, I am who asks.
124144
I would like to know how can I restart xorg server via simple bash script. I want to learn bash and this script will help my friend with his problem.  My friend's issue: He wanted a display manager, but does not wanted his xorg server to be run by root, and the plan was to create a bash script that kills the display manager in his case SDDM, and then, script would startx as a regular user. He is running gentoo.
116894
I want to run a command before and after every single command that gets executed in a terminal (i.e. clear before and then reset). I want this to happen automatically and not with a short alias or similar.  I have looked into bashrc and /usr/share/bash-completion/bash_completion although the latter seems to be just for the auto completion feature with the Tab?   Where should I make my changes?
11663
I am looking for a way to clean up the mess when my top-level script exits.  Especially if I want to use set -e, I wish the background process would die when the script exits.
55288
G'day,   I have tried to solve this problem all morning but have not had success. I would like to search for certain scripts in a particular folder and execute them all in parallel. The scripts have different names, but all end with "run.sh". Below what I have tried without success.   The first approach was to use find in combination with -execdir. This works, however, the scripts are executed in a sequantial fashion. I want all scripts to be executed simultaneously (parallel). There seems to be no option to achieve this with -execdir  find . -name "*run.sh" -type f -execdir 'nohup' {} '&amp;' \;   Then, I tried using xargs because there is has a parallel option (-P). I have not tried the parallel option yet, because I am unable to get xargs to run the scripts in their respective subfolders. The commands below execute all scripts, but do that in the folder I am running the command in, therefore the scripts themselves do not work. The scripts have to be executed in their own subfolders. In the above example, -execdir is doing that as opposed to -exec. How do I achieve that with xargs?  nohup find . -name "*run.sh" -type f | xargs -0 -I{} bash -c f\ \{\}   or  nohup find . -name "*run.sh" -type f | xargs -0 -I{} bash -c "f {}"   or  nohup find . -name "*run.sh" -type f | xargs -0 -I{} bash -c "./{}"    I am really frustrated and am hoping that there is somebody out there that can help.  Thank you so much!
10868
If script.sh is just something typical like  #!/bin/bash echo "Hello World!"   Is there a preferred way to run the script? I think you first have to chmod it so it becomes executable?
114013
I would like to run something like this:  bash -c "some_program with its arguments"   but to have an interactive bash keep running after some_program ends.  I'm sure -c is not a good way as man bash seys:     An interactive shell is one started without non-option arguments and   without  the  -c  option   So how to do this ?  The main goal is described   NOTE   I need to terminate some_program from time to time I don't want to put it to the background I want to stay on the bash then to do something else I want to be able to run the program again
74746
How do I reboot a Ubuntu Server from the command line? sudo reboot now never seems to work for me. Because its a server, I don't have a window manager installed, so I can't do it from a GUI (which always seems to work).    I've had the problem for years on different versions of the operating system. It happens in virtual machines and on real metal. The same problem exists with sudo shutdown now, too.  I've lived with it in the past. The difference now is I don't want to just hit the power button because I might lose data.
64676
I want to start an Xorg server (which should only feature a minimal xterm terminal emulator from a newly created &quot;pristine&quot; tty). I have thought this to be as simple as issuing a xinit or maybe a startx however both have failed me. Therefore the question: How to manually run/init/start a Xorg server on a different VT/TTY? here the Longer background story to the question at hand: This is the backgroud and what I have tried already: Looking at man openvt I was able to run a shell on a newly created tty (or vt, cannot tell precisly the different vt&lt;&gt;tty) like this:  $&gt; sudo openvt -s /bin/bash  the -s of causes the direct switch to that new tty/vt on that new tty I wanted to manually start a Xorg server which according to man xinit should start with a minimal xterm application. On the new shell on the switched to tty I (created via openvt) I hence issues this command:  $&gt; su -c 'xinit xterm -display :4 -- :4' - mahr &amp;&gt;/tmp/output  and I receive this output $&gt; cat /tmp/output X.Org X Server 1.19.6 Release Date: 2017-12-20 X Protocol Version 11, Revision 0 Build Operating System: Linux 4.4.0-148-generic x86_64 Ubuntu Current Operating System: Linux scitech 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 Kernel command line: BOOT_IMAGE=/vmlinuz-4.15.0-70-generic root=/dev/mapper/ubuntu--vg-root ro Build Date: 03 June 2019  08:10:35AM xorg-server 2:1.19.6-1ubuntu4.3 (For technical support please see http://www.ubuntu.com/support)  Current version of pixman: 0.34.0     Before reporting problems, check http://wiki.x.org     to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting,     (++) from command line, (!!) notice, (II) informational,     (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: &quot;/home/mahr/.local/share/xorg/Xorg.4.log&quot;, Time: Thu Nov 28 10:57:53 2019 (==) Using system config directory &quot;/usr/share/X11/xorg.conf.d&quot; (EE)  Fatal server error: (EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied) (EE)  (EE)  Please consult the The X.Org Foundation support       at http://wiki.x.org  for help.  (EE) Please also check the log file at &quot;/home/mahr/.local/share/xorg/Xorg.4.log&quot; for additional information. (EE)  (EE) Server terminated with error (1). Closing log file.  Session terminated, terminating shell...xinit: giving up xinit: unable to connect to X server: Connection refused xinit: unexpected signal 2  ...terminated.
10766
Can I make a bash command line that only runs a certain command if the process is not already running (in the background)?  How do I check*, if a command is already running?  (so I can add the next command with &amp;&amp; in between them so the next one only executes if the first one is true).  *: test, determine, discover, find out
50840
I want to do such as following:  #!/bin/bash command1 pause 30 seconds command2 exit   This is only example script with pause of 30 seconds between run of 2 command.  How to do this?
81080
I'm creating a simple bash script and I want to create a select menu in it, like this:  $./script  echo "Choose your option:"  1) Option 1   2) Option 2   3) Option 3   4) Quit     And according to user's choice, I want different actions to be executed. I'm a bash shell scripting noob, I've searched the web for some answers, but got nothing really concrete.
101499
How do I stop/start ssh? I've tried   /etc/init.d/ssh restart sudo service ssh restart sudo restart ssh   I get errors every time.
58375
So when i try to use the Xorg command as a normal user, this is the error that it gives me :   /usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server   but i don't understand, what are the "console users"?  and when i switch to root it gives me another error :   _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed _XSERVTransMakeAllCOTSServerListeners: server already running (EE)  Fatal server error: (EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)  (EE)  Please consult the The X.Org Foundation support       at http://wiki.x.org  for help.  (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information. (EE)  (EE) Server terminated with error (1). Closing log file.   So what is going on and what are the reason for each of these errors?   UPDATE: and the output of the command netstat -ln | grep -E '[.]X|:6[0-9][0-9][0-9] is :  unix  2      [ ACC ]     STREAM     LISTENING     18044    @/tmp/.X11-unix/X0 unix  2      [ ACC ]     STREAM     LISTENING     47610    @/tmp/.X11-unix/X1 unix  2      [ ACC ]     STREAM     LISTENING     18045    /tmp/.X11-unix/X0 unix  2      [ ACC ]     STREAM     LISTENING     47611    /tmp/.X11-unix/X1
36270
Is there a script or a way in linux that when I try to execute a shell script/process, if the same is running, it will prompt that same is running and will exit otherwise it will continue.
104543
I'm trying to build a process container. The container will trigger other programs. For example - a bash script that launches running background tasks with '&amp;' usage.  The important feature I'm after is this: when I kill the container, everything that has been spawned under it should be killed. Not just direct children, but their descendants too.  When I started this project, I mistakenly believed that when you killed a process its children were automatically killed too. I've sought advice from people who had the same incorrect idea. While it's possible to catch a signal and pass the kill on to children, that's not what I'm looking for here.  I believe what I want to be achievable, because when you close an xterm, anything that was running within it is killed unless it was nohup'd. This includes orphaned processes. That's what I'm looking to recreate.  I have an idea that what I'm loooking for involves unix sessions.  If there was a reliable way to identify all the descendants of a process, it would be useful to be able to send them arbitrary signals, too. e.g. SIGUSR1.
104056
I'm trying some things with my shell. This includes the following command:  kill $$  My expectation was that the shell would log me out and terminate itself. But instead the bash persists without change.   Any idea why?  I ran this command on different environments (archlinux, debian). The behavior was always the same.
35519
Is there any way to make/run a bash script on reboot (like in Debian/Ubuntu for instance, since thats what my 2 boxes at home have)  Also, any recommended guides for doing cron jobs? I'm completely new to them (but they will be of great use)