Last active
January 17, 2020 17:03
-
-
Save Gamblt/074a697befcec9d4be9e96c9af0f81e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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 {} \; | |
Remove files by mask | |
find ./path_to_find -name "*.spec.ts" -type f -delete | |
######################################################## DISK | |
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 | |
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment