Skip to content

Instantly share code, notes, and snippets.

@Gamblt
Last active January 17, 2020 17:03
Show Gist options
  • Save Gamblt/074a697befcec9d4be9e96c9af0f81e1 to your computer and use it in GitHub Desktop.
Save Gamblt/074a697befcec9d4be9e96c9af0f81e1 to your computer and use it in GitHub Desktop.

Revisions

  1. Gamblt renamed this gist Jan 17, 2020. 1 changed file with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions Linux Admin → Linux Admin Docker
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    Create sudo user with bash and homedir:
    useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser



    ######################################################### FILES
    Truncate file
    truncate -s 0 /var/log/syslog

    @@ -18,6 +21,8 @@ Remove files by mask
    find ./path_to_find -name "*.spec.ts" -type f -delete



    ######################################################## DISK
    Disk Info:
    sudo aprted -l
    sudo df -h
    @@ -30,9 +35,27 @@ SSH keys
    ssh-keygen -t rsa
    ~/.ssh/authorized_keys



    ######################################################## NETWORK
    Show LISTEN ports
    netstat -ntlp | grep LISTEN

    #Show ports2
    sudo iptables -t nat -L -n



    ######################################################## DOCKER
    #Show all docker containers internal IP
    #For common docker
    docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)
    #For docker-compose usage
    docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)



    ######################################################## DATABASE
    DB. Import big file by console
    psql --host=127.0.0.1 --port=5432 --dbname=mycity --username=mycity --password -f /path_dump/dump.sql

  2. Gamblt revised this gist Jan 17, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Linux Admin
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    Create sudo user with bash and homedir:
    useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser

    Truncate file
    truncate -s 0 /var/log/syslog

    Find folders and set access for them:
    sudo find . -type d -exec chmod 755 {} +

  3. Gamblt revised this gist Sep 15, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Linux Admin
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,9 @@ Delete: find . -name "*.bak" -type f -delete
    Remove *.gz files older than 1 day
    find ./path_to_find -name "*.gz" -type f -mtime +1 -exec rm {} \;

    Remove files by mask
    find ./path_to_find -name "*.spec.ts" -type f -delete


    Disk Info:
    sudo aprted -l
  4. Gamblt revised this gist Sep 15, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Linux Admin
    Original file line number Diff line number Diff line change
    @@ -26,3 +26,7 @@ ssh-keygen -t rsa

    Show LISTEN ports
    netstat -ntlp | grep LISTEN

    DB. Import big file by console
    psql --host=127.0.0.1 --port=5432 --dbname=mycity --username=mycity --password -f /path_dump/dump.sql

  5. Gamblt revised this gist Sep 5, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Linux Admin
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,10 @@ useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser
    Find folders and set access for them:
    sudo find . -type d -exec chmod 755 {} +

    Get/Delete files by mask:
    Check: find . -name "*.bak" -type f
    Delete: find . -name "*.bak" -type f -delete

    Remove *.gz files older than 1 day
    find ./path_to_find -name "*.gz" -type f -mtime +1 -exec rm {} \;

  6. Gamblt revised this gist Jun 9, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Linux Admin
    Original file line number Diff line number Diff line change
    @@ -19,3 +19,6 @@ sudo du --max-depth=1 2> /dev/null | sort -n -r | head -n20
    SSH keys
    ssh-keygen -t rsa
    ~/.ssh/authorized_keys

    Show LISTEN ports
    netstat -ntlp | grep LISTEN
  7. Gamblt revised this gist May 31, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion Linux Admin
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,8 @@ sudo df -h
    sudo df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs

    Show largest directorries in current path:
    sudo du --max-depth=1 2> /dev/null | sort -n -r | head -n20
    sudo du --max-depth=1 2> /dev/null | sort -n -r | head -n20

    SSH keys
    ssh-keygen -t rsa
    ~/.ssh/authorized_keys
  8. Gamblt revised this gist May 31, 2016. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion Linux Admin
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,13 @@ Find folders and set access for them:
    sudo find . -type d -exec chmod 755 {} +

    Remove *.gz files older than 1 day
    find ./path_to_find -name "*.gz" -type f -mtime +1 -exec rm {} \;
    find ./path_to_find -name "*.gz" -type f -mtime +1 -exec rm {} \;


    Disk Info:
    sudo aprted -l
    sudo df -h
    sudo df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs

    Show largest directorries in current path:
    sudo du --max-depth=1 2> /dev/null | sort -n -r | head -n20
  9. Gamblt revised this gist May 31, 2016. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion Linux Admin
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,8 @@
    Create sudo user with bash and homedir:
    useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser
    useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser

    Find folders and set access for them:
    sudo find . -type d -exec chmod 755 {} +

    Remove *.gz files older than 1 day
    find ./path_to_find -name "*.gz" -type f -mtime +1 -exec rm {} \;
  10. Gamblt created this gist May 31, 2016.
    2 changes: 2 additions & 0 deletions Linux Admin
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    Create sudo user with bash and homedir:
    useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser