Trending November 2023 # How To Multitask In The Linux Terminal With Screen # Suggested December 2023 # Top 20 Popular

You are reading the article How To Multitask In The Linux Terminal With Screen updated in November 2023 on the website Hatcungthantuong.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 How To Multitask In The Linux Terminal With Screen

Many people don’t know about screen, an excellent little tool, or “a terminal multiplexer,” if you want to get technical. I firmly believe everyone who uses the terminal, for whatever reason, should have it in their arsenal. It’s that useful.

Screen makes multitasking in the terminal dead easy. With it, you can run many tools in parallel, each in their session. After you run something in its own “screen,” you can then detach and re-attach to it at will. Being able “to leave things running in a detached session” allows you to jump between tools.

If you’re juggling lots of tasks in the terminal every day, you’re either already using it, or you’ll love it after you try it!

Install screen

Screen is available for almost every distro under the sun – since it’s an old, tried and tested, albeit somewhat unknown, little treasure. To install it on Debian, Ubuntu, Mint or anything that uses apt, use:

sudo

apt

install

screen

In mere seconds you’ll be up and running, since it’s also small and without many dependencies.

First session

We’ll only delve into screen’s basic features that will allow you to use it immediately. If you like what you see by the end of this tutorial, its manual page explains the extra functions, but we thought they’d be too much for the first introduction in its use.

To use it, just add it in front of anything you’d enter in the terminal. Let’s create a document in the popular nano editor as an example. If it’s not installed, available on your distribution, or if you prefer something else, swap “nano” with your choice.

screen

nano

mte_screen.txt

By adding “screen” in front of the usual command, we ran it in one of screen’s sessions. It might look like it didn’t have any result, but as we’ll see in the next step, it did.

Detach from session

Type something in nano and pressing Ctrl + A and then D on your keyboard. Nano º or whatever editor you were using – will disappear. In the terminal, you’ll see a message similar to:

[

detached from terminal-ID

]

Now you’re back to what you could refer to as the starting terminal from where you ran screen before. But your session with nano isn’t gone.

Get back to the running session

Since you have a session running in the background, you can get back to it by entering:

screen

-r

After hitting Enter, you’ll be right where you left off in nano. You can detach and reattach the screen as many times as you like. But that’s just one app running in the background, far from what you’d call true multitasking.

Create a second session

While back to the original terminal and detached from the running nano session, repeat the first step to run something in a second session. For simplicity’s sake, we created a second document with nano using:

screen

nano

mte_2nd.txt

Screen, though, isn’t restricted to running multiple sessions of the same app: try running anything with it. Screen proves its usefulness when used for something like compressing many files into an archive with 7z, a process that takes some time. Instead of staring at a terminal, waiting for 7z to finish, you can detach its session and let it run in the background.

Session list

If you followed our previous steps, you now have two sessions running with screen. screen -r won’t work like before because it wouldn’t know where to attach. When you have multiple sessions, to go back to one of them, you first have to know its ID. To find it, enter:

screen

-list

Screen will display a list of all available sessions.

In our case, as you can see in our screenshot, to go back to either session, we’d have to enter:

screen

-r

14384

or

screen

-r

14336

Useful extras

If you run a task that exits after completion with screen, the screen session will end with it. That’s why you could have run some tasks in screen sessions but now have no active sessions show up. The tasks could have completed their goals in the meantime.

If you want a session to remain active in such cases, instead of running a command with screen added before it, run “screen” on its own to create a new session, and then type your command there before detaching. If you run a command in a session you manually created, the session won’t exit when the task completes.

Screen also allows you to create a new session from within an existing one. Just hit the command combination Ctrl + A, and then press C to create a new screen and jump to it.

For other useful commands you’ll probably end up using, press Ctrl + A and then:

A to enter a title for the session for easier recognition and management

K to kill the current session

N or P to move to the next or previous active session

0 to 9 to move between the first ten active sessions

Not just for juggling tasks

We saved the best for last: screen isn’t bound to a specific terminal. After detaching from a session, you can close the terminal window if you were in a graphic environment, or you can even log-out. As long as your computer is running, the session will remain active.

And this means that you can reattach to a running session from a different terminal. As you can see in our screenshot, we used Guake to reattach to a session we created in Mint’s default terminal.

Since the implications of this might not have adequately sunk in, think of this usage scenario: you can log in remotely to your computer, with SSH, and start a task with screen. Then, detach and log off. The job will keep running until it either completes or you decide to re-log on, reattach to the screen session and manually end it!

How’s that for “multitasking?”

Odysseas Kourafalos

OK’s real life started at around 10, when he got his first computer – a Commodore 128. Since then, he’s been melting keycaps by typing 24/7, trying to spread The Word Of Tech to anyone interested enough to listen. Or, rather, read.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

You're reading How To Multitask In The Linux Terminal With Screen

How To Search Terminal History In Linux

If you’re a frequent user of the terminal, you know how important it is to keep track of the commands you’ve executed. But what if you need to find a specific command you’ve used in the past? This is where searching terminal history comes in handy.

In this article, we’ll dive into the details of searching terminal history, including a detailed description, code examples, related concepts, and methods to help you understand and apply this concept in a professional setting.

What is Terminal History?

Terminal history is a record of all the commands you’ve executed in the terminal. This history is usually saved in a file located in your home directory, and it can be accessed and manipulated using various commands and tools.

By default, most terminal emulators save the last 500 to 1000 commands you’ve executed. However, this limit can be increased or decreased depending on your preferences.

How to Search Terminal History

Searching terminal history is a simple process that involves using the history command and piping its output to the grep command. Here’s an example:

This command will search your entire terminal history for any commands that contain the phrase “search term”. The output will include the line number of each matching command, which you can use to execute that command again.

If you want to limit the search to a specific number of commands, you can use the -n option with the history command. For example, the following command will search the last 50 commands for the phrase “search term”:

You can also search for commands that match a specific pattern using regular expressions. For example, the following command will search for any commands that start with “git”:

To make the search case-insensitive, you can use the -i option with the grep command. For example:

Related Concepts and Methods Using the Up Arrow Key

If you want to quickly access a command you’ve executed in the past, you can use the up arrow key. Each time you press the up arrow key, the terminal will display the previous command you’ve executed. You can keep pressing the up arrow key to cycle through your command history.

Using the Ctrl+R Shortcut

Another way to search your terminal history is by using the Ctrl+R shortcut. This shortcut will open up a reverse search prompt where you can type in a search term. As you type, the terminal will display the most recent command that matches your search term. You can keep pressing Ctrl+R to cycle through your command history.

Editing Terminal History

You can also edit your terminal history using the history command. For example, if you want to delete a specific command from your history, you can use the -d option followed by the line number of the command you want to delete. For example:

history -d 123

This command will delete the command on line 123 from your terminal history.

Conclusion

Searching terminal history is a useful skill that can save you time and effort when working in the terminal. By using the history and grep commands, you can easily search your command history for specific commands or patterns. Additionally, using the up arrow key and Ctrl+R shortcut can help you quickly access and cycle through your command history.

How To Quickly Empty The Trash In Macos Using Terminal

However, permanently getting rid of the contents within the Trash isn’t always that easy and may result in errors. So if you run into any trouble, you can quickly empty the Trash in macOS using Terminal instead. You’ll find the complete procedure below.

Table of Contents

Delete the Trash in Mac Using Terminal (macOS El Capitan and Later)

If you use a Mac running macOS 10.11 El Capitan or later (such as Big Sur or Monterey), you can quickly empty the Trash using Terminal.

2. Type the following command:

sudo rm -r

Note: Do not run the command yet.

3. Press the Space key once to add a single space to the end of the command. It’s essential to do that. If not, the command will fail.

4. Open the Trash.

5. Select the files you want to delete while holding down the Command key. If you want to remove everything, press Command + A to highlight all files and folders instantly.

6. Drag the highlighted files into the Trash. Depending on how many items you want to delete, multiple file paths may show up in Terminal.

7. Press Enter.

8. Type in your administrator password.

9. Press Enter. Terminal will delete the specified items from the Trash. You won’t receive a confirmation, so it’s best to double-check.

If Terminal fails to delete a specific file or files, adding the f (force) option will override issues caused by conflicting permissions. Type sudo rm -rf in step 2. 

Emptying the Trash permanently deletes the files (unless you’ve set up Time Machine on your Mac). Hence, if you prefer confirmation before deleting each time, you can use the i (interactive) option—e.g., sudo rm -ri.

Delete the Trash in Mac Using Terminal (macOS Yosemite and Earlier)

On a Mac running macOS 10.10 Yosemite or earlier, emptying the Trash using Terminal is relatively uncomplicated. 

2. Type the following command:

sudo rm -rf ~/.Trash/*

3. Press Enter.

4. Type in your administrator password.

5. Press Enter.

Alternative Ways to Delete Problematic Files in Trash

Deleting the Trash using Terminal is quick. But it’s also inconvenient. If you can’t empty the Trash using the GUI (graphical user interface) in macOS due to a specific file or files, run through the pointers below the next time.

Delete Items Individually Unlock Files and Check Permissions

While you’re at it, you may also want to scroll down to the Sharing & Permissions section and set Privilege to Read & Write for your user account. You may not be able to do that if you don’t have administrative privileges.

Force-Quit Relevant Programs

Additionally, you might want to check if the relevant program is stuck. To do that, open the Apple menu and select Force-quit. If the program appears within the list, select the item and choose Force Quit. Here are other ways to force-quit apps in macOS.

Restart Your Mac

Restarting your Mac can also help resolve bugs, glitches, and conflicts preventing you from emptying the Trash.

Just open the Apple menu and select Restart. Then, leave the box next to Reopen windows when logging back in unchecked and choose Restart.

Disable Conflicting Startup Programs

If you continue to have trouble emptying the Trash normally, you probably have a conflicting program that boots alongside macOS. 

Booting your Mac in Safe Mode can also help you identify problematic or sketchy startup programs and extensions that cause issues.

Take Out the Trash

Despite being able to empty the Trash using Terminal in macOS, it’s best to stick to the graphical user interface, if possible. Taking the time to figure out what prevents you from deleting files within Mac’s Trash rather than force-deleting its contents may help you avoid having to deal with the same problem going forward.

That being said, if you end up permanently removing files and folders you later want to recover, don’t forget to restore the lost items using Time Machine.

How To Install Windows Terminal Without The Store

How to Install Windows Terminal Without the Store The source code is available for free for download on GitHub

671

Share

X

Microsoft has launched a dedicated terminal that allows you to open all other command-line tools from within it.

Windows 11 comes with Windows Terminal pre-installed, but, on Windows 10, you need to manually install it yourself.

Windows Terminal can be installed directly from the Microsoft Store.

However, you can also install it without the Store by using the source code available on GitHub.

X

INSTALL BY CLICKING THE DOWNLOAD FILE

To fix Windows PC system issues, you will need a dedicated tool

Fortect is a tool that does not simply cleans up your PC, but has a repository with several millions of Windows System files stored in their initial version. When your PC encounters a problem, Fortect will fix it for you, by replacing bad files with fresh versions. To fix your current PC issue, here are the steps you need to take:

Download Fortect and install it on your PC.

Start the tool’s scanning process to look for corrupt files that are the source of your problem

Fortect has been downloaded by

0

readers this month.

Microsoft has developed a new, modern, feature-rich terminal application called Windows Terminal. It’s meant to gather all the command-line tools like Command Prompt and PowerShell in one place.

This is quite a nifty idea, and in the opinion of many Windows 10 users, long overdue. Although it’s initially intended for developers, anyone who wants to enter a few command lines is welcome.

Not only that but regular updates and constant development are promised.

While Windows Terminal is officially out, Microsoft only allows you to install it via Microsoft Store in Windows 10.

What does Windows Terminal do?

One of the main features of this new terminal application is multiple-tab support. Windows 10 users have asked for this forever, and now it’s finally happening.

What this actually means? It means that you will be able to open, for example, Command Prompt, PowerShell, WSL, and Raspberry Pi all at once, each on a separate and connected tab. And all that under a single Windows Terminal window.

Other notable features include a new text rendering engine that will allow the display of a lot more symbols, text characters, glyphs, and even emojis and a new open-source monospaced font.

Along with this, many more customization options and profiles with different font styles, colors, transparency, and other things, let you decide how Windows Terminal looks and feels.

What does my PC need to run Windows Terminal?

Before you start, there are some very important prerequisites:

How can I install Windows Terminal without Microsoft Store?

1. Download the .msixbundle file from the latest release for Microsoft Terminal from GitHub. It is available in the Assets section.

2. Launch a Powershell window to the file location of the downloaded file.

3. Type this command, and replace [name] with the full name of the downloaded file : Add-AppxPackage [name]

In our case, the command looks like this: Add-AppxPackage Microsoft.WindowsTerminalPreview_Win10_1.16.2641.0_8wekyb3d8bbwe.msixbundle

4. Press Enter to run the command.

5. Windows Terminal has been installed and you can now use it on your PC.

If you don’t want to install Windows Terminal from the Microsoft Store, there is a quick workaround for this. You can install it directly from the source code.

Yes, that’s right. Windows Terminal it’s open-source and you can find all the things you need on GitHub’s dedicated page for it.

If something isn’t right or you can’t find certain things, there is a README file as well as some scripts in the /tools directory.

As you can see, it’s pretty simple to take an early look at Microsoft’s new Windows Terminal. Just head over to GitHub and clone, build, test, and run the Terminal in any way you want.

Of course, if you find any bugs or issues with the source code for GitHub’s Windows Terminal, share them with the world so everyone may contribute and get rid of them.

How can I install Windows Terminal from Microsoft Store on Windows 10?

If you would rather use the Store to install this tool, feel free to do so. This is the fastest way of getting the tool on your PC. This is what you need to do:

Learn more about a variety of PowerShell commands you can run on Windows 10 by reading our guide.

Still experiencing issues?

Was this page helpful?

x

Start a conversation

How Does Umask Work In Linux With Syntax?

Introduction to Linux Umask

UMASK is an abbreviation for user mask and is sometimes called a User file creation mask. In Linux, there are many instances when one would need to create a file or a directory as per the use case requirement. While doing this, one needs to make sure that the permission of the newly created file or directory should comply with the use case scenarios. Now, suppose a Linux system is used for developing applications suited for only one kind of scenario tackling. In that case, it is erstwhile to change the base permission or the default permission of the newly created files or folders. UMASK is the command that comes in handy while fixing the default permission to something that most applications being developed in that Linux box would typically have.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax

Before we even jump into understanding what scenarios umask would help or what is the working principle of umask, it is beneficial to understand the syntax behind the umask so that while going through the working principle, we can keep the syntax in mind.

Syntax #1

0: read-write and execute

1: read & write

2: read & execute

3: read-only

4: write & execute

5: write only

6: execute only

7: no permission

If you recall from a previous understanding of file permission, you would see that the numbers are just the opposite of the actual file permission numbers. The reason is the calculation we will talk about. Using the numbers in the umask, you would see that the permission to the file or directory is the one you would be expecting as text and not the numbers listed above. So, for example, after calculation, if umask is 1st number is 0, you would get 7 or 6 as the 1st number post calculation, and that is exactly the number for reading, write and execute for a file or directory, respectively.

Syntax #2 umask u=rwx, g=, o=

Here umask is the same keyword, u refers to users, g refers to groups,o refers to others. And the letters r refers to read,w refers to write,x refers to execute. Here as well, there is a calculation that will follow to get to the actual file permission.

How Does Umask Work in Linux?

In order to understand how umask works in Linux, it is more important to note a few important parameters that become the base for obtaining the file permissions. By default, base permission for a file is 666, and the directory is 777. Number 7 won’t exist, and number 6 will have action as No permission in case of files. This is because it is a rule of thumb that files with execute permissions are not allowed to be created by Linux, and one would need to do that after the file is created and as a separate step!

The next thing is how and where do we change the value of umask. This needs to be changed in the ~/.bashrc file. ~/.bashrc lets you set parameters or attributes or configurations for terminal sessions. In case you need to change the umask for only current sessions, you would need to put it as a command-line input.

umask 027 umask

Output:

Once you have set the umask values, these will try to be used as a NOT operator to calculate the file permissions. As already mentioned, the default base permission for files is 666. The directory is 777; let us look at 2 different calculations (for files and directory) to understand how we arrive at permission numbers from the umask code.

Get File permission

The intention is to subtract the umask number from the base permission to get the actual file permission. For example, if the umask is 027 [0 (read & write for user), 2 (read-only for the group), 7 (no permission for others)] then the calculation is as follows:

Base permission: 666

umask: 027

File permission: 666 – 027 = 640* (rw-r—–)

*Please note that 6 – 7 is -1, but in Linux, it is adjusted to be 0.

Get Directory Permission

The intention is to subtract the umask number from the base permission to get the actual file permission. For example, if the umask is 022 [0 (read, write& execute for user), 2 (read & execute for group and others)] then the calculation is as follows:

Base permission: 777

umask: 027

File permission: 777 – 022 = 750 (rwxr-x—)

Groups can read and execute into a directory but can only read a file inside it.

Others can do nothing, i.e., no permission.

Without umask

Code:

mkdir new DirWO touch new FileWO ls -l

Output:

With umask

Code:

umask 027 mkdir newDir touch new File ls -l

Output:

A useful tip: Try to first understand the base scenario and then watch out for permission in a numerical form. Then subtract it from the base permission to get the umask number.

Conclusion

In this article, we have learned about how we use scenario-based numbering to understand what the default umask number should be, and then in accordance with that, we set up the umask either in bashrc or only for that terminal only as per requirement.

Recommended Articles

We hope that this EDUCBA information on “Linux Umask” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

What Is Windows Terminal In Windows 11 And Ways To Open Windows Terminal

What is Windows Terminal in Windows 11 and Ways To Open Windows Terminal What is Windows Terminal?

As you can see from the screenshot below, I have installed WSL. Using the below-mentioned command, you can install WSL (Windows Subsystem for Linux) in a few minutes.

How To Open Windows Terminal On Windows 11/10 1.  With the Help of Search

2. Pin Windows Terminal To The Taskbar 3. Start Menu

Start Menu is the place where you can find all the apps installed on your computer (desktop or laptop). You can even reach the Windows Terminal with the help of the Start Menu. Here are the steps for the same –

4. Create Desktop Shortcut

Want to save yourself the effort of going through the above 2 steps every single time? How about creating a shortcut for Windows Terminal on the desktop. Here are the steps for the same –

In Type the location of the item copy-paste the below-mentioned text

%LocalAppData%MicrosoftWindowsAppswt.exe

Name this shortcut as Windows Terminal

5. Create A Shortcut’s Shortcut

Firing up something at the command of a hotkey combo has a charm of its own and the same can be applied to Windows Terminal. Here we shall assign a shortcut to the Windows Terminal shortcut that we have created above. For that  –

Hit the Shortcut tab

Every time you press this combo, Windows Terminal will open.

6. Run Windows Terminal With The Help of Run Command

Another quick way to fire up Windows Terminal is to use the Run dialog box which again is a fairly simple process. All you have to do is press Windows key + R to open the Run dialog box. When the dialog box opens, type chúng tôi and press Enter.

7. Configure At Startup

You can choose to launch the Windows Terminal as soon as your Windows boots up, quite like any other app. On the other hand, you can always manage your startup items using the ways we have mentioned in this post. Back to configuring Windows 11 Windows Terminal on startup – here’s how that can be done –

Using any of the above ways open Windows Terminal

From the right-hand side, select Launch on machine startup

Wrapping Up

It’s always fun to delve deep into the various facets of the Windows operating system. And, if up until now you haven’t seen Windows Terminal or didn’t know how to open Windows Terminal, maybe this post will pique your interest. For more such content, keep reading Tweak Library.

Related Topics

Quick Reaction:

About the author

Sarang Bhargava

Update the detailed information about How To Multitask In The Linux Terminal With Screen on the Hatcungthantuong.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!