aum Posted July 27, 2023 Share Posted July 27, 2023 (edited) When you finally start working with the Linux command line, you'll find numerous ways to make the process more efficient. By running two or more commands at once, you'll not have to wait until one finishes to start the next. These days, the majority of my time spent on Linux is via GUI applications. That doesn't mean I can completely avoid the command line. Why? Partially because I also work with servers. But, every so often, I'll opt to use the command line on the desktop. For instance, when I need to run upgrades on a system, I'll open a terminal window and walk through the process manually. Why? Because it's more efficient. With an Ubuntu-based system, that process often requires running a few commands. For that, I have two options: I can run a single command, wait for it to complete, run the next command, wait for it to complete, run the next command…you get the picture. Now, before we continue, let me explain a few things. First, the commands you combine together do not run simultaneously. Instead, the first command will run and, when the first command completes, the second command will run (and so on). The next thing to keep in mind is that should the first command fail, the next commands will not run. Finally, this approach is different from piping commands (which I'll talk about in a later article), where the output of the first command serves as the input for the second command. What we're doing here is simply running multiple commands from a single typed line. These commands could be completely different. For example, you could list the contents of a directory, update apt, and then list the usage of your drives with the dh command. That's part of the beauty of this feature -- it's flexibility. You can also run a mixture of commands that require sudo privileges and commands that don't. So, how is this done? It's very simple. Let me show you how.How to combine Linux commands What you'll need: The only thing you'll need for this demonstration is a running instance of Linux. It doesn't matter what distribution you use, as this process is the same on all versions. Remember, to run certain admin-level commands, you'll need a user with sudo privileges. With those things at the ready, let's run some commands. I'll first demonstrate the commands one at a time, so you can see how it all comes together. 1. Run your first command Let's first run a simple command. We're going to create a new, empty, file. The command to be used is touch, and is run like this: touch zdnet_test The above command creates a new file called zdnet_test. 2. Run your second command The next command will add content to the file. That command looks something like this: echo "Hello, ZDNET!" > zdnet_test 3. View the contents of the file You can now view the contents of the new file with the command: cat zdnet_test The output of the command will print "Hello, ZDNET!". 4. Run them all at once Now that you know the command sequence (and what it does), let's combine them all together, such that we'll create the file, add content to the file, and view the file. The command for this will be: touch zdnet_test && echo "Hello, ZDNET!" > zdnet_test && cat zdnet_test As you can see, the && is the trick for combing commands together. It really is that simple. 5. One last trick Remember, I said you would need sudo privileges for some commands? Let's say you want to update apt, run and upgrade, and then clean up your system by removing any unused dependencies. The three individual commands for that are sudo apt-get update, sudo apt-get upgrade, and sudo apt-get autoremove. To combine them together, all three commands will require sudo privileges, so the command looks like this: sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove Ah, but there's another trick. Instead of typing sudo for each command, you could use this: sudo sh -c 'apt-get update && apt-get upgrade && apt-get autoremove' What we've done above is use the sh command interpreter with the -c option, such that everything in single quotes gets sudo privilege escalation. And that's all there is to it. Although this approach won't save you a ton of time, it will prevent you from having to wait until one command completes before running the next. This can be very helpful when running a group of commands, each of which takes considerable time (such as a backup). Instead of having to wait for one command to complete before running the next, run them all at once, and walk away to take care of other business. That's efficient. Source Edited August 4, 2023 by Matt Remove text format. Quote Link to comment Share on other sites More sharing options...
Administrator Matt Posted July 30, 2023 Administrator Share Posted July 30, 2023 @aum mate you know better than anyone that coloring the text with black makes any topic unrenderable on dark themes, so please avoid doing that. Thanks. Tux 528 and Kalju 2 Quote Link to comment Share on other sites More sharing options...
aum Posted August 3, 2023 Author Share Posted August 3, 2023 On 7/30/2023 at 5:32 AM, Matt said: @aum mate you know better than anyone that coloring the text with black makes any topic unrenderable on dark themes, so please avoid doing that. Thanks. Thanks, Mate! I didn't see any coloring of the text with black otherwise I'd have not posted it. I don't know what happened? Anyway, I'll be extra careful in my future posts. Best and warmest regards! Matt 1 Quote Link to comment Share on other sites More sharing options...
Kalju Posted August 3, 2023 Share Posted August 3, 2023 38 minutes ago, aum said: Thanks, Mate! I didn't see any coloring of the text with black otherwise I'd have not posted it. I don't know what happened? Anyway, I'll be extra careful in my future posts. Best and warmest regards! Weird You can't see. It's strange why this problem has not been solved until now, because it has been going on for a long time, almost 10 years, and I have personally pointed it out many times. Apparently, this can only be caused by childish tantrums. Here are the pictures/screenshots of page now, ie today on 03. Aug 2023 11:43 UTC: 1st picture - theme IPS Dark 2nd picture - theme IPS Night And of course all have been copied with the text and formatting of the entire article, and, of course, the black color added to the text specially (using the force method). p style element.style { color: #080a12; font-size: 1.125rem; padding: 0px; } and then, in addition, a semi-transparent/blurring "curtain" is also placed in front. Why, dear people? And it's really, really good to read stuff like this. Saves the eyes very well. And of course, all those who point this out are terribly bad people. Pictures: 1. theme IPS Dark 2. theme IPS Night Article html code in spoiler (there you can see <div style="color:#080a12;font-size:16px;"> and <p style="color:#080a12;font-size:1.125rem;padding:0px;"> etc and this color:#080a12 is forced black text) Spoiler <div data-role="commentContent" class="ipsType_normal ipsType_richText ipsPadding_bottom ipsContained" data-controller="core.front.core.lightboxedImages"> <p> <span style="font-size:22px;"><strong>When you finally start working with the Linux command line, you'll find numerous ways to make the process more efficient. By running two or more commands at once, you'll not have to wait until one finishes to start the next.</strong></span> </p> <p> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">These days, the majority of <a href="https://www.zdnet.com/article/the-most-important-reason-you-should-be-using-linux-at-home/" rel="external nofollow noopener" style="color:#080a12;" target="_blank">my time spent on Linux</a> is via GUI applications. That doesn't mean I can completely avoid the command line. Why? Partially because I also work with servers. But, every so often, I'll opt to use the command line on the desktop. For instance, when I need to run upgrades on a system, I'll open a terminal window and walk through the process manually.</span> </p> <div style="color:#080a12;font-size:16px;"> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Why? Because it's more efficient.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">With an <a href="https://www.zdnet.com/article/how-to-install-steam-on-any-ubuntu-based-linux-distribution-so-you-can-play-a-world-of-games/" rel="external nofollow noopener" style="color:#080a12;" target="_blank">Ubuntu-based system</a>, that process often requires running a few commands. For that, I have two options: I can run a single command, wait for it to complete, run the next command, wait for it to complete, run the next command…you get the picture.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Now, before we continue, let me explain a few things. First, the commands you combine together do not run simultaneously. Instead, the first command will run and, when the first command completes, the second command will run (and so on). </span> </p> <div style="color:#080a12;font-size:16px;"> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">The next thing to keep in mind is that should the first command fail, the next commands will not run. Finally, this approach is different from piping commands (which I'll talk about in a later article), where the output of the first command serves as the input for the second command. </span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">What we're doing here is simply running multiple commands from a single typed line. These commands could be completely different. For example, you could list the contents of a directory, update apt, and then list the usage of your drives with the <em>dh </em>command. That's part of the beauty of this feature -- it's flexibility. You can also run a mixture of commands that require sudo privileges and commands that don't.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">So, how is this done? It's very simple. Let me show you how.How to combine Linux commands </span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;"><strong>What you'll need: </strong>The only thing you'll need for this demonstration is <a href="https://www.zdnet.com/article/how-to-enable-linux-on-your-chromebook-and-why-you-should/" rel="external nofollow noopener" style="color:#080a12;" target="_blank">a running instance of Linux</a>. It doesn't matter what distribution you use, as this process is the same on all versions. Remember, to run certain admin-level commands, you'll need a user with sudo privileges. </span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">With those things at the ready, let's run some commands. I'll first demonstrate the commands one at a time, so you can see how it all comes together.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <strong><span style="font-size:14px;">1. Run your first command</span></strong> </p> <div style="color:#080a12;font-size:16px;"> <div> <div> <div> <p style="font-size:1.125rem;padding:0px;"> </p> <p style="font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Let's first run a simple command. We're going to create a new, empty, file. The command to be used is touch, and is run like this:</span> </p> </div> </div> </div> </div> <div style="color:#080a12;font-size:16px;"> </div> <div style="color:#080a12;font-size:16px;"> <pre style="font-size:1em;padding:0px;"><span style="font-size:14px;">touch zdnet_test</span></pre> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">The above command creates a new file called zdnet_test.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <strong><span style="font-size:14px;">2. Run your second command</span></strong> </p> <div style="color:#080a12;font-size:16px;"> <div> <div> <div> <p style="font-size:1.125rem;padding:0px;"> </p> <p style="font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">The next command will add content to the file. That command looks something like this:</span> </p> </div> </div> </div> </div> <div style="color:#080a12;font-size:16px;"> <pre style="font-size:1em;padding:0px;"><span style="font-size:14px;">echo "Hello, ZDNET!" > zdnet_test</span></pre> </div> <div style="color:#080a12;font-size:16px;"> <div> <div> <div> <h2 style="font-size:2.25rem;padding:0px;"> <span style="font-size:14px;">3. View the contents of the file</span> </h2> </div> </div> </div> <div> <div> <div> <p style="font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">You can now view the contents of the new file with the command:</span> </p> </div> </div> </div> </div> <div style="color:#080a12;font-size:16px;"> <pre style="font-size:1em;padding:0px;"><span style="font-size:14px;">cat zdnet_test</span></pre> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">The output of the command will print "Hello, ZDNET!".</span> </p> <div style="color:#080a12;font-size:16px;"> <div> <div> <div> <h2 style="font-size:2.25rem;padding:0px;"> <span style="font-size:14px;">4. Run them all at once</span> </h2> </div> </div> </div> <div> <div> <div> <p style="font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Now that you know the command sequence (and what it does), let's combine them all together, such that we'll create the file, add content to the file, and view the file. The command for this will be:</span> </p> </div> </div> </div> </div> <div style="color:#080a12;font-size:16px;"> <pre style="font-size:1em;padding:0px;"><span style="font-size:14px;">touch zdnet_test && echo "Hello, ZDNET!" > zdnet_test && cat zdnet_test</span></pre> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">As you can see, the && is the trick for combing commands together. It really is that simple.</span> </p> <div style="color:#080a12;font-size:16px;"> <div> <div> <div> <h2 style="font-size:2.25rem;padding:0px;"> <span style="font-size:14px;">5. One last trick</span> </h2> </div> </div> </div> <div> <p style="font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Remember, I said you would need sudo privileges for some commands? Let's say you want to update apt, run and upgrade, and then clean up your system by removing any unused dependencies. </span> </p> <p style="font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">The three individual commands for that are sudo apt-get update, sudo apt-get upgrade, and sudo apt-get autoremove. To combine them together, all three commands will require sudo privileges, so the command looks like this:</span> </p> </div> </div> <div style="color:#080a12;font-size:16px;"> </div> <div style="color:#080a12;font-size:16px;"> <pre style="font-size:1em;padding:0px;"><span style="font-size:14px;">sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove</span></pre> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Ah, but there's another trick. Instead of typing sudo for each command, you could use this:</span> </p> <div style="color:#080a12;font-size:16px;"> <pre style="font-size:1em;padding:0px;"><span style="font-size:14px;">sudo sh -c 'apt-get update && apt-get upgrade && apt-get autoremove'</span></pre> </div> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">What we've done above is use the <em>sh </em>command interpreter with the -c option, such that everything in single quotes gets sudo privilege escalation.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">And that's all there is to it. Although this approach won't save you a ton of time, it will prevent you from having to wait until one command completes before running the next. This can be very helpful when running a group of commands, each of which takes considerable time (such as a backup). </span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;">Instead of having to wait for one command to complete before running the next, run them all at once, and walk away to take care of other business. That's efficient.</span> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> </p> <p style="color:#080a12;font-size:1.125rem;padding:0px;"> <span style="font-size:14px;"><strong><a href="https://www.zdnet.com/article/how-to-run-multiple-linux-commands-at-once/" rel="external nofollow noopener" target="_blank">Source</a></strong></span> </p> </div> Matt 1 Quote Link to comment Share on other sites More sharing options...
aum Posted August 3, 2023 Author Share Posted August 3, 2023 5 minutes ago, Kalju said: Apparently, this can only be caused by childish tantrums. Good to know, Mate. Kalju 1 Quote Link to comment Share on other sites More sharing options...
Administrator Matt Posted August 3, 2023 Administrator Share Posted August 3, 2023 1 hour ago, aum said: I don't know what happened? It is always best to use the remove format button we have on the editor, and then you format the topic as you wish from title and text etc.. Also, it would be nice if you edit the topic and do that in order to be readable for everyone now and in the future. @Kalju I always appreciate your wisdom. I have tried to work on a script that strip away all copied formatting/CSS Styles on paste action in the editor, but IPS Ckedior has limits and doesn't allow everything. I hope they will have a solution for this on their IPS 5 version since they will have Dark/Light theme included. Kalju 1 Quote Link to comment Share on other sites More sharing options...
aum Posted August 3, 2023 Author Share Posted August 3, 2023 6 hours ago, Matt said: It is always best to use the remove format button we have on the editor, and then you format the topic as you wish from title and text etc.. Thanks @Matt. A really helpful and actionable advice -- focused on solving the problem. Much appreciated. Quote Link to comment Share on other sites More sharing options...
Ecarion Posted August 4, 2023 Share Posted August 4, 2023 For the record, the command "apt-get" and "aptitude" has been replace since several years (probably when "Debian 8 aka Jessie" was published). If you need one example : "apt update && apt full-upgrade" @aum you can take this one. But they didn't remove yet ? That's right (even "Debian 12 aka BookWorm") has the both preinstalled ("apt-get --help" and "aptitude --help" inside the .iso official). Despite the fact a huge number of people use "apt" (everyday), there is a drawback because a lot of people doesn't want to learn sic... To resume, they read one old topic over internet and that's enough for them. Unless a big change (announce), as you can assume this kind of change will need a very long time (years or decades). About the dark mode ? I don't use it at all but @Kalju@Matt you can probably fixes these troubles with the file called "userContent.css" (which work's for Firefox and Vivaldi (follow this guide)). @-moz-document domain(nsaneforums.com) { #cb-nexxe__topbar{position:unset !important;} /* 1) Create a folder called "chrome" in your profil (because usually it doesn't exist). */ /* 2) Then put (recpoy) the file inside this folder. /* Every change will be apply but for that it's require a full reboot of your web browser. */ /* How to avoid the reboot ? There is probably an addon but I won't be able to give any advice. */ } Otherwise you can use an addon but according to my memory, it's better to use an alternative to Stylus (which has a bad story) Quote Link to comment Share on other sites More sharing options...
Administrator Matt Posted August 4, 2023 Administrator Share Posted August 4, 2023 @aum You are welcome, and yet you didn't edit the topic. I will fix it. Quote Link to comment Share on other sites More sharing options...
aum Posted August 4, 2023 Author Share Posted August 4, 2023 4 hours ago, Matt said: @aum ... and yet you didn't edit the topic. ... How to fix what I don't see? Quote Link to comment Share on other sites More sharing options...
aum Posted August 4, 2023 Author Share Posted August 4, 2023 12 hours ago, Ecarion said: For the record, the command "apt-get" and "aptitude" has been replace since several years .. For the record, I use commend apt-get almost every day. In fact just checked and it works! Quote Link to comment Share on other sites More sharing options...
mp68terr Posted August 4, 2023 Share Posted August 4, 2023 Black text under the dark theme has been a 'problem' for years, but at the end those who want to read the thread always find a way to do so It's just not as direct as it should be. Anyway in this windows world it's always nice to read threads about linux. Thanks to those who post. aum 1 Quote Link to comment Share on other sites More sharing options...
aum Posted August 5, 2023 Author Share Posted August 5, 2023 5 hours ago, mp68terr said: ... those who want to read the thread always find a way to do so ... And it takes less energy ... overall. 5 hours ago, mp68terr said: Anyway in this windows world it's always nice to read threads about linux. Thanks to those who post. Nice to see an appreciative kind heart! 🙂 Quote Link to comment Share on other sites More sharing options...
Ecarion Posted August 18, 2023 Share Posted August 18, 2023 On 8/4/2023 at 3:21 PM, aum said: For the record, I use commend apt-get almost every day. In fact just checked and it works! Apparently there is some kind of confusion. Because I had never said the opposite (read carefully again the 3rd line (which confirm the fact I had check it myself)). PS : In the case, you still don't understand that's not my trouble and it will be useless to reply (from my point of view, it's very clear and I was a helper for almost 2 decades (on the internet)). Quote Link to comment Share on other sites More sharing options...
aum Posted August 18, 2023 Author Share Posted August 18, 2023 (edited) 8 hours ago, Ecarion said: Apparently there is some kind of confusion. On 8/3/2023 at 8:47 PM, Ecarion said: For the record, the command "apt-get" and "aptitude" has been replace[d] since several years (probably when "Debian 8 aka Jessie" was published) ... But they didn't remove yet ? That's right (even "Debian 12 aka BookWorm") has the both preinstalled ("apt-get --help" and "aptitude --help" inside the .iso official). On 8/3/2023 at 8:47 PM, Ecarion said: ... 8 hours ago, Ecarion said: In the case, you still don't understand that's not my trouble and it will be useless to reply With respect and best and warmest regards @Ecarion Edited August 18, 2023 by aum Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.