Skip to content

Instantly share code, notes, and snippets.

@dingo-d
Last active August 31, 2016 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dingo-d/af7e54bb0298304b58a1dabc5a6ba428 to your computer and use it in GitHub Desktop.
Save dingo-d/af7e54bb0298304b58a1dabc5a6ba428 to your computer and use it in GitHub Desktop.
List of useful commands for ubuntu server

ADD USER

sudo adduser newuser

sudo adduser newuser root

sudo adduser newuser sudo

sudo usermod -a -G www-data newuser

sudo groupadd {groupname}

sudo adduser {username} {groupname}

SOLVING PERMISSION ISSUES BY MOUNTING A COPY

http://blog.netgusto.com/solving-web-file-permissions-problem-once-and-for-all/

PERMISSIONS FOR WORDPRESS

sudo find . -type f -exec chmod 664 {} +

sudo find . -type d -exec chmod 775 {} +

sudo chmod 660 wp-config.php

DDOS SOLVING

/sbin/iptables -L -v

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

/sbin/iptables -I INPUT -s XX.XX.XX.XX -j DROP

sudo /sbin/iptables-save

SAMBA

sudo apt-get update

sudo apt-get install samba

sudo smbpasswd -a <user_name>

sudo nano /etc/samba/smb.conf

----- ADD AT THE END -----

[{my-folder}]

path = /var/www/html/{my-folder}

valid users = @{groupname}

read only = no

create mode = 0777

directory mode = 0777

sudo service smbd restart

PHPMYADMINA INSTALLATION

sudo apt-get update

sudo apt-get install phpmyadmin

PUT THE CHECKMARK FROM SPACE TO APACHE2 AND ON dbconfig-common SAY YES

sudo php5enmod mcrypt

sudo service apache2 restart

MYSQL COMMANDS

mysql -u {username} -p

---- in mysql ----

show databases;

select {databasename}

show tables;

mysql query;

ADD AUTH KEYES

nano ~/.ssh/authorized_keys

RANDOM USEFUL COMMANDS

Write full size in MB

ls -l --block-size= M

Empty file

truncate -s 0 {filename}

Process view

htop

Change owner of a directory

sudo chown -r {user}:{group} foldername/

Restart server/mysql service

sudo reboot

sudo service mysql restart

View last X number of lines in a file

tail filename -n X

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment