Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.80 KB | None | 0 0
  1. RED HAT CERTFIED SYSTEM ADMINISTRATOR V 7 EXAM NOTES
  2.  
  3.  
  4.  
  5. IMPORTANT THINGS
  6.  
  7. mount -o remount,rw | fix corrupted partitioning
  8.  
  9. awk '/bash/ {print $0}' /etc/passwd > bash.txt | takes any line containing bash and put them in file bash.txt
  10.  
  11. cd /root
  12. wget "http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm"
  13. rpm -ivh epel-release-7-0.2.noarch.rpm
  14. yum repolist all
  15. yum install ntfs-3g
  16.  
  17.  
  18. VLC MEdia Player
  19.  
  20. Installation (copy/paste) for EL7: rpm -Uvh http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm && rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
  21. yum yum install vlc
  22.  
  23. -----------------------------------------------------------------
  24. NETWORKING /etc/sysconfig/network-scripts/ifcfg-eth0
  25.  
  26. DEVICE=eth0
  27. BOOTPROTO=static
  28. IPADDR=192.168.122.10
  29. NETMASK=255.255.255.0
  30. GATEWAY=192.168.122.1
  31. DNS1=8.8.8.8
  32. DNS2-8.8.4.4
  33. ONBOOT=YES
  34.  
  35. -----------------------------------------------------------------------
  36.  
  37.  
  38. Disable FIREWALLD AND IPTABLES-SAVE
  39. ================================================================================
  40. systemctl disable firewalld
  41. systemctl stop firewalld
  42. systemctl start iptables
  43. systemctl start ip6tables
  44. systemctl enable iptables
  45. systemctl enable ip6tables
  46.  
  47. iptables-save > /etc/sysconfig/iptables
  48.  
  49.  
  50.  
  51. TO have script start at boot
  52. ==================================================================================
  53.  
  54. vi /etc/rc.d/rc.local
  55. tar -cvzf /root/backup.sh /home/bigtymer37/
  56.  
  57.  
  58. VNC Cent OS 6
  59. ===============================================================================
  60.  
  61.  
  62. yum install tigervnc vinagre tigervnc-server
  63.  
  64. /etc/sysconfig/vncserver
  65.  
  66. VNCSERVERS="1:username 2:username"
  67. VNCSERVERARGS[2]="-geometry 800x600 -no listen tcp -localhost"
  68.  
  69. systemctl enable firewalld
  70. systemctl start vnc-servers
  71. firewall-cmd --permanent --zone=public --add-server vnc-server
  72.  
  73. Cent-OS 7
  74.  
  75. yum install tigervnc-server
  76. cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
  77. vi /etc/systemd/system/vncserver@:2.service
  78.  
  79. edit
  80.  
  81. [Unit]
  82. Description=Remote desktop service (VNC)
  83. After=syslog.target network.target
  84.  
  85. [Service]
  86. Type=forking
  87. # Clean any existing files in /tmp/.X11-unix environment
  88. ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
  89. ExecStart=/sbin/runuser -l bigtymer37 -c “/usr/bin/vncserver %i -geometry 1280×1024″
  90. PIDFile=/home/bigtymer37/.vnc/%H%i.pid
  91. ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
  92.  
  93. [Install]
  94. WantedBy=multi-user.target
  95.  
  96.  
  97.  
  98. su bigtymer37 ---------------------- ver importannt
  99.  
  100. vncserver ------------create password
  101.  
  102. systemctl enable firewalld
  103. systemctl start firewalld
  104. firewall-cmd --permanent --zone=public --add-port=5902/tcp
  105. systemctl restart firewalld
  106.  
  107. systemctl start vncserver@:2.service
  108. systemctl enable vncserver@:2.service
  109.  
  110. from client compueter
  111.  
  112. vinagre 192.168.122.12
  113. vncviewer 192.168.122.12
  114.  
  115. XFS REDUCE AND GROW
  116.  
  117.  
  118. pvcreate /dev/sda
  119. vgcreate -s 1M cent /dev/sda
  120. vgdisplay --- check total extents
  121. lvcreate -n data -l 255 cent
  122. mkfs.xfs /dev/mapper/cent-data
  123. mkdir /cent
  124. mount /dev/mapper/cent-data /cent
  125. lvextend --size +50M -r /dev/mapper/cent-data ----- TO GROW XFS LOGICAL VOLUME MUST BE MOUNTED BUT NOT ON EXT4 !!!!!!!
  126. xfs_growfs /cent
  127. lvreduce --size -50M -r /dev/mapper/cent-data ------- -r allows file system to grow / reduce aswell as logical volume CAN NOT SHRINK XFS FILESYSTEM ONLY EXT file systems
  128.  
  129. ==============================================================================
  130.  
  131. Add extra SWAP SPACE
  132. pvcreate /dev/sda
  133. vgcreate extra /dev/sda
  134. lvcreate -n swap -l 205 extra
  135. mkswap /dev/mapper/extra-swap
  136. vi /etc/fstab
  137. /dev/mapper/extra-swap swap swap defaults 0 0
  138. swapon -va
  139. free -m
  140. ==============================================================================
  141. Virtualization
  142.  
  143. yum groupinstall Virtualization*
  144.  
  145. images stored in /var/lib/libvirt/images
  146.  
  147. yum install qemu-kvm python-virtinst virt-manager virt-top virt-viewer libvirt libvirt-client
  148.  
  149. virt-install --prompt | run install from cmd
  150.  
  151. virt-install -n cent7-server -r 2048 --disk \path=/var/lib/libvirt/images/cent7-server.img,size=15 \-l http://192.168.0.15/cent \-x ks=http://192.168.0.15/cent/ks.cfg
  152.  
  153.  
  154. virsh list --all
  155.  
  156. virsh destroy centos.img | shuts down vm then delete image from /var/lib/libvirt/images/
  157.  
  158. virsh autostart (domain name) | starts on boot up
  159. virsh autostart --disable (domain name) | disables at bootup
  160. virt-viewer (domain name) access virtual machine gui
  161.  
  162. SNAPSHOTS of VMS
  163.  
  164. virsh snapshot-create-as cent-server snap1-C-S "snap1 description" --diskspec vda,file=/var/lib/libvirt/images/cent-server.qcow2 --disk-only --atomic
  165. Domain snapshot snap1-C-S created
  166.  
  167. virsh snapshot-create cent-server
  168.  
  169. virsh snapshot-create cent-server | create snapshot
  170.  
  171. virsh snapshot-list cent-server | list snapshot
  172.  
  173. virsh snapshot-revert cent-server ****** | revert snapshot Make sure VM is off when you revert
  174.  
  175.  
  176. virsh snapshot-delete cent-server ****** | delete snapshot
  177.  
  178. cd /var/lib/libvirt/images/ | REMOVE VM
  179. rm ****.img
  180. cd /etc/libvirt/qemu/
  181. rm ****.xml
  182.  
  183. virt-clone --prompt | to clone VM
  184.  
  185. ADDING STORAGE
  186.  
  187. dd if=/dev/zero of=/var/lib/libvirt/images/sdb1.img bs=1M seek=512 count=0
  188.  
  189. -------------------------------------------------
  190. nfs
  191.  
  192. vi /etc/exports
  193.  
  194. /nfs 192.168.122.167(rw,async)
  195. exportfs
  196.  
  197. FROM OTHER MACHINE
  198.  
  199. mount -t nfs 192.168.122.10:/nfs /nfs
  200.  
  201. AUTOMOUNTER!!! important DO NOT HAVE DIRECTORY CREATED BEFORE ADDING TO AUTO.NFS
  202. vi /etc/auto.master
  203.  
  204. /nfs /etc/auto.nfs
  205.  
  206. :wq!
  207.  
  208. vi /etc/auto.nfs
  209.  
  210. home -fstype=nfs,rw,sync 192.168.122.10:/hello
  211.  
  212. service autofs restart
  213.  
  214. cd /nfs/home
  215.  
  216.  
  217. SMB
  218. ============================================================
  219.  
  220. yum install cifs-utils
  221.  
  222. yum install samba-client
  223.  
  224. Edit the /etc/fstab file and add the following line:
  225.  
  226. smbserver:/shared /mnt cifs rw,username=user01,password=user01 0 0
  227.  
  228.  
  229.  
  230. AUTOMOUNT CIFS
  231.  
  232. vi /etc/auto.master
  233.  
  234. /cifs /etc/auto.cifs
  235.  
  236. wq!
  237.  
  238. vi /etc/auto.cifs
  239. winbox -fstype,rw,noperm,user=user01,pass=user01 192.168.122.12:/hello
  240.  
  241. :wq!
  242.  
  243. service autofs restart
  244.  
  245. cd /cifs/winbox
  246.  
  247.  
  248.  
  249. ------------------------------------------------------------
  250.  
  251. FORMATING A DRIVE
  252.  
  253. Make sure drive is unmounted
  254.  
  255. df to check mounted drives
  256.  
  257. fdisk /dev/sdb
  258.  
  259. n to select partition
  260.  
  261. p to select primary partition
  262.  
  263. enter select beggining of drive
  264.  
  265. enter select end of drive
  266.  
  267. t
  268.  
  269. 83 for linux 82 for swap
  270.  
  271. w to save
  272.  
  273.  
  274. mkfs.ext4 /dev/sdb
  275.  
  276. partprobe /dev/sdb
  277.  
  278. fsck -t ext4 /dev/sdb check filesystem
  279.  
  280. mount /dev/sdb /sdb1
  281.  
  282. ======================================================
  283.  
  284. Logical volumes
  285.  
  286. # Useful LVM commands
  287. # pvdisplay - Displays currently configured PVs.
  288. # pvchk - Checks the integrity of a physical volume.
  289. # pvs - Lists configured PVs and the associated VGs.
  290. # pvmove - Moves PVs in a VG from the specified partition to free locations
  291. on other partitions; prerequisite is to disable the PE.
  292. # vgcfgbackup - Backs up and restores the configuration files associated with LVM
  293. # vgchange - Similar to pvchange, allows you to activate or deactivate a VG. For
  294. # vgck - Checks the integrity of a volume group.
  295. # vgcreate - Creates a VG, from two or more configured PVs: for example,
  296. # vgdisplay - Displays characteristics of currently configured VGs.
  297. # vgextend - if you�ve create a new PV vgextend vg00 /dev/sda11 adds the
  298. space from /dev/sda11 to vg00.
  299. # vgrename - Allows renaming of LVs.
  300. # vgs - Displays basic information on configured VGs.
  301. # vgscan - Scans and displays basic information on configured VGs.
  302. # lvcreate - Creates a new LV in an existing VG.
  303. # lvdisplay - Displays currently configured LVs.
  304. # lvextend - Adds space to an LV: the lvextend -L6G /dev/volume01/lv01
  305. command extends lv01 to 6GB, assuming space is available.
  306. # lvrename - Renames an LV.
  307. # lvresize - Resizes an LV; can be done by -L for size. For example, lvresize -L
  308. 6GB volume01/lvl01 changes the size of lvl01 to 6GB.
  309. # lvs - Lists all configured LVs.
  310.  
  311. # Don't setup a LVM vol for the /boot dir. Linux can't read from it on boot.
  312.  
  313. pvcreate /dev/sdb /dev/sdc
  314. vgcreate cent -s 8M /dev/sdb /dev/sdc | -s add physeical extent
  315. lvcreate -n data -l 50 vol-group | -l specifies logical extent size
  316. mkdir /cent-data
  317. mkfs.ext4 /dev/mapper/cent-data
  318. mount /dev/mapper/cent-data /cent-data
  319. partprobe /dev/mapper/cent-data
  320. fsck -t ext4 /dev/mapper/cent-data
  321. blkid
  322. add UUID to fstab or auto.master and auto.cent-data
  323. =====================================================================================
  324.  
  325. LUKS ENCRYPTION
  326. pvcreate /dev/sdb /dev/sdc
  327. vgcreate cent -s 8M /dev/sdb /dev/sdc | -s add physeical extent
  328. lvcreate -n data -l 50 vol-group | -l specifies logical extent size
  329. lvcreate -n data -L 1G+ cent
  330. cryptsetup luksFormat /dev/mapper/cent-data
  331. cryptsetup LuksOpen /dev/mappert/cent-data crypt | opens /dev/mapper/crypt
  332. mkfs.ext4 /dev/mapper/crypt
  333. partprobe /dev/mapper/crypt
  334. fsck /dev/mapper/crypt
  335. mount /dev/mapper/crypt /crypt
  336. blkid
  337. add to fstab
  338. /dev/mapper/crypt /crypt ext4 defaults 1 1
  339. add to crypttab
  340. crypt /dev/mapper/cent-data none
  341. =====================================================================================
  342. HOW TO ADD KEY FILE TO LUKS
  343. ====================================================================================
  344.  
  345. dd if=/dev/urandom of=/root/crypt bs=1024 count=4 | create a keyfile with random bits of 4kb
  346.  
  347. chmod 0400 /root/keyfile | read only permission for root
  348.  
  349. sudo cryptsetup luksAddKey /dev/mapper/crypt /root/crypt | adds keyfile
  350.  
  351. vi /etc/crypttab
  352.  
  353. crypt /dev/mapper/cent-data /root/crypt | adds the keyfile in at the end
  354.  
  355.  
  356. =======================================================================
  357. RED HAT PACKAGE MANAGER
  358.  
  359. rpm -qp --requires filename looks for dependencies
  360. rpm -qp --provides file name
  361.  
  362.  
  363. ==========================================================================
  364. IPTABLES
  365.  
  366. iptables -L -nv --list | all rules
  367.  
  368. iptables -F | flushes table
  369.  
  370. iptables -P INPUT DROP
  371. iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT;
  372. iptables -I INPUT 2 -p tcp --dport 22 -j ACCEPT
  373. iptables -I INPUT 3 -m state --state ESTABLISHED, RELATED -j ACCEPT
  374.  
  375.  
  376.  
  377. iptables -P OUTPUT DROP
  378. iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
  379. iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
  380. iptables -I OUTPUT 1 -m state --state ESTABLISHED,RELATED -j ACCEPT
  381. iptables -I OUTPUT 2 -p tcp --dport 80 -j ACCEPT
  382. iptables -I OUTPUT 3 -p tcp --dport 22 -j ACCEPT
  383. iptables -I OUTPUT 4 -p udp --dport 53 -j ACCEPT
  384. iptables -I OUTPUT 5 -m state --state NEW,RELATED -j ACCEPT
  385.  
  386.  
  387. TO BLOCK IPS
  388. iptables -I INPUT 2 --source 210.0.0.0/8 DROP
  389.  
  390.  
  391. CENT OS 7
  392.  
  393.  
  394. systemctl enable iptables.service | starts iptables service on boot
  395. systemctl enable ip6tables.service
  396. systemctl enable nfs-server.service | starts nfs-server on boot
  397. systemctl enable firewalld.server | starts firewalld on boot
  398. systemctl stop firewalld.service
  399. systemctl start iptables.service
  400. systemctl start ip6tables.service
  401.  
  402. firewall-cmd --state ----------Check Status
  403. firewall-cmd --reload -------------Reload rules without loosing state
  404. firewall-cmd --get-zones ---------------- Shows zones
  405. firewall-cmd --get-services ------------- shows services
  406. firewall-cmd --list-all-zones ----------shows all zones with enabled service
  407. firewall-cmd --get-services -------------shows a list of all enabled services
  408. firewall-cmd --permanent --zone=public --add-service=nfs-server --------add nfs-server to firewall public zone
  409. firewall-cmd --permanent --zone=public --add-service=rpc-bind -----------add rpc-bind which is tcp wrapper for nfs
  410. firewall-cmd --permanent --zone=public --add-service=http -------------------add web access in public zone
  411. firewall-cmd --permanent --zone=public --remove-service=nfs-server ----removes nfs-server from public zone after restart
  412. firewall-cmd --permanent --zone=public --change-interface=eth0 -change zone on interface
  413. firewall-cmd --get-zone-of-interface=eth0 -- get zones on interface
  414. firewall-cmd --zone=public --list-ports - list ports open on zone
  415. firewall-cmd --panic-on ---- block all traffic in emergency
  416. firewall-cmd --panic-off ---- unblock all traffic
  417. firewall-cmd --add-service=http ------------- add http in deafault zone
  418. firwall-cmd --zone=public --list-all -----list services on zone
  419.  
  420. DISABLE FIREWALLD ENABLE IPTABLES
  421.  
  422. yum -y install iptables-services
  423.  
  424. systemctl mask firewalld
  425. systemctl enable iptables
  426. systemctl enable ip6tables
  427. systemctl stop firewalld
  428. systemctl disable firewalld
  429. systemctl start iptbales
  430. systemctl start ip6tables
  431.  
  432.  
  433. ==================================================================
  434. SSH
  435.  
  436. ssh-keygen
  437. scp /root/.ssh/id_rsa.pub 192.168.122.11:/root/.ssh/ ---from pc you want to automatically connect to server
  438. cat id_rsa.pub >> authorized_keys < do this on server
  439. chmod 700 /root/.ssh <
  440. chmod 644 /root/.ssh/authorized_keys <
  441.  
  442.  
  443. CRONTAB
  444.  
  445. crontab -e | edit roots crontab
  446.  
  447. crontab -l | show root crontab
  448.  
  449. crontab -u john -e | edit johns crontab
  450.  
  451. crontab -u john -l | list johns crontab
  452.  
  453. 30 8 * * * tar -cvzf /root/backup.tar /home/bigtymer
  454. * 9 * * * mv /root/backup.tar /
  455. 30 9 * * * tar -xvzf backup.tar
  456.  
  457. 30 21 * * * echo "Hello World!" >> ~/helloworld.txt
  458.  
  459. minute hour day of month day of week command
  460.  
  461. cat /var/spool/root
  462.  
  463. service crond restart
  464.  
  465. =====================================================================
  466.  
  467. RED HAT PACKAGE MANAGER
  468.  
  469.  
  470.  
  471. Install and update software packages from Red Hat Network, a remote repository, or from the local file system.
  472.  
  473. Redhat network updates (requires subscription)
  474. rhn_register
  475.  
  476. Configuration of repositories other than the RHN is accomplished through text configuration files located in the directory:
  477. /etc/yum.repos.d/
  478. • A configuration file for each repository (or group of related repos) should
  479. be created in /etc/yum.repos.d/
  480. • The name of each repo config file should end in “.repo”.
  481.  
  482. Yum Repository Mandatory Configuration Items
  483. Repository ID: Short name for identifying this repository in reports
  484. [MyRepo]
  485. Name: Longer description of this repository
  486. name=My Custom Repository
  487. Baseurl: Description of protocol and location needed to locate the repo files.
  488. baseur=http://192.168.0.15/cent
  489.  
  490. Yum Repository Common Optional Configuration Items
  491. gpgcheck: Defines whether yum should attempt to validate package signatures. “0″ = “off”, “1″ = “on”.
  492. gpgcheck=1
  493. gpgkey: Defines (via URL) where the keys for signature validation are located (typically file:///etc/pki/rpm-gpg/<key name>)
  494. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  495. enabled (Optional) Defines whether this repository should be currently active. “0″ = “off”, “1″ = “on”.
  496. enabled=1
  497.  
  498.  
  499.  
  500. RPM Cheat Sheet
  501. # rpm -i[v,h] name-ver-rel.arch.rpm : Installs a package
  502. # rpm -U[v,h] name-ver-rel.arch.rpm : Upgrades a package if an older version was previously installed. Otherwise, simply installs the new version.
  503. # rpm -F[v,h] name-ver-rel.arch.rpm : Upgrades a package if an older version is installed. Otherwise, does nothing — does not install new packages if no older version was installed.
  504.  
  505. Upgrading a Kernel
  506. Always use #rpm -i …
  507.  
  508. Uninstalling
  509. # rpm -e name[-ver][-rel]
  510.  
  511. RPM over a Network
  512. # rpm -ivh ftp://{Host}/path/to/packagename-ver-rel.arch.rpm
  513. # rpm -ivh http://{Host}/path/to/packagename-ver-rel.arch.rpm
  514. And wildcard “globbing” is allowed:
  515. # rpm -ivh http://{Host}/path/to/packagename*
  516.  
  517. rpm -qa lists all installed packages.
  518. rpm -q pkg Reports the version of the package.
  519. rpm -qf /path/file Reports which package provided the file.
  520. rpm -qc pkg Lists all configuration files of the package.
  521. rpm -qd pkg Lists all documentation of the package.
  522. rpm -qi pkg Reports a description of the package.
  523. rpm -ql pkg Lists all files contained in the package.
  524. rpm -qR pkg Lists all dependencies.
  525. rpm -q –scripts Lists the scripts that run when installing/removing.
  526. rpm -q{c|d|i|l|R}p /path/to/packagename-ver-rel-arch.rpm Reports the same info as above, but pulls info from the .rpm file instead of the rpm database.
  527. rpm -V (or –verify) Validate Package Signatures
  528.  
  529. Import GPG key, check sigs.
  530. 1. Import the Red Hat GPG public key (It can be found on the installation CD or in the /etc/pki/rpm-gpg/ directory):
  531. # rpm –import /media/disk/RPM-GPG-KEY-redhat-release
  532. or:
  533. # rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  534. 2. Check the signature of the package in question:
  535. # rpm –checksig /path/to/package-ver-rel.arch.rpm
  536.  
  537. View a list of the packages originally installed on the system:
  538. # less /root/install.log
  539. View a list of the packages installed through yum:
  540. # less /var/log/yum.log
  541. Query the RPM database for the packages installed right now:
  542. # rpm -qa
  543.  
  544. Update the kernel package appropriately to ensure a bootable system.
  545.  
  546. rpm -ivh kernel_package_name
  547.  
  548.  
  549.  
  550. =============================================================
  551. SE LINUX
  552. yum install policycoreutils-python x86_64
  553.  
  554. getsebool -a | grep httpd find selinux booleans for apache web server server
  555.  
  556.  
  557. semanage user -l | lists users
  558.  
  559.  
  560. semanage boolean -l | grep httpd <<<<<shows what each boolean does
  561.  
  562.  
  563.  
  564. send SE contents from one fold to another
  565. chcon -R --reference=/var/www/html /var/www/html/files
  566.  
  567. setsebool -P nfs_export_all_rw=1 | allows nfs export shares to read,write
  568.  
  569.  
  570.  
  571. APACHE INSTALLATION SERVER
  572. =============================================================
  573. yum install httpd
  574.  
  575. mkdir /var/www/html/cent
  576.  
  577. mount -o loop cent.iso /var/www/html/cent1.iso /var/www/html/cent
  578.  
  579. mkdir /var/www/html/repo
  580.  
  581. cp -ar /var/www/html/cent/. /var/www/html/repo/
  582.  
  583. chcon -R --reference=/var/www/html /var/www/html/repo
  584.  
  585. service httpd restart
  586.  
  587. chkconfig httpd on
  588.  
  589.  
  590. ================================================================================
  591.  
  592.  
  593. Yum & REPOS
  594.  
  595.  
  596. Yum install --downloadonly --downloaddir=/var/www/html/repo kernel.x86_64
  597. yum --add-repo repository epel6 ------------------add repo
  598. yum-config-manager --disable repository epelxxxxxxxxxx -------------- disable repo
  599. yum-config-manager --enable repository epelxxxxxxxxxxx--------------enable repo
  600. yum clean all -----------------cleans up repo
  601. yum repolist all ---------------- list all repos
  602.  
  603.  
  604. CREATE REPO
  605. mount -o loop cent7.iso /cent7
  606. mkdir /var/www/html/cent7
  607. cp -ar /cent7 /var/www/html/cent7
  608. chcon -R --reference=var/www/html/ /var/www/html/cent7
  609. cd /etc/yum.repos.d
  610. vi cent7.repo
  611. [centos7]
  612. name=centos7
  613. baseurl=file:///var/www/html/cent7/ or http://192.168.0.15/cent7
  614. enabled=1
  615. gpgcheck=1
  616. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  617.  
  618. yum clean all
  619. yum repolist all
  620.  
  621.  
  622. =============================================================
  623.  
  624. KICKSTART
  625.  
  626. system-config-kickstart /root/anaconda.ks ---- open ks file in gui save to apache installation server.
  627.  
  628. virt-install -n cent7-server -r 3000 --disk path=/var/lib/libvirt/images/cent7-server.img,size=15 -l http://192.168.0.15/cent --vcpus=4 -x "ks=http://192.168.0.15/cent/ks.cfg"
  629.  
  630.  
  631.  
  632. =======================================================LDAP=================================================
  633.  
  634. TO SET UP LDAP SERVER
  635.  
  636. yum install -y openldap openldap-clients openldap-servers migrationtools
  637.  
  638. slappasswd -s redhat -n > /etc/openldap/passwd ----------- add secret key
  639.  
  640. IMPORTANT
  641.  
  642. openssl req -new -x509 -nodes -out /etc/openldap/certs/cert.pem -keyout /etc/openldap/certs/priv.pem -days 365 ----------- creates certificate
  643.  
  644. Country Name (2 letter code) [XX]:
  645. State or Province Name (full name) []:
  646. Locality Name (eg, city) [Default City]:
  647. Organization Name (eg, company) [Default Company Ltd]:
  648. Organizational Unit Name (eg, section) []:
  649. Common Name (eg, your name or your server's hostname) []:instructor.example.com
  650. Email Address []:
  651.  
  652. cd /etc/openldap/certs
  653. chown ldap:ldap *
  654. chmod 600 priv.pem
  655.  
  656. cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
  657.  
  658. # slaptest
  659. 53d61aab hdb_db_open: database "dc=my-domain,dc=com": db_open(/var/lib/ldap/id2entry.bdb) failed: No such file or directory (2).
  660. 53d61aab backend_startup_one (type=hdb, suffix="dc=my-domain,dc=com"): bi_db_open failed! (2)
  661. slap_startup failed (test would succeed using the -u switch)
  662.  
  663. chown ldap:ldap /var/lib/ldap/*
  664. systemctl enable slapd
  665. systemctl start slapd
  666. netstat -lt | grep ldap
  667. cd /etc/openldap/schema
  668. ldapadd -Y EXTERNAL -H ldapi:/// -D "cn=config" -f cosine.ldif
  669. ldapadd -Y EXTERNAL -H ldapi:/// -D "cn=config" -f nis.ldif
  670. Then, create the /etc/openldap/changes.ldif file and paste the following lines (replace password with the previously created password):
  671.  
  672. dn: olcDatabase={2}hdb,cn=config
  673. changetype: modify
  674. replace: olcSuffix
  675. olcSuffix: dc=example,dc=com
  676.  
  677. dn: olcDatabase={2}hdb,cn=config
  678. changetype: modify
  679. replace: olcRootDN
  680. olcRootDN: cn=Manager,dc=example,dc=com
  681.  
  682. dn: olcDatabase={2}hdb,cn=config
  683. changetype: modify
  684. replace: olcRootPW
  685. olcRootPW: passwd # previously generated password
  686.  
  687. dn: cn=config
  688. changetype: modify
  689. replace: olcTLSCertificateFile
  690. olcTLSCertificateFile: /etc/openldap/certs/cert.pem
  691.  
  692. dn: cn=config
  693. changetype: modify
  694. replace: olcTLSCertificateKeyFile
  695. olcTLSCertificateKeyFile: /etc/openldap/certs/priv.pem
  696.  
  697. dn: cn=config
  698. changetype: modify
  699. replace: olcLogLevel
  700. olcLogLevel: -1
  701.  
  702. dn: olcDatabase={1}monitor,cn=config
  703. changetype: modify
  704. replace: olcAccess
  705. olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=Manager,dc=example,dc=com" read by * none
  706.  
  707. THEN MODIFY
  708.  
  709.  
  710. ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/openldap/changes.ldif
  711. SASL/EXTERNAL authentication started
  712. SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
  713. SASL SSF: 0
  714. modifying entry "olcDatabase={2}hdb,cn=config"
  715. modifying entry "olcDatabase={2}hdb,cn=config"
  716. modifying entry "olcDatabase={2}hdb,cn=config"
  717. modifying entry "cn=config"
  718. modifying entry "cn=config"
  719. modifying entry "cn=config"
  720. modifying entry "olcDatabase={1}monitor,cn=config"
  721.  
  722. Create the /etc/openldap/base.ldif file and paste the following lines:
  723.  
  724. dn: dc=example,dc=com
  725. dc: example
  726. objectClass: top
  727. objectClass: domain
  728.  
  729. dn: ou=People,dc=example,dc=com
  730. ou: People
  731. objectClass: top
  732. objectClass: organizationalUnit
  733.  
  734. dn: ou=Group,dc=example,dc=com
  735. ou: Group
  736. objectClass: top
  737. objectClass: organizationalUnit
  738.  
  739. Build the structure of the directory service:
  740. ldapadd -x -w redhat -D cn=Manager,dc=example,dc=com -f base.ldif
  741.  
  742. Create two users for testing:
  743.  
  744. mkdir /home/guests
  745. useradd -d /home/guests/ldapuser01 ldapuser01
  746. passwd ldapuser01
  747.  
  748. useradd -d /home/guests/ldapuser02 ldapuser02
  749. passwd ldapuser02
  750.  
  751.  
  752. cd /usr/share/migrationtools
  753.  
  754. Edit the migrate_common.ph file and replace in the following lines:
  755.  
  756. $DEFAULT_MAIL_DOMAIN = "example.com";
  757. $DEFAULT_BASE = "dc=example,dc=com";
  758.  
  759.  
  760. Create the current users in the directory service:
  761.  
  762. grep ":10[0-9][0-9]" /etc/passwd > passwd
  763.  
  764. ./migrate_passwd.pl passwd users.ldif
  765.  
  766. ldapadd -x -w redhat -D cn=Manager,dc=example,dc=com -f users.ldif
  767.  
  768. adding new entry "uid=ldapuser01,ou=People,dc=example,dc=com"
  769.  
  770. adding new entry "uid=ldapuser02,ou=People,dc=example,dc=com"
  771.  
  772. grep ":10[0-9][0-9]" /etc/group > group
  773.  
  774. ./migrate_group.pl group groups.ldif
  775.  
  776. ldapadd -x -w redhat -D cn=Manager,dc=example,dc=com -f groups.ldif
  777.  
  778. Test the configuration with the user called ldapuser01:
  779.  
  780. ldapsearch -x cn=ldapuser01 -b dc=example,dc=com
  781. firewall-cmd --permanent --zone=public --add-service=ldap
  782. firewall-cmd --permanent --zone=public --add-service=nfs
  783.  
  784. firewall-cmd --reload -------------Reload the firewall configuration:
  785. local4.* /var/log/ldap.log ---------Edit the /etc/rsyslog.conf file and add the following line
  786. systemctl restart rsyslog
  787. chmod 744 /home/guests/ldapuser*
  788.  
  789.  
  790. ===========================================================================================================
  791.  
  792. Configure LDAP Client
  793.  
  794. yum install -y openldap-clients nss-pam-ldapd openldap-servers
  795. scp /etc/openldap/certs 192.168.122.11:/etc/openldap/cacerts --------------- FROM SERVER
  796. authconfig-tui
  797.  
  798. Choose the following options:
  799.  
  800. - Cache Information
  801. - Use LDAP
  802. - Use MD5 Passwords
  803. - Use Shadow Passwords
  804. - Use LDAP Authentication
  805. - Local authorization is sufficient
  806. In the LDAP Settings, type:
  807.  
  808. Use TLS
  809. ldap://instructor.example.com
  810. dc=example,dc=com
  811.  
  812.  
  813.  
  814. NFS on LDAP
  815. vi /etc/exports
  816.  
  817. /home/guests/ldapuser01 192.168.122.11(rw,sync,no_root_squash)
  818. /home/guests/ldapuser02 192.168.122.11(rw,sync,no_root_squash)
  819. service nfs restart
  820. exportfs -v
  821.  
  822. vi /etc/auto.master
  823. /home/guests /etc/auto.guests
  824.  
  825. vi /etc/auto.guests
  826.  
  827. * -rw,nfs4 192.168.0.15:/home/guests/&
  828.  
  829.  
  830.  
  831. systemctl reload nfs
  832. systemctl start iptables.service
  833. systemctl start ip6tables.service
  834. systemctl start firewalld.service
  835. systemctl start autofs.service
  836. systemctl start slapd.service
  837. firewall-cmd --get-services
  838. firewall-cmd --permanent --zone=public --add-service=ldap
  839. firewall-cmd --permanent --zone=public --add-service=nfs
  840. firewall-cmd --permanent --zone=public --add-service=ldaps
  841. systemctl enable slapd.service
  842. systemctl enable autofs.service
  843. systemctl enable iptables.service
  844. systemctl enable ip6tables.service
  845. systemctl enable firewalld.service
  846. ==================================================================
  847.  
  848. Grub2
  849.  
  850. grub2-mkconfig -o /boot/grub2/grub.cfg
  851.  
  852. vi /usr/sbin/update-grub
  853.  
  854. #!/bin/bash
  855. exec grub2-mkconfig -o /boot/grub2/grub.cfg -----------makes script for update-grub
  856.  
  857. init 6
  858.  
  859. edit line "e" with vmlinuz put init=/bin/sh at end to enter single user mode with shell
  860.  
  861. passwd to update password
  862.  
  863. touch ./autorelabel
  864.  
  865. exec /sbin/init ----------------to reboot
  866.  
  867. How to add password to grub
  868.  
  869. vi /etc/grub.d/00_header
  870.  
  871. add at bottom of file
  872. cat <<EOF
  873. set superusers="bigtymer37"
  874. password bigtymer37 passwordhere
  875. EOF
  876.  
  877. update-grub or grub2-mkconfig -o /boot/grub2/grub.cfg
  878.  
  879. grub-mkpasswd-pbkdf2
  880.  
  881. vi /etc/grub.d/00header
  882.  
  883. add at bottom of file
  884. cat <<EOF
  885. set superusers="bigtymer37"
  886. password_pbkdf2 bigtymer37 pbkdf2
  887. EOF
  888.  
  889. grub2-mkconfig /boot/grub2/grub.cfg
  890.  
  891. ==================================================================================================
  892.  
  893. SYSTEM D
  894.  
  895.  
  896. systemctl enable iptables.service | starts iptables service on boot ---------------- enable on boot
  897. systemctl enable ip6tables.service -----------enable on boot
  898. systemctl enable nfs-server.service | starts nfs-server on boot -----------enables on boot
  899. systemctl enable firewalld.server | enables on boot firewalld on boot
  900. systemctl stop firewalld.service ------------ stop service
  901. systemctl start iptables.service -------------starts service
  902. systemctl start ip6tables.service------------- starts service
  903. systemctl isolate runlevel6.target ----------same as init 6 restart
  904. systemctl isolate runlevel3.target -------------same as init 3
  905. systemctl isolate shutdown.target ----------------- same as init 0
  906. systemctl list-units --type target --all -------------list all units that are currently loaded
  907. systemctl list-units --type target --all ----------- list all units regardless of state
  908. systemctl set-default multi-user.target
  909.  
  910.  
  911. ACCESS CONTROL LISTS
  912. ======================================================================
  913.  
  914. getfacl /etc/hosts
  915. setfacl -m u:bigtymer37:rw /etc/hosts
  916. chmod 644 /etc/hosts
  917.  
  918.  
  919. AT COMMAND
  920.  
  921. vi /root/backup.sh
  922. tar -cvzf /root/backup-at.tar /home/bigtymer37
  923.  
  924. at -f /root/backup.sh Aug19,2014
  925. at -f /root/backup.sh now + 15 minutes
  926. at -f /root/backup.sh now + 7 days
  927. at -f mycrontest.sh 10pm tomorrow --- job 14 at Sun Jul 8 22:00:00 2007
  928. at -f mycrontest.sh 2:00 tuesday ---job 15 at Tue Jul 10 02:00:00 2007
  929. at -f mycrontest.sh 2:00 july 11 -----job 16 at Wed Jul 11 02:00:00 2007
  930. at -f mycrontest.sh 2:00 next week
  931.  
  932. atq
  933. atrm (number of at id)
  934.  
  935.  
  936. NTP
  937. ===============================================================================
  938.  
  939. vi ntp.conf
  940. systemctl enable ntpd
  941. systemctl start ntpd
  942. ntpq -q -----------list synchronized time server
  943. systemctl stop ntpd
  944. ntpdate centos1.pool.org
  945. systemctl ntpd start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement