VanillaGranilla

CentOS/RHCSA notes

Sep 3rd, 2013
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.94 KB | None | 0 0
  1. Credit to http://www.pantz.org/ - source URL http://www.pantz.org/software/linux/rhcsa_study_guide.html
  2. -------------------------------------------------------------------------------------------------------
  3.  
  4. Below are my notes that I made after taking and passing the Red Hat Certified Systems Administrator (RHCSA) test. As usual I looked for RHCSA study guides and notes. I was not impressed with any of them so I made my own.
  5.  
  6. Use the notes below after going through a book like the RHCSA/RHCE Red Hat Linux Certification Study Guide. The book will help you understand what your doing below better. These notes are just quick descriptions and commands on how to get things done. It was made as more of an easy way to review different topics and run through how to do different tasks. There are also little notes on things you should know.
  7.  
  8. #####################
  9. ### Installing OS ###
  10. #####################
  11. # Use CentOS to practice as it is almost exactly the same as RH. The differences won't matter.
  12. # Install CentOS directly to a machine, don't use a VM. You will make another VM later to practice
  13. # On the initial boot screen hit Tab to see boot options. Put the word "text" at the end
  14. # of the boot option to boot in text mode.
  15.  
  16. # For FTP or HTTP install start install and select "URL" then put in:
  17. # ftp://192.168.0.1/pub/inst or similar FTP url where install files are
  18. # http://192.168.0.1/pub/inst or similar HTTP url where install files are
  19.  
  20. # Press Alt-F3,Alt-F4 or Alt-F5 if you have issues during install. They will show you the
  21. # log and error messages. Also you can get to a prompt and other cool things if you try
  22. # other Alt-F? keys.
  23.  
  24. # By default SELinux is enabled in enforcing mode.You can check this with the "sestatus" command.
  25. # Iptables is turned on by default.
  26.  
  27. ##############################
  28. ### General Administration ###
  29. ##############################
  30. # From the desktop get to terminal consoles. CTRL-ALT-F1 through F6
  31. # From desktop bring up a GUI terminal click Applications -> System Tools -> Terminal.
  32. # You can also right click anywhere on the desktop and select "Open Terminal".
  33.  
  34. # Linux uses 3 data streams. Standard In (STDIN), Standard Out (STDOUT),
  35. # Standard Error (STERR). You can send data to and from programs and files. < and >
  36. # can direct these streams in different directions to programs and files. Programs
  37. # can also send data to each other using the pipe |
  38. # Output from ls command to a file. Do this with grep or any other program also
  39. ls > filename
  40. # Send data from file to contacts program
  41. contacts < datafile
  42. # cat a file and read it with less
  43. cat /var/log/messages | less
  44. # Run program blah and send all errors to file errors
  45. blah 2> errors
  46.  
  47. # Pwd shows you which directory your currently in
  48. pwd
  49.  
  50. # Change to a dir like /var
  51. cd /var
  52.  
  53. # Show regular files in a directory
  54. ls
  55. # Show all file in a dir including hidden ones. Hidden files start with a period.
  56. ls -a
  57. # Show all files in var dir with a long listing and with SELinux contexts
  58. ls -laZ /var
  59.  
  60. # Make a blank file blah
  61. touch blah
  62. # Change date/time of current file to right now
  63. touch filename
  64.  
  65. # Make a directory blah in the /tmp dir
  66. mkdir /tmp/blah
  67. # Delete the dir you just made
  68. rmdir /tmp/blah
  69.  
  70. # Copy file /etc/passwd to /tmp
  71. cp /etc/passwd /tmp
  72. # Copy all files and directories from /etc/ to /tmp. -r recursive copy.
  73. cp -r /etc/* /tmp
  74.  
  75. # To rename a file use the move command. Rename file blah to blah1
  76. mv blah blah1
  77. # Move a file /var/boss to /tmp
  78. mv /var/boss /tmp
  79.  
  80. # Delete a file using the remove command (rm). Delete file boss
  81. rm boss
  82. # Remove a whole dir with all files in it. Example removing /tmp/blah dir. -f force -r recursive
  83. rm -rf /tmp/blah
  84.  
  85. # Create a link to a file. Allows you to make a shortcut to the file name.
  86. # Hard links include a copy of the file. Create link to blah in current dir to file /etc/blah
  87. ln /etc/blah blah
  88. # Softlink is just a redirect to the file. It uses the -s option.
  89. ln -s /etc/blah blah
  90.  
  91. # Show all running processes. First column is username, second is Process ID, CPU usage is third
  92. # The top of the output tells you what each column is. Check it out for the rest of the columns.
  93. ps -aux
  94. # Show processes for just user blah
  95. ps -u blah
  96. # Show all processes in SELinux context
  97. ps auxZ
  98.  
  99. # Use Top to see system load and processor and memory usage. Watch processes.
  100. top
  101.  
  102. # To change process priority use nice and renice commands. -20 highest priority, 19 lowest
  103. # Start process at lowest priority
  104. nice -n 19 ./process_intensive_task
  105. # Change priority of running process PID 455
  106. renice -1 455
  107.  
  108. # To kill process with process id 22 (use ps to find id's)
  109. kill 22
  110. # Kill all proceses of a certian name blah
  111. killall blah
  112.  
  113. # Find files named blah using the find command starting from the root dir /. Case sensitive.
  114. find / -name blah
  115. # Case insensitive search for same
  116. find / -iname blah
  117. # Use glob characters (* ? []) to help find things
  118. # * - any number of alphanumeric chars. Ex. blah* finds any word blah with 0 or more
  119. letters or numbers after it.
  120. # ? - any single alphanumeric chars. Ex. blah? finds any word blah with one letter or number after it.
  121. # [] - any range of letters or numbers. Ex. blah[12] finds any combo of blah1 blah2
  122. # Find a files owned by user jose
  123. find / -user jose
  124. # Find file belonging to group boo
  125. find / -group boo
  126.  
  127. # Use the locate command to find files faster than find.
  128. # Locate file dog
  129. locate dog
  130. # You have to make the locate database for this to work. It is run every day from cron.
  131. /etc/cron.daily/mlocate.cron
  132. # Hint is to run this when you first start the test and background it like so
  133. /etc/cron.daily/mlocate.cron &
  134.  
  135. # View files on the screent with cat. Ex. show file boo
  136. cat boo
  137.  
  138. # Use programs less and more to open and look at files. Ex file boo
  139. # Use arrows or page up and down keys to scroll up and down
  140. more boo or less boo
  141.  
  142. # Show the beginning of a file with the head command
  143. head /etc/passwd
  144.  
  145. # Show the end of a file with the tail command
  146. tail /etc/passwd
  147. # Show last 20 lines of file
  148. tail -n 20 /etc/passwd
  149.  
  150. # Use the sort program show lines of a file in alphabetical order depending on the first
  151. # letter in each line. Check man page to see how to sort in other orders
  152. sort /etc/passwd
  153.  
  154. # Use the grep command to find words or patterns in files. Like the word bash in /etc/passwd
  155. grep bash /etc/passwd
  156. # Find word dog in file /etc/blah. Output matching lines to file /tmp/boo
  157. grep dog /etc/blah > /tmp/boo
  158.  
  159. # Use diff command to see differences in files. Like between files boot and pie
  160. diff boot pie
  161.  
  162. # Wc can count words or lines of a file
  163. # Count words in a file boo
  164. wc -w boo
  165. # Count lines in file boo
  166. wc -l boo
  167.  
  168. # Use sed to stream edit files. Which means change them on the fly.
  169. # Like open file boo and change word dog to cat then save it
  170. sed -e 's/dog/cat/g' boo
  171. # See more examples here http://www.pantz.org/software/shell/shelloneliners.html
  172.  
  173. # Use awk to find words or numbers in files and print them out in a column format
  174. # Find all lines with the word bash in it
  175. awk '/bash/ {print $0}' /etc/passwd
  176. # See more examples here http://www.pantz.org/software/shell/shelloneliners.html
  177.  
  178. # Learn to edit files from a terminal with the program Vi.
  179. # Go here to learn the commands http://www.pantz.org/software/vi/vireference.html
  180.  
  181.  
  182. # Sysstat package has sar and iostat. Use sar to check system activty and io over time
  183. # Reports are put in /var/log/sa dir.
  184. # Check cron jobs in /etc/cron.d to run at intervals. Configs are in /etc/sysconfig/sysstat
  185. # /etc/cron.d/sysstat
  186. sar -A (shows output)
  187.  
  188. # Use gzip or bzip2 to compress a file
  189. gzip file1.txt
  190. bzip2 file1.txt
  191. # uncompress either with -d
  192. gzip -d file1.txt.gz
  193. bzip2 -d file1.txt.bz2
  194.  
  195. # Use tar to collect a bunch of files into one file
  196. # Tar up and compress all files in /opt into file called opt.tar.gz
  197. tar czvf opt.tar.gz /opt
  198. # Untar files back to /opt
  199. tar xvzf opt.tar.gz /opt
  200.  
  201. # User star to archive files on a system using SELinux
  202. # install star
  203. yum install star
  204. # Create file opt.star and save all extended attribs record headers with acl
  205. star -xattr -H=exustar -c -f=opt.star /opt/
  206. # Extract archive
  207. tar -x -f=opt.star
  208.  
  209. # System wide crontab is at /etc/crontab. Cron job files are also in /etc/cron.d/ dir.
  210. # Cron files can have their own environment variables located in the file like the following
  211. SHELL=/bin/bash
  212. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  213. MAILTO=root
  214. HOME=/
  215. # Cron job file format is the following, except for /etc/crontab that has an extra field for user
  216. # Minute Hour Day of Month Month Day of Week Command
  217. # (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
  218. 0 2 12 * 0,6 /usr/bin/find
  219. # Users have their own cron files called crontabs.
  220. # Edit your own crontab file
  221. crontab -e
  222. # Show your crontabs
  223. crontab -l
  224. # As root edit user1's crontab
  225. crontab -u user1
  226.  
  227. # If /etc/cron.allow does not exist and cron.deny does then users listed in .deny can't edit their tab
  228. # If both exist then only users in cron.allow can edit cron tabs. Same goes for at.allow and at.deny
  229.  
  230. # You can use the at program to schedule a one time command
  231. at now +2 hour
  232. at> /sbin/ping -c 127.0.0.1
  233. at>Ctrl-D
  234. # Will ping localhost in 2hrs
  235. # show at jobs
  236. atq
  237. # Remove job 1
  238. atrm 1
  239.  
  240. # Config files for rsyslog are /etc/init.d/rsyslog and /etc/rsyslog.conf
  241. # Levels of logging in ascending order: debug, info, notice, warn, err, crit, alert, emerg
  242. # There is also none priority that logs nothing like warn.none logs no warning messages
  243. # rsyslogd logs all messages of a given priority or higher. use that level and it logs that
  244. # level and higher. Use * to log all levels like auth.*
  245. # Most log files are written to /var/log/
  246. # Logrotate facility rotates logs on a weekly basis. Check /etc/logrotate.conf and the
  247. # scripts in /etc/logrotate.d dir.
  248.  
  249. # Install a VNC server and client. RH uses tigervnc
  250. yum install vinagre tigervnc tigervnc-server
  251. # Edit /etc/sysconfig/vncservers file put in lines for user1 and user2. examples are in file.
  252. VNCSERVER="1:user1 2:user2"
  253. VNCSERVERARGS[2]="-geometry 800x600"
  254. # Stop vnc server, so we can setup the users
  255. service vncserver stop
  256. # Login as the user or su to the. start vncserver or port 5902
  257. vncserver :2
  258. # Make sure iptables has port 5902 open if not open it
  259. system-config-firewall-tui
  260. # Connect to server on port 5902 with vnc client like vncviewer or vinagre
  261. vncviewer 192.168.0.1:2
  262. # To start a gui: vnc viewer Applications | Internet | Remote Desktop Viewer or Tiger VNC Viewer
  263. # To configure gnome based vnc server called vino run vino-preferences
  264.  
  265. # SSH line to connect to vnc over ssh on a remote system
  266. ssh -L 5902:sv1.example.com:5902 [email protected]
  267. # Then use a vnc client to connect to 127.0.0.1:2 as the server is listening on localhost
  268.  
  269. ############################
  270. ### System Documentation ###
  271. ############################
  272. # /usr/share/doc has tons of documentation on programs
  273. # Run commands by themselves for a quick help.
  274. # Run "man command" to see docs on that command
  275. # To search man pages title keywords use "whatis" like "whatis virsh"
  276. # To search man pages with keywords in the description use "apropos" like "apropos virsh"
  277. # To ensure that you can access the appropriate man pages, after installing new packages run
  278. /etc/crond.daily/makewhatis.cron
  279.  
  280. ###########################
  281. ### Installing Software ###
  282. ###########################
  283. # Install Apache webserver (as root)
  284. yum install httpd
  285. service httpd start
  286. # Check if running on localhost with browser http://127.0.0.1/. Install firefox if need be.
  287. yum install firefox
  288. # If not check if iptables is allowing it. Use system-config-firewall command to open port 80
  289. chkconfig httpd on
  290. # By default webserver files are kept in /var/www/html/
  291.  
  292. # Install VSFTP server (as root)
  293. yum install vsftpd
  294. service vsftpd start
  295. # Check if running on localhost with browser ftp://127.0.0.1/
  296. # If not check if iptables is allowing it. Use system-config-firewall command to open port 21.
  297. chkconfig vsftpd on
  298.  
  299. ########################
  300. ### File Permissions ###
  301. ########################
  302. # Chmod g or o or u (for section) + or - (to add or remove permisison) r or w or x (to set perm)
  303. chmod u+x file or chmod ugo+w file
  304. # Chmod number equiv r = 4, w = 2, and x = 1. Combine numbers for permisison setting.
  305. chmod 755 file (equiv to 4+2+1,4+1,4+1)
  306. # SUID SGUID and sticky are SUID=4, SGID=2, and sticky bit=1
  307. chmod 4764 file sets SUID bit.
  308. # Sticky bit (t) on dir using ugo/rwx format
  309. chmod o+t /tmp
  310. # Set group id bit on dir test
  311. chmod g+s /tmp/test
  312. # Chown user and group use -R for recursive
  313. chown username.groupname file
  314. # Chgrp changes group onwership.Below changes file owership to testgrp
  315. chgrp testgrp file
  316.  
  317. ######################
  318. ### File Attribues ###
  319. ######################
  320. # Lsattr lists file attributes. chattr sets file attributes
  321. chattr +i /etc/file (keep a file from being written to)
  322. lsattr /etc/file (look at attributes)
  323. chattr -i /etc/file (remove imutable attribute)
  324.  
  325. #############
  326. ### ACL's ###
  327. #############
  328. # File system has to have acl's turned on to use them. Edit /etc/fstab and in the
  329. # options section put "acl" like /dev/sdb2 /home ext4 defaults,acl 1,2.
  330. # Then remount file system to apply.
  331. mount -o remount /home
  332. # Get file ACL's (acl package has to be installed)
  333. getfacl filename
  334. # Modify acl's. Example for user Bob giving him rwx to file
  335. setfacl -m u:bob:rwx file
  336. # Remove acl on file for user bob
  337. setfacl -x u:bob file (add in -R to recursivly do the same)
  338. # Set acl group access for group luser on file
  339. setfacl -m g:luser:r--
  340. # Remove all acls on a file (going nuclear)
  341. setfacl -b file
  342. # Set acl mask (what file is allowed to be set to)
  343. setfacl -m mask:r-- file (makes it so only read acl can be set from now on)
  344.  
  345. ############################################
  346. ### IPTables (Firewall) and TCP wrappers ###
  347. ############################################
  348. # Iptables file is kept in file /etc/sysconfig/iptables
  349. # Start iptables
  350. /etc/init.d/iptables start or service iptables start
  351. # List all rules
  352. iptables -L
  353. # List all rules with rule numbers
  354. iptables -L --line-numbers
  355. # Stop iptables
  356. /etc/init.d/iptables stop or service iptables stop
  357.  
  358. # Look in /etc/services file for any ports of the services you might need to open
  359.  
  360. # You can add a rules to a running system
  361. # Append a rule to the end of the INPUT chain
  362. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  363. # Insert a rule at postion number 2 on the INPUT chain
  364. iptables -I INPUT 2 -p tcp --dport 80 -j ACCEPT
  365. # Delete a specific rule. Rule #3 on the INPUT chain.
  366. iptables -D INPUT 3
  367. # Replace a current rule Example replacing rule #3
  368. iptables -R INPUT 3 -p tcp -s 192.168.0.0/24 --dport 80 -j ACCEPT
  369. # To save any of these additions run the save command. This will put them in /etc/sysconfig/iptables
  370. service iptables save
  371.  
  372. # To make changes to the /etc/sysconfig/iptables file directly
  373. service iptables stop
  374. vi /etc/sysconfig/iptables (put in your line or mod a current line) then save it.
  375. service iptables start
  376.  
  377. # Console firewall tool
  378. # Saving anything in here overwrites any changes made by hand to the file /etc/sysconfig/iptables
  379. system-config-firewall-tui
  380.  
  381. # GUI based firewall tool
  382. # Saving anything in here overwrites any changes made by hand to the file /etc/sysconfig/iptables
  383. system-config-firewall
  384.  
  385. # TCP wrappers protect services that communicate using TCP. This is similar to
  386. # Iptables, but protects the TCP ports on a service basis. Binaries linked to
  387. # libwrap.so.0 can be protected using the /etc/hosts.allow and /etc/hosts.deny files.
  388.  
  389. # If a match is found in the /etc/hosts.allow file it's allowed. Matching stops. Checked 1st.
  390. # If a match is found in the /etc/hosts.deny file it's denied. Matching stops. Checked 2nd.
  391. # If a match is not found in either then access is allowed.
  392. # Format is daemon_name : clients_ip_or_hostnames
  393. # Use "ALL" keyword for allowing any service or client
  394. # Use "." to specify any host with a certain domain name like .blah.org
  395.  
  396. # Examples of formating to allow or deny hosts to services in the hosts.allow or .deny files
  397. # Restrict sshd to 192.168.0.0 subnet
  398. sshd : 192.168.0.1/255.255.255.0
  399. # Everything from .blah.org
  400. ALL : .blah.org
  401. # Everything from 192.168. except 172.168 block for services telnet and ssh
  402. sshd,in.telnetd : 192.168. EXCEPT 172.168.
  403.  
  404. # To make a white list type connection for your services in your /etc/hosts.deny file
  405. # put ALL:ALL on the last line. Put the connections and services you want to allow
  406. # above that line. Don't put in a /etc/hosts.allow file at all. This will deny all
  407. # connections to those services except for what you listed.
  408.  
  409. ###########
  410. ### KVM ###
  411. ###########
  412. # A 64bit CPU is required for KVM host machine in RedHat.
  413.  
  414. # Install virtualization packages
  415. yum groupinstall Virtualization*
  416. # Installed individually if you like
  417. yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python python-virtinst libvirt-client
  418. # Load kernel module for KVM if it's not already running
  419. modprobe kvm
  420. # Check for module if need be. You'll see kvm and kvm_intel or kvm_amd
  421. lsmod |grep kvm
  422. # Start libvirtd so we can use virt-manager
  423. service libvirtd start
  424. # Restart networking so the VM's can use the network bridge (virbr0) to get out through the host
  425. service network restart
  426.  
  427. # Virtual Machine Manager is part of the virt-manager package.
  428. # Start it in a GUI by clicking Applications | System Tools | Virtual Machine Manager.
  429. # or start it by typing "virt-manager" in a terminal window in Gnome.
  430.  
  431. # 2 hypervisors, also known as virtual machine monitors, are
  432. # shown on the localhost system. These hypervisors work with QEMU as processor
  433. # emulators within the virtual machines.
  434.  
  435. # Create a Second Virtual Network
  436. # 1. Right-click the standard localhost (QEMU) hypervisor, select Details.
  437. # 2. In the details wiindow select Virtual Networks tab.
  438. # 3. Click the plus sign in the lower-left corner of the Virtual Networks tab to
  439. open the Create A New Virtual Network Wizard.
  440. # 4. Click Forward to continue.
  441. # 5. Assign a name for the new virtual network. Enter the name foo. Click Forward to continue.
  442. # 6. If not already input, type in the 192.168.101.0/24 network address in the
  443. # network text box. Click Forward to continue unil you get to the end.
  444.  
  445. # Default filesystem directory for KVM images is /var/lib/libvirt/images.
  446. # If you change it the do the following
  447. mkdir /opt/KVM
  448. su -
  449. chcon -R --reference /var/lib/libvirt/images /opt/KVM
  450. rmdir /var/lib/libvirt/images
  451. ln -s /opt/KVM /var/lib/libvirt/images
  452.  
  453. ### Virtualization Packages ###
  454. # qemu-kvm - The main KVM package
  455. # python-virtinst - Command line tools and libraries for creating VMs
  456. # virt-manager - GUI VM administration tool
  457. # virt-top - Command for VM statistics
  458. # virt-viewer - GUI connection to configured VMs
  459. # libvirt - C language toolkit with the libvirtd service
  460. # libvirt-client - C language toolkit for VM clients
  461.  
  462. ### Creating a KVM VM with GUI ###
  463. # 1. Open virt-manager from the menu or run "virt-manager" from the GUI term prog.
  464. # 2. Right-click the localhost (QEMU) hypervisor and click "Connect" in the pop-up
  465. menu that appears
  466. # 3. In the pop-up menu that appears, click New.
  467. # 4. Type in a name for the new VM. Select install method. Click Forward.
  468. # 5. Select install media and OS type and version. Click forward.
  469. # 6. Choose RAM and CPU. Click forward.
  470. # 7. Check the editable storage box and choose a size for you disk image. Select allocate
  471. entire disk is selected. Click forward.
  472. # 8. Click advanced options and make sure networks looks ok. Click finish.
  473. # 9. It will create the VM. It should be listed in the Virtual Machine Manager now.
  474. # 10. You can highlight the new VM and and click Open. You can now do the OS install.
  475. #
  476. # After installing a KVM guest you need to change the boot device.
  477. # Click Applications | System Tools | Virtual Machine
  478. # Manager. Enter the root administrative password if prompted, and double-click on
  479. # the desired VM. Then change the boot device with the following steps:
  480. # 1. In the window associated with the VM, click View | Details.
  481. # 2. In the window that appears, click Boot Options.
  482. # 3. Change boot order by clicking hard disk and move it up with the arrow button. Click apply.
  483. # 4. Click View | Console and then Virtual Machine | Run. The system will boot normally.
  484.  
  485. # Creating a KVM VM with install questions on the cmd line
  486. virt-install --prompt
  487.  
  488. # Installing VM in one line using virt-install. Assumes kickstart file and packages on ftp server.
  489. # Also assumes disk image was made ahead of time.
  490. virt-install -n hostname.domain.lan -r 1024 --disk \
  491. path=/var/lib/libvirt/images/hostname.domain.lan.img \
  492. -l ftp://192.168.0.1/pub/inst \
  493. -x �ks=ftp://192.168.1.1/pub/ks1.cfg�
  494. # This line creates the disk (5Gig) and uses a kickstart file and repo from an http server
  495. # Just copy over the RH DVD #1 to the root of an http server. Put the kickstart file there also.
  496. virt-install -n testmachine2.domain.lan -r 1000 \
  497. --disk path=/var/lib/libvirt/images/testmachine2.domain.lan.img,size=5 \
  498. -l http://192.168.0.245/ --vcpus=1 -x "ks=http://192.168.0.245/ks.cfg"
  499.  
  500. # Virsh commands to check and control VM's
  501. # List all configured VM's status
  502. virsh list --all
  503. # Start VM
  504. virsh start hostname.domain.lan
  505. # Gracefully shutdown a VM (may not work)
  506. virsh shutdown hostname.domain.lan
  507. # Hard stop a VM (like pulling the power on it) use if shutdown does not work.
  508. virsh destroy hostname.domain.lan
  509. # Reboot a guest
  510. virsh reboot hostname.domain.lan
  511. # Make sure VM starts on host reboot
  512. virsh autostart hostname.domain.lan
  513. # Keep Vm from starting on boot (or rm sym link from /etc/libvirt/qemu/autostart dir)
  514. virsh autostart --disable hostname.domain.lan
  515. # Take disk snapshot with VM off (not part of RHCSA but interesting). Can't do live snapshot in RH6.
  516. virsh snapshot-create-as hostname.domain.lan snapshot1 --disk-only --atomic
  517. # List snapshots for VM (not part of RHCSA)
  518. virsh snapshot-list hostname.domain.lan
  519. # List snapshot info (not part of RHCSA)
  520. virsh snapshot-info --current hostname.domain.lan
  521.  
  522. # Clone a VM with install questions on the command line
  523. # Make sure vm is stopped
  524. virsh destroy hostname.domain.lan
  525. # Start clone
  526. virt-clone --prompt
  527. # When booting the clone start it in run level 1 and change network IP,MAC,Hostname, etc.
  528.  
  529. # Re-creating a VM with the same name or deleting a VM for good
  530. # Stop the VM
  531. virsh destroy tester1.example.com
  532. # Delete associated XML file.
  533. rm /etc/libvirt/qemu/hostname.blah.xml
  534. # Delete VM disk image by name from images dir.
  535. /var/lib/libvirt/images/hostname.blah.img
  536. # Restart the VM daemon for changes to take effect
  537. /etc/init.d/libvirtd restart
  538.  
  539. ### Add virtual HD's to a KVM VM (Not on test) ###
  540. # Make a bunch of virtual HD's to practice LVM
  541. 1. Open virt-manager
  542. 2. Select regular localhost (QEMU) hypervisor, right click and select connect.
  543. 3. Right click a vm and then open. View | Details click Add Hardware.
  544. 4. Follow install wizard. On next boot partition the drive with fdisk or parted.
  545.  
  546. ### Notes on getting VM Networking going (not on test)###
  547. # On a KVM-based virtual host, you may notice additional firewall rules
  548. # the following additional rule,accepts traffic over a physical bridged network device.
  549. # /etc/sysconfig/iptables: -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
  550. # to make this work in /etc/sysctl.conf file set net.ipv4.ip_forward=1
  551. # To activate this run "sysctl -p"
  552. # More great info on getting NAT working with libvert http://wiki.libvirt.org/page/Networking
  553.  
  554. #################
  555. ### Kickstart ###
  556. #################
  557. # All machines have a kickstart file called /root/anaconda-ks.cfg with the options they were installed.
  558.  
  559. # You can put ks file on things like HD's or USB media and access it during install. During
  560. # initial install screen hit tab to get Grub boot line. Then at the end of the line put
  561. # ks=hd:sdb1:/ks.cfg for accessing a file on the second device's root partition #1.
  562. # For CDROM ks=cdrom:/ks.cfg. For FTP ks=ftp://192.168.0.1/pub/ks.cfg. For HTTP
  563. # and NFS ks=nfs:192.168.9.1/ks.cfg ks=http://192.168.9.1/ks.cfg
  564.  
  565. # To help modify a kickstart file install and use the RH system kickstart program
  566. # Install
  567. yum install system-config-kickstart
  568. # Start program use systems ks file as example
  569. system-config-kickstart /root/anaconda-ks.cfg
  570.  
  571. # Here is a kickstart file I used during testing. Make sure you open up iptables ports for on your kvm host that
  572. # your guests can use. If things won't work drop iptables to see if that is it. service iptables stop
  573. # Webserver 192.168.0.245 with RH DVD files were on local apache server along with kickstart the file.
  574. firewall --enabled --service=ssh
  575. install
  576. url --url="http://192.168.0.245/"
  577. repo --name="CentOS" --baseurl=http://192.168.0.245 --cost=100
  578. rootpw --iscrypted $1$Kiv/ikw81H@#JEjejowwudj333
  579. auth --useshadow --passalgo=sha512
  580. graphical
  581. firstboot --disable
  582. keyboard us
  583. lang en_US
  584. selinux --enforcing
  585. logging --level=info
  586. timezone America/New_York
  587. network --bootproto=dhcp --device=eth0 --onboot=on
  588. bootloader --append="crashkernel=auto rhgb" --location=mbr --driveorder="sda"
  589. zerombr
  590. clearpart --all --initlabel
  591. part / --fstype="ext4" --size=4600
  592. part swap --grow --size=200
  593. %packages
  594. @base
  595. @console-internet
  596. @core
  597. @debugging
  598. @directory-client
  599. @hardware-monitoring
  600. @java-platform
  601. @network-file-system-client
  602. @perl-runtime
  603. @print-client
  604. @server-platform
  605. @server-policy
  606. certmonger
  607. device-mapper-persistent-data
  608. ftp
  609. genisoimage
  610. krb5-workstation
  611. mtools
  612. oddjob
  613. pam_krb5
  614. pax
  615. perl-DBD-SQLite
  616. samba-winbind
  617. sgpio
  618. wodim
  619. %end
  620.  
  621.  
  622. #######################
  623. ### Logical Volumes ###
  624. #######################
  625.  
  626. ### Description of pieces ###
  627. # Physical volume (PV) A PV is a partition, configured (initialized) to the LVM partition type.
  628. # Physical extent (PE) A PE is a small uniform segment of disk space. PVs are split into PEs.
  629. # Logical extent (LE) Every LE is associated with a PE and can be combined into a volume group.
  630. # Volume group (VG) A VG is a bunch of LEs, grouped together.
  631. # Logical volume (LV) An LV is a part of a VG, which can be formatted and
  632. # then mounted on the directory of your choice.
  633.  
  634. ### The Process ###
  635. # Partition needs to be made on the disk.
  636. # The partition needs to be labeled as a logical volume.
  637. # The labeled partition can then be initialized as a physical volume.
  638. # One or more physical volumes can be combined as a volume group.
  639. # A volume group can be subdivided into logical volumes.
  640. # A logical volume can then be formatted to a Linux file system or as swap space.
  641. # The formatted logical volume can be mounted on a directory or as swap space.
  642.  
  643. # Make your partitions with fdisk and mark them with the LVM fs type
  644. # Assuming we have 2 hd's sda and sdb. We will use VG001 as the VG name.
  645. # Initialize the physical volumes
  646. pvcreate /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2
  647. # Create the volume group from the PV's
  648. vgcreate VG001 /dev/sda1 /dev/sda2
  649. # Add more PV's. We could have added all PV's above but wanted to show extending
  650. vgextend VG001 /dev/sdb1 /dev/sdb2
  651. # Create logical vols with size of 100Meg with the name disk1
  652. lvcreate -L 100M VG001 -n disk1
  653. # The device /dev/VG001/disk1 gets created and can be formatted and mounted.
  654. mkfs.ext4 /dev/VG001/disk1
  655. mkdir /disk1
  656. mount /dev/VG001/disk1 /disk1
  657. # You should put this in the /etc/fstab so it is mounted on boot
  658. /dev/mapper/VG001-disk1 /disk1 ext4 defaults 1 2
  659.  
  660. # Resize Logical Vol to make it bigger by adding a new disk partition (/dev/sdc1)
  661. # Unmount dir associated with lv Ex. /home
  662. umount /home
  663. # Extend the vg (vg001) with new partitions Ex. sdc1
  664. vgextend vg001 /dev/sdc1
  665. # Make sure it's added
  666. vgdisplay vg001
  667. # Extend the lv to 5G
  668. lvextend -L 5000M /dev/vg001/lv00
  669. # Expand the filesystem to use the new space
  670. resize2fs /dev/vg001/lv00
  671.  
  672. # GUI for managing LVM is system-config-lvm
  673.  
  674. # Useful LVM commands
  675. # pvdisplay - Displays currently configured PVs.
  676. # pvchk - Checks the integrity of a physical volume.
  677. # pvs - Lists configured PVs and the associated VGs.
  678. # pvmove - Moves PVs in a VG from the specified partition to free locations
  679. on other partitions; prerequisite is to disable the PE.
  680. # vgcfgbackup - Backs up and restores the configuration files associated with LVM
  681. # vgchange - Similar to pvchange, allows you to activate or deactivate a VG. For
  682. # vgck - Checks the integrity of a volume group.
  683. # vgcreate - Creates a VG, from two or more configured PVs: for example,
  684. # vgdisplay - Displays characteristics of currently configured VGs.
  685. # vgextend - if you�ve create a new PV vgextend vg00 /dev/sda11 adds the
  686. space from /dev/sda11 to vg00.
  687. # vgrename - Allows renaming of LVs.
  688. # vgs - Displays basic information on configured VGs.
  689. # vgscan - Scans and displays basic information on configured VGs.
  690. # lvcreate - Creates a new LV in an existing VG.
  691. # lvdisplay - Displays currently configured LVs.
  692. # lvextend - Adds space to an LV: the lvextend -L6G /dev/volume01/lv01
  693. command extends lv01 to 6GB, assuming space is available.
  694. # lvrename - Renames an LV.
  695. # lvresize - Resizes an LV; can be done by -L for size. For example, lvresize -L
  696. 6GB volume01/lvl01 changes the size of lvl01 to 6GB.
  697. # lvs - Lists all configured LVs.
  698.  
  699. # Don't setup a LVM vol for the /boot dir. Linux can't read from it on boot.
  700.  
  701. ###############
  702. ### SELINUX ###
  703. ###############
  704. # Install SELinux management tools
  705. yum install policycoreutils* (and other SE management tools)
  706. # Then start with
  707. system-config-selinux
  708.  
  709. # SELinux assigns different contexts to each file, known as subjects, objects, and actions
  710. # A subject is a process, like a running command, or an app like a running web server.
  711. # An object is a file.
  712. # An action is what may be done by the subject to the object.
  713. # Most SELinux settings are boolean. activitated or deactiviated by setting to 1 or 0.
  714. # Booleans are stored in the /selinux/booleans directory
  715. # Modify booleans with getsebool and setsebool set with -P to survice reboot.
  716. # To see all booleans use getsebool -a. Description on each use semanage boolean -l
  717.  
  718. -rwxr-----. root root system_u:object_r:admin_home_t:s0 .bashrc
  719. | | | | |
  720. user role type MLS Level Filename
  721.  
  722. # File to set selinux mode (enforcing, permissive, or disabled) /etc/sysconfig/selinux
  723.  
  724. # To show what mode your in use commands:
  725. getenforce or sestatus
  726. # Change current mode. For enabling, the line SELINUX= has to be set to enforcing
  727. setenforce enforcing or setenforce permissive
  728. # To show selinux status of users. Yum install policycoreutils* to get semanage program.
  729. semanage login -l
  730. # Change user bob to staff_u user. This also adds bob's mapping between linux users and SELinux.
  731. semanage login -a -s staff_u bob
  732. # Delete user bob from staff_u list
  733. semanage login -d bob
  734.  
  735. # Show SE file contexts
  736. ls -Z
  737. # Show process contexts
  738. ps -eZ
  739. # Default contexts are configured in /etc/selinux/targeted/contexts/files/file_contexts
  740. # Copy context from one dir to another recursively
  741. chcon -R --reference=/var/www/html/ /var/www/html/inst
  742. # Restore contexts back to default
  743. restorecon -F /var
  744.  
  745. # Logs for SElinux (records and show problems) are in /var/log/audit/audit.log
  746. # Use ausearch to Search for things like sudo issues in the access vector cache
  747. ausearch -m avc -c sudo
  748. # Show all avc issues
  749. ausearch -m avc
  750. # A better tool to find SELinux issues is sealeart
  751. sealert -a /var/log/audit/audit.log
  752.  
  753. # Show all SELinux booleans on the system
  754. getsebool -a
  755. # Set one to off. Ex. set user_ping to off. -P makes setting survive reboot
  756. setsebool -P user_ping off
  757.  
  758. ####################
  759. ### Boot Process ###
  760. ####################
  761. # Press A at the GRUB boot menu to append an option to the boot line.
  762. # Enter a 1 - 5 at the end of this menu to boot to that run level.
  763. # Enter the word "single" at the end of the prompt to do
  764. # everything but run the scripts listed in the /etc/rc1.d/ dir.
  765. # Single mode is great way to recover a forgotten root password. Just boot into single and type passwd.
  766. # Enter init=/bin/sh at the end of the prompt. This does not load init-related files
  767. # but mounts only the top-level root directory (/) in read-only mode
  768.  
  769. # To change the current bootable run level edit /etc/inittab file and change the number
  770. # in the line id:5:initdefault: to the level you want.
  771.  
  772. ### Grub ###
  773. # Change Grub boot menu items in file /boot/grub/grub.conf
  774. # Use grub-md5-crypt program to make a md5 password hash for the password --md5 line in
  775. # the /boot/grub/grub.conf
  776. # From the grub prompt find the grub.conf file (finding the boot dir)
  777. grub> find /grub/grub.conf or run grub> root
  778. # Look at grub conf file
  779. grub> cat (hd0,0)/grub/grub.conf
  780.  
  781. # Check run level with the "runlevel" command.
  782. # Change runlevel with the "init" or "telinit" command. Changing to run level 2:
  783. init 2 or telinit 2
  784. # Reboot the system with the reboot command
  785. reboot
  786. # Shutdown the system with the "shutdown" command.
  787. shutdown
  788.  
  789. # Upstart config files/boot process files are kept in /etc/init/ and /etc/sysconfig/init
  790.  
  791. # Show processes that start at different run levels
  792. chkconfg --list
  793. # Make sure postfix process starts at boot
  794. chkconfig postfix on ( or issue "off" so it does not start)
  795. # Turn off postfix at runlevel 4
  796. chkconfig --level 4 postfix off
  797. # Ntsysv is a console gui to manage runlevels. Issue command with runlevels to manage
  798. ntsysv --level 2345
  799. # Use gui to manage services
  800. system-config-services
  801.  
  802. ##################
  803. ### Networking ###
  804. ##################
  805. # Interface network files are in /etc/sysconfig/network-scripts dir.
  806. # They look like ifcfg-eth0. This is the default network interface.
  807. # Config options speak for themselves for the most part.
  808. # Networking on/off and hostname is in /etc/sysconfig/network
  809. # bring up interface
  810. ifup ifcfg-eth0 or ifup eth0
  811. # Shutdown interface
  812. ifdown ifcfg-eth0 or ifdown eth0
  813. # Show interface info
  814. ifconfig eth0
  815. # Show routing table
  816. netstat -nr or route
  817. # Add a default route to a box
  818. route add default gw 192.168.1.1
  819. # Add a route to a different network through a different interface
  820. route add -net 192.168.2.0 netmask 255.255.255.0 dev eth1
  821. # Show all network connections and listening services with PID's.
  822. netstat -punta
  823. # Show all arp entries
  824. arp
  825. # Delete arp entry
  826. arp -d hostname
  827. # Network console gui
  828. system-config-network-tui
  829. # GUI network editor.
  830. nm-connection-editor
  831. # Look in the upper right hand corner of the desktop for the Network Manager icon
  832. # Feel no shame using this during the test. System->Preferences->Network Connections.
  833. # Make a dhcp request with dhclient to configure eth0 for dynamic networking
  834. # This is done by default at boot if /etc/sysconfig/network-scripts says so.
  835. dhclient eth0
  836. # See if an ip address is working/responding on the network with the ping command
  837. # You can also use the hostname of a system. It will re
  838. ping 127.0.0.1
  839. # Check network status
  840. service network status
  841. # Restart networking
  842. service network restart
  843.  
  844. # DNS info is in /etc/resolv.conf file. Set system hostname in /etc/hosts and /etc/sysconfig/network
  845. # Order of search for /etc/hosts and DNS is in /etc/nsswitch file. The line is: hosts: files dns
  846.  
  847. # NTP settings are in /etc/ntp.conf multiple server lines can be put in like so
  848. server 0.rhel.pool.ntp.org
  849. server 1.rhel.pool.ntp.org
  850. # Make sure NTPD starts on boot: chkconfig ntpd on
  851.  
  852. ###################
  853. ### File Systems ###
  854. ###################
  855. ### fdisk (to make partitions) ###
  856. # If you need more than 4 partitions make the first 3 as primart and the 4th as extended.
  857. # Extended partition should always be the biggest as the rest parts have to fit in it.
  858. # point fdisk to a hard drive (real or virtual
  859. fdisk /dev/sda or fdisk /dev/vda
  860. # fdisk commands: (m)-for help, (n)-new part, primary-(p) or logical-(l) (e)-extended partition,
  861. # (a)-make partition bootable, (w)-write config to disk, (d)-delete part
  862. # Select the type of partition after making it with (t)- type .
  863. # Types: 82-Linux swap, 83-Linux partition, 8e-Linux LVM partition used as a physical vol
  864.  
  865. ### Parted (to make partitions) ###
  866. # Start parted on /dev/sda
  867. parted /dev/sda
  868. # Make a disk label if need be
  869. mklabel (type: msdos)
  870. # Make a partiiton (follow the prompts)
  871. mkpart
  872. # Show changes and check it
  873. p
  874. # del partition #1
  875. rm 1
  876. # Exit
  877. quit
  878. # To set flag for lvm or raid
  879. (parted) set
  880. Partition number? 1
  881. Flag to Invert? lvm or raid
  882. New state? [on]/off on
  883.  
  884. # If you make a swap partition, create it and active it with mkswap /dev/sda2;swapon /dev/sda2
  885.  
  886. # Check a file system for problems by unmouting it and running the fsck command
  887. umount /disk1
  888. fsck -t ext4 /dev/sda7
  889. mount /dev/sda7 /disk1
  890.  
  891. # Convert sda1 from ext3 to ext4 (can't go back after upgrading)
  892. tune2fs -O extent,uninit_bg,dir_index /dev/sda1
  893. # check if it worked
  894. dumpe2fs /dev/sda1 | grep �Filesystem features�
  895.  
  896. # Format any file systems with ext4. Ex. with /dev/sdb1
  897. mkfs.ext4 /dev/sdb1
  898.  
  899. ### LUKS ###
  900. # LUKS is an encrypted filesystem mounted on a specific directory.
  901. # Install needed packages.
  902. yum install cryptsetup-luks
  903. # Look for kernel modules for LUKS. Might not be loaded by default.
  904. lsmod | grep dm_crypt
  905. # If not loaded load them
  906. modprobe dm_crypt
  907. # Make a partition you want to be encrypted with fdisk or parted. Ex. /dev/sda1
  908. # Prepare (initialize) the partition for LUKS. Type your passphrase when asked.
  909. cryptsetup luksFormat /dev/sda1
  910. # Get UUID of device (optional)
  911. cryptsetup luksUUID /dev/sda1
  912. # Map the device to /dev/mapper. Use your own name here (ev) or use th UUID.
  913. cryptsetup luksOpen /dev/sda1 ev
  914. # Now format the device in the /dev/mapper dir
  915. mkfs.ext4 /dev/mapper/ev
  916. # Find UUID of drive (if you don't have it.)
  917. dumpe2fs /dev/mapper/ev | grep UUID
  918. # Make dir to mount vol to
  919. mkdir /ev
  920. # Put a line in /etc/crypttab so it will be activated on boot.
  921. # This will automatically load the dm_crypt module.
  922. # Replace ev with UUID if you choose to use that
  923. ev /dev/sda1 none
  924. # Put mount line in /etc/fstab either by UUID or the name you have chosen.
  925. /dev/mapper/ev /ev ext4 defaults 1 2
  926. or
  927. UUID=uuidNumber /ev ext4 defaults 1 2
  928. # Mount disk
  929. mount -a
  930. # On boot you will have to type a password to mount this LUKS partition
  931.  
  932. # To get device uuid's
  933. dumpe2fs /dev/vda1 | grep UUID or dumpe2fs /dev/mapper/7* | grep UUID
  934. # You can also use the program blkid
  935. blkid /dev/sda1
  936.  
  937. # Example of mounting NFS
  938. mount -t nfs hostname.example.com:/pubic /share
  939. # Example mounting with CIFS
  940. //server/pubic /share cifs rw,username=user,password=pass, 0 0
  941.  
  942. ### Automounter ###
  943. # Uses autofs service to mount things dynamically. Make sure it's running and starts on boot.
  944. # Relevant configuration files are auto.master, auto.misc, auto.net, and auto.smb, in the /etc dir
  945. # The misc net smb after the auto. name show what dir things will be mounted to from /
  946. # Make sure the /smb /misc /net and others your using for autofs don't exist. They will be auto created.
  947. # For example auto.smb would mount to the /smb dir and net mouts to /net (used for NFS mounts)
  948. # Automounter settings are in /etc/sysconfig/autofs
  949.  
  950. # In the auto.master the first field is the mount point.The second field is the location of the map file,
  951. # The third field can contain information such as a timeout value
  952.  
  953. # Example NFS mount in the /etc/auto.net file. auto.master has to have line /net -hosts
  954. project -rw,soft,intr,rsize=8192,wsize=8192 blah.example.net:/proj
  955. | | | |
  956. localdir mount options remote host remote mount point
  957.  
  958. # Example of a CD mounted to misc. Put this line in auto.misc
  959. cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
  960.  
  961. # Setting up automounted NFS home dir's. You have to remove your /home dir for this to work.
  962. # In auto.master put the line "/home /etc/auto.home"
  963. # In /etc/sysconfig/autofs uncomment the lines to
  964. DEFAULT_MAP_OBJECT_CLASS=�automountMap�
  965. DEFAULT_ENTRY_OBJECT_CLASS=�automount�
  966. DEFAULT_MAP_ATTRIBUTE=�automountMapName�
  967. DEFAULT_ENTRY_ATTRIBUTE=�automountKey�
  968. DEFAULT_VALUE_ATTRIBUTE=�automountInformation�
  969. # Make the file /etc/auto.home and put in
  970. * -fstype=nfs,rw,soft,intr,rsize=8192,wsize=8192,nosuid,tcp server.example.com:/home/&
  971. # restart autofs
  972. service autofs restart
  973.  
  974. ##########################
  975. ### Package Management ###
  976. ##########################
  977. # RPM packages can be installed with "rpm -ivh package.rpm" or rpm -ivh ftp://ftp.com/package.rpm
  978. # RPM packages can be Upgraded/installed with "rpm -Uvh package.rpm".
  979. -U replaces package if it's there, if not it just installs it.
  980. # RPM packages can be removed with "rpm -evh package.rpm"
  981. # See if package is installed with rpm -q package.rpm. See all install packages rpm -qa
  982. # List all file from package rpm -ql
  983. # Verify all files within packge against downloaded rpm. rpm --verify -p package.rpm
  984. # Install GPG key
  985. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  986.  
  987. # Important Yum file /etc/yum.conf and dir's /etc/yum.repos.d & /etc/yum
  988. # Get the full list of yum configuration directives and values run: yum-config-manager
  989.  
  990. # Install package with yum
  991. yum install packagename
  992. # Info about package
  993. yum info packagename
  994. # Remove package
  995. yum erase packagename
  996. # Update all packages on system
  997. yum update
  998. # Search for file in a package
  999. yum whatprovides */*filename
  1000. # Clean up downloaed packages, flush cache headers
  1001. yum clean all
  1002. # Look at all package groups available
  1003. yum grouplist
  1004. # Find info on a package group. Anything listed in "Optional Packages" will not be installed
  1005. yum groupinfo "Virtualization"
  1006. # Install group package
  1007. yum groupinstall "Virtualization"
  1008. # Remove group package
  1009. yum groupremove packagename
  1010.  
  1011. # GUI package management can be done by running "gpk-application" or
  1012. # click System | Administration | Add/Remove Software.
  1013.  
  1014. # Make a simple Yum repo in /etc/yum.repos.d. Example in "man yum.conf"
  1015. cd /etc/yum.repos.d
  1016. vi myrepo.repo the file will look like:
  1017. [myrepo]
  1018. name=foo
  1019. baseurl=http://192.168.1.1/inst
  1020. # Then run
  1021. yum clean all
  1022. yum update
  1023.  
  1024. #######################
  1025. ### User Management ###
  1026. #######################
  1027. # /etc/passwd contains basic user info.
  1028. Column Field Description
  1029. ---------------------------------------------------------------------
  1030. 1 Username The users login name. Usernames can include hyphens (-) or
  1031. underscores (_). They should not start with a number or include
  1032. uppercase letters.
  1033. 2 Password The password. You should see either an x, an asterisk (*), or a
  1034. random group of letters and numbers. An x points to /etc/shadow with
  1035. the actual password. An asterisk means the account is disabled. A random
  1036. group of letters and numbers represents the encrypted password.
  1037. 3 User ID The unique numeric user ID (UID) for that user. By default, Red Hat starts
  1038. user IDs at 500.
  1039. 4 User Info You can enter any information of wamt in this field. For example
  1040. the user�s full name, telephone number, e-mail address, or
  1041. physical location. You can leave this blank if you like.
  1042. 5 Home Directory By default, RHEL puts new home directories in /home/username
  1043. 6 Login Shell By default, RHEL assigns users to the bash shell. Change this to
  1044. any other shell you have installed on the system.
  1045.  
  1046. # /etc/group groups users are assigned to.
  1047. Column Field Description
  1048. ---------------------------------------------------------------------
  1049. 1 Groupname Each user gets their own group, with the same name as theirr
  1050. username. You can also create unique group names.
  1051. 2 Password The password. You should see either an x or a
  1052. random group of letters and numbers. An x points to /etc/
  1053. gshadow for the actual password. A random group of letters
  1054. and numbers represents the encrypted password.
  1055. 3 Group ID The numeric group ID (GID) associated with that user. By
  1056. default, RHEL creates a new group for every new user. If you
  1057. want to create a special group such as clowns, you should
  1058. assign a GID number outside the standard range, otherwise,
  1059. Red Hat GIDs and UIDs would probably get out of sequence.
  1060.  
  1061. 4 Group members Lists of usernames that are members of the group. If it�s
  1062. blank, and there is a username that is identical to the group
  1063. name, that user is the only member of that group.
  1064.  
  1065.  
  1066. # /etc/shadow supplent to /etc/passwd file. Consists of
  1067. Column Field Description
  1068. ---------------------------------------------------------------------
  1069. 1 Username Username
  1070. 2 Password Encrypted password; requires an x in the second column
  1071. of /etc/passwd
  1072. 3 Password history Date of the last password change, in number of days
  1073. after January 1, 1970
  1074. 4 mindays Minimum number of days that a user must keep a password
  1075. 5 maxdays Maximum number of days after which a password must be changed
  1076. 6 warndays # of days before password expiration when a warning is given
  1077. 7 inactive # of days after password expiration when an account is
  1078. made inactive
  1079. 8 disabled Number of days after password expiration when an
  1080. account is disabled
  1081.  
  1082. # /etc/login.defs file gives a baseline for a number of parameters in the shadow password suite
  1083. # MAIL_DIR - locally delivered e-mail, listed by username
  1084. # PASS_MAX_DAYS - After this number of days, the password must be changed.
  1085. # PASS_MIN_DAYS - Passwords must be kept for at least this number of days.
  1086. # PASS_MIN_LEN - A warning is given when a user tries to use a password shorter than this length.
  1087. # PASS_WARN_AGE - Users are warned this number of days before PASS_MAX_DAYS.
  1088. # UID_MIN,UID_MAX,GID_MIN, GID_MAX - Mins and maxes of userids and group id's.
  1089. # ENCRYPT_METHOD - hash type used for passwords on the system.
  1090. # Their a a bunch more. Look in the file for the rest.
  1091.  
  1092. # If editing password and group files by hand use the vipw or vigr programs.
  1093. # Use -s with vipw vigr to edit shadow versions of those files
  1094.  
  1095. # User "useradd" to add users to the system. Below adds user1 to system.
  1096. # -c adds comment, -d overrides default homedir, -e expiration date for account
  1097. # -f # of days after expiration acct expires, -G add user to these groups, -s shell
  1098. useradd user1 -c Mr.User1 -d /opt/home -e 2013-11-31 -f 1 -G grp1,grp2 -s /usr/bin/chsh
  1099. # Give user1 a password
  1100. passwd user1
  1101.  
  1102. # Delete user with "userdel". By default user homedir is not removed. -r deletes home dir
  1103. userdel -r user1
  1104.  
  1105. # Add group called clowns use id 1001. omit -g and it takes next available id
  1106. groupadd -g 1001 clowns
  1107. # Delete group clowns
  1108. groupdel clowns
  1109. # Set a group password with "gpasswd" program.
  1110. gpasswd mygroup
  1111.  
  1112. # Modify current users with usermod. -e change expiration, -G adds user to a group,
  1113. # -L locks account, -U unlocks account, -s new shell, -aG append user to existing group
  1114. # You can also open the /etc/passwd or /etc/group file by hand. Like changing the users shell.
  1115. usermod -e 2013-11-30 -s /bin/bash -aG group2 user1
  1116.  
  1117. # Groupmod changes group id or groupname
  1118. groupmod group1 group2 (changes group1 name to group2)
  1119.  
  1120. # Using SGID bit to allow users who are part of the same group to share files
  1121. # This assumes we used the commands above to create a group called group1 and
  1122. # Put our users who want to share files into that group. SGID allows files created
  1123. # in that directory automatically have their group ownership set to be the
  1124. # same as the group owner of the directory. You can also set SGID with chmod g+s dirname
  1125.  
  1126. mkdir /opt/shared
  1127. chown user1:group1
  1128. chmod 2770 /opt/shared
  1129.  
  1130. # Use gui system-config-users to administer users
  1131.  
  1132. # Chage command manages password aging info.
  1133. # -l lists account info, -d last change date for pass, -E assigns expiration for acct,
  1134. # -I locks acct # days after expire, -m set min number of days to keep pass, -M sets
  1135. # max # of days to keep pass (-1 to disable), -W days before pass must be changed
  1136.  
  1137. # Remove virtual console ttys in /etc/securetty file to stop direct root logins.
  1138. # Virtual consoles are started in /etc/init/start-ttys.conf
  1139. # /etc/security/access.conf file regulates user access to ttys and remote systems
  1140.  
  1141. # To only allow users in the wheel group to su to other users uncomment the following line
  1142. # in the /etc/pam.d/su file
  1143. auth required pam_wheel.so use_uid
  1144.  
  1145. # To limit tty's to only the root user make a file called /etc/nologin
  1146. # put any message you like in the file telling users only root has access.
  1147.  
  1148. # To execute a command with a groups privs use the sg command.
  1149. sg group1 -c 'cp /tmp/file1 /home/group1' (copy file1 to the group1 dir)
  1150.  
  1151. # Change the /etc/sudoers file using visudo to change access users have to the sudo command
  1152. # Give user1 full system access
  1153. user1 ALL=(ALL) ALL
  1154. # Give users in the wheel group full system access with no password
  1155. wheel ALL=(ALL) NOPASSWD: ALL
  1156.  
  1157. # /etc/skel dir contains default environment files for new accounts.
  1158.  
  1159. # /etc/bashrc file is used for aliases and functions, on a system-wide basis
  1160. # Change system wide umask here, defines the default prompt,
  1161. # includes settings from *.sh in the /etc/profile.d/ dir
  1162.  
  1163. # /etc/profile and /etc/profile.d is used for system-wide environments and startup files.
  1164. # /etc/profile uses PATH, USER, LOGNAME, MAIL, HOSTNAME, HISTSIZE, and HISTCONTROL variables
  1165. # and runs files in /etc/profile.d
  1166. # /etc/profile.d directory is designed to contain scripts to be executed by the /etc/profile file
  1167.  
  1168. ### Configuring an LDAP client ###
  1169. # You can configure LDAP with the system-config-authentication GUI or authconfig-tui.
  1170. # The GUI is the preferred method. Try not to do it by hand if at all possible.
  1171. # Here is the "by hand" method
  1172.  
  1173. # In the /etc/pam_ldap.conf file check/change the following lines
  1174. host 127.0.0.1 (change IP to the LDAP server)
  1175. base dc=example,dc=com (change to base distinguished name)
  1176. ssl start_tls (Required if TLS support is used to encrypt
  1177. passwords that are sent to the LDAP server.)
  1178. pam_password encryption schemes for passwords; crypt, nds, ad
  1179. uri ldap://127.0.0.1/ (change to ldap server use ldaps:// if using ssl
  1180. ssl no (change to yes if using ldaps)
  1181. tls_cacertdir /etc/openldap/cacerts (certs for ssl connection
  1182. nss_init, groups_ignoreusers root, ldap (Assumes no supplemental groups in the LDAP directory server)
  1183. pam_password md5 (password type if you want to use RH default change to: exop
  1184.  
  1185. # In the /etc/openldap/ldap.conf file put the following changing for your enviornment
  1186. URI ldap://127.0.0.1
  1187. HOST ldap1.example.com
  1188. BASE dc=example,dc=com
  1189. TLS_CACERTDIR /etc/openldap/cacerts
  1190.  
  1191. # In the /etc/nsswitch.conf file add ldap to lookups
  1192. passwd: files ldap
  1193. shadow: files ldap
  1194. group: files ldap
  1195.  
  1196.  
  1197. #######################
  1198. ### Different GUI's ###
  1199. #######################
  1200. system-config-lvm
  1201. system-config-authentication
  1202. system-config-network
  1203. system-config-selinux
  1204. system-config-services
  1205. system-config-users
  1206. system-config-firewall
  1207. system-config-kickstart
Advertisement
Add Comment
Please, Sign In to add comment