{"id":40,"date":"2008-06-18T18:30:19","date_gmt":"2008-06-18T16:30:19","guid":{"rendered":"http:\/\/blog.sqawasmi.com\/?p=40"},"modified":"2008-10-04T10:15:36","modified_gmt":"2008-10-04T08:15:36","slug":"rhce-notes","status":"publish","type":"post","link":"https:\/\/blog.sqawasmi.com\/index.php\/2008\/06\/18\/rhce-notes\/","title":{"rendered":"RHCE-Notes"},"content":{"rendered":"<p>This is RHCE notes i wrote while studding for the exam, it doesn&#8217;t cover all exam topics, maybe they can help you to review what did you studied no more..<br \/>\nUser Administration:<br \/>\n&#8211; adduser UserName<br \/>\n&#8211; deluser UserName<br \/>\n&#8211; usermod: to modifiy user information..<br \/>\n&#8211; chage: change expiration date for user account.<br \/>\n&#8211; always when you use a directory as a share for a group, use SGID, for ex: chmod 2770 \/share-dir<\/p>\n<p>for login\/logout scripts and bash, refer to this topic: <a title=\"Permanent Link: bash loging, startup scripts and shell initialization files\" rel=\"bookmark\" href=\"..\/index.php\/2006\/12\/19\/bash-loging-startup-scripts-and-shell-initialization-files\/\">bash loging, startup scripts and shell initialization files<\/a><\/p>\n<p>ACL:<br \/>\nmount with acl, ex:<br \/>\nmount -o remount, acl \/dev\/sda5 \/home<br \/>\nas root: touch \/home\/idle-boy\/a<\/p>\n<p>getfacl \/home\/idle-boy\/a<br \/>\ngetfacl: Removing leading &#8216;\/&#8217; from absolute path names<br \/>\n# file: home\/idle-boy\/a<br \/>\n# owner: root<br \/>\n# group: root<br \/>\nuser::rw-<br \/>\ngroup::r&#8211;<br \/>\nother::r&#8211;<\/p>\n<p>setfacl -m u:idle-boy:rw -m g:idle-boy:rwx \/home\/idle-boy\/a<\/p>\n<p>getfacl: Removing leading &#8216;\/&#8217; from absolute path names<br \/>\n# file: home\/idle-boy\/a<br \/>\n# owner: root<br \/>\n# group: root<br \/>\nuser::rw-<br \/>\nuser:idle-boy:rw-<br \/>\ngroup::r&#8211;<br \/>\ngroup:idle-boy:rwx<br \/>\nmask::rwx<br \/>\nother::r&#8211;<\/p>\n<p>Quotas:<br \/>\n&#8211; check if kernel support quota:<br \/>\ngrep CONFIG_QUOTA \/boot\/config-`uname -r`<br \/>\nyou should see:<br \/>\nCONFIG_QUOTA=y<\/p>\n<p>&#8211; quota package: quota<\/p>\n<p>Using Quota<br \/>\ntwo file have to be presented in the file system you need to activate quota in:<br \/>\nquota.user: for user related quota<br \/>\nquota.group: for group related quota<br \/>\nto create this files, you need to mount the file system with quota support:<\/p>\n<p>mount -t ext3 \/dev\/sdaX \/mount-point -o remount, usrquota, grpquota<\/p>\n<p>now create the files using quotacheck command:<br \/>\nquotacheck -cugm  \/mount-point<\/p>\n<p>to activate quota in the mount point use quotaon:<br \/>\nquotaon \/mount-point<\/p>\n<p>to edit users quota, use edquota command, for example:<br \/>\nedquota -u f00<\/p>\n<p>to report quota usege use repquota command&#8230;<\/p>\n<p>it&#8217;s better to automate quotacheck, use a cronjob for that..<\/p>\n<p>###############################<\/p>\n<p>PAM:<br \/>\nA very good book to read about\/understand PAM is: Pluggable Authentication Modules for Kenneth Geisshirt, from Packt Publishing.<\/p>\n<p>you can find information about PAM at this location:<br \/>\n\/usr\/share\/doc\/pam-version-num\/txts<\/p>\n<p>to prevent other users login but root:<br \/>\ntouch \/etc\/nologin<br \/>\nand \/etc\/pam.d\/login must contain:<br \/>\naccount    required     pam_nologin.so<br \/>\nafter the last auth module.<\/p>\n<p>you can type a msg in that file, the msg will appear for successful login (root) and failed login (other users)<\/p>\n<p>to control root access into tty, edit \/etc\/securetty<\/p>\n<p>Four different type of PAM modules:<br \/>\n&#8211; auth: username\/password are here..<br \/>\n&#8211; account: allows or denies access according to the account policies (ex\/ password expiration date)<br \/>\n&#8211; password: manages other password policies.<br \/>\n&#8211; session: applies settings for an application..<\/p>\n<p>###############################<\/p>\n<p>LDAP (client):<br \/>\nneeded rpm packages:<br \/>\nopenldap, openldap-client, nss_ldap<br \/>\ntwo files to be edited:<br \/>\n\/etc\/ldap.conf: change the following:<br \/>\nhost IP        ldap server ip is written here..<br \/>\nbase dc=sqawasmi,dc=com        sets the default base distinguished name, in this case, sqawasmi.com<br \/>\nssl strt_tls        needed if you want TLS support to encrypt passwords..<br \/>\npam_password        supports encryption schemes for passwords, options are: crypt, nds and ad<br \/>\nnss_init, groups_ignoreusers root, ldap        assumes no supplemental groups in LDAP server.<\/p>\n<p>\/etc\/openldap.conf<br \/>\nBASE dc=sqawasmi,dc=com        same as dc in \/etc\/ldap.conf<br \/>\nURI ldap:\/\/IP        LDAP server ip..<\/p>\n<p>make sure that your client will look for LDAP server for key authentication, for example:<br \/>\n\/etc\/nsswitch.conf:<br \/>\npasswd:    files    ldap<br \/>\nshadow:    files    ldap<br \/>\ngroup:    files    ldap<\/p>\n<p>there is no services to run in the boot process..<\/p>\n<p>###############################<\/p>\n<p>NIS (client):<br \/>\nrpm packages:<\/p>\n<p>to activate NIS client you need to edit one file:<br \/>\n\/etc\/yp.conf:<br \/>\ndomain NIS-DomainName    server    NIS-Server<\/p>\n<p>make sure that your client will look for NIS server for key authentication, for example:<br \/>\npasswd:    files    nis<br \/>\nshadow:    files    nis<br \/>\ngroup:    files    nis<\/p>\n<p>you need to activate ypbind and also chkconfig it to run in boot..<br \/>\nservice ypbind start &amp;&amp; chkconfig ypbind on<\/p>\n<p>##############################<\/p>\n<p>NFS<\/p>\n<p>man exports; to see the format of \/etc\/exports<br \/>\non server:<br \/>\n\/etc\/init.d\/portmap start &amp;&amp; \/etc\/init.d\/nfs start<br \/>\nedit \/etc\/exports, ex:<br \/>\n\/data *.sqawasmi.com(rw,sync) *(ro,sync) 10.0.0.0\/24(ro,sync)<br \/>\nexportfs -a<\/p>\n<p>on client:<br \/>\nmount -t nfs 10.0.0.1:\/data \/mnt\/share -o soft,timeo=300<\/p>\n<p>if you used the hostname to export to, then you need a working DNS, it use dnslookup to know the IP..<\/p>\n<p>to know that every thing is running in the server:<br \/>\nrpcinfo -p HOST<\/p>\n<p>show mounts on the server:<br \/>\nshowmount -e HOST<\/p>\n<p>put it in the boot process: chkconfig nfs on &amp;&amp; chkconfig portmap on<\/p>\n<p>for selinux see man nfs_selinux<\/p>\n<p>securing using iptables:<br \/>\nedit \/etc\/sysconfig\/nfs, and configure rcp* ports:<br \/>\nLOCKD_TCPPORT=33332<br \/>\nLOCKD_UDPPORT=33333<br \/>\nMOUNTD_PORT=33334<br \/>\nSTATD_PORT=33335<\/p>\n<p>in \/etc\/services put rquotad tcp\/udp ports:<br \/>\nrquotad         33330\/tcp<br \/>\nrquotad         33331\/udp<\/p>\n<p>grep nfs \/etc\/services<br \/>\ngrep portmap \/etc\/services<\/p>\n<p>open the ports&#8230;<\/p>\n<p>###################################<\/p>\n<p>vsFTPD:<br \/>\nenable anonymous access:<br \/>\nanonymous_enable=yes<br \/>\nenable remote users write:<br \/>\nwrite_enable=yes<br \/>\nenable local users login:<br \/>\nlocal_enable=yes<br \/>\nto enable pam authintication:<br \/>\npam_service_name=vsftpd<br \/>\nsupport the use of security commands of tcp_wrappers:<br \/>\ntcp_wrappers=yes<br \/>\nwelcome msg:<br \/>\nftpd_banner=Welcome..<br \/>\nor in users home directory, in .message, but you need to enable:<br \/>\ndirmessage_enable=yes<br \/>\ncontrolling who can loging using \/etc\/vsftpd\/user_list file, yes means don&#8217;t allow, no means allow them<br \/>\nuserlist_enable=yes<br \/>\n(pam also check \/etc\/vsftpd\/ftpusers for allowed users)<\/p>\n<p>for selinux see ftpd_selinux<\/p>\n<p>#####################################<\/p>\n<p>DNS<\/p>\n<p>install bind bind-utils caching-nameserver, and bind-chroot if you need it in chrooted environment..<\/p>\n<p>Caching Name Server:<br \/>\ncp \/etc\/named.caching-nameserver.conf \/etc\/named.conf<br \/>\nedit \/etc\/named.conf and change the following as you like:<br \/>\nlisten-on port 53 { 127.0.0.1; };   \/\/ for example: listen-on port 53 { 127.0.0.1; 10.0.0.1;};<br \/>\nallow-query     { localhost; }; allow-query  \/\/ ex: { localhost; 10.0.0.0\/24; }; to serv for 10.0.0.0\/24 network<\/p>\n<p>\/etc\/named start<br \/>\nchkconfig named on<\/p>\n<p>Slave Name Server:<br \/>\nsame as Caching file but add a zone (look at \/etc\/named.rfc1912.zones) for your domain and it&#8217;s master server, for example:<br \/>\nzone &#8220;sqawasmi.com&#8221; IN {<br \/>\ntype slave;<br \/>\nfile &#8220;slaves\/sqawasmi.com&#8221;;<br \/>\nmasters {<br \/>\n10.0.0.1;<br \/>\n};<br \/>\n}<\/p>\n<p>also you may add another zone for ptr, example:<\/p>\n<p>zone &#8220;0.0.10.in-addr.arpa&#8221; IN {<br \/>\ntype slave;<br \/>\nfile &#8220;slaves\/sqawasmi.rr.com&#8221;;<br \/>\nmasters {<br \/>\n10.0.0.1;<br \/>\n};<br \/>\n}<\/p>\n<p>A Forwarding Only Name Server:<br \/>\nyou need to add two things into options:<br \/>\nforward only;<br \/>\nforwarders {<br \/>\n10.0.0.1;<br \/>\n10.0.0.2;<br \/>\n};<\/p>\n<p>Master Name Server:<br \/>\nselinux: setsebool -P named_write_master_zones 1<br \/>\n(look at \/etc\/named.rfc1912.zones) for your domain and it&#8217;s master server, for example:<br \/>\nzone &#8220;sqawasmi.com&#8221; IN {<br \/>\ntype slave;<br \/>\nfile &#8220;sqawasmi.com&#8221;;<br \/>\n}<\/p>\n<p>also you may add another zone for ptr, example:<\/p>\n<p>zone &#8220;0.0.10.in-addr.arpa&#8221; IN {<br \/>\ntype slave;<br \/>\nfile &#8220;slaves\/sqawasmi.rr.com&#8221;;<br \/>\n}<\/p>\n<p>now you need to create a zones file under \/var\/named, you can use \/var\/named\/localhost.zone as template for your zone, for example:<br \/>\n\/var\/named\/sqawasmi.com.zone<br \/>\n$TTL    86400<br \/>\n@               IN SOA  @       sqawasmi.com. (<br \/>\n42              ; serial (d. adams)<br \/>\n3H              ; refresh<br \/>\n15M             ; retry<br \/>\n1W              ; expiry<br \/>\n1D )            ; minimum<\/p>\n<p>IN NS           @<br \/>\nIN A            10.0.0.10<br \/>\nblog            IN A            10.0.0.1<br \/>\nother        IN A            10.0.0.2<br \/>\nIN AAAA         ::1<\/p>\n<p>for ptr zone:<br \/>\n\/var\/named\/sqawasmi.com.rr.zone<br \/>\n$TTL    86400<br \/>\n@               IN SOA  @       sqawasmi.com. (<br \/>\n42              ; serial (d. adams)<br \/>\n3H              ; refresh<br \/>\n15M             ; retry<br \/>\n1W              ; expiry<br \/>\n1D )            ; minimum<\/p>\n<p>IN NS           @<br \/>\n10              IN ptr          sqawasmi.com.<br \/>\n1               IN ptr          blog.sqawasmi.com.<br \/>\n2               IN ptr          other.sqawasmi.com.<\/p>\n<p>finally you have to create a rndc key, use this:<br \/>\nrndc-confgen -a -b 512<\/p>\n<p>add this to your named.conf file:<br \/>\ninclude &#8220;\/etc\/rndc.key&#8221;;<\/p>\n<p>###################################<\/p>\n<p>NTP<br \/>\nClient:<br \/>\nchoose one of the servers listed in \/etc\/ntp.conf, then:<br \/>\nntpdate 0.rhel.pool.ntp.org<\/p>\n<p>\/etc\/init.d\/ntpd start<br \/>\nchkconfig ntpd on<\/p>\n<p>server:<br \/>\nallow other servers in your client to connect to you:<br \/>\nrestrict 10.0.0.0 mask 255.255.255.0 nomodify notrap<\/p>\n<p>or you can allow one client:<br \/>\nrestrict 10.0.0.2 mask 255.255.255.255 nomodify notrap<\/p>\n<p>####################################<\/p>\n<p>DHCP<br \/>\nServer:<br \/>\npackage: dhcp<br \/>\nconfiguration file: \/etc\/dhcp.conf<br \/>\nsee: \/usr\/share\/doc\/dhcp-*\/dhcpd.conf.sample<\/p>\n<p>Client:<br \/>\npackage: dhclient<\/p>\n<p>####################################<\/p>\n<p>SQUID<br \/>\nport number:<br \/>\nhttp_port 3128<\/p>\n<p>don&#8217;t cache URLs contain cgi-bin or ?<br \/>\nuse hierarchy_stoplist directive and urlpath_regex in acl<br \/>\nhierarchy_stoplist cgi-bin ?<br \/>\nacl DontCache urlpath_regex cgi-bin \\?<br \/>\ncache deny DontCache<\/p>\n<p>specify a freshness for a service:<br \/>\nyou can use refres_pattern directive:<br \/>\nrefresh_pattern regex:    Min    percent        Max<br \/>\nwhere<br \/>\nMin: is the time (in minutes) an object without an explicit expiry time should be considered fresh.<br \/>\nMax: is an upper (in minutes) limit on how long objects without an explicit expiry time will be considered fresh.<br \/>\nexample:<br \/>\nrefersh_pattern ^ftp:    1440    20%    10080<\/p>\n<p>use acl with src to create acl, ex:<br \/>\nacl my_lan src 10.0.0.0\/24<br \/>\nuse http_access to allow or deny all, networks, host, or ports, for example, allow my_lan and deny others<br \/>\nhttp_access allow my_lan<br \/>\nhttp_access deny all<\/p>\n<p>specify the local computer name:<br \/>\nvisible_hostname LocalComputerName<\/p>\n<p>to create a basic cache directories in \/var\/spool\/squid use:<br \/>\nsquid -z<\/p>\n<p>squid with nating:<br \/>\niptables -t nat -A PREROUTING -i eth0 -p tcp &#8211;dport 80 &#8211;j REDIRECT &#8211;to-ports 3128<\/p>\n<p>for selinux see;<\/p>\n<p>\/etc\/squid\/squid.conf has a lot explanation&#8230;<\/p>\n<p>####################################<\/p>\n<p>sendmail, Postfix and dovecot:<\/p>\n<p>sendmail:<br \/>\nadd your domain into \/etc\/mail\/local-host-names<br \/>\nvi \/etc\/mail\/sendmail.mc<br \/>\nallow other computers to to use your sendmail server, comment the following:<br \/>\nDAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA&#8217;)dnl<br \/>\ndon&#8217;t accept unresolvable domains, comment the follwoing:<br \/>\nFEATURE(`accept_unresolvable_domains&#8217;)dnl<\/p>\n<p>edit \/etc\/mail\/access to relay\/reject\/discard outgoing domains, for example<br \/>\n@example.org    REJECT<br \/>\ndeny.sqawasmi.com    REJECT<br \/>\nsqawasmi.com    RELAY<br \/>\n10.0.0    RELAY<\/p>\n<p>edit \/etc\/aliases to for aliasing and then do newaliases command<br \/>\nme    :    shaker<br \/>\nidle    :    shaker<br \/>\n~ # newaliases<\/p>\n<p>\/etc\/mail\/virtusertable used to map virual address to real address<\/p>\n<p>send from another host:<br \/>\ndefine(`SMART_HOST&#8217;, `smtp.sqawasmi.com&#8217;)dnl<br \/>\nyou should add access for this server in \/etc\/mail\/access<\/p>\n<p>make -C \/etc\/mail\/<\/p>\n<p>Postfix:<br \/>\nconfiguration file: \/etc\/postfix\/main.cf<\/p>\n<p>edit variables:<br \/>\nmyhostname: this is the host will appear in the hello&#8230;<br \/>\nmydomain: your domain name<br \/>\nmyorigin: this is the origin of the domain, for example sqawasmi.com, then all emails for shaker will be shaker@sqawasmi.com<br \/>\ninet_interfaces: what interfaces should i listen for?<br \/>\nmydestination: specifies the list of domains that this machine considers itself the final destination for.<br \/>\nmynetworks: specifies a list of trusted smtp clients.<\/p>\n<p>access goes in this file: \/etc\/postfix\/access<br \/>\nvirual: \/etc\/postfix\/virtual you need<\/p>\n<p>Dovecot:<br \/>\nconfiguration file:<br \/>\n\/etc\/dovecot.conf<\/p>\n<p>variables:<br \/>\nprotocols: choose the protocol you want to use..<br \/>\nlisten: if you don&#8217;t use the standard ports<br \/>\nssl listen: same as above&#8230;<\/p>\n<p>activate ssl:<br \/>\nssl_disable = no<br \/>\nssl_cert_file = \/etc\/pki\/dovecot\/certs\/dovecot.pem<br \/>\nssl_key_file = \/etc\/pki\/dovecot\/private\/dovecot.pem<br \/>\ncreating ssl certificates:<br \/>\nyou need to edit \/etc\/pki\/dovecot\/dovecot-openssl.cnf file as rquired<br \/>\nissue this command:<br \/>\n\/usr\/share\/doc\/dovecot-versionNumber\/examples\/mkcert.sh<\/p>\n<p>\/etc\/init.d\/dovecot start &amp;&amp; chkconfig dovecot on<\/p>\n<p>####################################<\/p>\n<p>tcp_wrappers<br \/>\ntwo files:<br \/>\n\/etc\/hosts.allow: tcp_wrappers look at this, if it find a match for the service it grants access, no additional searches are required, if no match in that file then it continue to read the next file:<br \/>\n\/etc\/hosts.deny: if it finds a match then deny access, if no match then access is automatically granted.<\/p>\n<p>format:<br \/>\ndaemon_list: client_list    or    ALL : ALL<\/p>\n<p>for example:<br \/>\n\/etc\/hosts.allow:<br \/>\nsshd : 10.0.0.2<br \/>\n\/etc\/hosts.deny:<br \/>\nsshd : ALL<br \/>\ndepending on those files, ssh login is permitted just for 10.0.0.2 host.<\/p>\n<p>you can use subnet or a domain like this:<br \/>\n\/etc\/hosts.allow:<br \/>\nsshd : 10.0.0.0\/255.255.255.0, .sqawasmi.com<br \/>\n\/etc\/hosts.deny:<br \/>\nsshd : ALL<br \/>\ndepending on those files, ssh login is permitted for 10.0.0.0 network and all computers in sqawasmi.com domain.<\/p>\n<p>you can use EXPECT operator to expect hosts\/networks or daemons..<\/p>\n<p>twist or spawn command to send messages, track access and log problems.. ex:<br \/>\n\/etc\/hosts.deny<br \/>\nsshd : nossh.sqawasmi.com : twist \/bin\/echo %c not allowed<\/p>\n<p>iptables:<br \/>\nhuh?<\/p>\n<h3>Related Images:<\/h3>","protected":false},"excerpt":{"rendered":"<p>This is RHCE notes i wrote while studding for the exam, it doesn&#8217;t cover all exam topics, maybe they can help you to review what did you studied no more..<br \/>\nUser Administration:<br \/>\n&#8211; adduser UserName<br \/>\n&#8211; deluser UserName<br \/>\n&#8211; usermod: to modifiy user information..<br \/>\n&#8211; chage: change expiration date for user account.<br \/>\n&#8211; always when you use a directory as a share for a group, use SGID, for ex: chmod 2770 \/share-dir<\/p>\n<p>for login\/logout scripts and bash, refer to this topic: bash loging, startup scripts and shell initialization files<\/p>\n<p>ACL:<br \/>\nmount with acl, ex:<br \/>\nmount -o remount, acl \/dev\/sda5 \/home<br \/>\nas root: touch \/home\/idle-boy\/a<\/p>\n<p>getfacl \/home\/idle-boy\/a<br \/>\ngetfacl: Removing leading &#8216;\/&#8217; from<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"footnotes":""},"categories":[18,20],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-linux-other-things","category-rhce"],"_links":{"self":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/comments?post=40"}],"version-history":[{"count":3,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/40\/revisions"}],"predecessor-version":[{"id":56,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/40\/revisions\/56"}],"wp:attachment":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/media?parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/categories?post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/tags?post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}