Skip to content

Instantly share code, notes, and snippets.

@gajeshbhat
Last active December 5, 2025 08:49
Show Gist options
  • Select an option

  • Save gajeshbhat/d05d252b4ae01d0b1caed7c64d96fde7 to your computer and use it in GitHub Desktop.

Select an option

Save gajeshbhat/d05d252b4ae01d0b1caed7c64d96fde7 to your computer and use it in GitHub Desktop.
Useful Linux Commands

Create screen

screen -S session_name - Create a new screen

List Screens

screen -ls

Restore a detached Screens

screen -r screen_details Ex: screen -r 18073.gajesh

Detach from screen

ctrl + a d

Linux screen Window commands

1. Create a new window : Ctrl+a c
2. Rename the current window : Ctrl+a A (Ctrl + a Shift + a)
3. Switch to window [0-9] : Ctrl+a [0-9]
4. Switch to window number > 9 : Ctrl + a " (Ctrl + a Shift + ") -> Select from list and hit enter
5. Split current region horizontally into two regions: Ctrl+a S
6. Split current region vertically into two regions : Ctrl+a |
7. Toggle between the current and previous windows : Ctrl+a Ctrl+a
8. Kill current window : Ctrl + a k : y and enter to kill current windows
9. Close all regions but the current one : Ctrl+a Q
10. Close the current region : Ctrl+a X

Linux Screen Other commands less knows ;)

Switch to window number > 9 by number : Ctrl + a ' type the window number and hit enter

More at : https://linuxize.com/post/how-to-use-linux-screen/

List Process Details by Name

ps -AF | grep "script/program_name"

Kill single Process

https://www.thegeekstuff.com/2009/12/4-ways-to-kill-a-process-kill-killall-pkill-xkill/

Kill all instances of a Process or Script by Name:

pkill -9 -f [search string] if you don't have pkill installed use ps -ef | grep [search string] | awk '{print $2}' | xargs kill -9 https://www.heatware.net/linux-unix/how-to-kill-all-instances-script-program-using-string-search/

SHow, Export and Import Iptables

  1. Show Iptables : sudo iptables -S
  2. Export Iptables : sudo iptables-save > iptables-export
  3. Copy Exported rules to the Client from controller : scp iptables-export user@server_b_ip_address:/tmp
  4. Save Iptables: sudo iptables-restore < /tmp/iptables-export
  5. Persist the Iptables: sudo service iptables save for Redhat/Centos if Iptables service does not exist use iptables-save > /etc/iptables.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment