OS Tools

  • Linux,  OS Tools

    find (Linux OS utility)

    Find, excluding a single directory:

    find . -path ./dir1 -prune -false -o -name "*" 

    Find, excluding a list of directories:

    find . \( -path ./dir1 -o -path ./dir2 \) -prune -false -o -name "*"

    Find files with creation date on a range:

    find -newermt "2017-11-06 17:30:00" ! -newermt "2017-11-06 22:00:00" -ls
  • GNU
    Linux,  OS Tools

    screen (Linux OS utility)

    Open a new (named) screen:

    screen -S session_name

    Lists all existing screen sessions:

    screen -ls

    Reconnects to an existing (detached) screen session:

    screen -r SCREEN_NAME_OR_NUMBER

    Force/reconnect to an Attached screen session:

    screen -rd SCREEN_NAME_OR_NUMBER

    Most useful keyboard shortcuts to manage an open session:

        Ctrl+a d Detach from current screen (without destroying it)
        Ctrl+a c Create a new window (with shell)
        Ctrl+a " List all window
        Ctrl+a 0 Switch to window 0 (by number )
        Ctrl+a A Rename the current window
        Ctrl+a S Split current region horizontally into two regions
        Ctrl+a | Split current region vertically into two regions
        Ctrl+a tab Switch the input focus to the next region
        Ctrl+a Ctrl+a Toggle between the current and previous region
        Ctrl+a Q Close all regions but the current one
        Ctrl+a X Close the current region
        Ctrl+a ESC Enters in copy mode (you can scroll the buffer with up/down pageup/pagedown keys), press ESC to return to the shell
        Ctrl+a [ Enters in copy mode (you can scroll the buffer with up/down pageup/pagedown keys), press ESC to return to the shell
            Once into copy mode:
              Move cursor to the text you want to copy
              Press SPACE to start highlighting
              Move cursor to end of text you want to copy
              Press SPACE to copy to the clipboard and exit from copy mode
              Press Ctrl+a ] to paste the text

    Resizing a screen Tab:

    type Ctrl-a :resize +10 to increase size

    How to unfreeze from accidental pressing of Ctrl-S:

    type Ctrl+q

    Sample ~/.screenrc

    # Turn off the welcome message
    startup_message off
    
    # Disable visual bell
    vbell off
    
    # Set scrollback buffer to 10000
    defscrollback 10000
    
    # Customize the status line
    hardstatus alwayslastline
    hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'