Running Commands in the Background
To ensure commands continue running even if you're disconnected from the shell or SSH, you can use tools like nohup, screen or tmux.
Using nohup
nohup allows a command to run in the background and continue running even after you log out.
The & at the end runs the command in the background, and nohup ensures it keeps running after logout.
Using screen
screen is a more powerful tool that allows you to create sessions that can be detached and reattached.
- Start a new screen session:
 - Run your command without the 
&sincescreenkeeps it running: - Detach from the screen session by pressing 
Ctrl+AthenD. 
You can reconnect to the session later with screen -r session_name.
Using tmux
tmux is another powerful tool, similar to screen, that allows for managing multiple terminal sessions inside a single window. It's especially useful for running long processes in the background, like large data transfers, and for maintaining sessions after disconnection from an SSH or shell session.
Using tmux, you can start a new session, run your command, and detach, with the assurance that your process will continue running in the background. Here’s how to use tmux for our data copying tasks:
- 
Starting a New
This command creates a new session namedtmuxSession: To begin, start a newtmuxsession by typing:session_name. - 
Running Your Command: Within the
There's no need to usetmuxsession, you can run any of the data copying commands previously mentioned. For example, to usersync:&to background the process, astmuxkeeps it running inside the session. - 
Detaching from
tmuxSession: To detach from the session and leave your process running in the background, pressCtrl+Bfollowed byD. This key combination detaches you from the session but leaves it running. - 
Reattaching to a
This command reopens yourtmuxSession: If you need to check the progress of your command or start a new task, you can reattach to yourtmuxsession using:tmuxsession where you left off. 
Benefits of Using tmux
- Multiple Windows and Panes: Unlike 
nohup,tmuxallows for complex window management, including multiple windows and panes within a single session, enhancing productivity and monitoring capabilities. - Session Management: 
tmuxprovides robust session management, allowing you to detach and reattach to sessions as needed, which is ideal for long-running processes or tasks initiated over SSH. - Customization: 
tmuxsupports extensive customization, including key bindings and appearance settings, making it a versatile tool for power users.