Skip to content

Instantly share code, notes, and snippets.

@afro-coder
Last active June 2, 2022 09:54

Revisions

  1. afro-coder revised this gist Jun 2, 2022. 1 changed file with 69 additions and 25 deletions.
    94 changes: 69 additions & 25 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,12 @@
    Linux Guide
    # Linux System Admin Primer

    ### Challenge
    https://github.com/livialima/linuxupskillchallenge

    ### Linux Guide
    https://tldp.org/LDP/intro-linux/html/index.html

    # Basic Commands
    ### Basic Commands
    ◦ ps
    ◦ df
    ◦ du
    @@ -14,58 +17,99 @@ https://github.com/livialima/linuxupskillchallenge
    ◦ zless
    ◦ grep

    # Check if SSH is enabled
    ### Check if SSH is enabled
    ```
    systemctl status sshd

    # Check for a Port that is listening on the server
    ```
    ### Check for a Port that is listening on the server
    ```
    ss -patun | grep 2222
    ```

    ## Firewall management
    ### Install a package

    Install a package
    ```
    yum install -y firewalld
    ```

    ### List Firewall ports
    List Firewall ports
    ```
    firewall-cmd --list-all
    ```

    ### Add predefined services
    Add predefined services
    ```
    firewall-cmd --permanent --add-service=httpd
    ```

    ### List predefined services
    List predefined services
    ```
    firewall-cmd --get-services
    ```

    #### open a port in linux, replace tcp with udp for UDP ports
    Add a service to the firewall
    ```
    firewall-cmd --permanent --add-service=http
    firewall-cmd --reload
    ```

    Open a port in linux, replace tcp with udp for UDP ports
    ```
    firewall-cmd --add-port=portnumber/tcp --permanent
    firewall-cmd --reload
    ```

    ### Selinux (Advanced) Turn it off for now

    # Selinux (Advanced) Turn it off for now
    ```
    setenforce 0
    ```

    ## Package Management
    ### Install a package or multiple
    yum install -y vim tmux
    Read about SELinux first
    https://wiki.gentoo.org/wiki/SELinux/Tutorials
    https://wiki.gentoo.org/wiki/Category:SELinux
    https://wiki.gentoo.org/wiki/SELinux/Tutorials/How_SELinux_controls_file_and_directory_accesses

    ### To view files owned by package
    ### Package Management
    Install a package or multiple
    ```
    yum install -y vim tmux
    ```
    #### To view files owned by package
    ```
    repoquery -l httpd

    ### Get installed packages
    ```
    #### Get installed packages with the name httpd
    ```
    yum list installed | grep httpd
    ```
    ### Process Management

    ## Process Management
    ### Grep Httpd pid
    #### Grep Httpd pid
    ```
    pgrep httpd
    ```

    ### Grep process list
    #### Grep process list
    ```
    ps aux | grep httpd
    ```

    ### Filter per process
    #### Filter per process
    ```
    ps -ylC httpd
    ```

    #### File Processing

    ## File Processing
    • vim → press i to go to insert mode, vimtutor will help you learn basic vim
    • wc → Word Count for lines → wc -l
    • shell redirection, >, >>, 2>1,
    • wc → Word Count for lines → wc -l #https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/text-information-tools.html
    • shell redirection, >, >>, 2>1 # https://tldp.org/LDP/abs/html/io-redirection.html

    Basic file commands https://tldp.org/LDP/abs/html/basic.html
    • less => View files in a pager mode -> Ability to view and search text
    • cat → Spit all the lines to the terminal
    • zless → compressed files
    • zgrep → grep through compressed files
    • zgrep → grep through compressed files
    • grep → grep through files
  2. afro-coder renamed this gist Jun 2, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. afro-coder revised this gist May 31, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,9 @@ firewall-cmd --permanent --add-service=httpd
    ### List predefined services
    firewall-cmd --get-services


    #### open a port in linux, replace tcp with udp for UDP ports
    firewall-cmd --add-port=portnumber/tcp --permanent
    firewall-cmd --reload


    # Selinux (Advanced) Turn it off for now
  4. afro-coder created this gist May 30, 2022.
    69 changes: 69 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    Linux Guide

    https://github.com/livialima/linuxupskillchallenge


    # Basic Commands
    ◦ ps
    ◦ df
    ◦ du
    ◦ vim
    ◦ top
    ◦ less
    ◦ more
    ◦ zless
    ◦ grep

    # Check if SSH is enabled
    systemctl status sshd

    # Check for a Port that is listening on the server
    ss -patun | grep 2222

    ## Firewall management
    ### Install a package
    yum install -y firewalld

    ### List Firewall ports
    firewall-cmd --list-all

    ### Add predefined services
    firewall-cmd --permanent --add-service=httpd

    ### List predefined services
    firewall-cmd --get-services




    # Selinux (Advanced) Turn it off for now
    setenforce 0

    ## Package Management
    ### Install a package or multiple
    yum install -y vim tmux

    ### To view files owned by package
    repoquery -l httpd

    ### Get installed packages
    yum list installed | grep httpd

    ## Process Management
    ### Grep Httpd pid
    pgrep httpd

    ### Grep process list
    ps aux | grep httpd

    ### Filter per process
    ps -ylC httpd

    ## File Processing
    • vim → press i to go to insert mode, vimtutor will help you learn basic vim
    • wc → Word Count for lines → wc -l
    • shell redirection, >, >>, 2>1,
    • less => View files in a pager mode -> Ability to view and search text
    • cat → Spit all the lines to the terminal
    • zless → compressed files
    • zgrep → grep through compressed files