├── missfont.log
├── title.txt
├── compile
├── RHCSA_Cheat_Sheet.epub
├── RHCSA_Cheat_Sheet.mobi
├── RHCSA_Cheat_Sheet-A4.pdf
└── RHCSA_Cheat_Sheet-A5.pdf
├── metadata.xml
├── minor-push.sh
├── chapters
├── 080-Manage-users-and-groups-draft.markdown
├── 090-Manage-security-draft.markdown
├── 060-Create-and-configure-file-systems-draft.markdown
├── 020-Exam-objectives-draft.markdown
├── 010-Introduction-draft.markdown
├── 070-Deploy-configure-and-maintain-systems-draft.markdown
├── 040-Operate-running-systems-draft.markdown
├── 050-Configure-local-storage-draft.markdown
└── 030-Understand-and-use-essential-tools-draft.markdown
├── templates
├── epub.css
└── a5.tex
└── README.md
/missfont.log:
--------------------------------------------------------------------------------
1 | mktextfm pplr9e
2 | mktextfm pplr9e
3 | mktextfm pplr9e
4 |
--------------------------------------------------------------------------------
/title.txt:
--------------------------------------------------------------------------------
1 | % Red Hat Certified System Administrator (RHCSA) Cheat Sheet
2 | % Fabrizio Di Carlo
3 |
--------------------------------------------------------------------------------
/compile/RHCSA_Cheat_Sheet.epub:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fdicarlo/RHCSA_cs/HEAD/compile/RHCSA_Cheat_Sheet.epub
--------------------------------------------------------------------------------
/compile/RHCSA_Cheat_Sheet.mobi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fdicarlo/RHCSA_cs/HEAD/compile/RHCSA_Cheat_Sheet.mobi
--------------------------------------------------------------------------------
/compile/RHCSA_Cheat_Sheet-A4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fdicarlo/RHCSA_cs/HEAD/compile/RHCSA_Cheat_Sheet-A4.pdf
--------------------------------------------------------------------------------
/compile/RHCSA_Cheat_Sheet-A5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fdicarlo/RHCSA_cs/HEAD/compile/RHCSA_Cheat_Sheet-A5.pdf
--------------------------------------------------------------------------------
/metadata.xml:
--------------------------------------------------------------------------------
1 | Creative Commons Non-Commercial Share Alike 3.0
2 | en
3 |
--------------------------------------------------------------------------------
/minor-push.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | cp -R ../RHCSA_cs/ ~/Dropbox/
3 | ruby build.rb
4 | cp -R ../RHCSA_cs
5 | git add -A; git commit -m "update"; git push origin master
6 |
--------------------------------------------------------------------------------
/chapters/080-Manage-users-and-groups-draft.markdown:
--------------------------------------------------------------------------------
1 | # Manage users and groups
2 |
3 | ## Create, delete, and modify local user accounts.
4 | ## Change passwords and adjust password aging for local user accounts.
5 | ## Create, delete, and modify local groups and group memberships.
6 | ## Configure a system to use an existing LDAP directory service for user and group information.
7 |
8 |
9 | \newpage
10 | \pagebreak
11 |
12 |
--------------------------------------------------------------------------------
/chapters/090-Manage-security-draft.markdown:
--------------------------------------------------------------------------------
1 | # Manage security
2 |
3 | ## Configure firewall settings using system-config-firewall or iptables.
4 | ## Set enforcing and permissive modes for SELinux.
5 | ## List and identify SELinux file and process context.
6 | ## Restore default file contexts.
7 | ## Use boolean settings to modify system SELinux settings.
8 | ## Diagnose and address routine SELinux policy violations
9 |
10 |
11 | \newpage
12 | \pagebreak
13 |
14 |
--------------------------------------------------------------------------------
/chapters/060-Create-and-configure-file-systems-draft.markdown:
--------------------------------------------------------------------------------
1 | # Create and configure file systems
2 |
3 | ## Create, mount, unmount, and use ext2, ext3, and ext4 file systems.
4 | ## Mount, unmount, and use LUKS-encrypted file systems.
5 | ## Mount and unmount CIFS and NFS network file systems.
6 | ## Configure systems to mount ext4, LUKS-encrypted, and network file systems automatically.
7 | ## Extend existing unencrypted ext4-formatted logical volumes.
8 | ## Create and configure set-GID directories for collaboration.
9 | ## Create and manage Access Control Lists (ACLs).
10 | ## Diagnose and correct file permission problems.
11 |
12 |
13 | \newpage
14 | \pagebreak
15 |
16 |
--------------------------------------------------------------------------------
/templates/epub.css:
--------------------------------------------------------------------------------
1 | /* This defines styles and classes used in the book */
2 | body { }
3 | code { font-family: monospace; }
4 | h1, h2, h3, h4, h5, h6 { text-align: center; margin-bottom:2em;}
5 | h1.title { }
6 | h2.author { }
7 | p{
8 | padding:0;
9 | margin:0;
10 | text-indent:2em;
11 | }
12 | blockquote{
13 | margin-left:3em;
14 | margin-right:3em;
15 | }
16 | .caption{
17 | text-align:center;
18 | font-style:italic;
19 | margin-bottom:1em;
20 | margin-top:.2em;
21 | font-size:.8em;
22 | }
23 | blockquote > p{
24 | text-indent:0;
25 | margin-bottom:1em;
26 | }
27 | img{
28 | display:block;
29 | margin-left: auto;
30 | margin-right: auto;
31 | text-align:center;
32 | margin-top:1em;
33 | }
--------------------------------------------------------------------------------
/templates/a5.tex:
--------------------------------------------------------------------------------
1 | \documentclass[ebook,article,oneside,english]{memoir}
2 | \usepackage[breaklinks=true,unicode=true]{hyperref}
3 | \usepackage[utf8]{inputenc}
4 | \linespread{1.1} % Palatino needs more leading (space between lines)
5 | \pagestyle{plain}
6 |
7 | $if(numbersections)$
8 | $else$
9 | \setcounter{secnumdepth}{-1}
10 | $endif$
11 |
12 | $for(header-includes)$
13 | $header-includes$
14 | $endfor$
15 |
16 | $if(title)$
17 | \title{$title$}
18 | $endif$
19 | $if(author)$
20 | \author{$for(author)$$author$$sep$\\$endfor$}
21 | $endif$
22 | $if(date)$
23 | \date{$date$}
24 | $else$
25 | \date{}
26 | $endif$
27 |
28 | \begin{document}
29 | $if(title)$
30 | \maketitle
31 | $endif$
32 |
33 | $for(include-before)$
34 | $include-before$
35 |
36 | $endfor$
37 | $if(toc)$
38 | \tableofcontents
39 |
40 | $endif$
41 | $body$
42 | $for(include-after)$
43 |
44 | $include-after$
45 | $endfor$
46 |
47 | \end{document}
--------------------------------------------------------------------------------
/chapters/020-Exam-objectives-draft.markdown:
--------------------------------------------------------------------------------
1 | # Red Hat Certified System Administrator (RHCSA) Exam objectives[^020-1]
2 |
3 | Red Hat reserves the right to add, modify, and remove objectives. Such changes will be made public in advance through revisions to this document.
4 |
5 | RHCSA exam candidates should be able to accomplish the tasks below without assistance. These have been grouped into several categories.
6 |
7 | **Understand and use essential tools**:
8 |
9 | * Access a shell prompt and issue commands with correct syntax.
10 | * Use input-output redirection (>, >>, |, 2>, etc.).
11 | * Use grep and regular expressions to analyze text.
12 | * Access remote systems using ssh and VNC.
13 | * Log in and switch users in multiuser runlevels.
14 | * Archive, compress, unpack, and uncompress files using tar, star, gzip, and bzip2.
15 | * Create and edit text files.
16 | * Create, delete, copy, and move files and directories.
17 | * Create hard and soft links.
18 | * List, set, and change standard ugo/rwx permissions.
19 | * Locate, read, and use system documentation including man, info, and files in /usr/share/doc.
20 |
21 | Note: Red Hat may use applications during the exam that are not included in Red Hat Enterprise Linux for the purpose of evaluating candidate's abilities to meet this objective.
22 |
23 | **Operate running systems**:
24 |
25 | * Boot, reboot, and shut down a system normally.
26 | * Boot systems into different runlevels manually.
27 | * Use single-user mode to gain access to a system.
28 | * Identify CPU/memory intensive processes, adjust process priority with renice, and kill processes.
29 | * Locate and interpret system log files.
30 | * Access a virtual machine's console.
31 | * Start and stop virtual machines.
32 | * Start, stop, and check the status of network services.
33 |
34 | **Configure local storage**:
35 |
36 | * List, create, delete, and set partition type for primary, extended, and logical partitions.
37 | * Create and remove physical volumes, assign physical volumes to volume groups, and create and delete logical volumes.
38 | * Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot.
39 | * Configure systems to mount file systems at boot by Universally Unique ID (UUID) or label.
40 | * Add new partitions and logical volumes, and swap to a system non-destructively.
41 |
42 | **Create and configure file systems**:
43 |
44 | * Create, mount, unmount, and use ext2, ext3, and ext4 file systems.
45 | * Mount, unmount, and use LUKS-encrypted file systems.
46 | * Mount and unmount CIFS and NFS network file systems.
47 | * Configure systems to mount ext4, LUKS-encrypted, and network file systems automatically.
48 | * Extend existing unencrypted ext4-formatted logical volumes.
49 | * Create and configure set-GID directories for collaboration.
50 | * Create and manage Access Control Lists (ACLs).
51 | * Diagnose and correct file permission problems.
52 |
53 | **Deploy, configure, and maintain systems**:
54 |
55 | * Configure networking and hostname resolution statically or dynamically.
56 | * Schedule tasks using cron.
57 | * Configure systems to boot into a specific runlevel automatically.
58 | * Install Red Hat Enterprise Linux automatically using Kickstart.
59 | * Configure a physical machine to host virtual guests.
60 | * Install Red Hat Enterprise Linux systems as virtual guests.
61 | * Configure systems to launch virtual machines at boot.
62 | * Configure network services to start automatically at boot.
63 | * Configure a system to run a default configuration HTTP server.
64 | * Configure a system to run a default configuration FTP server.
65 | * Install and update software packages from Red Hat Network, a remote repository, or from the local file system.
66 | * Update the kernel package appropriately to ensure a bootable system.
67 | * Modify the system bootloader.
68 |
69 | **Manage users and groups**:
70 |
71 | * Create, delete, and modify local user accounts.
72 | * Change passwords and adjust password aging for local user accounts.
73 | * Create, delete, and modify local groups and group memberships.
74 | * Configure a system to use an existing LDAP directory service for user and group information.
75 |
76 | **Manage security**:
77 |
78 | * Configure firewall settings using system-config-firewall or iptables.
79 | * Set enforcing and permissive modes for SELinux.
80 | * List and identify SELinux file and process context.
81 | * Restore default file contexts.
82 | * Use boolean settings to modify system SELinux settings.
83 | * Diagnose and address routine SELinux policy violations.
84 |
85 | \newpage
86 | \pagebreak
87 |
88 | [^020-1]: Red Hat Certified System Administrator (RHCSA) Exam objectives (EX200):
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RHCSA Cheat Sheet
2 |
3 | The Red Hat Certification Program[^010-1] are IT Professional certifications for Red Hat products and general Linux related skills such as system administration on Red Hat Enterprise Linux, all certifications are given after passing exams. The program distinguishes itself in that the exams are performance-based, meaning that students must perform tasks on a live system, rather than answering multiple choice questions.
4 |
5 | RHCSA[^010-2] is the entry-level certification that focuses on actual competencies at system administration, including installation and configuration of a Red Hat Linux system and attaching it to a live network running network services.
6 | To achieve the RHCSA certification the student must pass EX200, a half-day hands-on lab exam. The minimum passing score for the exam is 210 out of 300 possible points (70%). There is no prerequisite for the exam, but Red Hat recommends preparing for the exam by taking courses in Red Hat System Administration (RH124 or RH135) if one does not have previous experience.
7 | RHCSA was launched in 2002 as Red Hat Certified Technician (RHCT). As of July 2009 there were 30,000 RHCTs. In November 2010 it was renamed to RHCSA.
8 |
9 | After some recent success of Red Hat, I decided to investigate the subject again but after some Google's query about the topic I was not able anything of interesing, except some valid books[^010-3] but these is nothing that I can't consult on my eBook's reader or that I can share with my friends, so I started to write a collaborative notes on GitHub.
10 |
11 | As I said I'm not a SysAdmin but I'm simple Linux passionate, I wrote (and I'm writing) this ebook not for money but following my passion, my knowledge and the "Exam objectives" so, for sure, you can find some mistakes or something wrong, please send me a mail or update the notes.
12 |
13 |
14 | ## Using the book
15 |
16 | The book can be read in three different ways, starting from most recommended to least recommended:
17 |
18 | 1. The most recommended option is to clone the repository to download the files to your local machine. **RHCSA Cheat Sheet** it was written to be edited and modified by anyone. It is written as a single text file using the format [markdown][markdown] and prepared so as to be able to automatically generate its versions in ePub and Mobi (for e-Book's readers) as well as PDF using [PanDoc][pandoc].
19 |
20 | In order to function you need to have the following software installed (at least on my computer):
21 |
22 | * [Pandoc][pandoc]
23 | * [Geany][geany]
24 | * [KindleGen][kindlegen]
25 |
26 | [markdown]: http://daringfireball.net/projects/markdown/
27 | [pandoc]: http://johnmacfarlane.net/pandoc/
28 | [geany]: http://www.geany.org/
29 | [kindlegen]: http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211
30 |
31 | 2. The second, preferred, option is to use the GitHub viewer site, which display the Cheat Sheet in the browser [example].
32 | The contents are updated synchronously as commits are made to the book. You can use the Contents section above to link to the chapters.
33 |
34 | [example]: https://github.com/fdicarlo/RHCSA_cs/blob/master/chapters/020-Exam-objectives-draft.markdown
35 |
36 | 3. **Compiled** versions are available! Look in the compile/ directory.
37 |
38 | ## Edit and regeneration
39 |
40 | To edit the text you can simply change the files:
41 |
42 | $ chapters/[number of chapter].markdown <- Single chapters
43 | $ title.txt <- Title and author
44 | $ metadata.xml <- License and language
45 |
46 | To regenerate the text for sharing there is a script:
47 |
48 | $ ruby build.rb
49 |
50 | The language MultiMarkdown to handle text in the book is quite easy to use and practice should be understandable without great effort. A guide to the use of language is also available here:
51 |
52 | * [Pandoc’s markdown](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown)
53 |
54 | ## Development
55 |
56 | This book has an unusual development design. The content is open-sourced, meaning anyone can be an author. Authors submit content or revisions using the GitHub interface.
57 |
58 | ### What to contribute?
59 |
60 | The current chapter list is not finalized. If you see something that is missing (Bash, networks, commands, tricks etc.), feel free to start there.
61 |
62 | * Cleaning up code and making code more polish
63 | * Giving better explanations
64 | * Spelling/grammar mistakes
65 | * Suggestions
66 | * Contributing to the RH notebook styles
67 |
68 | ### Commiting
69 |
70 | * All commits are welcome, even if they are minor ;)
71 | * If you are unfamiliar with Github, you can email me contributions to the email below.
72 |
73 | ## Contributions and Thanks
74 |
75 | One final thanks: **RHCSA Cheat Sheet** would never have been realized in this form without the contributions of explanation:
76 |
77 | *
78 | *
79 |
80 | Contact the main author, Fabrizio Di Carlo at or [@fdicarlo]
81 |
82 | [@fdicarlo]: https://twitter.com/fdicarlo
83 |
84 | [^010-1]:
85 | [^010-2]:
86 | [^010-3]: Michael Jang's RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300) and Damian Tommasino's Hands-on Guide to the Red Hat Exams: RHCSA and RHCE Cert Guide and Lab Manual
87 |
--------------------------------------------------------------------------------
/chapters/010-Introduction-draft.markdown:
--------------------------------------------------------------------------------
1 | # Why this notes
2 |
3 | The Red Hat Certification Program[^010-1] are IT Professional certifications for Red Hat products and general Linux related skills such as system administration on Red Hat Enterprise Linux, all certifications are given after passing exams. The program distinguishes itself in that the exams are performance-based, meaning that students must perform tasks on a live system, rather than answering multiple choice questions.
4 |
5 | RHCSA[^010-2] is the entry-level certification that focuses on actual competencies at system administration, including installation and configuration of a Red Hat Linux system and attaching it to a live network running network services.
6 | To achieve the RHCSA certification the student must pass EX200, a half-day hands-on lab exam. The minimum passing score for the exam is 210 out of 300 possible points (70%). There is no prerequisite for the exam, but Red Hat recommends preparing for the exam by taking courses in Red Hat System Administration (RH124 or RH135) if one does not have previous experience.
7 | RHCSA was launched in 2002 as Red Hat Certified Technician (RHCT). As of July 2009 there were 30,000 RHCTs. In November 2010 it was renamed to RHCSA. Unfortunately, due to mathematical intractability of most Bayesian models, the reader is only shown simple, artificial examples. This can leave the user with a so-what feeling about Bayesian inference. In fact, this was the author's own prior opinion.
8 |
9 | After some recent success of Red Hat, I decided to investigate the subject again but after some Google's query about the topic I was not able anything of interesing, except some valid books[^010-3] but these is nothing that I can't consult on my eBook's reader or that I can share with my friends, so I started to write a collaborative notes on GitHub.
10 |
11 | As I said I'm not a SysAdmin but I'm simple Linux passionate, I wrote (and I'm writing) this ebook not for money but following my passion, my knowledge and the "Exam objectives" so, for sure, you can find some mistakes or something wrong, please send me a mail or update the notes.
12 |
13 |
14 | ## Using the book
15 |
16 | The book can be read in three different ways, starting from most recommended to least recommended:
17 |
18 | 1. The most recommended option is to clone the repository to download the files to your local machine. **RHCSA Cheat Sheet** it was written to be edited and modified by anyone. It is written as a single text file using the format [markdown][markdown] and prepared so as to be able to automatically generate its versions in ePub and Mobi (for e-Book's readers) as well as PDF using [PanDoc][pandoc].
19 |
20 | In order to function you need to have the following software installed (at least on my computer):
21 |
22 | * [Pandoc][pandoc]
23 | * [Geany][geany]
24 | * [KindleGen][kindlegen]
25 |
26 | [markdown]: http://daringfireball.net/projects/markdown/
27 | [pandoc]: http://johnmacfarlane.net/pandoc/
28 | [geany]: http://www.geany.org/
29 | [kindlegen]: http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211
30 |
31 | 2. The second, preferred, option is to use the GitHub viewer site, which display the Cheat Sheet in the browser [example].
32 | The contents are updated synchronously as commits are made to the book. You can use the Contents section above to link to the chapters.
33 |
34 | [example]: https://github.com/fdicarlo/RHCSA_cs/blob/master/chapters/020-Exam-objectives-draft.markdown
35 |
36 | 3. **Compiled** versions are available! Look in the compile/ directory.
37 |
38 | ## Edit and regeneration
39 |
40 | To edit the text you can simply change the files:
41 |
42 | $ chapters/[number of chapter].markdown <- Single chapters
43 | $ title.txt <- Title and author
44 | $ metadata.xml <- License and language
45 |
46 | To regenerate the text for sharing there is a script:
47 |
48 | $ ruby build.rb
49 |
50 | The language MultiMarkdown to handle text in the book is quite easy to use and practice should be understandable without great effort. A guide to the use of language is also available here:
51 |
52 | * [Pandoc’s markdown](http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown)
53 |
54 | ## Development
55 |
56 | This book has an unusual development design. The content is open-sourced, meaning anyone can be an author. Authors submit content or revisions using the GitHub interface.
57 |
58 | ### What to contribute?
59 |
60 | The current chapter list is not finalized. If you see something that is missing (Bash, networks, commands, tricks etc.), feel free to start there.
61 |
62 | * Cleaning up code and making code more polish
63 | * Giving better explanations
64 | * Spelling/grammar mistakes
65 | * Suggestions
66 | * Contributing to the RH notebook styles
67 |
68 | ### Commiting
69 |
70 | * All commits are welcome, even if they are minor ;)
71 | * If you are unfamiliar with Github, you can email me contributions to the email below.
72 |
73 | ## Contributions and Thanks
74 |
75 | One final thanks: **RHCSA Cheat Sheet** would never have been realized in this form without the contributions of explanation:
76 |
77 | *
78 | *
79 |
80 | Contact the main author, Fabrizio Di Carlo at or [@fdicarlo]
81 |
82 | [@fdicarlo]: https://twitter.com/fdicarlo
83 |
84 | [^010-1]:
85 | [^010-2]:
86 | [^010-3]: Michael Jang's RHCSA/RHCE Red Hat Linux Certification Study Guide (Exams EX200 & EX300) and Damian Tommasino's Hands-on Guide to the Red Hat Exams: RHCSA and RHCE Cert Guide and Lab Manual
87 |
88 | \newpage
89 | \pagebreak
90 |
--------------------------------------------------------------------------------
/chapters/070-Deploy-configure-and-maintain-systems-draft.markdown:
--------------------------------------------------------------------------------
1 | # Deploy, configure, and maintain systems
2 |
3 | ## Configure networking and hostname resolution statically or dynamically.
4 |
5 | ### Configure networking
6 |
7 | Networking is a big part of the RHCSA and RHCE. If you aren't super comfortable with configuring networking via network config files, then its probably a good idea to use the network management tools available.
8 |
9 | In Red Hat Enterprise Linux you can type "setup" at the command line. This will open up the Text Mode Setup Utility, which allows you to configure network, firewall, athentication, keyboard, RHN, and System Services.
10 |
11 | If you do venture into the networking configuration files, these are the important ones:
12 |
13 | * /etc/hosts The static table lookup for hostnames
14 | * /etc/resolv.conf The resolver configuration file
15 | * /etc/sysconfig/network Contains hostname setting
16 | * /etc/sysconfig/network-scripts/ifcfg-eth0 The first network device configuration
17 |
18 | These are files that will be essential to know about during the exam if you are altering config files.
19 |
20 | There will no doubt be some need to configure networks during the RHCSA and RHCE, so either way be prepared to fix network connections.
21 |
22 | ### Configuring the hostname
23 |
24 | Configuring the hostname can be done in the /etc/sysconfig/network file. Edit this file with the updated hostname and then on reboot, the new hostname will be reflected.
25 |
26 | ~] vim /etc/sysconfig/network
27 | NETWORKING=yes
28 | HOSTNAME=rhel-01
29 |
30 | ## Schedule tasks using cron.
31 |
32 | Cron is a utility used to schedule tasks to run at a certain time on various intervals. First is to make sure its installed, although it is installed by default on a normal installation.
33 |
34 | ~] rpm -qa | grep cron
35 | cronie-1.4.4-2.el6.x86_64
36 | cronie-anacron-1.4.4-2.el6.x86_64
37 |
38 | The easiest way to get guidance on how to use a utility is to use the man page. In this case the proper documentation is kind of hidden.
39 |
40 | ~] man 5 crontab
41 |
42 | This page lays out the options for cron, why its not found by simply using "man cron" is beyond me, but its not.
43 |
44 | The format for this goes as follows:
45 |
46 | * * * * * command to be executed
47 | - - - - -
48 | | | | | |
49 | | | | | |
50 | | | | | +----- day of week (0 - 6) (Sunday=0)
51 | | | | +---------- month (1 - 12)
52 | | | +--------------- day of month (1 - 31)
53 | | +-------------------- hour (0 - 23)
54 | +------------------------- min (0 - 59)
55 |
56 | An example of a cron job would be configuring a job to run every day on minute 0 hour 12 daily, or daily at 12:00pm.
57 |
58 | 0 12 * * * /bin/echo "some job" >> echo.log
59 |
60 | Another example would be to run a job weekly at 3:30pm on Sunday
61 |
62 | 30 15 * * 0 /bin/echo "another job" >> echo.log
63 |
64 | ## Configure systems to boot into a specific runlevel automatically.
65 |
66 | Depending on what the system running Red Hat Enterprise Linux 6 is going to be used for, you will want it to boot into the appropriate runlevel.
67 |
68 | The file that controls the runlevel that a system boots into is the /etc/inittab.
69 |
70 | # Default runlevel. The runlevels used are:
71 | # 0 - halt (Do NOT set initdefault to this)
72 | # 1 - Single user mode
73 | # 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
74 | # 3 - Full multiuser mode
75 | # 4 - unused
76 | # 5 - X11
77 | # 6 - reboot (Do NOT set initdefault to this)
78 | #
79 | id:5:initdefault:
80 |
81 | In this case the default runlevel that this system will boot into is runlevel 5. Make note of what not to do. As noted above, do not set the default runlevel to 0 or 6, which is shutdown and reboot, for obvious reasons.
82 |
83 | ## Install Red Hat Enterprise Linux automatically using Kickstart.
84 |
85 | Installing a system via Kickstart comes in pretty useful in real life. Whether there is time to do that in the 2.5 hours that they give you on the exam is questionable, but regardless its an objective.
86 |
87 | There are a few ways to create a kickstart file, that would be used in the automatic installation of a Redhat Enterprise Linux 6 system. Theres always writing the thing from scratch, which while always an optoin, is not so efficient. Besides that there is:
88 |
89 | system-config-kickstart (requires installing this application)
90 |
91 | using the anaconda-ks.cfg that was created during an installation.
92 |
93 | On the exam you would probably (hopefully) be provided with a premade kickstart file, so we work from there.
94 |
95 | Lets say we have this info:
96 |
97 | kickstart file = http://192.168.111.23/pub/ks/redhat6.kfg
98 | ip of new install = 192.168.111.222 (same subnet)
99 | netmask = 255.255.255.0
100 |
101 | First we would boot the system with some sort of boot media, most likely the RHEL 6 CD-ROM #1 and at the boot prompt (when it asks you what you want to do) you would type a command like this, substituting your own info:
102 |
103 | linux ks=http://192.168.111.23/pub/ks/redhat6.kfg append ip=192.168.111.222 netmask=255.255.255.0
104 |
105 | As long as everying is configured correctly and the installation media is where is should be, then this should install pretty hands off. Of course, anything besides this already configured environment would just take way too much time to be included on the exam. As long as you know how to install via ks file, you are probably good.
106 |
107 | ## Configure a physical machine to host virtual guests.
108 |
109 | A default RHEL 6 system should come prepared to host virtual guests, minus the packages. In RHEL5 you had to make sure that you were running the xen kernel, which would require installing and booting into that kernel. RHEL 6 is simple, if it Virtualization is not installed, install it.
110 |
111 | ~] yum groupinstall "Virtualization"
112 |
113 | That will install everything needed to run virtual guests on RHEL 6.
114 |
115 | ## Install Red Hat Enterprise Linux systems as virtual guests.
116 |
117 |
118 |
119 | ## Configure systems to launch virtual machines at boot.
120 | ## Configure network services to start automatically at boot.
121 | ## Configure a system to run a default configuration HTTP server.
122 |
123 | Installing apache via yum on Red Hat Enterprise Linux 6 does most of the setup for you.
124 |
125 | ~] yum install httpd
126 |
127 | :::bash
128 | ~] service httpd start
129 |
130 | Now if you try to visit the main ip or domain of the server, you may run into an issue getting to the site. Whenever you enable a network service like a web server, you also have to allow the outside to use that service. We have to add an entry into iptables.
131 |
132 | ~] iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
133 |
134 | This would add an entry into iptables, but to survive a reboot we would have to save this.
135 |
136 | ~] service iptables save
137 |
138 | Now an easier way of doing this, is to use system-config-firewall, which is the gui/tui tool to configure a firewall.
139 |
140 | ~] system-config-firewall
141 |
142 | This may not make things perfect, but it can definitely give you a jump start to molding rules on an exam.
143 |
144 | ## Configure a system to run a default configuration FTP server.
145 |
146 | ### FTP
147 |
148 | vsftpd installs with a default configuration that works for this requirement. So a basic:
149 |
150 | ~] yum install vsftpd
151 |
152 | ~] chkconfig vsftpd on
153 |
154 | This will get your default server up and running. But what about firewall and selinux?
155 |
156 | ### Iptables
157 |
158 | For iptables you want to open up port 20 and 21, to allow ftp requests in.
159 |
160 | ~] iptables -I INPUT 5 -p tcp -m tcp --dport 20 -j ACCEPT
161 |
162 | ~] iptables -I INPUT 5 -p tcp -m tcp --dport 21 -j ACCEPT
163 |
164 | Then remember to always save your iptables rules so they survive a reboot.
165 |
166 | ### Selinux
167 |
168 | SELinux is now a part of the exams, so you have to know how to apply the correct context to the directories that will be used by vsftpd.
169 |
170 | Here's a tip: All this information is stored in man pages, so rather than memorizing, use the resources available. If you search for _selinux, then all services that have information on how to be configured with SELinux will show up. To search the man pages use:
171 |
172 | ~] man -k _selinux
173 | ftpd_selinux (8) - Security-Enhanced Linux policy for ftp daemons
174 |
175 | ~] man ftpd_selinux
176 |
177 | To make a ftp server's content available you can see it says to run the following:
178 |
179 | semanage fcontext -a -t public_content_t "/var/ftp(/.*)?"
180 |
181 | restorecon -F -R -v /var/ftp
182 |
183 | Thats it. As long as you can install the application, vsftpd, open the correct ports in iptables, and set context in SELinux, then you are good to go on this objective.
184 |
185 | ## Install and update software packages from Red Hat Network, a remote repository, or from the local file system.
186 |
187 | Red Hat Network is pretty easy to work with.
188 |
189 | ~] rhn_register
190 |
191 | And follow the instructions. Now, if you arent lucky enough to have a subscription to this wonderful service, then you will most likely using a repo that you create, or that is given to you.
192 |
193 | Most common situation is having a remote repository that you need to pull packages from. Usually you be given a url to connect to looking something like this: http://myremote.com/repo/i386/. The yum repo files are located in /etc/yum.repos.d/ and end with a .repo extension. The format is simple to setup a repo on the fly.
194 |
195 | [myremote]
196 | name=myremote
197 | baseurl=http://myremote.com/repo/i386/
198 | enabled=1
199 | gpgcheck=0
200 |
201 | Those are the essential elements to pull packages via yum from that repo.
202 |
203 | Setting up a local repo with a disk is almost the same with a few steps before. First the disk needs to be mounted, and the packages copied from Packages/ into another directory on the server. In this case we will use file:///directory/path/to/repo/ as the url, where /directory/path/to/repo/ is the directory that contains the rpm files.
204 |
205 | Next the package creatrepo needs to be installed. Once installed cd into the directory and run:
206 |
207 | ~] createrepo .
208 |
209 | Now that you have a repo setup, yum needs to know about it. Create a file named mylocal.repo in the /etc/yum.repos.d/ directory.
210 |
211 | [mylocal]
212 | name=mylocal
213 | baseurl=file:///directory/path/to/repo/
214 | enabled=1
215 | gpgcheck=0
216 |
217 | Run a yum command to test, and it should be pulling information about packages from the local repo.
218 |
219 | ~] yum list httpd
220 |
221 | ## Update the kernel package appropriately to ensure a bootable system.
222 | ## Modify the system bootloader.
223 |
224 |
225 | \newpage
226 | \pagebreak
227 |
228 |
--------------------------------------------------------------------------------
/chapters/040-Operate-running-systems-draft.markdown:
--------------------------------------------------------------------------------
1 | # Operate running systems
2 |
3 | ## Boot, reboot, and shut down a system normally.
4 |
5 | Basically, they are referring to these actions on the command line. I'm sure everyone is able to do this on a pc, but not necessarily a live Red Hat Enterprise Linux Server remotely.
6 |
7 | The commands are simple for the server.
8 |
9 | ### Reboot
10 |
11 | $ sudo reboot
12 |
13 | Another way
14 |
15 | $ sudo shutdown -r now
16 |
17 | Changing to init 6 will reboot as well, which is what init 6 does.
18 |
19 | $ sudo init 6
20 |
21 | ### Shutdown
22 |
23 | On the same note, init 0 calls all of the shutdown scripts and gracefully shuts down your machine.
24 |
25 | $ sudo init 0
26 |
27 | Surprisingly you can also use the shutdown command to shutdown completely by using the -h switch.
28 |
29 | $ sudo shutdown -h
30 |
31 | I think we all know how to boot the computer, so that shouldn't be a problem. :-)
32 |
33 | ## Boot systems into different runlevels manually.
34 |
35 | Red Hat Enterprise Linux is similar to most other linux distributions in its core functionality. The ability to run the operating system in multiple run levels is an important skill to have.
36 |
37 | If you type into your terminal:
38 |
39 | $ runlevel
40 |
41 | you should see a number as the output.
42 |
43 | $ N 3
44 |
45 | This is the runlevel my server was running at the time this was written.
46 |
47 | There are 6 runlevels:
48 |
49 | * Runlevel 0 - Halt
50 | * Runlevel 1 - Single User mode. Most services turned off, including networking. Used to perform maintenance on the server usually. Boots logged into roots account, no password.
51 | * Runlevel 2 - This is basic functions, multi-user mode, without any networking.
52 | * Runlevel 3 - This is what servers usually run in, as it provides all of the services of the normal server, without the graphical user interface.
53 | * Runlevel 4 - Doesn't really get used.
54 | * Runlevel 5 - This provides the same functions of runlevel 3, along with services to allow for desktop functionality (graphical user interface).
55 | * Runlevel 6 - Reboot
56 |
57 | The command to jump runlevels is actually really easy. Just type init followed by the runlevel you want to switch into.
58 |
59 | $ init 1
60 |
61 | The above command would turn off most services and drop you into single user mode.
62 |
63 | ## Use single-user mode to gain access to a system.
64 |
65 | Booting into single user mode is the easiest way to gain access to a Red Hat Enterprise Linux server.
66 |
67 | This is only feasible if you have access to the physical console, which you will on the RHCSA and RHCE exams.
68 |
69 | * At the beginning of the boot process you should see the grub menu pop up with a countdown and some kernel options (or perhaps just one option).
70 | * It should be counting down at this point and says: "Press any key to enter the menu". In this case you would hit any key.
71 | * At the bottom of the screen there is an explanation of the few options that are available to use on this page. One of these options is "e" for edit. Hit "e" to edit the boot kernel options. NOTE: (You can also use "a" for append, although they both accomplish the same thing.)
72 | * You would now edit the main kernel options, adding either "single" or even just "1" at the end. Once you have completed that hit enter, the "b" for boot.
73 | * You are now in single user mode, and be auto logged in as root.
74 |
75 | NOTE: for Red Hat Enterprise Linux 6.0 there is a bug that will prevent you from changing your root password in single user mode. This is a result of SELinux. For this situation you would want to temporarily disable SELinux.
76 |
77 | # setenforce 0
78 |
79 | Now you should be allowed to change your root password.
80 |
81 | ## Identify CPU/memory intensive processes, adjust process priority with renice, and kill processes.
82 |
83 | A few commands to help you identify processes on the exam are ps and top. These are commands that you will actually use extensively to monitor systems in the workplace.
84 |
85 | ### ps - report a snapshot of the current processes.
86 |
87 | ps helps you see what processes are being run, what files and commands they are being run with, who they are being run by, as well and their process ids. All the above items are crucial when troubleshooting issues on a Red Hat Enterprise Linux 6 system.
88 |
89 | a few good examples pulled from a man page:
90 |
91 | EXAMPLES
92 |
93 | # To see every process on the system using standard syntax:
94 | $ ps -e
95 | $ ps -ef
96 | $ ps -eF
97 | ps -ely
98 |
99 | # To see every process on the system using BSD syntax:
100 | $ ps ax
101 | $ ps axu
102 |
103 | # To print a process tree:
104 | $ ps -ejH
105 | $ ps axjf
106 |
107 | # To get info about threads:
108 | $ ps -eLf
109 | $ ps axms
110 |
111 | # To get security info:
112 | $ ps -eo euser,ruser,suser,fuser,f,comm,label
113 | $ ps axZ
114 | $ ps -eM
115 |
116 | # To see every process running as root (real & effective ID) in user format:
117 | $ ps -U root -u root u
118 |
119 | There is plenty of more info on this in the man pages as well as a plethoura of information on the web for ps.
120 |
121 | ### top - display Linux tasks
122 |
123 | At its most basic usage you can just type:
124 |
125 | $ top
126 |
127 | There is a whole lot of options that go along with that command: "man top" to see them all.
128 |
129 | ### renice — alter priority of running processes
130 |
131 | As stated in the description, renice is a linux utility to change the priority of a process. This could obviously come in handy while trying to keep a process at bay.
132 |
133 | Example from the man page:
134 |
135 | renice +1 987 -u daemon root -p 32
136 |
137 | This would change the priority of process ID's 987 and 32, and all processes owned by users daemon and root.
138 |
139 | Man Page http://linux.die.net/man/8/renice
140 |
141 | ### kill - terminate a process
142 |
143 | Like it states in the name, this kills processes. Once you have identified the process you would like to kill with top or ps, you would use the kill command to terminate that process.
144 |
145 | The most common implementation of this is:
146 |
147 | # kill 2342
148 |
149 | If that doesnt kill the process you would use the -9 switch, which will take out most any process.
150 |
151 | # kill -9 2342
152 |
153 | NOTE: The -9 command should be used with caution. Make sure you are killing the right pid, otherwise terrible things may transpire, especially on the RHCSA or the RHCE, where time is of concern.
154 |
155 | ## Locate and interpret system log files.
156 |
157 | Most of the logs you will deal with are going to be located in /var/log/. There are some exceptions to this, such as apache vhosts. Many people write the logs for a specific virtual host in a folder with the web content.
158 |
159 | Aside from the occasional exception, this is the spot.
160 |
161 | Logs are written in a way that makes them easy to parse through with text processing tools like cat, grep, and awk.
162 |
163 | One example would be searching for Failed logins in /var/log/secure
164 |
165 | $ cat /var/log/messages | grep Failed | less
166 | Apr 1 16:17:06 mytest sshd[19632]: Failed password for root from 84.204.56.234 port 39045 ssh2
167 | Apr 1 16:17:09 mytest sshd[19634]: Failed password for root from 84.204.56.234 port 39351 ssh2
168 | Apr 1 16:17:13 mytest sshd[19636]: Failed password for root from 84.204.56.234 port 39660 ssh2
169 | Apr 1 22:13:40 mytest sshd[19741]: Failed password for bin from 200.76.17.194 port 53407 ssh2
170 | Apr 1 22:13:43 mytest sshd[19744]: Failed password for bin from 200.76.17.194 port 40100 ssh2
171 | Apr 1 22:13:46 mytest sshd[19747]: Failed password for bin from 200.76.17.194 port 51759 ssh2
172 | Apr 1 22:13:49 mytest sshd[19749]: Failed password for bin from 200.76.17.194 port 45675 ssh2
173 | Apr 1 22:13:52 mytest sshd[19751]: Failed password for bin from 200.76.17.194 port 54379 ssh2
174 | Apr 1 22:13:55 mytest sshd[19753]: Failed password for bin from 200.76.17.194 port 12218 ssh2
175 | Apr 2 06:05:01 mytest sshd[20102]: Failed password for root from 117.211.83.59 port 34815 ssh2
176 |
177 | By using the cat command we are able to read all contents of the file, but thats a lot of stuff. We only want to see Failed logins. We then pipe the result of cat, into grep and process the text there. Grep picks out any line that contains Failed. I then piped it to less to output only the last 10 lines.So now you can see all these failed password attempts on our test server. Wow.
178 |
179 | Lets say we just want to process the text, and get a count of how many logins were failed in this file. We can pipe the output into wc -l, which counts lines.
180 |
181 | $ cat /var/log/messages | grep Failed | wc -l
182 | 90
183 |
184 | Thats a lot of failed logins. That lets us know we should probably tighten up our security a bit, maybe change the port for ssh. Thats something that is covered down the road though. But you can see the value in combining text processing utilities in order to get a clean final result.
185 |
186 | Some key tools to look at are:
187 |
188 | * cat - http://man.he.net/man1/cat
189 | * tail - http://man.he.net/man1/tail
190 | * head - http://linux.die.net/man/1/head
191 | * wc - http://linux.die.net/man/1/wc
192 | * less - http://linux.die.net/man/1/less
193 | * more - http://linux.die.net/man/1/more
194 | * grep - http://linux.die.net/man/1/grep
195 | * awk - http://linux.die.net/man/1/awk
196 | * sed - http://linux.die.net/man/1/sed
197 |
198 | ## Access a virtual machine's console.
199 |
200 | Knowing how to access the virtual machines console is essential, and if you have never used it could take a few minutes to figure out.
201 |
202 | There are two ways to pull it up, one from the gui menu in on the desktop, and the other with the following command in terminal:
203 |
204 | $ virt-manager
205 |
206 | For images of what it looks like, if you have never seen it, check out Red Hat's website on the Virtual Machine Manager. Its fairly straightforward.
207 |
208 | http://virt-manager.et.redhat.com/index.html
209 |
210 | ## Start and stop virtual machines.
211 |
212 | Starting and stopping virtual machines is just like starting and stopping real machines.
213 |
214 | The only main difference, is that you can start and stop them right from the . Virtual Machine Manager
215 |
216 | The Red Hat Enterprise Linux 6 Virtual Machine Manager has a fairly intuitive graphical user interface, with obvious start and stop buttons for each machine. If you haven't used it at all, It would be good to download a trial copy of Red Hat, to get an idea of how to navigate the program.
217 |
218 | ### List VMs on the system
219 |
220 | # virsh list
221 |
222 | ### Start a VM
223 |
224 | # virsh create /etc/libvert/qemu/vm_file_name.xml
225 |
226 | ### Kill a VM
227 |
228 | #### Shutsdown without notification
229 |
230 | #virsh destroy domain-id
231 |
232 | ###Shutdown a VM
233 |
234 | ####Shutdown down with notification
235 | #virsh shutdown domain-id
236 |
237 | ## Start, stop, and check the status of network services.
238 |
239 | There are a few things to consider when dealing with network services:
240 |
241 | * You want to make sure the service is running, if not start it.
242 | * You want to be able to restart the service, to reload a config file that you may have changed.
243 | * You want to have the ability to turn the service off, if you don't plan on using it.
244 | * Also, you need to be able to set the service up to start on boot, or vise versa.
245 |
246 | Service management takes place with the service command. Go figure.
247 |
248 | To start the httpd service, you would type:
249 |
250 | $ sudo /sbin/service httpd start
251 |
252 | To stop it:
253 |
254 | $ sudo /sbin/service httpd stop
255 |
256 | To restart it:
257 |
258 | $ sudo /sbin/service httpd restart
259 |
260 | To reload it (refresh configs without stopping and starting):
261 |
262 | $ sudo /sbin/service httpd reload
263 |
264 | How do you know what services you can do that with? Well that can be listed with the tool that will handing startup programs. chkconfig.
265 |
266 | chkconfig is used to manage what runlevel a program with automatically start or get killed in. To list all your services you would just type
267 |
268 | $ sudo /sbin/chkconfig --list
269 |
270 | Thats a big list. But you get the idea, you can see how they are either on or off in each runlevel. To narrow down the list we can use grep to process the list and filter out say, our httpd service.
271 |
272 | $ sudo /sbin/chkconfig --list | grep httpd
273 | httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
274 |
275 | So we can see that in runlevels 2-5 we have httpd on in. If that were not the case, and my server rebooted, when it came back up all my sites would be disabled, until I manually went in and started the service.
276 |
277 | To change the values of that you would just run chkconfig followed by the service and whether you want to on or off in the main runlevels.
278 |
279 | $ sudo /sbin/chkconfig httpd on
280 |
281 | You can actually control what runlevels you want the service on in as well by adding the --level switch followed by the runlevels.
282 |
283 | $ sudo /sbin/chkconfig --level 45 httpd off
284 | $ sudo /sbin/chkconfig --list | grep httpd
285 | httpd 0:off 1:off 2:on 3:on 4:off 5:off 6:off
286 |
287 | I turned off the httpd service for runlevel 4 and 5 there.
288 |
289 | \newpage
290 | \pagebreak
291 |
--------------------------------------------------------------------------------
/chapters/050-Configure-local-storage-draft.markdown:
--------------------------------------------------------------------------------
1 | # Configure local storage
2 |
3 | ## List, create, delete, and set partition type for primary, extended, and logical partitions.
4 |
5 | The official tool is now parted, but you can still use fdisk to create partitions. I'm a fan of fdisk, so thats what I will be using here.
6 |
7 | ### List partitions
8 |
9 | To list all partitions that are on your server, you would issue the fdisk command, with the list switch.
10 |
11 | $ fdisk -l
12 |
13 | ### Create new partitions
14 |
15 | In order to create new partitions you would first have to open the device in fdisk. I will be opening /dev/sdb and creating both a primary and extended partition. We use the n command to create a new partition.
16 |
17 | $ sudo fdisk /dev/sdb
18 |
19 | Command (m for help): n
20 | Command action
21 | e extended
22 | p primary partition (1-4)
23 | p
24 | Partition number (1-4, default 1): 1
25 | First sector (2048-8388607, default 2048):
26 | Using default value 2048
27 | Last sector, +sectors or +size{K,M,G} (2048-8388607, default 8388607): +250M
28 |
29 | Command (m for help): p
30 |
31 | Disk /dev/sdb: 4294 MB, 4294967296 bytes
32 | 255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
33 | Units = sectors of 1 * 512 = 512 bytes
34 | Sector size (logical/physical): 512 bytes / 512 bytes
35 | I/O size (minimum/optimal): 512 bytes / 512 bytes
36 | Disk identifier: 0xd26a7e50
37 |
38 | Device Boot Start End Blocks Id System
39 | /dev/sdb1 2048 514047 256000 83 Linux
40 |
41 | Command (m for help): n
42 | Command action
43 | e extended
44 | p primary partition (1-4)
45 | e
46 | Partition number (1-4, default 2):
47 | Using default value 2
48 | First sector (514048-8388607, default 514048):
49 | Using default value 514048
50 | Last sector, +sectors or +size{K,M,G} (514048-8388607, default 8388607): +500M
51 |
52 | Command (m for help): w
53 | The partition table has been altered!
54 |
55 | Calling ioctl() to re-read partition table.
56 | Syncing disks.
57 | $ sudo partprobe
58 |
59 | ### Delete partitions
60 |
61 | Deleting partitions is even easier. You would just type d at the fdisk prompt, tell it which partition number you are deleting, and the write the changes with the w flag.
62 |
63 | $ sudo fdisk /dev/sdb
64 |
65 | Command (m for help): p
66 |
67 | Disk /dev/sdb: 4294 MB, 4294967296 bytes
68 | 255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
69 | Units = sectors of 1 * 512 = 512 bytes
70 | Sector size (logical/physical): 512 bytes / 512 bytes
71 | I/O size (minimum/optimal): 512 bytes / 512 bytes
72 | Disk identifier: 0x08bafe2e
73 |
74 | Device Boot Start End Blocks Id System
75 | /dev/sdb1 2048 1026047 512000 83 Linux
76 | /dev/sdb2 1026048 1538047 256000 5 Extended
77 |
78 | Command (m for help): d
79 | Partition number (1-5): 2
80 |
81 | Command (m for help): p
82 |
83 | Disk /dev/sdb: 4294 MB, 4294967296 bytes
84 | 255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
85 | Units = sectors of 1 * 512 = 512 bytes
86 | Sector size (logical/physical): 512 bytes / 512 bytes
87 | I/O size (minimum/optimal): 512 bytes / 512 bytes
88 | Disk identifier: 0x08bafe2e
89 |
90 | Device Boot Start End Blocks Id System
91 | /dev/sdb1 2048 1026047 512000 83 Linux
92 |
93 | Command (m for help): w
94 | The partition table has been altered!
95 |
96 | Calling ioctl() to re-read partition table.
97 | Syncing disks.
98 | $ sudo partprobe
99 |
100 | ### Set partition type
101 |
102 | In order to use the disk we have to set a partition type. In this case we just make it a general Linux format #83. If it were going to be part of a raid array, we would make it Linux raid auto, #fd.
103 |
104 | $ fdisk /dev/sdb
105 |
106 | Command (m for help): t
107 | Selected partition 1
108 | Hex code (type L to list codes): L
109 |
110 | 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
111 | 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
112 | 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
113 | 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
114 | 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
115 | 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
116 | 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
117 | 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
118 | 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
119 | 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
120 | a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
121 | b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
122 | c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs
123 | e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
124 | f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
125 | 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
126 | 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
127 | 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
128 | 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
129 | 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
130 | 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
131 | 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
132 | 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
133 | 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
134 | 1e Hidden W95 FAT1 80 Old Minix
135 | Hex code (type L to list codes): 83
136 |
137 | Command (m for help): w
138 | The partition table has been altered!
139 |
140 | Calling ioctl() to re-read partition table.
141 | Syncing disks.
142 |
143 | Redhat actually encourages the use of parted nowadays, with works a little differently. To see information about that, see this link http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/s1-disk-storage-parted.html
144 |
145 | ## Create and remove physical volumes, assign physical volumes to volume groups, and create and delete logical volumes.
146 |
147 | ### Create and remove physical volumes
148 |
149 | Creating a physical volume in LVM is the first step in the LVM setup. Its the part where you actually tell Red Hat Enterprise Linux that you want a disk to be used for LVM.
150 |
151 | pvcreate is the command used to add the physical volumes, or physical partitions.
152 |
153 | ~] pvcreate /dev/sdb
154 | ~] Physical volume "/dev/sdb" successfully created
155 |
156 | pvremove is used to disassociate the volume from LVM.
157 |
158 | ~] pvremove /dev/sdb
159 | ~] Labels on physical volume "/dev/sdb" successfully wiped
160 |
161 | ### Assign physical volumes to volume groups
162 |
163 | Once that physical volume has been created we can add it to a volume group with the vgcreate or vgextend (if the volume group has already been created).
164 |
165 | If the volume group does not exist, you can create it and add physical volumes in one shot:
166 |
167 | ~] vgextend MyVolGroup /dev/sdc
168 | No physical volume label read from /dev/sdc
169 | Physical volume "/dev/sdc" successfully created
170 | Volume group "MyVolGroup" successfully extended
171 |
172 | To assign a new physical volume to an existing volume group we use vgextend:
173 |
174 | ~] vgextend MyVolGroup /dev/sdc
175 | Volume group "MyVolGroup" successfully extended
176 |
177 | Similarly if we want to remove /dev/sdc from that group we would run ''vgreduce'':
178 |
179 | ~] vgreduce MyVolGroup /dev/sdc
180 | Removed "/dev/sdc" from volume group "MyVolGroup"
181 |
182 |
183 | ### Create and delete logical volumes
184 |
185 | Logical Volumes have similar commands to create and delete as Volume Groups and Physical Volumes.
186 |
187 | To create a new logical volume:
188 |
189 | ~] lvcreate -L 100M MyVolGroup
190 | Logical volume "lvol0" created
191 |
192 | To display the volume after for confirmation:
193 |
194 | ~] lvdisplay MyVolGroup
195 | --- Logical volume ---
196 | LV Name /dev/MyVolGroup/lvol0
197 | VG Name MyVolGroup
198 | LV UUID zwLMev-i63w-7Jpk-XuqZ-VGl7-89Ov-WpoewP
199 | LV Write Access read/write
200 | LV Status available
201 | # open 0
202 | LV Size 100.00 MiB
203 | Current LE 25
204 | Segments 1
205 | Allocation inherit
206 | Read ahead sectors auto
207 | - currently set to 256
208 | Block device 253:2
209 |
210 | To delete the logical volume you would use the LV Name listed in the results of lvdisplay:
211 |
212 | :::bash ~] lvremove /dev/MyVolGroup/lvol0 Do you really want to remove active logical volume lvol0? [y/n]: y Logical volume "lvol0" successfully removed
213 |
214 | ## Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot.
215 |
216 | This is a brand new objective that was not present on the RHEL5 requirements. There are a few steps to this, but once you go through it a few times its not too bad.
217 |
218 | First step is to create a partition with fdisk or parted. We will use fdisk here.
219 |
220 | ~] fdisk -c -u /dev/sdb
221 |
222 | Command (m for help): n
223 | Command action
224 | e extended
225 | p primary partition (1-4)
226 | p
227 | Partition number (1-4, default 1): 1
228 | First sector (2048-8388607, default 2048):
229 | Using default value 2048
230 | Last sector, +sectors or +size{K,M,G} (2048-8388607, default 8388607): +200M
231 |
232 | Command (m for help): t
233 | Selected partition 1
234 | Hex code (type L to list codes): 83
235 |
236 | Command (m for help): w
237 | The partition table has been altered!
238 |
239 | Calling ioctl() to re-read partition table.
240 | Syncing disks.
241 |
242 | Now that the partition is created, we have to luks encrypt it. First we fill it with random data for security:
243 |
244 | ~] dd if=/dev/urandom of=/dev/sdb1 bs=1M
245 | dd: writing '/dev/sdb1': No space left on device
246 | 201+0 records in
247 | 200+0 records out
248 | 209715200 bytes (210 MB) copied, 26.0497 s, 8.1 MB/s
249 |
250 | Then we can encrypt the partition with luksFormat:
251 |
252 | ~] cryptsetup luksFormat /dev/sdb1
253 |
254 | WARNING!
255 | ========
256 | This will overwrite data on /dev/sdb1 irrevocably.
257 |
258 | Are you sure? (Type uppercase yes): YES
259 | Enter LUKS passphrase:
260 | Verify passphrase:
261 |
262 | Now that the partition is encrypted, we open it and give it a label. The label is the name that it will show up as under /dev/mapper/
263 |
264 | ~] cryptsetup luksOpen /dev/sdb1 mynew_data
265 | Enter passphrase for /dev/sdb1:
266 |
267 | Once the partition is setup and luks encrypted, it will be available in the /dev/mapper/ directory. You can do an ls on the /dev/mapper/ directory to confirm.
268 |
269 | ~] ls /dev/mapper/
270 | control mynew_data VolGroup-lv_root VolGroup-lv_swap
271 |
272 | Next steps involve creating a filesystem, adding the partition into the /etc/crypttab file, as well as in the /etc/fstab file in order to configure automounting on boot.
273 |
274 | ~] mkfs.ext4 /dev/mapper/mynew_data
275 | mke2fs 1.41.14 (22-Dec-2010)
276 | Filesystem label=
277 | OS type: Linux
278 | Block size=1024 (log=0)
279 | Fragment size=1024 (log=0)
280 | Stride=0 blocks, Stripe width=0 blocks
281 | 50800 inodes, 202752 blocks
282 | 10137 blocks (5.00%) reserved for the super user
283 | First data block=1
284 | Maximum filesystem blocks=67371008
285 | 25 block groups
286 | 8192 blocks per group, 8192 fragments per group
287 | 2032 inodes per group
288 | Superblock backups stored on blocks:
289 | 8193, 24577, 40961, 57345, 73729
290 | Writing inode tables: done
291 | Creating journal (4096 blocks): done
292 | Writing superblocks and filesystem accounting information: done
293 |
294 | This filesystem will be automatically checked every 25 mounts or
295 | 180 days, whichever comes first. Use tune2fs -c or -i to override
296 | ~] vim /etc/crypttab
297 |
298 | In the /etc/crypttab file you would simply place the name of the encrypted device, as well as the path to the device:
299 |
300 | mynew_data /dev/sdb1
301 |
302 | Then we make the directory and add an entry into fstab, so that it mounts on boot:
303 |
304 | ~] mkdir /mynew_data
305 | ~] vim /etc/fstab
306 |
307 | # Add the following:
308 | /dev/mapper/mynew_data /mynew_data ext4 defaults 1 2
309 |
310 | Thats it. You should run the mount command in order to verify your entries are correct in fstab, to prevent any boot issues.
311 |
312 | ~] mount -a
313 |
314 | ~] mount
315 | # .... lots of data here that im leaving out
316 | /dev/mapper/mynew_data on /mynew_data type ext4 (rw,relatime,seclabel,barrier=1,data=ordered)
317 |
318 | Awesome, try that a few times and you should be good to go on setting up luks encrypted partitions.
319 |
320 | ## Configure systems to mount file systems at boot by Universally Unique ID (UUID) or label.
321 |
322 | Configuring a filesystem to mount via UUID or label is an essential part of managing filesystems and partitions on the Red Hat Enterprise Linux system, and will most probably be something you will see on an RHCSA/RHCE exam.
323 |
324 | First we will configure mounting at boot time via UUID. To find the UUID of a device you have to issue just one command:
325 |
326 | ~] blkid
327 | /dev/sda1: UUID="183e5753-fbe7-4cf7-b974-f6cb9a326a33" TYPE="ext4"
328 | /dev/sda2: UUID="1OJDNK-4gpP-s3YE-cK7o-1urJ-cXHk-jPnuF7" TYPE="LVM2_member"
329 | /dev/sdb1: UUID="1c1fa5a2-11e5-4d6b-89e9-61a15dcbe0f6" TYPE="crypto_LUKS"
330 | /dev/mapper/VolGroup-lv_swap: UUID="dc82e68f-f1b9-409d-a1f7-c556eb6eb78a" TYPE="swap"
331 | /dev/sdc: UUID="vFLamh-rudP-T1jc-ZrrH-LTgD-FUuq-IHUBgM" TYPE="LVM2_member"
332 | /dev/mapper/VolGroup-lv_root: UUID="5bbc084b-1af0-464f-8629-9490a75cacd9" TYPE="ext4"
333 | /dev/mapper/mynew_data: UUID="f8b694a6-916d-4ffa-8e5c-a7ed8ab25b5d" TYPE="ext4"
334 |
335 | Once you have the UUID you can head over to /etc/fstab to create the entry. Here we will pick our new luks partition.
336 |
337 | ~] vim /etc/fstab
338 | Inside of fstab we need to add a line. (if you already have a line for this partition, comment it out with #)
339 |
340 | UUID=f8b694a6-916d-4ffa-8e5c-a7ed8ab25b5d /mynew_data ext4 defaults 1 2
341 |
342 | Then write/save the file and quit :wq You can confirm that this is entered correctly by using the mount command:
343 |
344 | ~] mount -a
345 |
346 | ~] mount
347 | ..ommitted data...
348 | /dev/mapper/mynew_data on /mynew_data type ext4 (rw,relatime,seclabel,barrier=1,data=ordered)
349 |
350 | Now to mount a filesystem via label requires another step, to label the filesystem. Luckily this is done in one easy step using e2label. I am going to label the filesystem luksdrive
351 |
352 | ~] e2label /dev/mapper/mynew_data luksdrive
353 |
354 | Now we can unmount the filesystem, change our fstab to use a label, and run mount a again to see it mounted via label instead.
355 |
356 | ~] umount /mynew_data/
357 |
358 | Verify its unmounted
359 |
360 | ~] mount
361 |
362 | Then edit /etc/fstab this time using LABEL=luksdrive in place of UUID. So the line should look like:
363 |
364 | LABEL=luksdrive /mynew_data ext4 defaults 1 2
365 | Run mount -a and mount to confirm:
366 |
367 | ~] mount -a
368 |
369 | ~] mount
370 | ..ommitted data...
371 | /dev/mapper/mynew_data on /mynew_data type ext4 (rw,relatime,seclabel,barrier=1,data=ordered)
372 |
373 | Thats all there is to that. I would try that out a number of times to make sure you have the process down. Repitition is key.
374 |
375 | ## Add new partitions and logical volumes, and swap to a system non-destructively.
376 |
377 | \newpage
378 | \pagebreak
379 |
380 |
--------------------------------------------------------------------------------
/chapters/030-Understand-and-use-essential-tools-draft.markdown:
--------------------------------------------------------------------------------
1 | # Understand and use essential tools
2 |
3 | ## Access a shell prompt and issue commands with correct syntax
4 |
5 | This is first requirement should stop anyone who may not know, or may have never used a shell prompt from attempting the test. If you can open your terminal, navigate and type commands then you have accomplished this. If not, then you should check out the basics and start there.
6 |
7 | Alternatively
8 |
9 | **Ctrl+Alt+F1** to **F6** are the virtual consoles provided by the getty/agetty programs. Ctrl+Alt+F7 is the console where your X server is running. The GUI (Gnome/KDE or any other) runs over X. So to get back into your GUI window manager: type:
10 | **Ctrl+Alt+F7**.
11 |
12 | ## Use input-output redirection (>, >>, |, 2>, etc.)
13 |
14 | Input output redirection is one of the base skills you will need as a sysadmin. On the exam you will have to be able to redirect data from one command into another, and/or into a file.
15 |
16 | Some examples:
17 |
18 | $ echo "this is input" > file.txt
19 |
20 | or
21 |
22 | $ cat /var/log/messages | less
23 |
24 | You can easily redirect input / output to any file other than the screen. This is achieved in Linux using input and output redirection symbols:
25 |
26 | * ">" Output redirection
27 | * "<" Input redirection
28 |
29 | Using a combination of these symbols and the standard file descriptors you can achieve complex redirection tasks quite easily.
30 |
31 | * ">" overwright
32 | * "<" send into a command or file
33 | * ">>" append
34 | * "<<" append into a command or file
35 | * "|" funnel into
36 | * "2>" redirect errors
37 | * "2>&1" redirect errors to std out
38 |
39 | ## Use grep and regular expressions to analyze text
40 |
41 | RHCSA requirements state that you must know how to use grep to analyze text. This is actually going to be pretty necessary to do many administration tasks on a daily basis.
42 |
43 | Grep returns any lines that have characters, words, or expressions that match your query.
44 |
45 | Basic usage examples of this include:
46 |
47 | * Find "Permission Denied" entries in a log file
48 |
49 | $ grep -r "Permission Denied" /path/to/logfile/
50 |
51 | * Find "Permission Denied" entries in a log file by using output redirection
52 |
53 | $ cat /path/to/file/ | grep "Permission Denied"
54 |
55 | ## Access remote systems using ssh and VNC
56 |
57 | ### SSH
58 |
59 | SSH is such an integrated part of this exam that its kind of weird that this is one of the official requirements. But nonetheless there are a number of different options that you can apply to make you more efficient in exam.
60 |
61 | * Basic ssh access is simple:
62 |
63 | $ ssh user@host
64 |
65 | * ssh to a custom port:
66 |
67 | $ ssh -p port_number user@host
68 |
69 | * ssh bringing X (required to run programs like system-config-users remotely)
70 |
71 | $ ssh -X user@host
72 |
73 | * ssh as another user (another way)
74 |
75 | $ ssh -l user host
76 |
77 | * Display debugging messages as it connects. Useful if you have having some issues connecting to a certain machine.
78 |
79 | $ ssh -v user@host
80 |
81 | Those are the main options for ssh, as always "man ssh" to see all the other magic.
82 |
83 | ### VNC
84 |
85 | **On the remote machine, that you will be connecting to, you should have tigervnc-server installed.**
86 |
87 | $ yum install tigervnc-server
88 |
89 | This puts a config file on your remote machine in /etc/sysconfig/vncservers
90 |
91 | VNCSERVERS="2:myusername"
92 | VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd"
93 |
94 | Aside from changing "username" you want it to look like this. All we did to change it, is remove the "-localhost" directive. This would have restricted us from connecting from a remote system without a tunnel setup. Since this is an exam and not the real world, we can disable that.
95 |
96 | Set up your password on the remote machine by running
97 |
98 | $ vncpasswd
99 |
100 | And finally start your vncserver
101 |
102 | $ vncserver :1
103 |
104 | The output should look like this:
105 |
106 | [root@rhel6 ~]# vncserver :1
107 | New 'rhel6.local:1 (root)' desktop is rhel6.local:1
108 | Starting applications specified in /root/.vnc/xstartup
109 | Log file is /root/.vnc/rhel6.local:1.log
110 |
111 | The default vnc client on Red Hat Enterprise Linux 6 is tigervnc. If it is not already installed on the system:
112 |
113 | $ yum install tigervnc
114 |
115 | To connect to the newly setup vncserver just type:
116 |
117 | $ vncviewer rhel6.local:5901
118 |
119 | (replace rhel6.local with your remote host)
120 |
121 | ## Log in and switch users in multiuser runlevels.
122 |
123 | If you have followed along to this point, you have logged in, and most likely been in either runlevel 3 or runlevel 5. Runlevels determine how much of the systems services are actually running. Most common runlevel for servers is going to be 3, most services that are not GUI oriented (including the Gnome Desktop) are turned off. Runlevel 5 is what you see when you boot into the desktop environment.
124 |
125 | Switching between these levels is fairly straightforward. To switch to runlevel 3 type:
126 |
127 | $ init 3
128 |
129 | Then to see what runlevel you are in type:
130 |
131 | $ runlevel
132 | Switching between users, also straightforward. To switch to bob, assuming bob is a user on the system:
133 |
134 | $ su - bob #note: We put the dash in there to gain the users login profile.
135 | # So if I switched to root and didnt use the - operator,
136 | #I wouldn't have /usr/sbin in my path.
137 |
138 | Switching to root is a common task.
139 |
140 | $ su -
141 |
142 | ## Archive, compress, unpack, and uncompress files using tar, star, gzip, and bzip2.
143 |
144 | ###tar
145 |
146 | Create a tar file from a folder called test1:
147 |
148 | $ tar cvf test1.tar test1
149 |
150 | * c = create
151 | * v = verbose
152 | * f = file
153 |
154 | Extract test1.tar
155 |
156 | $ tar xvf test1.tar
157 |
158 | * x = extract
159 | * v = verbose
160 | * f = file
161 |
162 | List contents of tar archive
163 |
164 | $ tar tf test1.tar
165 |
166 |
167 | ###star
168 |
169 | Man page for star:
170 |
171 | man star
172 |
173 | ###gzip
174 |
175 | This is most commonly used in combination with tar, using the z switch. Tar itself does not compress, it just packs.
176 |
177 | $ tar cvzf test1.tar.gz test1
178 |
179 | Although it can be used by itself
180 |
181 | $ gzip test1
182 |
183 | gunzip test1.gz
184 |
185 | note that this does not preserve the .gz file, it extracts it and removes it.
186 |
187 | ###bzip2
188 |
189 | bzip2 uses a different algorithm to compress files than the other tools, but very similar options
190 |
191 | Create a bzip2 file
192 |
193 | $ bzip2 test1
194 |
195 | note that this does not preserve the original file(s), it will compress and delete the uncompressed version also does not compress directories, only files.
196 | Check out the man page:
197 |
198 | man bzip2
199 |
200 | ## Create and edit text files.
201 |
202 | Using a command line text editor is a skill that is absolutely necessary. Without it most tasks cannot be performed. The default editor used it vim. vim is a enhanced version of vi, which is not quite as pretty as vim.
203 |
204 | To use vim simply type vim and then the filename
205 |
206 | $ vim filename.txt
207 |
208 | There are options that can be given such as:
209 |
210 | * -R Open in read-only
211 | * -b Start in binary mode
212 |
213 | There is also a list of options for using vim once you are editing, to move around and actually edit. It may seem cumbersome at first, but once you are used to vim you will love it.
214 |
215 | Check out the man page for more options:
216 |
217 | man vim
218 |
219 | ## Create, delete, copy, and move files and directories.
220 |
221 | Administering a system requires moving, copying, and deleting files and directories. These are tasks that you will encounter on a constant basis and are essential to the RHCE.
222 |
223 | Some of the most important commands are the ones that we will list below.
224 |
225 | ### ls - List contents of a directory
226 |
227 | list the contents of the home directory.
228 |
229 | $ ls /home/
230 |
231 | ###cp - Copy a file or group of files to another location on the machine.
232 |
233 | copy file1 as file2
234 |
235 | $ cp file1 file2
236 |
237 | ### mv - Move a file or directory
238 |
239 | move a directory to the /tmp directory
240 |
241 | $ mv directory /tmp/
242 |
243 | ### cd - Change directory
244 |
245 | * navigate into the /home/ directory
246 |
247 | $ cd /home/
248 |
249 | * navigate from home into the /etc directory, using the .. to reverse out of the directory
250 |
251 | $ cd ../etc/
252 |
253 | ### rm - remove files or directories.
254 |
255 | * remove file1
256 |
257 | $ rm file1
258 |
259 | * remove directory with all contents (Caution when using this!)
260 |
261 | $ rm -rf directory1/
262 |
263 | ### touch - create a new blank file
264 |
265 | * create a blank file named myfile.txt
266 |
267 | $ touch myfile.txt
268 |
269 | ### mkdir - create a new directory
270 |
271 | * create a directory in the present working directory
272 |
273 | $ mkdir directory1
274 |
275 | ### pwd - Get the present working directory
276 |
277 | * find the present working directory. Handy when you need to see where in the system you are.
278 |
279 | $ pwd
280 | $ /home/david/
281 |
282 | ### head- Display first lines of a file, default to 10 lines
283 |
284 | * display the first 10 lines of file1
285 |
286 | head file1
287 |
288 | ::bash
289 |
290 | * display the first 50 lines of file1
291 |
292 | head -50 file1
293 |
294 |
295 | ### tail -Display last lines of a file, default to 10 lines
296 |
297 | * display the last 10 lines of file1
298 |
299 | tail file1
300 |
301 | * display the last 50 lines of file1
302 |
303 | tail -50 file1
304 |
305 | ## Create hard and soft links.
306 |
307 | ### Hard Links
308 |
309 | A hard link is a link where two files are really the same file.
310 |
311 | Watch how when we create a file, and link to it with a hard link, the inodes (exact location on the harddisk) are the same.
312 |
313 | $ touch file.txt
314 | $ ln file.txt file1.txt
315 | $ ls -li file*
316 | 524594 -rw-r--r--. 2 root root 0 Mar 21 12:54 file1.txt
317 | 524594 -rw-r--r--. 2 root root 0 Mar 21 12:54 file.txt
318 |
319 | When we create a third file linking it to the original, we see the same thing. They all are have an inode of 524594.
320 |
321 | $ ln file.txt file2.txt
322 | $ ls -li file*
323 | 524594 -rw-r--r--. 3 root root 0 Mar 21 12:54 file1.txt
324 | 524594 -rw-r--r--. 3 root root 0 Mar 21 12:54 file2.txt
325 | 524594 -rw-r--r--. 3 root root 0 Mar 21 12:54 file.txt
326 |
327 | What happens if we delete the original file?
328 |
329 | $ rm file.txt
330 | rm: remove regular empty file 'file.txt'? y
331 | $ ls -li file*
332 | 524594 -rw-r--r--. 2 root root 0 Mar 21 12:54 file1.txt
333 | 524594 -rw-r--r--. 2 root root 0 Mar 21 12:54 file2.txt
334 |
335 | As you can see, the other two files are in tact and have not been removed, even though the original file is gone. That is because they are all the same file, when you make a hard link to it you are just putting another reference to it with a different name. Until the last file with that inode gets deleted, that file lives on.
336 |
337 | Lets put some text in file2.txt and see what happens
338 |
339 | $ echo "things" >> file2.txt
340 | $ ls -li file*
341 | 524594 -rw-r--r--. 2 root root 7 Mar 21 13:01 file1.txt
342 | 524594 -rw-r--r--. 2 root root 7 Mar 21 13:01 file2.txt
343 | $ cat file1.txt
344 | things
345 | $ cat file2.txt
346 | things
347 |
348 | As you can see, the files both grew to 7 bytes, and when we look inside each one, they both have the same text. That's because they are the same.
349 |
350 | ### Soft Links
351 |
352 | A soft link is much different from a hard link. Most people relate hard links to shortcuts in Windows. When you put a shortcut on your Desktop, it is just a link to the something on your computer. If you delete it no biggie, its just a link. Soft links are the same way.
353 |
354 | $ touch testfile.txt
355 | $ ln -s testfile.txt testfile1.txt
356 | $ ls -li testfile*
357 | 524726 lrwxrwxrwx. 1 root root 12 Mar 21 13:11 testfile1.txt -> testfile.txt
358 | 524725 -rw-r--r--. 1 root root 0 Mar 21 13:11 testfile.txt
359 |
360 | Here we created a file, testfile.txt, and then ran ln -s to create a soft link. When we ran ls -li we see that now the inodes are different, and testfile1.txt shows highlighted with an arrow to testfile.txt.
361 |
362 | OK, so now lets repeat what we did above for hard links. I will make another soft link, linking to the original file testfile.txt and call it testfile2.txt. Then I'll delete the original and ls -li
363 |
364 | $ ln -s testfile.txt testfile2.txt
365 | $ ls -li testfile*
366 | 524726 lrwxrwxrwx. 1 root root 12 Mar 21 13:11 testfile1.txt -> testfile.txt
367 | 524727 lrwxrwxrwx. 1 root root 12 Mar 21 13:15 testfile2.txt -> testfile.txt
368 | 524725 -rw-r--r--. 1 root root 0 Mar 21 13:11 testfile.txt
369 | $ rm testfile.txt
370 | rm: remove regular empty file 'testfile.txt'? y
371 | $ ls -li testfile*
372 | 524726 lrwxrwxrwx. 1 root root 12 Mar 21 13:11 testfile1.txt -> testfile.txt # Imagine RED here
373 | 524727 lrwxrwxrwx. 1 root root 12 Mar 21 13:15 testfile2.txt -> testfile.txt # Imagine RED here
374 |
375 | If we try and cat the two files, to see the contents, we get an error. We can no longer access these files, they are broken links.
376 |
377 | $ cat testfile*
378 | cat: testfile1.txt: No such file or directory
379 | cat: testfile2.txt: No such file or directory
380 |
381 | ## List, set, and change standard ugo/rwx permissions.
382 |
383 | Permissions rule on compooters. Controlling them, essential. Linux has a number of different tools to do this, we list the essentials for the exam here.
384 |
385 | ### ls
386 |
387 | This is one of the most common commands used when probing a filesystem. ls lists the files in a directory, and the -l switch shows permissions, ownership, size, and date modified
388 |
389 | [root@rhel6 ~]# ls -l
390 | total 28
391 | -rw-------. 1 root root 1403 Mar 21 15:40 anaconda-ks.cfg
392 | -rw-r--r--. 1 root root 15932 Mar 21 15:39 install.log
393 | -rw-r--r--. 1 root root 5337 Mar 21 15:37 install.log.syslog
394 |
395 | ### chmod
396 |
397 | Permissions are as follows:
398 |
399 | * 1 execute
400 | * 2 write
401 | * 4 read
402 |
403 | ..or in letter format
404 |
405 | * x execute
406 | * w write
407 | * r read
408 |
409 | note: the first bit is reserved for type, files are -, directories are d, links are l
410 |
411 | For example, to change all three above files to 777 or readable, writable, and executable by all:
412 |
413 | # chmod changes permission bits, either with numeric or letter permission options.
414 | [root@rhel6 ~]# chmod 777 ./*
415 | [root@rhel6 ~]# ls -l
416 | total 28
417 | -rwxrwxrwx. 1 root root 1403 Mar 21 15:40 anaconda-ks.cfg
418 | -rwxrwxrwx. 1 root root 15932 Mar 21 15:39 install.log
419 | -rwxrwxrwx. 1 root root 5337 Mar 21 15:37 install.log.syslog
420 |
421 | A more reasonable permissions set would be to allow others to read files, but only allow the owner to read, write, and execute.
422 |
423 | [root@rhel6 ~]# chmod 644 ./*
424 | [root@rhel6 ~]# ls -l
425 | total 28
426 | -rw-r--r--. 1 root root 1403 Mar 21 15:40 anaconda-ks.cfg
427 | -rw-r--r--. 1 root root 15932 Mar 21 15:39 install.log
428 | -rw-r--r--. 1 root root 5337 Mar 21 15:37 install.log.syslog
429 |
430 | Directories usually have a similar permissions set. They allow owner to rwx, but everyone else to rx. 755 would be the numerical value.
431 |
432 | If directories are not executable, you cannot change into them with cd. cd essentially executes itself on the directory when you use it.
433 |
434 | If we want to use the letter format as opposed to numbers. we combine the ugo/rwx to apply permissions. To give the group permissions to execute install.log we combine g+x:
435 |
436 | [root@rhel6 ~]# chmod g+x install.log
437 | [root@rhel6 ~]# ls -l
438 | total 28
439 | -rw-r--r--. 1 nobody nobody 1403 Mar 21 15:40 anaconda-ks.cfg
440 | -rw-r-xr--. 1 david root 15932 Mar 21 15:39 install.log
441 | -rw-r--r--. 1 root david 5337 Mar 21 15:37 install.log.syslog
442 |
443 | ### chown
444 |
445 | chown is used to change ownership of files and directories.
446 |
447 | Using the same group of files, we can change the owner from root to david on install.log.
448 |
449 | [root@rhel6 ~]# chown david.david install.log
450 | [root@rhel6 ~]# ls -l
451 | total 28
452 | -rw-r--r--. 1 root root 1403 Mar 21 15:40 anaconda-ks.cfg
453 | -rw-r--r--. 1 david david 15932 Mar 21 15:39 install.log
454 | -rw-r--r--. 1 root root 5337 Mar 21 15:37 install.log.syslog
455 |
456 | We can also change just group on a file, to allow the group certain permissions. Here we change install.log.syslog to be owned by group david, but still owner is root.
457 |
458 | [root@rhel6 ~]# chown root.david install.log.syslog
459 | [root@rhel6 ~]# ls -l
460 | total 28
461 | -rw-r--r--. 1 root root 1403 Mar 21 15:40 anaconda-ks.cfg
462 | -rw-r--r--. 1 david david 15932 Mar 21 15:39 install.log
463 | -rw-r--r--. 1 root david 5337 Mar 21 15:37 install.log.syslog
464 |
465 | If we don't want anyone to see have access, we could change it to a user like nobody. In this case, everyone would be able to read it, but nobody could write and execute anaconda-ks.config.
466 |
467 | [root@rhel6 ~]# chown nobody.nobody anaconda-ks.cfg
468 | [root@rhel6 ~]# ls -l
469 | total 28
470 | -rw-r--r--. 1 nobody nobody 1403 Mar 21 15:40 anaconda-ks.cfg
471 | -rw-r--r--. 1 david david 15932 Mar 21 15:39 install.log
472 | -rw-r--r--. 1 root david 5337 Mar 21 15:37 install.log.syslog
473 |
474 | ### chgrp
475 |
476 | chgrp does the same thing as chown does, except it only changes the group. Handy if you just want to apply group permissions to a group of files that have various owners.
477 |
478 | [root@rhel6 ~]# chgrp root install.log
479 | [root@rhel6 ~]# ls -l
480 | total 28
481 | -rw-r--r--. 1 nobody nobody 1403 Mar 21 15:40 anaconda-ks.cfg
482 | -rw-r--r--. 1 david root 15932 Mar 21 15:39 install.log
483 | -rw-r--r--. 1 root david 5337 Mar 21 15:37 install.log.syslog
484 |
485 | ## Locate, read, and use system documentation including man, info, and files in /usr/share/doc.
486 |
487 | Man pages, docs, and info are all saving graces on the exams (Thanks to Gianluca[^030-1] for this tips).
488 |
489 | The most commonly used help pages are man pages.
490 |
491 | $ man vim
492 |
493 | This will give you the manual pages, with descriptions of the options, examples, and information about the application. If you don't remember exactly what man page you need, but you know what utility you are trying to use you can search man pages.
494 |
495 | For example, lets find all man pages relating to Ruby.
496 |
497 | [root@rhel6 ~]# man -k ruby
498 | erb (1) - an embedded Ruby language interpreter
499 | erb1.8 (1) - an embedded Ruby language interpreter
500 | erb1.9.1 (1) - an embedded Ruby language interpreter
501 | gem (1) - the front end to RubyGems
502 | gem1.8 (1) - the front end to RubyGems
503 | gem1.9.1 (1) - the front end to RubyGems
504 | irb (1) - interactive ruby
505 | irb1.8 (1) - interactive ruby
506 | irb1.9.1 (1) - interactive ruby
507 | rake1.9.1 (1) - a ruby build program with capabilities similar to make
508 | rdoc (1) - Generate documentation from Ruby script files
509 | rdoc1.8 (1) - Generate documentation from Ruby script files
510 | rdoc1.9.1 (1) - Generate documentation from Ruby script files
511 | ri (1) - Ruby Information at your fingertips
512 | ri1.8 (1) - Ruby Information at your fingertips
513 | ri1.9.1 (1) - Ruby Information at your fingertips
514 | ruby (1) - Interpreted object-oriented scripting language
515 | ruby1.8 (1) - Interpreted object-oriented scripting language
516 | ruby1.9.1 (1) - Interpreted object-oriented scripting language
517 | testrb (1) - Automatic runnter for Test::Unit of Ruby
518 | testrb1.8 (1) - Automatic runnter for Test::Unit of Ruby
519 | testrb1.9.1 (1) - Automatic runnter for Test::Unit of Ruby
520 |
521 | This is helpful output of results from the search. Really helpful in situations that you forgot the name of a certain utility.
522 |
523 | Info is nearly identical, referencing the info docs. Its not quite as nice to use, and therefore is not as popular.
524 |
525 | You could also get information from the /usr/share/docs. Here you can find other information about the program itself, or that particular version. The following output is a typical doc directory.
526 |
527 | [root@rhel6 yum-3.2.27]# pwd
528 | /usr/share/doc/yum-3.2.27
529 | [root@rhel6 yum-3.2.27]# ls
530 | AUTHORS ChangeLog COPYING INSTALL README TODO
531 | As you can see its very different, simply text files with license, readme, install instructions, etc. For most of your referencing in an exam situation, use the man pages.
532 |
533 | Or you can simply use:
534 |
535 | $ ls -l /usr/share/doc | grep ruby
536 | drwxr-xr-x 2 root root 4096 ott 21 11:58 libmysql-ruby
537 | drwxr-xr-x 2 root root 4096 ott 21 11:59 libruby
538 | drwxr-xr-x 10 root root 4096 ott 24 19:21 libruby1.8
539 | drwxr-xr-x 8 root root 4096 feb 23 18:59 libruby1.9.1
540 | drwxr-xr-x 2 root root 4096 feb 23 18:59 libruby1.9.1-dbg
541 | drwxr-xr-x 3 root root 4096 ott 24 19:22 libtcltk-ruby1.8
542 | drwxr-xr-x 3 root root 4096 feb 23 18:59 libtcltk-ruby1.9.1
543 | drwxr-xr-x 2 root root 4096 ott 21 11:58 ruby
544 | drwxr-xr-x 2 root root 4096 ott 24 19:21 ruby1.8
545 | drwxr-xr-x 2 root root 4096 feb 23 18:59 ruby1.9.1
546 | drwxr-xr-x 2 root root 4096 feb 23 18:59 ruby1.9.1-dev
547 | drwxr-xr-x 3 root root 4096 feb 23 18:59 ruby1.9.1-examples
548 | drwxr-xr-x 2 root root 4096 feb 23 18:59 ruby1.9.1-full
549 | drwxr-xr-x 2 root root 4096 feb 18 19:45 ruby-dev
550 | drwxr-xr-x 3 root root 4096 ott 21 12:03 rubygems
551 | drwxr-xr-x 2 root root 4096 ott 21 11:58 ruby-mysql
552 |
553 | **Exam tip: If you dont get any output from man pages, try running the following command, which will build the man pages.**
554 |
555 | # first check for the package
556 | [root@rhel6 ~]# rpm -qi man
557 | # then if its installed try
558 | [root@rhel6 ~]# makewhatis &
559 |
560 | ## Questions
561 |
562 | * Enter a command that lists all users who use bash as their default shells.
563 | * Search a string root in /etc/passwd file and save in /somefile.
564 | * What command compresses the /home directory into an archive in bzip2 format, in a file named homearch.tar.bz2?
565 | * Enter a command that creates a /home/testuser/smb.conf file soft-linked to the /etc/samba/smb.conf file.
566 |
567 | \newpage
568 | \pagebreak
569 |
570 | [^030-1]: Gianluca Varisco
571 |
--------------------------------------------------------------------------------