It seems like these random executions could be carried out by even the lowest ranked soldiers. Did the commanders of these soldiers encourage acts like these or were there limits to when and where prisoners could be shot?
The problem with camps was a lack of oversight once the initial responsibilities had been established. Meaning the answer to this question depends largely on who the camp commandant was and how tight a ship they wanted to run.
Let's start, not with concentration camps, but with Soviet POW camps. Soviet POWs were kept in horrible conditions, and German guards often tormented them. A common practice was siccing guard dogs at prisoners and betting on which dog would do the most damage. Guards also liked to use Soviet POWs for "target practice." So needless to say random killings of prisoners was a common practice, at least among certain aspects of the army.
Now moving to camps, as said above it depended on the camp commandant. Majdanek stands out in this regard. It's two successive commandants, Karl Koch and Hermann Florstedt, stole from the camp massively and instituted a regime of terror in the camp. It became notorious for its corruption and brutality at every level. So in this case random murders of inmates was a common feature of life in the camp. The guards were also Romanian and Croatian, they developed a reputation for savage cruelty and brutality, as well as being difficult to control. Eventually both Koch and Florstedt were arrested for wastefulness. Koch was particularly famous for an event, where in he selected a group of Jews marched them in front of a gate and had them executed; later claiming they tried to "escape."
So there wasn't a time when you could just kill whenever you wanted, but if a guard did just randomly execute an inmate, depending on the camp the punishment would range from nothing, to a slap on the wrist. Radicals on the bottom worked to satisfy the whims of those at the top. Take low ranking SS lackey Gustave Sorge. He enjoyed beating defenceless prisoners to death in Buchenwald. He later would testify: "We believed that we were helping state and leadership when we abused prisoners and drove them to their deaths."
This violence wasn't just during the later periods either. In early 1933, when groups of Jews were temporarily sent to Dachau, hundreds died from abuse/murder by the guards despite the Nazis not yet wanting to kill Jews. Another example is the case of four Jews in Dachau, Erwin Kahn, Rudolf Benario, Ernst Goldmann, and Arthur Kahn. They were made an example of by the newly inaugurated SS leadership. However, the SS commandant had worked his men into a frenzy, and one day a group of SS guards took it upon themselves to lead the 4 Jews out to the woods and execute them. A wave of killings by power hungry SS guards followed after that.
Here is what a Czech prisoner, named Karel Kašák, wrote in his observations while spending time in one of the camps:
May 9 [1941]. Again a Jew shot in Freiland II. He started to run. The sentry told us that although he has instructions to shoot without warning, he shouted twice. The [prisoner] stopped and just exclaimed: “I want to go there” and fell after two shots … Again they have put a group of lifeless and unconscious Jews on the cart. Human flesh, the bodies of these sons of God, stacked like logs, arms and legs swaying limply—a horrendous picture that we witness daily …
May 14. In the afternoon they again shot a Jew in Freiland II …
May 15. Again a Jew shot. They threw his cap behind the sentry and the Kapo forced him with a truncheon to fetch it. Complete exhaustion has made [the Jewish prisoners] unrecognizable, like in a trance, with a far-away gaze …
May 16. At nine in the morning two more Jews shot in Freiland II. They threw the exhausted men into the water and held them under water until they had almost lost consciousness, and definitely lost their minds, and Kapo Sammetinger hit them with the spade until he had forced them to cross the sentry line, whereupon they were immediately shot.
Now Ghettos were worse for this type of behaviour. The liquidation of the Ghettos was an orgy of violence. In one roundup in the Warsaw Ghetto during 1942, 10,000 people were shot. Mostly because the soldiers later claimed they were "resisting" or they were trying to send a message to get the other Jews moving faster. A similar story is told in other ghettos. In Luniniec ghetto around 2000 were shot during the liquidation. During the liquidation of Yanov another 2000 were shot. Liquidations were never pretty, and by their nature very chaotic.
A source I would recommend if you want some reading. Check out KL: A History of the Nazi Concentration Camps by Nikolaus Wachsmann.
It highly depends on the camp and you cannot really generalize it. I did some research and some (pregrad) papers on the Mauthausen concentration camp ( http://en.mauthausen-memorial.at/index_open.html ), which was one of the worst ones (but not as horrible as Auschwitz).
Mauthausen itself also went through different phases ... in the beginning it was meant as a work camp with "only" the ones who were not able to work any more being murdered, but over the time it basically changed into a death-camp where the guards were basically allowed to do whatever they want with them (it's recorded that they led them outside in the winter to shower with cold water and then let them freeze). In the sub-camps (those were camps that were basically founded to give companies that helped the Nazi government) there was an astonishingly high survival rate and the prisoners actually did not get shot or tortured, but what happened often is that the ones who were weak or old were deported to the main camp in Mauthausen to die.
So yeah as very often in history I would say the answer to your question is: partially.
Sorry if it is written in a confusing way ... pretty much everything I have done about this topic was in German. If you have any specific questions I will try to answer in more detail.
Sid_Burn's answer is great.
Just want to add that it also VERY much depends on the year. The regime radicalized after 1936, and especially after 1939/40. And this meant that commandants, police supervisors, etc., who may have been more "legalistic" and kept a fairly tight reign over their men--not uncommon in 1934--were often eased out, replaced by more radical (and brutal) officials in the late '30s, and especially after the war began. Some of this radicalization was due to the internal politics of the SS, under Himmler.
But most importantly, as the complexion of the camps changed, so too did the "allowable" treatment of prisoners change.
To give a famous example: Dachau. Dachau was established right after Hitler came to power, in 1933. Originally, in 1933-34, it held mostly socialists and communists (rounded up after the Reichstag Fire, in a massive purge of the left.) Many of these Socialists were only interned in Dachau for a few months--they were released (with the threat of a return always hanging over their heads, ensuring their good behavior).
After 1936, more so-called "undesirables" were sent there, such as homosexuals, criminals, vagrants & beggars (rounded up during the pre-Olympics sweep), and Jehovah's witnesses. These non-political prisoners made up more than 50% of the camp population by 1936; they were generally NOT released, and treatment of them was far harsher.
In 1938, in the days after the mass-arrests Krystalnacht, 30,000 Jews were rounded up and sent to concentration camps; many Jews ended up in Dachau.
Here's the thing:
In Dachau, in the mid-1930s, the official number of deaths (caveat: the OFFICIAL, i.e. SS-recorded deaths) were about 40 people a year, with the causes listed from disease or "shot while trying to escape." Many of these deaths were sheer brutality--prisoners beaten to death, though this was usually not listed as the cause.
But after Jews arrived in Dachau in large numbers in 1938, this number jumped to about 2,000 in 1939. (with the same alleged reasons for death--disease, escape attempts--listed).
Clearly, as the camp makeup changed (from political prisoners, to "undesirables", to Jews) treatment of prisoners became harsher and more lethal.
After 1940 or so, of course, everything changes again, as Jewish prisoners were deported in large numbers to ghettos and (after 1941) death camps in Poland.
And conditions in (and treatment of prisoners in) camps in Germany also became far, far worse after 1940.
One of the other commenters used Mauthausen, in Austria, as a prime example of this… from a work-camp in 1938, to a brutal work-camp in 1941, to a brutal work-camp that, by 1944, so starved its prisoners to death, that it might as well be considered an extermination camp in all but name and method (namely, starvation instead of firing squads or gas chambers).
Clearly, the "rules" (especially the unwritten rules of what was allowable or desirable) changed dramatically over time.
Edit: grammar