Skip to content

Instantly share code, notes, and snippets.

View montgomerykern's full-sized avatar
🐵
I may be slow to respond.

Montgomery James Kern montgomerykern

🐵
I may be slow to respond.
  • NetCraft
  • North Carolina
  • 15:23 (UTC -04:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am montgomerykern on github.
  • I am montgomerykern (https://keybase.io/montgomerykern) on keybase.
  • I have a public key ASBNmjFotarE6HAhnLulweUTpkabW5scUfZRksQi-AUA7go

To claim this, I am signing this object:

ziping files/directories examples
Creates the archive data.zip and puts all the files in the current directory in it in compressed form, type:
$ zip data *
Note: No need to add .zip extension or suffix as it is added automatically by zip command.
Use the ls command to verify new zip file:
$ ls
Set up a 1 GB swap file
Adding a swap file gives Discourse some extra breathing room during memory-intensive operations. 1GB swap should suffice, though if you are attempting the minimum memory configuration you should set up a 2GB swap.
In the shell you have opened to your droplet, do the following:
Create an empty swapfile
sudo install -o root -g root -m 0600 /dev/null /swapfile
@montgomerykern
montgomerykern / permissions_advanced.txt
Created February 15, 2016 08:19
Permissions Advanced
Scanning your server for 777 files and directories
Why are 777 files and directories dangerous:
A directory or file that is set to 777 is open to the world (in some cases) for writing. So if you are a hacker who knows what they are doing, they can exploit a 777 directory, insert code and even files into your server and then use that file or code to affect more files on your server.
A 777 directory should be used sparingly and sometimes not at all. It is most often used when there are IMAGES that need to be uploaded or any file types that can not be executed. Or in cases where directories are totally secure ahead of time through programming.
What about php and html files:
@montgomerykern
montgomerykern / permissions.txt
Last active March 30, 2016 11:29
CLI Commands Permissions
# for directories
find . -type d -print0 | xargs -0 chmod 0755
# for files
find . -type f -print0 | xargs -0 chmod 0644
#Cent OS Based
find . -type d -perm 777 -exec chmod 755 {} \; (for changing the directory permission)
@montgomerykern
montgomerykern / mv.txt
Last active February 8, 2016 06:35
Moving Files in Linux with the MV Command
# mv source dest
# mv /path/to/source /path/to/dest
#
# mv /var/www/vhost/domain.com /var/www/html/
How do I Move Multiple Directories?
Use the following syntax to move dir1 and dir2 to /path/to/dest/ directory:
$ mv -v dir1 dir2 /path/to/dest/
@montgomerykern
montgomerykern / surreport.sh
Created February 6, 2016 03:10
Server Utilization Report Script
#!/bin/bash
date;
echo "uptime:"
uptime
echo "Currently connected:"
w
echo "--------------------"
echo "Last logins:"
last -a |head -3
echo "--------------------"
@montgomerykern
montgomerykern / root-mail-dump.sh
Created February 6, 2016 03:03
This is a handly little tidbit for deleting all root user mail on linux Debian 8.
#!/bin/bash
#Root Mail User Email Dump Script
cat /dev/null > /var/mail/root
@montgomerykern
montgomerykern / XenToolsInstall.txt
Last active September 2, 2015 21:39
XenTools Install
mkdir /mnt/xs-tools
mount /dev/cdrom /mnt/xs-tools
cd /mnt/xs-tools/Linux/
bash install.sh
@montgomerykern
montgomerykern / XenCommands.txt
Created September 2, 2015 18:39
XenServer 6.50 - Tools Restart
$ service openvswitch stop
$ xe-toolstack-restart
$ service openvswitch start