This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
how_to [2011/12/14 20:16] k2patel [Enable port below 1024 for all users] |
how_to [2020/08/10 02:35] (current) |
||
---|---|---|---|
Line 21: | Line 21: | ||
To drop all the table in the mysql database - use the following command. | To drop all the table in the mysql database - use the following command. | ||
+ | <WRAP prewrap> | ||
<code mysql> | <code mysql> | ||
mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE] | mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE] | ||
</code> | </code> | ||
+ | </WRAP> | ||
==== How to list pear using php ==== | ==== How to list pear using php ==== | ||
Line 69: | Line 69: | ||
</code> | </code> | ||
+ | |||
+ | ==== Force Change password next login ==== | ||
+ | |||
+ | <code bash> | ||
+ | chage -d 0 <Username> | ||
+ | </code> | ||
==== Setting up Multiple ip using single file ==== | ==== Setting up Multiple ip using single file ==== | ||
Line 195: | Line 201: | ||
If you need to run cron with your own php.ini and send result to mail use following. | If you need to run cron with your own php.ini and send result to mail use following. | ||
+ | <WRAP prewrap> | ||
<code bash> | <code bash> | ||
*/1 */2 * * * /usr/local/bin/php --php-ini /srv/www/conf/php.ini /srv/www/public_html/cron.php | /usr/bin/mail -s "Output of crontab" xyz@yahoo.com | */1 */2 * * * /usr/local/bin/php --php-ini /srv/www/conf/php.ini /srv/www/public_html/cron.php | /usr/bin/mail -s "Output of crontab" xyz@yahoo.com | ||
</code> | </code> | ||
+ | </WRAP> | ||
==== Exit Codes ==== | ==== Exit Codes ==== | ||
At some point you feel like there is no exit code documentation and you want find you what should it return.\\ | At some point you feel like there is no exit code documentation and you want find you what should it return.\\ | ||
Line 289: | Line 295: | ||
</code> | </code> | ||
+ | Redhat / Fedora | ||
+ | NM looks for /etc/dhclient-<interface>.conf then /etc/dhcp/dhclient-<interface>.conf \\ | ||
+ | and will merge the first found into the dhclient config files it produces. | ||
==== Enable port below 1024 for all users ==== | ==== Enable port below 1024 for all users ==== | ||
Line 314: | Line 323: | ||
**Step 2** : Create Raid Drive. ( this command will create "/dev/md10" ) | **Step 2** : Create Raid Drive. ( this command will create "/dev/md10" ) | ||
+ | <WRAP prewrap> | ||
<code bash> | <code bash> | ||
mdadm --create --level=10 --raid-devices=4 --spare-devices=0 --chunk=128 --layout=f2 /dev/md10 /dev/sdf1 /dev/sdg1 /dev/sdh1 /dev/sdi1 | mdadm --create --level=10 --raid-devices=4 --spare-devices=0 --chunk=128 --layout=f2 /dev/md10 /dev/sdf1 /dev/sdg1 /dev/sdh1 /dev/sdi1 | ||
</code> | </code> | ||
+ | </WRAP> | ||
**Step 3**: Format Drive ( I am formatting for XFS ) | **Step 3**: Format Drive ( I am formatting for XFS ) | ||
<code bash> | <code bash> | ||
mkfs.xfs /dev/md10 | mkfs.xfs /dev/md10 | ||
+ | </code> | ||
+ | |||
+ | ** Moving Between Machine ** | ||
+ | create if you don't have it already | ||
+ | |||
+ | <note warning> | ||
+ | Do not keep or include UUID in destination System, Simply copy rest of the part leaving UUID behind. | ||
+ | </note> | ||
+ | |||
+ | Source System : | ||
+ | <code bash> | ||
+ | mdadm --examine --scan > /etc/mdadm.conf | ||
+ | mdadm --stop /dev/md10 | ||
+ | </code> | ||
+ | |||
+ | Destination System :\\ | ||
+ | Add / Create mdadm | ||
+ | |||
+ | <code bash | /etc/mdadm.conf> | ||
+ | ARRAY /dev/md10 level=raid10 num-devices=4 metadata=0.90 devices=/dev/sdg1,/dev/sdh1,/dev/sdi1,/dev/sdj1 | ||
+ | </code> | ||
+ | |||
+ | Now assemble it on new system. | ||
+ | <code bash > | ||
+ | mdadm --assemble --scan --verbose /dev/md10 /dev/sdg1 /dev/sdh1 /dev/sdi1 /dev/sdj1 | ||
</code> | </code> | ||
Mount /dev/md10 - Enjoy.!! | Mount /dev/md10 - Enjoy.!! | ||
+ | |||
+ | ==== ramfs on Linux ==== | ||
+ | <note warning>Do not confuse your self with tmpfs and ramfs as both are diff. entity</note> | ||
+ | |||
+ | To create/mount ramfs you can use following command.\\ | ||
+ | Please make sure folder already exists. | ||
+ | |||
+ | <code bash> | ||
+ | mount -t ramfs none /tmp/toall | ||
+ | </code> | ||
+ | |||
+ | ==== Reduce default tmpfs size ==== | ||
+ | Default size of **/dev/shm** is almost 50% of your memory.\\ | ||
+ | In order to reduce it to some optimal value you can update your /etc/fstab.\\ | ||
+ | just add size variable in your option field : comma saperated : will do. | ||
+ | |||
+ | <code bash> | ||
+ | tmpfs /dev/shm tmpfs defaults,size=8g 0 0 | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== Password Hashing Algorithm ==== | ||
+ | |||
+ | === Display Hashing Algorithm on server === | ||
+ | |||
+ | <code bash> | ||
+ | authconfig --test | grep hashing | ||
+ | </code> | ||
+ | |||
+ | === Change Algorithm on server === | ||
+ | |||
+ | <code bash> | ||
+ | authconfig --passalgo=sha512 --update | ||
+ | </code> | ||
+ | |||
+ | ==== Changing encrypted file system password ==== | ||
+ | |||
+ | If you have encrypted partitions you can change password using following commands. | ||
+ | |||
+ | <note warning>Replace sda2 with your drive number</note> | ||
+ | |||
+ | === Check which key slot is occupied === | ||
+ | |||
+ | <code bash> | ||
+ | cryptsetup luksDump /dev/sda2 | ||
+ | </code> | ||
+ | |||
+ | === Now add key to next free slot === | ||
+ | |||
+ | <code bash> | ||
+ | cryptsetup luksAddKey /dev/sda2 | ||
+ | </code> | ||
+ | |||
+ | === Now remove / Disable Previous slot === | ||
+ | |||
+ | <code bash> | ||
+ | cryptsetup luksKillSlot /dev/sda2 0 | ||
+ | </code> | ||
+ | |||
+ | ==== Check for Operation Windigo infection ==== | ||
+ | <code bash> | ||
+ | ssh -G 2>&1 | grep -e illegal -e unknown > /dev/null && echo “System clean” || echo “System infected” | ||
+ | </code> | ||
+ | [[http://news.softpedia.com/news/quot-Operation-Windigo-quot-Attack-Infects-10-000-Unix-Servers-Millions-of-PCs-at-Risk-432920.shtml?utm_source=dlvr.it&utm_medium=twitter|Ref.]] | ||
+ | |||
+ | ==== Creating patch for rpm ==== | ||
+ | this can be used as '%patch0 -p1 -b <file_name>' | ||
+ | <code bash> | ||
+ | diff -ru hdf-4.2.12-orig hdf-4.2.12-diff >| ../SOURCES/hdf-4.2.12.example.patch | ||
+ | </code> | ||
+ | |||
+ | ==== Configure option for Fedora / Redhat ==== | ||
+ | replace amaya with your application etc...\\ | ||
+ | This is usefull while compiling sources for systems | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | ../configure -enable-system-raptor '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--exec_prefix=/usr' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' '--libexecdir=/usr/lib64/amaya' '--localstatedir=/var' '--datadir=/usr/share/amaya' '--sysconfdir=/etc/amaya' '--with-logdir=$(localstatedir)/log/amaya' '--with-pidfile=$(localstatedir)/run/amaya.pid' | ||
+ | </code> | ||
+ | </WRAP> | ||
+ | |||
+ | ==== Run single command parallel'y with diff values ==== | ||
+ | <WRAP prewrap> | ||
+ | <code bash> | ||
+ | (echo "http://test.k2patel.in"; echo "http://test.ornl.gov"; echo "http://yahoo.com" ) | parallel 'ab -n 50 -c 50 {}' | ||
+ | </code> | ||
+ | </WRAP> | ||
+ | |||
+ | ==== Print yum variable value ==== | ||
+ | <code python> | ||
+ | import yum | ||
+ | import pprint | ||
+ | |||
+ | yvar = yum.YumBase() | ||
+ | pprint.pprint(yvar.conf.yumvar, width=1) | ||
+ | </code> | ||
+ | |||
+ | ==== Disable Predictable interface name in RHEL / CentOS ==== | ||
+ | Pass following during boot kernel command line. | ||
+ | <code bash> | ||
+ | net.ifnames=0 | ||
+ | </code> |