Skip to content

Instantly share code, notes, and snippets.

@valyakuttan
Last active June 18, 2024 04:04
Show Gist options
  • Save valyakuttan/1e653cbebbe73b917b1e3df2ec473aa1 to your computer and use it in GitHub Desktop.
Save valyakuttan/1e653cbebbe73b917b1e3df2ec473aa1 to your computer and use it in GitHub Desktop.

Linux Cheat Sheet

  1. Linux distribution related commands

  • How to find the distribution details

    $ cat /etc/*release
    
  1. File Utilities

  • Delete all files except those with extension 'rs'

    $ find . -type f -not -name '*.rs' -print0 | xargs -0 rm
  • Make compressed archive

    $ tar cfJ foo.tar.xz foo/ bar/
  • Uncompress an archive

    $ tar xfJ foo.tar.xz foo/ bar/
  1. Network Commands

    • wget

      - #### Get the public ip
      
        ```bash   
        
        $ dig +short myip.opendns.com @resolver1.opendns.com
        
        ```
         
        or by
         
        ```bash   
        
        $ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
        
        ```
      
    • ss(socket statistics)

      - #### List all tcp ports with port number 
      
        ```bash
         
        $ ss -nlt
      
        ```
      
      - ##### List all ipv4 listening ports
      
        ```bash
      
        $ ss -4 -n state listening
      
        ```
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment