Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added and rearranged topics
  • Loading branch information
fire1ce committed Nov 14, 2018
1 parent 7b0d1e0 commit dc9c122
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 64 deletions.
8 changes: 8 additions & 0 deletions src/linux/Services/apache.md
Expand Up @@ -9,6 +9,14 @@ description: Linux - Apache how to, guides, examples, and simple usage
ps -ylC httpd | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'
```

## Find Root of a Site and CD to it

Replace domain.com with desired domain

```bash
cd `grep "domain.com" /etc/apache2/conf/httpd.conf -A7|grep Root|head -1|awk '{print $2}'`
```

<!-- Donation Button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" align="center"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="Q94AU5RUD4X6A"><input type="image" src="https://raw.githubusercontent.com/fire1ce/3os.org/gh-pages/assets/images/beerDonation.png" width="150px" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></form>
<!-- Donation Button -->
26 changes: 26 additions & 0 deletions src/linux/centos7.md
Expand Up @@ -185,6 +185,32 @@ LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
```

## Fix NFS mount on Boot - Centos 7

Append text to the end of /usr/lib/systemd/system/nfs-idmap.service

```bash
[Install]
WantedBy=multi-user.target
```

Append text to the end of /usr/lib/systemd/system/nfs-lock.service

```bash
[Install]
WantedBy=nfs.target
```

Enable related services

```bash
systemctl enable nfs-idmapd.service
systemctl enable rpc-statd.service
systemctl enable rpcbind.socket
```

Reboot the server

<!-- Donation Button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" align="center"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="Q94AU5RUD4X6A"><input type="image" src="https://raw.githubusercontent.com/fire1ce/3os.org/gh-pages/assets/images/beerDonation.png" width="150px" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></form>
<!-- Donation Button -->
106 changes: 45 additions & 61 deletions src/linux/general/general.md
@@ -1,7 +1,35 @@
title: Linux General
title: Linux General Topics
description: Linux General how to, guides, examples, and simple usage

# Linux General
# Linux General Topics

## Redirect Output to a File and Stdout

The command you want is named `tee`:

```bash
foo | tee output.file
```

For example, if you only care about stdout:

```bash
ls -a | tee output.file
```

If you want to include stderr, do:

```bash
program [arguments...] 2>&1 | tee outfile
```

2>&1 redirects channel 2 (stderr/standard error) into channel 1 (stdout/standard output), such that both is written as stdout. It is also directed to the given output file as of the tee command.

Furthermore, if you want to append to the log file, use tee -a as:

```bash
program [arguments...] 2>&1 | tee -a outfile
```

## Add Permanent Path to Application

Expand Down Expand Up @@ -35,6 +63,16 @@ Run this command for "Bash":
echo 'export PATH="'$(pwd)':$PATH"' >> ~/.bashrc && source ~/.bashrc
```

## Create Symbolic Links

To create a symbolic link in Unix/Linux, at the terminal prompt, enter:

```bash
ln -s source_file target_file
```

to remove symbolic link use the `rm` command on the link

## Update Time Zone

```bash
Expand Down Expand Up @@ -71,14 +109,14 @@ net.core.somaxconn = 1024
net.core.netdev_max_backlog = 2000
```

## Rescan drives
## Rescan Drives for the OS

```bash
echo "- - -" > /sys/class/scsi_host/host0/scan
echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
```

## Find PTR owner - reversal
## Find PTR Owner - Reversal Look Up

```bash
dig 0.168.192.in-addr.arpa. NS
Expand All @@ -98,81 +136,27 @@ For zsh shell run:
echo "export LC_ALL=C" >> ~/.zshrc && source ~/.zshrc
```

## Open last edited file
## Open Last Edited File

```bash
less `ls -dx1tr /usr/local/cpanel/logs/cpbackup/*|tail -1`
```

## Kill process that runs more than X time
## Kill Process That Runs More Than X Time

Kill cgi after 30 secs:

```bash
for i in `ps -eo pid,etime,cmd|grep cgi|awk '$2 > "00:30" {print $1}'`; do kill $i; done
```

## Fix NFS mount on boot - Centos 7

Append text to the end of /usr/lib/systemd/system/nfs-idmap.service

```bash
[Install]
WantedBy=multi-user.target
```

Append text to the end of /usr/lib/systemd/system/nfs-lock.service

```bash
[Install]
WantedBy=nfs.target
```

Enable related services

```bash
systemctl enable nfs-idmapd.service
systemctl enable rpc-statd.service
systemctl enable rpcbind.socket
```

Reboot the server

## Update Date and Time on Linux Server

```bash
sudo ntpd -qg; sudo hwclock -w
```

## Clone Linux User

```bash
#!/bin/bash
SRC=$1
DEST=$2

SRC_GROUPS=$(id -Gn ${SRC} | sed "s/${SRC} //g" | sed "s/ ${SRC}//g" | sed "s/ /,/g")
SRC_SHELL=$(awk -F : -v name=${SRC} '(name == $1) { print $7 }' /etc/passwd)

useradd --groups ${SRC_GROUPS} --shell ${SRC_SHELL} --create-home ${DEST}
passwd ${DEST}
```

## Clear BOOT on Ubuntu when 100%

```bash
dpkg --purge `dpkg --list|grep "linux-"|grep -v \`uname -r|sed 's/-generic//g'\`|cut -d" " -f3|grep "[0-9]-"|paste -sd " " -`
```

## Find root of a site and CD to it

Replace domain.com with desired domain

```bash
cd `grep "domain.com" /etc/apache2/conf/httpd.conf -A7|grep Root|head -1|awk '{print $2}'`
```

## Generate CSR with OPENSSL
## Generate CSR with OpenSSL

Generate key:

Expand Down
6 changes: 3 additions & 3 deletions src/linux/general/memorySwap.md
@@ -1,7 +1,7 @@
title: Linux Memory & Swap
description: Linux Memory & Swap how to, guides, examples, and simple usage

# Linux Memory & Swap
# Linux Memory & Swap Related Topics

## Who uses RAM

Expand All @@ -25,13 +25,13 @@ vm.overcommit_memory = 0
vm.overcommit_ratio = 80
```

## Who is using SWAP
## Who Is Using Swap Memory

```bash
grep VmSwap /proc/*/status 2>/dev/null | sort -nk2 | tail -n5
```

## Clear cache and swap
## Clear Cache and Swap

```bash
echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a
Expand Down
14 changes: 14 additions & 0 deletions src/linux/ubuntu.md
@@ -0,0 +1,14 @@
title: Linux - Centos 7 Related Topics
description: Linux - Centos 7 how to, guides, examples, and simple usage

# Ubuntu Related Topics

## Clear BOOT Partition on Ubuntu when 100%

```bash
dpkg --purge `dpkg --list|grep "linux-"|grep -v \`uname -r|sed 's/-generic//g'\`|cut -d" " -f3|grep "[0-9]-"|paste -sd " " -`
```

<!-- Donation Button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" align="center"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="Q94AU5RUD4X6A"><input type="image" src="https://raw.githubusercontent.com/fire1ce/3os.org/gh-pages/assets/images/beerDonation.png" width="150px" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></form>
<!-- Donation Button -->

0 comments on commit dc9c122

Please sign in to comment.