Skip to content

Instantly share code, notes, and snippets.

@Gamblt
Last active January 17, 2020 17:03
Show Gist options
  • Select an option

  • Save Gamblt/074a697befcec9d4be9e96c9af0f81e1 to your computer and use it in GitHub Desktop.

Select an option

Save Gamblt/074a697befcec9d4be9e96c9af0f81e1 to your computer and use it in GitHub Desktop.
Create sudo user with bash and homedir:
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 {} \;
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment