From dc9c12252fef4cbf56f70fcd17b25745e080231e Mon Sep 17 00:00:00 2001 From: fire1ce Date: Wed, 14 Nov 2018 09:11:25 +0200 Subject: [PATCH] added and rearranged topics --- src/linux/Services/apache.md | 8 +++ src/linux/centos7.md | 26 ++++++++ src/linux/general/general.md | 106 ++++++++++++++------------------ src/linux/general/memorySwap.md | 6 +- src/linux/ubuntu.md | 14 +++++ 5 files changed, 96 insertions(+), 64 deletions(-) create mode 100644 src/linux/ubuntu.md diff --git a/src/linux/Services/apache.md b/src/linux/Services/apache.md index 77cf8b6d7..a6b726c6d 100644 --- a/src/linux/Services/apache.md +++ b/src/linux/Services/apache.md @@ -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}'` +``` +
\ No newline at end of file diff --git a/src/linux/centos7.md b/src/linux/centos7.md index b150929ad..adcff5fb0 100644 --- a/src/linux/centos7.md +++ b/src/linux/centos7.md @@ -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 +
\ No newline at end of file diff --git a/src/linux/general/general.md b/src/linux/general/general.md index 9d93d70b9..aee7d2813 100644 --- a/src/linux/general/general.md +++ b/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 @@ -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 @@ -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 @@ -98,13 +136,13 @@ 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: @@ -112,67 +150,13 @@ Kill cgi after 30 secs: 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: diff --git a/src/linux/general/memorySwap.md b/src/linux/general/memorySwap.md index 8fbe35154..3d275ff61 100644 --- a/src/linux/general/memorySwap.md +++ b/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 @@ -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 diff --git a/src/linux/ubuntu.md b/src/linux/ubuntu.md new file mode 100644 index 000000000..398175f29 --- /dev/null +++ b/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 " " -` +``` + + +
+ \ No newline at end of file