Alpha
Share and Organize Code
login register
HotNewTop
F.A.Q.
1. To begin adding code first register.
2. Create your own tags for code that you add.
3. To see your own code click Me, to see all code click Everyone, or filter by people rob.
4. To follow a user, click on their username, rob and hit follow.
5. Add other code to your library by clicking the
button near the code titles (note that you can not edit these codes).
6. To create a copy of a code that you can edit use fork.
7. If you can't find your code, double check your filter settings as you can filter by Category, User and Tag simultaneously.
8. Add comments to a code by clicking on it's title or the comments link underneath it.

Restart Server (plain)

1
2
3
4
5
6
# Shutting down your server this way depending on platform...
# will most likely cause the server to run fsck during start up
shutdown -r now

# Shutdown this way for a faster reboot...
reboot
[+] (2) more...
comments (0) flag fork

List Only Directories (plain)

1
2
3
4
# This examples list all the directories in /var/log/
tree -d /var/log
# OR type this to remove any indentations
tree -di /var/log
comments (0) flag fork

List Directories & Files (plain)

1
2
3
4
5
6
7
8
ls    # list dir / files
ls -lah | more    # list all files in list / human readable format
ls -d    # list directories only
ls -lR    # list files / dir in list format recursively
ls -lahRG    # list all files / dirs, list format, recursively, with colour format (if colours not already set in environment variables)
ls -lah | sort -bn +4    # list files by size smallest to largest
ls -lah | sort -bnr +4    # list files by size largest to smallest
ls -lahG *.txt    # list only .txt files (with other options mentioned above)
[+] (4) more...
comments (1) flag fork

Show Used HDD Space (plain)

1
df -h
comments (0) flag fork

Show Amount of RAM Used (plain)

1
2
3
4
5
# In MB
free -m

# In GB
free -g
[+] (1) more...
comments (1) flag fork

Display Top 3 RAM Hogs (plain)

1
ps auxf | sort -nr -k 4 | head -3 | awk '{print $11 $12}'
comments (1) flag fork

Display Zombie Processes (plain)

1
ps aux | awk '{ print $8 " " $2 }' | grep -w Z
comments (1) flag fork

Kill Process (plain)

1
2
3
4
5
6
7
8
9
# You can see the top processes by typing: top -c
# Then kill a process based on process ID:
kill 15647
# OR multiple processes
kill 1567 3245 57654

# If the process refuses to die you can force it by...
# This will stop whatever it's doing, not recommended unless necessary
kill -9 15647
[+] (5) more...
comments (1) flag fork

Recursively Search for a String in Multiple Directories & Files (plain)

1
2
3
# Don't run this from the / directory... it would be really taxing on the server
cd /home
find . | xargs grep -i some_pattern
comments (1) flag fork

GZip Compress File (plain)

1
gzip file.txt
comments (1) flag fork

List IP Addresses Connected and Number of Connections (plain)

1
netstat -plan | grep :80 | awk {'print $5'} | cut -d: -f 1 | sort | uniq -c | sort -nk 1
comments (1) flag fork

List Processes Listening on Port 443 (plain)

1
lsof -nPi :443
comments (1) flag fork

Create SVN repository and users (plain) (source)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
svnadmin create /path/to/<repo_name>
chown -R apache:apache /path/to/<repo_name>

vi /path/to/<repo_name>/conf/svnserve.conf
auth-access = write
password-db = passwd

<Location /svn>
    DAV svn
    SVNPath /home/svn/<sitename>
    Authtype Basic
    AuthName "My Repository"
    AuthUserFile /home/svn/mofodata/conf/passwd
    Require valid-user
</Location>
[+] (11) more...
comments (0) flag fork