Difference between pages "Linux Fundamentals, Part 3" and "Install/de/Partitioning"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
{{Article
<noinclude>
|Author=Drobbins
{{InstallPart|the process of partitioning and filesystem creation}}
|Previous in Series=Linux Fundamentals, Part 2
</noinclude>
|Next in Series=Linux Fundamentals, Part 4
===Vorbereiten der Festplatte ===
}}
== Before You Start ==


=== About this tutorial ===
Diese Sektion handelt über die verschiedenen Möglichkeiten Funtoo Linux auf einer Festplatte zu installieren und zu booten.
Welcome to "Intermediate administration," the third of four tutorials designed to prepare you for the Linux Professional Institute's 101 (release 2) exam. This tutorial (Part 3) is ideal for those who want to improve their knowledge of fundamental Linux administration skills. We'll cover a variety of topics, including system and Internet documentation, the Linux permissions model, user account management, and login environment tuning.


If you are new to Linux, we recommend that you start with [[Linux Fundamentals, Part 1|Part 1]] and [[Linux Fundamentals, Part 2|Part 2]]. For some, much of this material will be new, but more experienced Linux users may find this tutorial to be a great way of "rounding out" their foundational Linux system administration skills.
==== Einleitung ====


By the end of this series of tutorials (eight in all covering the LPI 101 and 102 exams), you will have the knowledge you need to become a Linux Systems Administrator and will be ready to attain an LPIC Level 1 certification from the Linux Professional Institute if you so choose.
Früher gab es nur eine Variante einen PC zu booten, alle Desktop- und Servercomputer hatten einen voreingestellten PC  BIOS, alle Festplatten nutzten den Master Boot Record (MBR) um das System zu booten und unsere Festplatten waren  mit dem MBR Partitionsschema in verschiedene Regionen partitioniert. Das war einfach wie's gemacht wurde. Und uns gefiel es!


== System and network documentation ==
Dann kamen EFI und UEFI, neue firmware designt das System zu booten, gemeinsam mit GTP Partitionstabellen um Partitionen auf Festplatten größer als 2.2TB zu definieren.
Plötzlich haben wir eine breite Wahl von Optionen, Linux Systeme zu installieren und zu booten. Damit haben wir nun eine komplexere Situation als damals.


=== Types of Linux system documentation ===
Nehmen wir einen Moment um die verfügbaren Optionen, zur Konfiguration der Festplatte um Linux zu booten, zu besprechen.
There are essentially three sources of documentation on a Linux system: manual pages, info pages, and application-bundled documentation in '''/usr/share/doc'''. In this section, we'll explore each of these sources before looking "outside the box" for more information.
Diese Installationsanleitung nutzt und empfiehlt die old-school Methode des BIOS bootens mit hilfe des MBR. Es funktioniert und (außer in seltenen Fällen) ist universal unterstützt.
Mit dieser Methode ist nichts falsch, solange deine Systemfestplatte nur bis zu 2TB groß ist. Solange wird diese Methode die volle Kapazität deiner Festplatte nutzen.  


=== Manual pages ===
Es gibt aber einige Situationen, in denen diese old-school Methode nicht optimal ist. Falls du eine Systemfestplatte >2TB hast, dann erlauben dir MBR Partitionen keinen Zugang zum gesamten Speicher.
Manual pages, or "man pages", are the classic form of UNIX and Linux reference documentation. Ideally, you can look up the man page for any command, configuration file, or library routine. In practice, Linux is free software, and some pages haven't been written or are showing their age. Nonetheless, man pages are the first place to look when you need help.
Das ist also ein Grund gegen diese Methode. Ein Weiterer ist, dass es "PC" Systeme gibt, welche das booten via BIOS nicht mehr unterstützen und dich zwingen via UEFI zu booten.
Aus Mitleid für die PC-Nutzer, die in diese Zwickmühle geraten, decken wir das Booten via UEFI zusätzlich in dieser Installationsanleitung ab .  


To access a man page, simply type <span style="color:green">man</span> followed by your topic of inquiry. A pager will be started, so you will need to press <span style="color:green">q</span> when you're done reading. For example, to look up information about the <span style="color:green">ls</span> command, you would type:
Unsere empfehlung ist immer noch die old-school Methode, es seiden du hast Gründe dagegen.
<pre>
Der Bootloader, den wir nutzen um den Linux Kernel zu laden, heißt GRUB. Also nennen wir die Methode  '''BIOS + GRUB(MBR) ''' Methode.
$ man ls
Es ist die traditionelle Methode um ein Linux System bootbar zu machen.
</pre>
Knowing the layout of a man page can be helpful to jump quickly to the information you need. In general, you will find the following sections in a <span style="color:green">man</span> page:
{| {{table}}
|-
|NAME
|Name and one-line description of the command
|-
|SYNOPSIS
|How to use the command
|-
|DESCRIPTION
|In-depth discussion on the functionality of the command
|-
|EXAMPLES
|Suggestions for how to use the command
|-
|SEE ALSO
|Related topics (usually man pages)
|}


=== man page sections ===
Falls du via UEFI booten willst, empfehlen wir dir nicht den MBR zum booten zu nutzen, was nur manche Systeme unterstützen, sondern wir empfehlen UEFI zu nutzen um GRUB zu laden.
The files that comprise manual pages are stored in '''/usr/share/man''' (or in '''/usr/man''' on some older systems). Inside that directory, you will find that the manual pages are organized into the following sections:
GRUB wird dann das Linux System booten. Wir referenzieren zu dieser Methode mit '''UEFI + GRUB (GPT)'''.
{| {{table}}
|-
|man1
|User programs
|-
|man2
|System calls
|-
|man3
|Library functions
|-
|man4
|Special files
|-
|man5
|File formats
|-
|man6
|Games
|-
|man7
|Miscellaneous
|}


=== Multiple man pages ===
Und ja, es gibt noch weitere Methoden, von denen einige auf der [[Boot Methods]] Seite dokumentiert sind.
Some topics exist in more than one section. To demonstrate this, let's use the <span style="color:green">whatis</span> command, which shows all the available man pages for a topic:
Unsere Empfehlung war immer die '''BIOS + GRUB (GPT)'' Methode, welche allerdings nun nicht mehr konsistent und hardwareübergreifend unterstützt wird.  
<pre>
$ whatis printf
printf              (1) - format and print data
printf              (3) - formatted output conversion
</pre>
In this case, <span style="color:green">man printf</span> would default to the page in section 1 ("User Programs"). If we were writing a C program, we might be more interested in the page from section 3 ("Library functions"). You can call up a man page from a certain section by specifying it on the command line, so to ask for printf(3), we would type:
<pre>
$ man 3 printf
</pre>


=== Finding the right man page ===
'''Die größte Frage ist immer -- Welche Bootmethode sollst du nutzen?''' Hier ist mein Gedankengang.
Sometimes it's hard to find the right man page for a given topic. In that case, you might try using <span style="color:green">man -k</span> to search the NAME section of the man pages. Be warned that it's a substring search, so running something like <span style="color:green">man -k ls</span> will give you a lot of output! Here's an example using a more specific query:
<pre>
$ man -k whatis
apropos              (1)  - search the whatis database for strings
makewhatis          (8)  - Create the whatis database
whatis              (1)  - search the whatis database for complete words
</pre>


=== All about apropos ===
;Grundsatz 1 - Old School: Falls du verlässlich via System Rescue CD booten kannst und dir ein leicht blaues Menü angezeigt wird, dann bootet die CD via BIOS und es ist sehr wahrscheinlich, das du auch Funtoo Linux via BIOS booten kannst. Also gehe old-school und nutze diese Methode, es sei denn du hast Gründe via UEFI zu booten. Zum Beispiel eine Systemfestplatte >2.2TB  In diesem Fall beachte Grundsatz 2, wenn dein System UEFI unterstützt.
The example on the previous panel brings up a few more points. First, the <span style="color:green">apropos</span> command is exactly equivalent to <span style="color:green">man -k</span>. (In fact, I'll let you in on a little secret. When you run <span style="color:green">man -k</span>, it actually runs <span style="color:green">apropos</span> behind the scenes.) The second point is the <span style="color:green">makewhatis</span> command, which scans all the man pages on your Linux system and builds the database for <span style="color:green">whatis</span> and <span style="color:green">apropos</span>. Usually this is run periodically by root to keep the database updated:
<pre>
# makewhatis
</pre>
For more information on "man" and friends, you should start with its man page:
<pre>
$ man man
</pre>


=== The MANPATH ===
;Grundsatz 2 - New School: Falls du verlässlich via System Rescue CD booten kannst und dir ein schwarz und weißes Menü, --Glückwunsch, dein System ist konfiguriert UEFI zu unterstützen. Das bedeutet das du bereit bist Funtoo Linux einzurichten um via UEFI zu booten. Dein System könnte immer noch das Booten übers BIOS unterstützen, aber versuch es einfach mal mit UEFI als erstes. Du kannst in deiner BIOS Konfiguration herum stochern und damit spielen.  
By default, the <span style="color:green">man</span> program will look for man pages in '''/usr/share/man''', '''/usr/local/man''', '''/usr/X11R6/man''', and possibly '''/opt/man'''. Sometimes, you may find that you need to add an additional item to this search path. If so, simply edit '''/etc/man.conf''' in a text editor and add a line that looks like this:
<pre>
MANPATH /opt/man
</pre>
From that point forward, any man pages in the '''/opt/man/man*''' directories will be found. Remember that you'll need to rerun <span style="color:green">makewhatis</span> to add these new man pages to the whatis database.


=== GNU info ===
;Was ist der große Unterschied zwischen Old School und New School?: Hier ist der Deal. Falls du mit old-school MBR Partitionen gehst, deine <code>/boot</code> Partition wird ein ext2 Dateisystem haben, und du wirst <code>fdisk</code>nutzen um MBR Partitionen zu erstellen. Fallse du mit new-school GPT Partitionen und booten via UEFI gehst, wird deine <code>/boot</code> Partition ein  vfat Dateisystem haben, da UEFI dies lesen kann,außerdem wirst du <code>gdisk</code> nutzen um GPT Partitionen zu erstellen. Und du wirst GRUB ein wenig anders installieren. Das ist alles was es zu wissen gibt, für den Fall das du neugierig warst.
One shortcoming of man pages is that they don't support hypertext, so you can't jump easily from one to another. The GNU folks recognized this shortcoming, so they invented another documentation format: "info" pages. Many of the GNU programs come with extensive documentation in the form of info pages. You can start reading info pages with the <span style="color:green">info</span> command:
<pre>
$ info
</pre>
Calling <span style="color:green">info</span> in this way will bring up an index of the available pages on the system. You can move around with the arrow keys, follow links (indicated with a star) using the Enter key, and quit by pressing <span style="color:green">q</span>. The keys are based on Emacs, so you should be able to navigate easily if you're familiar with that editor. For an intro to the Emacs editor, see the developerWorks tutorial, [http://www-106.ibm.com/developerworks/edu/l-dw-linuxemacs-i.html Living in Emacs].


You can also specify an info page on the command line:
;Notiere auch: Um Funtoo Linux via new-school UEFI Methode bootbar zu machen ist es notwendig, dass die System Rescue CD via UEFI gebooted wurde -- und du den ursprünglichen schwarz und weißen Bildschirm siehst. Ansonsten wird UEFI nicht aktiv sein und du wirst nicht in der Lage sein Funtoo Linux korrekt zu installieren.
<pre>
$ info diff
</pre>
For more information on using the info reader, try reading its info page. You should be able to navigate primitively using the few keys I've already mentioned:
<pre>
$ info info
</pre>


=== /usr/share/doc ===
{{Note|'''Einige Motherboards unterstützen UEFI nicht richtig.''' Informiere dich. Zum Beispiel, das Award BIOS in meinem Gigabyte GA-990FXA-UD7 rev 1.1 hat eine Option das Booten via UEFI für CD/DVD zu aktivieren. '''Das ist aber nicht ausreichend um UEFI für Festplatten zu nutzen und Funtoo Linux zu installieren.''' UEFI muss für entfernbare Datenträger und fixierte Datenträger unterstützt werden. (Damit du deine neue Funtoo Installation booten kannst) Tatsächlich haben die neueren Revisionen des Boards(rev 3.0) volle UEFI unterstützung. Das könnte der dritte Grundsatze sein -- kenne die Hardware. }}
There is a final source for help within your Linux system. Many programs are shipped with additional documentation in other formats: text, PDF, PostScript, HTML, to name a few. Take a look in '''usr/share/doc''' (or '''/usr/doc''' on older systems). You'll find a long list of directories, each of which came with a certain application on your system. Searching through this documentation can often reveal some gems that aren't available as man pages or info pages, such as tutorials or additional technical documentation. A quick check reveals there's a lot of reading material available:
<pre>
$ cd /usr/share/doc
$ find . -type f | wc -l
7582
</pre>
Whew! Your homework this evening is to read just half (3791) of those documents. Expect a quiz tomorrow. ;-)


=== The Linux Documentation Project ===
==== Old-School (BIOS/MBR) Methode ====
In addition to system documentation, there are a number of excellent Linux resources on the Internet. The [http://www.tldp.org/ Linux Documentation Project] is a group of volunteers who are working on putting together the complete set of free Linux documentation. This project exists to consolidate various pieces of Linux documentation into a location that is easy to search and use.


=== An LDP overview ===
{{Note|Falls du via System Rescue CD booten kannst und dir ein leicht blaues Menü angezeigt wird nutze diese Methode. Falls du die new-school Methode nutzen wirst, [[#New-School (UEFI/GPT) Methode|Klicke hier um direkt zu UEFI/GPT zu springen.]]}}
The LDP is made up of the following areas:


* Guides - longer, more in-depth books, such as [http://www.tldp.org/LDP/lpg/index.html The Linux Programmer's Guide]
===== Vorbereitung  =====
* HOWTOs - subject-specific help, such as the [http://www.tldp.org/HOWTO/DSL-HOWTO/index.html DSL HOWTO]
* FAQs - Frequently Asked Questions with answers, such as the [http://www.tldp.org/FAQ/faqs/BLFAQ Brief Linux FAQ]
* Man pages - help on individual commands (these are the same manual pages you get on your Linux system when you use the man command).


If you aren't sure which section to peruse, you can take advantage of the search box, which allows you to find things by topic.
Erstens, es ist ein gute Idee sicherzustellen, dass du die richtige Festplatte zum Partitionieren gefunden hast. Versuche es mit diesem Befehl und verifiziere, dass  <code>/dev/sda</code> die Festplatte zum Partitionieren ist:


The LDP additionally provides a list of Links and Resources such as [http://www.tldp.org/LDP/LG/current/ Linux Gazette] (see links in [[#Resources|Resources]]) and [http://www.lwn.net/ Linux Weekly News], as well links to mailing lists and news archives.
<console>
# ##i##fdisk -l /dev/sda


=== Mailing lists ===
Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
Mailing lists provide probably the most important point of collaboration for Linux developers. Often projects are developed by contributors who live far apart, possibly even on opposite sides of the globe. Mailing lists provide a method for each developer on a project to contact all the others, and to hold group discussions via e-mail. One of the most famous development mailing lists is the [http://www.tux.org/lkml/ Linux Kernel Mailing List].
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


=== More about mailing lists ===
In addition to development, mailing lists can provide a method for asking questions and receiving answers from knowledgeable developers, or even other users. For example, individual distributions often provide mailing lists for newcomers. You can check your distribution's Web site for information on the mailing lists it provides.


If you took the time to read the LKML FAQ at the link on the previous panel, you might have noticed that mailing list subscribers often don't take kindly to questions being asked repeatedly. It's always wise to search the archives for a given mailing list before writing your question. Chances are, it will save you time, too!
#        Start          End    Size  Type            Name
1        2048  1250263694  596.2G  Linux filesyste Linux filesystem
</console>


=== Newsgroups ===
Nun, ist es empfohlen, das du alle existierende MBR oder GTP Partitionstabellen auf der Festplatte, welche das System beim Booten verwirren könnten löschst. Wir machen dies mit <code>sgdisk</code>:
Internet "newsgroups" are similar to mailing lists, but are based on a protocol called NNTP ("Network News Transfer Protocol") instead of e-mail. To participate, you need to use an NNTP client such as <span style="color:green">slrn</span> or <span style="color:green">pan</span>. The primary advantage is that you only take part in the discussion when you want, instead of having it continually arrive in your inbox. :-)
{{fancywarning|Dies wird deine existierende Partitionen unerreichbar machen! Du bist "stark" gewarnt und  geraten alle wichtigen/kritischen Daten vorher zu sichern.}}


The newsgroups of primary interest start with comp.os.linux. You can browse the list on the [http://www.tldp.org/links/#ng LDP] site.
<console>
# ##i##sgdisk --zap-all /dev/sda


=== Vendor and third-party Web sites ===
Creating new GPT entries.
Web sites for the various Linux distributions often provide updated documentation, installation instructions, hardware compatibility/incompatibility statements, and other support such as a knowledge base search tool. For example:
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
</console>


* [http://www.redhat.com/ Redhat Linux]
Diese Ausgabe ist nichts beängstigendes, da der Befehl trotzdem erfolgreich war:
* [http://www.debian.org/ Debian Linux]
* [http://www.gentoo.org/ Gentoo Linux]
* [http://www.suse.com/ SuSE Linux]
* [http://www.caldera.com/ Caldera]
* [http://www.turbolinux.com/ Turbolinux]


=== Hardware and software vendors ===
<console>
Many hardware and software vendors have added Linux support to their products in recent years. At their sites, you can find information about which hardware supports Linux, software development tools, released sources, downloads of Linux drivers for specific hardware, and other special Linux projects. For example:
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory.  
***************************************************************
</console>


* [http://www.ibm.com/linux/ IBM and Linux]
===== Partitionierung =====
* [http://www.hp.com/products1/linux/ HP and Linux]
* [http://www.sun.com/linux/ Sun and Linux]
* [http://technet.oracle.com/tech/linux/content.html Oracle and Linux].


== The Linux permissions model ==
Nun werden wir  <code>fdisk</code> nutzen um die MBR Partitionstabelle und die Partitionen zu erstellen:


=== One user, one group ===
<console>
In this section, we'll take a look at the Linux permissions and ownership model. We've already seen that every file is owned by one user and one group. This is the very core of the permissions model in Linux. You can view the user and group of a file in a ls -l listing:
# ##i##fdisk /dev/sda
<pre>
</console>
$ ls -l /bin/bash
-rwxr-xr-x    1 root    wheel      430540 Dec 23 18:27 /bin/bash
</pre>
In this particular example, the '''/bin/bash''' executable is owned by root and is in the wheel group. The Linux permissions model works by allowing three independent levels of permission to be set for each filesystem object -- those for the file's owner, the file's group, and all other users.


=== Understanding "ls -l" ===
Innerhalb <code>fdisk</code>, folge diesen Schritten:
Let's take a look at our <span style="color:green">ls -l</span> output and inspect the first column of the listing:
<pre>
$ ls -l /bin/bash
-rwxr-xr-x    1 root    wheel      430540 Dec 23 18:27 /bin/bash
</pre>
This first field -rwxr-xr- contains a symbolic representation of this particular files' permissions. The first character (-) in this field specifies the type of this file, which in this case is a regular file. Other possible first characters:
{| {{table}}
|-
|'d'
|directory
|-
|'l'
|symbolic link
|-
|'c'
|character special device
|-
|'b'
|block special device
|-
|'p'
|fifo
|-
|'s'
|socket
|}


=== Three triplets ===
'''Leere die Partitionstabelle''':
<pre>
$ ls -l /bin/bash
-rwxr-xr-x    1 root    wheel      430540 Dec 23 18:27 /bin/bash
</pre>
The rest of the field consists of three character triplets. The first triplet represents permissions for the owner of the file, the second represents permissions for the file's group, and the third represents permissions for all other users:
<pre>
"rwx"
"r-x"
"r-x"
</pre>
Above, the r means that reading (looking at the data in the file) is allowed, the w means that writing (modifying the file, as well as deletion) is allowed, and the x means that "execute" (running the program) is allowed. Putting together all this information, we can see that everyone is able to read the contents of and execute this file, but only the owner (root) is allowed to modify this file in any way. So, while normal users can copy this file, only root is allowed to update it or delete it.


=== Who am I? ===
<console>
Before we take a look at how to change the user and group ownership of a file, let's first take a look at how to learn your current user id and group membership. Unless you've used the su command recently, your current user id is the one you used to log in to the system. If you use su frequently, however, you may not remember your current effective user id. To view it, type <span style="color:green">whoami</span>:
Command (m for help): ##i##o ↵
<pre>
</console>
# whoami
root
# su drobbins
$ whoami
drobbins
</pre>


=== What groups am I in? ===
'''Erstelle Partition 1''' (boot):
To see what groups you belong to, use the <span style="color:green">groups</span> command:
<pre>
$ groups
drobbins wheel audio
</pre>
In the above example, I'm a member of the drobbins, wheel, and audio groups. If you want to see what groups other user(s) are in, specify their usernames as arguments:
<pre>
$ groups root daemon
root : root bin daemon sys adm disk wheel floppy dialout tape video
daemon : daemon bin adm
</pre>


=== Changing user and group ownership ===
<console>
To change the owner or group of a file or other filesystem object, use <span style="color:green">chown</span> or <span style="color:green">chgrp</span>, respectively. Each of these commands takes a name followed by one or more filenames.
Command (m for help): ##i##n ↵
<pre>
Partition type (default p): ##i##↵
# chown root /etc/passwd
Partition number (1-4, default 1): ##i##↵
# chgrp wheel /etc/passwd
First sector: ##i##↵
</pre>
Last sector: ##i##+128M ↵
You can also set the owner and group simultaneously with an alternate form of the <span style="color:green">chown</span> command:
</console>
<pre>
# chown root:wheel /etc/passwd
</pre>
You may not use <span style="color:green">chown</span> unless you are the superuser, but <span style="color:green">chgrp</span> can be used by anyone to change the group ownership of a file to a group to which they belong.


=== Recursive ownership changes ===
'''Erstelle Partition 2''' (swap):
Both <span style="color:green">chown</span> and <span style="color:green">chgrp</span> have a -R option that can be used to tell them to recursively apply ownership and group changes to an entire directory tree. For example:
<pre>
# chown -R drobbins /home/drobbins
</pre>


=== Introducing chmod ===
<console>
<span style="color:green">chown</span> and <span style="color:green">chgrp</span> can be used to change the owner and group of a filesystem object, but another program, called <span style="color:green">chmod</span>, is used to change the rwx permissions that we can see in an <span style="color:green">ls -l</span> listing. <span style="color:green">chmod</span> takes two or more arguments: a "mode", describing how the permissions should be changed, followed by a file or list of files that should be affected:
Command (m for help): ##i##n ↵
<pre>
Partition type (default p): ##i##↵
$ chmod +x scriptfile.sh
Partition number (2-4, default 2): ##i##↵
</pre>
First sector: ##i##↵
In the above example, our "mode" is +x. As you might guess, a +x mode tells <span style="color:green">chmod</span> to make this particular file executable for both the user and group and for anyone else.
Last sector: ##i##+2G ↵
Command (m for help): ##i##t ↵
Partition number (1,2, default 2): ##i## ↵
Hex code (type L to list all codes): ##i##82 ↵
</console>


If we wanted to remove all execute permissions of a file, we'd do this:
'''Erstelle root Partition:'''
<pre>
$ chmod -x scriptfile.sh
</pre>


=== User/group/other granularity ===
<console>
So far, our <span style="color:green">chmod</span> examples have affected permissions for all three triplets -- the user, the group, and all others. Often, it's handy to modify only one or two triplets at a time. To do this, simply specify the symbolic character for the particular triplets you'd like to modify before the + or - sign. Use u for the "user" triplet, g for the "group" triplet, and o for the "other/everyone" triplet:
Command (m for help): ##i##n ↵
<pre>
Partition type (default p): ##i##↵
$ chmod go-w scriptfile.sh
Partition number (3,4, default 3): ##i##↵
</pre>
First sector: ##i##↵
We just removed write permissions for the group and all other users, but left "owner" permissions untouched.
Last sector: ##i##↵
</console>


=== Resetting permissions ===
'''Verifiziere die Partitionstabelle:'''
In addition to flipping permission bits on and off, we can also reset them altogether. By using the = operator, we can tell <span style="color:green">chmod</span> that we want the specified permissions and no others:
<pre>
$ chmod =rx scriptfile.sh
</pre>
Above, we just set all "read" and "execute" bits, and unset all "write" bits. If you just want to reset a particular triplet, you can specify the symbolic name for the triplet before the = as follows:
<pre>
$ chmod u=rx scriptfile.sh
</pre>


=== Numeric modes ===
<console>
Up until now, we've used what are called symbolic modes to specify permission changes to <span style="color:green">chmod</span>. However, there's another common way of specifying permissions: using a 4-digit octal number. Using this syntax, called numeric permissions syntax, each digit represents a permissions triplet. For example, in 1777, the 777 sets the "owner", "group", and "other" flags that we've been discussing in this section. The 1 is used to set the special permissions bits, which we'll cover later (see " The elusive first digit" at the end of this section). This chart shows how the second through fourth digits (777) are interpreted:
Command (m for help): ##i##p
{| {{table}}
!Mode
!Digit
|-
|rwx
|7
|-
|rw&minus;
|6
|-
|r&minus;x
|5
|-
|r&minus;&minus;
|4
|-
|&minus;wx
|3
|-
|&minus;w&minus;
|2
|-
|&minus;&minus;x
|1
|-
|&minus;&minus;&minus;
|0
|}


=== Numeric permission syntax ===
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Numeric permission syntax is especially useful when you need to specify all permissions for a file, such as in the following example:
Units: sectors of 1 * 512 = 512 bytes
<pre>
Sector size (logical/physical): 512 bytes / 512 bytes
$ chmod 0755 scriptfile.sh
I/O size (minimum/optimal): 512 bytes / 512 bytes
$ ls -l scriptfile.sh
Disklabel type: dos
-rwxr-xr-x    1 drobbins drobbins        0 Jan  9 17:44 scriptfile.sh
Disk identifier: 0x82abc9a6
</pre>
In this example, we used a mode of 0755, which expands to a complete permissions setting of -rwxr-xr-x.


=== The umask ===
Device    Boot    Start      End    Blocks  Id System
When a process creates a new file, it specifies the permissions that it would like the new file to have. Often, the mode requested is 0666 (readable and writable by everyone), which is more permissive that we would like. Fortunately, Linux consults something called a "umask" whenever a new file is created. The system uses the umask value to reduce the originally specified permissions to something more reasonable and secure. You can view your current umask setting by typing umask at the command line:
/dev/sda1          2048    264191    131072  83 Linux
<pre>
/dev/sda2        264192  4458495  2097152  82 Linux swap / Solaris
$ umask
/dev/sda3        4458496 625142447 310341976  83 Linux
0022
</console>
</pre>
On Linux systems, the umask normally defaults to 0022, which allows others to read your new files (if they can get to them) but not modify them.


To make new files more secure by default, you can change the umask setting:
'''Schreibe die Partitionstabelle auf die Festplatte:'''
<pre>
$ umask 0077
</pre>
This umask will make sure that the group and others will have absolutely no permissions for any newly created files. So, how does the umask work? Unlike "regular" permissions on files, the umask specifies which permissions should be turned off. Let's consult our mode-to-digit mapping table so that we can understand what a umask of 0077 means:
{| {{table}}
!Mode
!Digit
|-
|rwx
|7
|-
|rw&minus;
|6
|-
|r&minus;x
|5
|-
|r&minus;&minus;
|4
|-
|&minus;wx
|3
|-
|&minus;w&minus;
|2
|-
|&minus;&minus;x
|1
|-
|&minus;&minus;&minus;
|0
|}


Using our table, the last three digits of 0077 expand to ---rwxrwx. Now, remember that the <span style="color:green">umask</span> tells the system which permissions to disable. Putting two and two together, we can see that all "group" and "other" permissions will be turned off, while "user" permissions will remain untouched.
<console>
Command (m for help): ##i##w
</console>


=== Introducing suid and sgid ===
Deine neue MBR Partitionstabelle wird nun auf die Systemfestplatte geschrieben.
When you initially log in, a new shell process is started. You already know that, but you may not know that this new shell process (typically bash) runs using your user id. As such, the bash program can access all files and directories that you own. In fact, we as users are totally dependent on other programs to perform operations on our behalf. Because the programs you start inherit your user id, they cannot access any filesystem objects for which you haven't been granted access.


For example, the passwd file cannot be changed by normal users directly, because the "write" flag is off for every user except root:
{{Note|Du bist noch nicht fertig mit der Partitionierung! Jetzt, springe zu [[#Creating filesystems|Creating filesystems]].}}
<pre>
$ ls -l /etc/passwd
-rw-r--r--    1 root    wheel        1355 Nov  1 21:16 /etc/passwd
</pre>
However, normal users do need to be able to modify /etc/passwd (at least indirectly) whenever they need to change their password. But, if the user is unable to modify this file, how exactly does this work?


=== suid ===
==== New-School (UEFI/GPT) Methode ====
Thankfully, the Linux permissions model has two special bits called <span style="color:green">suid</span> and <span style="color:green">sgid</span>. When an executable program has the <span style="color:green">suid</span> bit set, it will run on behalf of the owner of the executable, rather than on behalf of the person who started the program.


Now, back to the '''/etc/passwd problem'''. If we take a look at the <span style="color:green">passwd</span> executable, we can see that it's owned by root:
{{Note|Falls du verlässlich via System Rescue CD booten kannst und dir ein schwarz und weißes Menü angezeigt wurde, verwende diese Methode. Ansonsten diese Methode wird nicht funktionieren!}}
<pre>
$ ls -l /usr/bin/passwd
-rwsr-xr-x    1 root    wheel      17588 Sep 24 00:53 /usr/bin/passwd
</pre>
You'll also note that in place of an x in the user's permission triplet, there's an s. This indicates that, for this particular program, the <span style="color:green">suid</span> and executable bits are set. Because of this, when <span style="color:green">passwd</span> runs, it will execute on behalf of the root user (with full superuser access) rather than that of the user who ran it. And because <span style="color:green">passwd</span> runs with root access, it's able to modify the '''/etc/passwd''' file with no problem.


=== suid/sgid caveats ===
Die <tt>gdisk</tt>Befehle um GTP Partitionstabellen zu erstellen lauten wie folgt. Passe die Große jeweils an, falls notwendig, diese Voreinstellungen werden für die meisten Nutzer funktionieren.Beginne <code>gdisk</code>:
We've seen how <span style="color:green">suid</span> works, and <span style="color:green">sgid</span> works in a similar way. It allows programs to inherit the group ownership of the program rather than that of the current user.


{{fancyimportant|Here's some miscellaneous yet important information about suid and sgid. First, suid and sgid bits occupy the same space as the x bits in a ls -l listing. If the x bit is also set, the respective bits will show up as s (lowercase). However, if the x bit is not set, it will show up as a S (uppercase).}}
<console>
# ##i##gdisk /dev/sda
</console>


{{fancyimportant|Another important note: suid and sgid come in handy in many circumstances, but improper use of these bits can allow the security of a system to be breached. It's best to have as few suid programs as possible. The passwd command is one of the few that must be suid.}}
Innerhalb <tt>gdisk</tt>, folge diesen Schritten:


=== Changing suid and sgid ===
'''Erstelle eine neue leere Partitionstabelle''' (Dies wird alle Daten löschen!):
Setting and removing the <span style="color:green">suid</span> and <span style="color:green">sgid</span> bits is fairly straightforward. Here, we set the suid bit:
<pre>
# chmod u+s /usr/bin/myapp
</pre>
And here, we remove the <span style="color:green">sgid</span> bit from a directory. We'll see how the <span style="color:green">sgid</span> bit affects directories in just a few panels:
<pre>
# chmod g-s /home/drobbins
</pre>


=== Permissions and directories ===
<console>
So far, we've been looking at permissions from the perspective of regular files. When it comes to directories, things are a bit different. Directories use the same permissions flags, but they are interpreted to mean slightly different things.
Command: ##i##o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): ##i##y ↵
</console>


For a directory, if the "read" flag is set, you may list the contents of the directory; "write" means you may create files in the directory; and "execute" means you may enter the directory and access any sub-directories inside. Without the "execute" flag, the filesystem objects inside a directory aren't accessible. Without a "read" flag, the filesystem objects inside a directory aren't viewable, but objects inside the directory can still be accessed as long as someone knows the full path to the object on disk.
'''Erstelle Partition 1''' (boot):


=== Directories and sgid ===
<console>
And, if a directory has the "sgid" flag enabled, any filesystem objects created inside it will inherit the group of the directory. This particular feature comes in handy when you need to create a directory tree to be used by a group of people that all belong to the same group. Simply do this:
Command: ##i##n ↵
<pre>
Partition Number: ##i##1 ↵
# mkdir /home/groupspace
First sector: ##i##↵
# chgrp mygroup /home/groupspace
Last sector: ##i##+500M ↵
# chmod g+s /home/groupspace
Hex Code: ##i##↵
</pre>
</console>
Now, any users in the group mygroup can create files or directories inside '''/home/groupspace''', and they will be automatically assigned a group ownership of mygroup as well. Depending on the users' umask setting, new filesystem objects may or may not be readable, writable, or executable by other members of the mygroup group.


=== Directories and deletion ===
''Erstelle Partition 2''' (swap):
By default, Linux directories behave in a way that may not be ideal in all situations. Normally, anyone can rename or delete a file inside a directory, as long as they have write access to that directory. For directories used by individual users, this behavior is usually just fine.


However, for directories that are used by many users, especially '''/tmp''' and '''/var/tmp''', this behavior can be bad news. Since anyone can write to these directories, anyone can delete or rename anyone else's files -- even if they don't own them! Obviously, it's hard to use '''/tmp''' for anything meaningful when any other user can type <span style="color:green">rm -rf /tmp/*</span> at any time and destroy everyone's files.
<console>
Command: ##i##n ↵
Partition Number: ##i##2 ↵
First sector: ##i##↵
Last sector: ##i##+4G ↵
Hex Code: ##i##8200 ↵
</console>


Thankfully, Linux has something called the sticky bit. When '''/tmp''' has the sticky bit set (with a <span style="color:green">chmod +t</span>), the only people who are able to delete or rename files in '''/tmp''' are the directory's owner (typically root), the file's owner, or root. Virtually all Linux distributions enable '''/tmp''''s sticky bit by default, but you may find that the sticky bit comes in handy in other situations.
'''Erstelle Partition 3''' (root):


=== The elusive first digit ===
<console>
And to conclude this section, we finally take a look at the elusive first digit of a numeric mode. As you can see, this first digit is used for setting the sticky, suid, and sgid bits:
Command: ##i##n ↵
{| {{table}}
Partition Number: ##i##3 ↵
!suid
First sector: ##i##↵
!sgid
Last sector: ##i##↵##!i## (for rest of disk)
!sticky
Hex Code: ##i##↵
!mode digit
</console>
|-
|on
|on
|on
|7
|-
|on
|on
|off
|6
|-
|on
|off
|on
|5
|-
|on
|off
|off
|4
|-
|off
|on
|on
|3
|-
|off
|on
|off
|2
|-
|off
|off
|on
|1
|-
|off
|off
|off
|0
|}


Here's an example of how to use a 4-digit numeric mode to set permissions for a directory that will be used by a workgroup:
Während des Prozesses kannst du mit "<tt>p</tt>" und Enter die aktuelle Partitionstabelle anschauen. Falls du einen Fehler machst "<tt>d</tt>" eine existierende Partition löschen.
<pre>
Wenn du fertig bist mit deiner Partitionierung kannst du mit "<tt>w</tt>" die Konfiguration auf die Festplatte schreiben lassen.
# chmod 1775 /home/groupfiles
</pre>
As homework, figure out the meaning of the 1755 numeric permissions setting. :)


== Linux account managment ==
'''Schreibe Partitionstabelle auf die Festplatte''':


=== Introducing /etc/passwd ===
<console>
In this section, we'll look at the Linux account management mechanism, starting with the '''/etc/passwd''' file, which defines all the users that exist on a Linux system. You can view your own '''/etc/passwd''' file by typing less '''/etc/passwd'''.
Command: ##i##w ↵
Do you want to proceed? (Y/N): ##i##Y ↵
</console>


Each line in '''/etc/passwd''' defines a user account. Here's an example line from my '''/etc/passwd''' file:
Die Partitionstabelle wird nun auf die Festplatte geschrieben und <tt>gdisk</tt> wird beendet.
<pre>
drobbins:x:1000:1000:Daniel Robbins:/home/drobbins:/bin/bash
</pre>
As you can see, there is quite a bit of information on this line. In fact, each '''/etc/passwd''' line consists of multiple fields, each separated by a ''':'''.


The first field defines the username (drobbins), and the second field contains an x. On ancient Linux systems, this field contained an encrypted password to be used for authentication, but virtually all Linux systems now store this password information in another file.
Nun, wurden deine GTP/GUID Partitionen erstellt und sie werden gezeigt wie folgt under ''block devices'' unter Linux:


The third field (1000) defines the numeric user id associated with this particular user, and the fourth field (1000) associates this user with a particular group; in a few panels, we'll see where group 1000 is defined.


The fifth field contains a textual description of this account -- in this case, the user's name. The sixth field defines this user's home directory, and the seventh field specifies the user's default shell -- the one that will be automatically started when this user logs in.
* <tt>/dev/sda1</tt>, wird für das <tt>/boot</tt> Dateisystem genutzt,  
* <tt>/dev/sda2</tt>, wird für den swap Speicher genutzt, und
* <tt>/dev/sda3</tt>, wird für das root Dateisystem verwendet.


=== /etc/passwd tips and tricks ===
==== Erstelle Dateisysteme ====
You've probably noticed that there are many more user accounts defined in '''/etc/passwd''' than actually log in to your system. This is because various Linux components use user accounts to enhance security. Typically, these system accounts have a user id ("uid") of under 100, and many of them will have something like /bin/false listed as a default shell. Since the '''/bin/false''' program does nothing but exit with an error code, this effectively prevents these accounts from being used as login accounts -- they are for internal use only.


=== /etc/shadow ===
{{Note|Dieser Abschnitt behandelt BIOS ''und'' UEFI Installationen. Nicht Überspringen!}}
So, user accounts themselves are defined in '''/etc/passwd'''. Linux systems contain a companion file to '''/etc/passwd''' that's called '''/etc/shadow'''. This file, unlike '''/etc/passwd''', is readable only by root and contains encrypted password information. Let's look at a sample line from '''/etc/shadow''':
<pre>
drobbins:$1$1234567890123456789012345678901:11664:0:-1:-1:-1:-1:0
</pre>
Each line defines password information for a particular account, and again, each field is separated by a :. The first field defines the particular user account with which this shadow entry is associated. The second field contains an encrypted password. The remaining fields are described in the following table:
{| {{table}}
|-
|field 3
|# of days since 1/1/1970 that the password was modified
|-
|field 4
|# of days before password will be allowed to be changed (0 for "change anytime")
|-
|field 5
|# of days before system will force user to change to a new password (-1 for "never")
|-
|field 6
|# of days before password expires that user will be warned about expiration (-1 for "no warning")
|-
|field 7
|# of days after password expiration that this account is automatically # disabled by the system (-1 for "never disable")
|-
|field 8
|# of days that this account has been disabled (-1 for "this account is enabled")
|-
|field 9
|Reserved for future use
|}


=== /etc/group ===
Bevor du die neuen Partitionen nutzen kannst, müssen die Partitionen mit Dateisystem ''metadata'' initialisiert werden.
Next, we take a look at the '''/etc/group file''', which defines all the groups on a Linux system. Here's a sample line:
Dieser Prozess ist bekannt als "Erstellen des Dateisystems".
<pre>
Nachdem die Dateisysteme erstellt wurden kann die Festplatte eingebunden werden und Daten speichern.
drobbins:x:1000:
</pre>
The '''/etc/group field''' format is as follows. The first field defines the name of the group; the second field is a vestigial password field that now simply holds an x, and the third field defines the numeric group id of this particular group. The fourth field (empty in the above example) defines any users that are members of this group.


You'll recall that our sample '''/etc/passwd line''' referenced a group id of 1000. This has the effect of placing the drobbins user in the drobbins group, even though the drobbins username isn't listed in the fourth field of /etc/group.
Lass es uns simple halten. Nutzt du old-school MBR Partitionen? Falls ja, erstellen wir ein ext2 Dateisystem unter /dev/sda1:


=== Group notes ===
<console>
A note about associating users with groups: on some systems, you'll find that every new login account is associated with an identically named (and usually identically numbered) group. On other systems, all login accounts will belong to a single users group. The approach that you use on the system(s) you administrate is up to you. Creating matching groups for each user has the advantage of allowing users to more easily control access to their own files by placing trusted friends in their personal group.
# ##i##mkfs.ext2 /dev/sda1
</console>


=== Adding a user and group by hand ===
Falls du new-school GPT Partitionen für UEFI nutzt, erstellst du ein vfat Dateisystem unter /dev/sda1, da UEFI dieses lesen kann:
Now, I'll show you how to create your own user and group account. The best way to learn how to do this is to add a new user to the system manually. To begin, first make sure that your EDITOR environment variable is set to your favorite text editor:
<pre>
# echo $EDITOR
vim
</pre>
If it isn't, you can set EDITOR by typing something like:
<pre>
# export EDITOR=/usr/bin/emacs
# vipw
</pre>
You should now find yourself in your favorite text editor with the '''/etc/passwd''' file loaded up on the screen. When modifying system '''passwd''' and '''group''' files, it's very important to use the <span style="color:green">vipw</span> and <span style="color:green">vigr</span> commands. They take extra precautions to ensure that your critical '''passwd''' and '''group''' files are locked properly so they don't become corrupted.


=== Editing /etc/passwd ===
Now that you have the '''/etc/passwd''' file up, go ahead and add the following line:
<pre>
testuser:x:3000:3000:LPI tutorial test user:/home/testuser:/bin/false
</pre>
We've just added a "testuser" user with a UID of 3000. We've added him to a group with a GID of 3000, which we haven't created just yet. Alternatively, we could have assigned this user to the GID of the users group if we wanted. This new user has a comment that reads LPI tutorial test user; the user's home directory is set to /home/testuser, and the user's shell is set to /bin/false for security purposes. If we were creating an non-test account, we would set the shell to /bin/bash. OK, go ahead and save your changes and exit.


=== Editing /etc/shadow ===
<console>
Now, we need to add an entry in '''/etc/shadow''' for this particular user. To do this, type <span style="color:green">vipw -s</span>. You'll be greeted with your favorite editor, which now contains the /etc/shadow file. Now, go ahead and copy the line of an existing user account (one that has a password and is longer than the standard system account entries):
# ##i##mkfs.vfat -F 32 /dev/sda1
<pre>
</console>
drobbins:$1$1234567890123456789012345678901:11664:0:-1:-1:-1:-1:0
</pre>
Now, change the username on the copied line to the name of your new user, and ensure that all fields (particularly the password aging ones) are set to your liking:
<pre>
testuser:$1$1234567890123456789012345678901:11664:0:-1:-1:-1:-1:0
</pre>
Now, save and exit.


=== Setting a password ===
Nun, lass uns eine swap Partition erstellen. Die Partition wird genutzt als Überlauf (virtueller Zwischenspeicher) , wenn dein RAM ausgelastet ist oder wenn du dein System in den Ruhezustand versetzen willst.
You'll be back at the prompt. Now, it's time to set a password for your new user:
<pre>
# passwd testuser
Enter new UNIX password: (enter a password for testuser)
Retype new UNIX password: (enter testuser's new password again)
</pre>


=== Editing /etc/group ===
Du wirst kein Dateisystem auf der swap Partition erstellen, denn swap wird nicht zum Speichern von Datein genutzt, aber es ist notwendig eine swap Partition zu initialisieren via dem  <code>mkswap</code> Befehl. Dann werden wir den Befehl <code>swapon</code> ausführen, damit ist die swap Partition sofort aktiv innerhalb deiner aktuellem (live CD) Umgebung.
Now that '''/etc/passwd''' and '''/etc/shadow''' are set up, it's now time to get '''/etc/group''' configured properly. To do this, type:
Für den Fall das der swap im späterem Installationsprozess benötigt wird:
<pre>
<console>
# vigr
# ##i##mkswap /dev/sda2
</pre>
# ##i##swapon /dev/sda2
Your '''/etc/group''' file will appear in front of you, ready for editing. Now, if you chose to assign a default group of users for your particular test user, you do not need to add any groups to '''/etc/groups'''. However, if you chose to create a new group for this user, go ahead and add the following line:
</console>
<pre>
testuser:x:3000:
</pre>
Now save and exit.


=== Creating a home directory ===
Nun, müssen wir das root Dateisystem erstellen. Dort wird das Wurzelverzeichnis von Funtoo Linux leben.
We're nearly done. Type the following commands to create testuser's home directory:
Wir empfehlen im allgemeinen ext4 oder XFS als root Dateisystem. Bist du nicht sicher wähle ext4.  
<pre>
Hier steht wie man ein ext4 root Dateisystem erstellt:
# cd /home
# mkdir testuser
# chown testuser.testuser testuser
# chmod o-rwx testuser
</pre>
Our user's home directory is now in place and the account is ready for use. Well, almost ready. If you'd like to use this account, you'll need to use vipw to change testuser's default shell to '''/bin/bash''' so that the user can log in.


=== Account admin utils ===
<console>
Now that you know how to add a new account and group by hand, let's review the various time-saving account administration utilities available under Linux. Due to space constraints, we won't cover a lot of detail describing these commands. Remember that you can always get more information about a command by viewing the command's man page. If you are planning to take the LPIC 101 exam, you should spend some time getting familiar with each of these commands.
# ##i##mkfs.ext4 /dev/sda3
{| {{table}}
</console>
|-
|newgrp
|By default, any files that a user creates are assigned to the user's group specified in /etc/passwd. If the user belongs to other groups, he or she can type newgrp thisgroup to set current default group membership to the group thisgroup. Then, any new files created will inherit thisgroup membership.
|-
|chage
|The chage command is used to view and change the password aging setting stored in '''/etc/shadow'''.
|-
|gpasswd
|A general-purpose group administration tool.
|-
|groupadd/groupdel/groupmod
|Used to add/delete/modify groups in /etc/group
|-
|useradd/userdel/usermod
|Used to add/delete/modify users in /etc/passwd. These commands also perform various other convenience functions. See the man pages for more information.
|-
|pwconv/grpconv
|Used to convert passwd and group files to "new-style" shadow passwords. Virtually all Linux systems already use shadow passwords, so you should never need to use these commands.
|}


== Tuning the user environment ==
...und hier steht wie du ein XFS root Dateisystem erstellen kannst, falls du XFS wählst:


=== Introducing "fortune" ===
<console>
Your shell has many useful options that you can set to fit your personal preferences. So far, however, we haven't discussed any way to have these settings set up automatically every time you log in, except for re-typing them each time. In this section we will look at tuning your login environment by modifying startup files.
# ##i##mkfs.xfs /dev/sda3
</console>


First, let's add a friendly message for when you first log in. To see an example message, run <span style="color:green">fortune</span>:
Deine Dateisysteme (und swap) wurden nun initialisiert, so dass sie nun eingehängt werden können (angehängt an deine existierende Verzeichnisstruktur) und zum Speichern genutzt werden können. Jetzt sind wir fertig um mit der Funtoo Linux Installation zu beginnen, auf unseren brand neuen Dateisystemen.
<pre>
$ fortune
No amount of careful planning will ever replace dumb luck.
</pre>


=== .bash_profile ===
{{fancywarning|1=
Now, let's set up <span style="color:green">fortune</span> so that it gets run every time you log in. Use your favorite text editor to edit a file named .bash_profile in your home directory. If the file doesn't exist already, go ahead and create it. Insert a line at the top:
Wenn du mit einen OpenVZ Host arbeitest, nutze bitte nur ext4. Das Parallels Entwicklerteam testet ausschließlich mit ext4 und moderne Versionen des <code>openvz-rhel6-stable</code> sind '''nicht''' kompatible mit XFS. Es könnten Kernel Bugs auftreten.
<pre>
}}
fortune
</pre>
Try logging out and back in. Unless you're running a display manager like xdm, gdm, or kdm, you should be greeted cheerfully when you log in:
<pre>
mycroft.flatmonk.org login: chouser
Password:
Freedom from incrustations of grime is contiguous to rectitude.
$
</pre>
 
=== The login shell ===
When bash started, it walked through the '''.bash_profile''' file in your home directory, running each line as though it had been typed at a bash prompt. This is called sourcing the file.
 
Bash acts somewhat differently depending on how it is started. If it is started as a login shell, it will act as it did above -- first sourcing the system-wide '''/etc/profile''', and then your personal '''~/.bash_profile'''.
 
There are two ways to tell bash to run as a login shell. One way is used when you first log in: bash is started with a process name of -bash. You can see this in your process listing:
<pre>
$ ps u
USER      PID %CPU %MEM  VSZ  RSS TTY      STAT START  TIME COMMAND
chouser    404  0.0  0.0  2508 156 tty2    S    2001  0:00 -bash
</pre>
You will probably see a much longer listing, but you should have at least one COMMAND with a dash before the name of your shell, like -bash in the example above. This dash is used by the shell to determine if it's being run as a login shell.
 
=== Understanding --login ===
The second way to tell bash to run as a login shell is with the <span style="color:green">--login</span> command-line option. This is sometimes used by terminal emulators (like xterm) to make their bash sessions act like initial login sessions.
 
After you have logged in, more copies of your shell will be run. Unless they are started with <span style="color:green">--login</span> or have a dash in the process name, these sessions will not be login shells. If they give you a prompt, however, they are called interactive shells. If bash is started as interactive, but not login, it will ignore '''/etc/profile''' and '''~/.bash_profile''' and will instead source '''~/.bashrc'''.
{| {{table}}
!interactive
!login
!profile
!rc
|-
|yes
|yes
|source
|ignore
|-
|yes
|no
|ignore
|source
|-
|no
|yes
|source
|ignore
|-
|no
|no
|ignore
|ignore
|}
 
=== Testing for interactivity ===
Sometimes bash sources your '''~/.bashrc''', even though it isn't really interactive, such as when using commands like rsh and scp. This is important to keep in mind because printing out text, like we did with the fortune command earlier, can really mess up these non-interactive bash sessions. It's a good idea to use the PS1 variable to detect whether the current shell is truly interactive before printing text from a startup file:
<pre>
if [ -n "$PS1" ]; then
fortune
fi
</pre>
 
=== /etc/profile and /etc/skel ===
As a system administrator, you are in charge of '''/etc/profile'''. Since it is sourced by everyone when they first log in, it is important to keep it in working order. It is also a powerful tool in making things work correctly for new users as soon as they log into their new account.
 
However, there are some settings that you may want new users to have as defaults, but also allow them to change easily. This is where the '''/etc/skel''' directory comes in. When you use the <span style="color:green">useradd</span> command to create a new user account, it copies all the files from '''/etc/skel''' into the user's new home directory. That means you can put helpful '''.bash_profile''' and '''.bashrc''' files in '''/etc/skel''' to get new users off to a good start.
 
=== export ===
Variables in bash can be marked so that they are set the same in any new shells that it starts; this is called being marked for export. You can have bash list all of the variables that are currently marked for export in your shell session:
<pre>
$ export
declare -x EDITOR="vim"
declare -x HOME="/home/chouser"
declare -x MAIL="/var/spool/mail/chouser"
declare -x PAGER="/usr/bin/less"
declare -x PATH="/bin:/usr/bin:/usr/local/bin:/home/chouser/bin"
declare -x PWD="/home/chouser"
declare -x TERM="xterm"
declare -x USER="chouser"
</pre>
 
=== Marking variables for export ===
If a variable is not marked for export, any new shells that it starts will not have that variable set. However, you can mark a variable for export by passing it to the <span style="color:green">export</span> built-in:
<pre>
$ FOO=foo
$ BAR=bar
$ export BAR
$ echo $FOO $BAR
foo bar
$ bash
$ echo $FOO $BAR
bar
</pre>
In this example, the variables FOO and BAR were both set, but only BAR was marked for export. When a new bash was started, it had lost the value for FOO. If you exit this new bash, you can see that the original one still has values for both FOO and BAR:
<pre>
$ exit
$ echo $FOO $BAR
foo bar
</pre>
 
=== Export and set -x ===
Because of this behavior, variables can be set in '''~/.bash_profile''' or '''/etc/profile''' and marked for export, and then never need to be set again. There are some options that cannot be exported, however, and so they must be put in your '''~/.bashrc''' and your ''profile'' in order to be set consistently. These options are adjusted with the set built-in:
<pre>
$ set -x
</pre>
The <span style="color:green">-x</span> option causes bash to print out each command it is about to run:
<pre>
$ echo $FOO
$ echo foo
foo
</pre>
This can be very useful for understanding unexpected quoting behavior or similar strangeness. To turn off the <span style="color:green">-x</span> option, do <span style="color:green">set +x</span>. See the bash man page for all of the options to the set built-in.
 
=== Setting variables with "set" ===
The <span style="color:green">set</span> built-in can also be used for setting variables, but when used that way, it is optional. The bash command <span style="color:green">set FOO=foo</span> means exactly the same as <span style="color:green">FOO=foo</span>. Un-setting a variable is done with the <span style="color:green">unset</span> built-in:
<pre>
$ FOO=bar
$ echo $FOO
bar
$ unset FOO
$ echo $FOO
</pre>
 
=== Unset vs. FOO= ===
This is ''not'' the same as setting a variable to nothing, although it is sometimes hard to tell the difference. One way to tell is to use the <span style="color:green">set</span> built-in with no parameters to list all current variables:
<pre>
$ FOO=bar
$ set | grep ^FOO
FOO=bar
$ FOO=
$ set | grep ^FOO
FOO=
$ unset FOO
$ set | grep ^FOO
</pre>
Using <span style="color:green">set</span> with no parameters like this is similar to using the <span style="color:green">export</span> built-in, except that <span style="color:green">set</span> lists all variables instead of just those marked for export.
 
=== Exporting to change command behavior ===
Often, the behavior of commands can be altered by setting environment variables. Just as with new bash sessions, other programs that are started from your bash prompt will only be able to see variables that are marked for export. For example, the command <span style="color:green">man</span> checks the variable PAGER to see what program to use to step through the text one page at a time.
<pre>
$ PAGER=less
$ export PAGER
$ man man
</pre>
With PAGER set to <span style="color:green">less</span>, you will see one page at a time, and pressing the space bar moves on to the next page. If you change PAGER to <span style="color:green">cat</span>, the text will be displayed all at once, without stopping.
<pre>
$ PAGER=cat
$ man man
</pre>
 
=== Using "env" ===
Unfortunately, if you forget to set PAGER back to <span style="color:green">less</span>, <span style="color:green">man</span> (as well as some other commands) will continue to display all their text without stopping. If you wanted to have PAGER set to <span style="color:green">cat</span> just once, you could use the <span style="color:green">env</span> command:
<pre>
$ PAGER=less
$ env PAGER=cat man man
$ echo $PAGER
less
</pre>
This time, PAGER was exported to <span style="color:green">man</span> with a value of <span style="color:green">cat</span>, but the PAGER variable itself remained unchanged in the bash session.
 
== Summary and resources ==
 
=== Summary ===
Congratulations on finishing Part 3 of this tutorial series! At this point, you should know how to locate information in system and Internet documentation, and you should have a good grasp of the Linux permissions model, user account management, and login environment tuning.
 
=== Resources ===
Be sure to check out the various Linux documentation resources covered in this tutorial -- particularly the [http://www.tldp.org/ Linux Documentation Project]. You'll find its collection of guides, HOWTOs, FAQs, and man pages to be invaluable. Be sure to check out [http://www.lwn.net/ Linux Weekly News] as well.
 
The [http://www.tldp.org/guides.html Linux System Administrators guide] (available from the "Guides" section at www.tldp.org) is a good complement to this series of tutorials -- give it a read! You may also find Eric S. Raymond's [http://www.tldp.org/HOWTO/Unix-and-Internet-Fundamentals-HOWTO/ Unix and Internet Fundamentals HOWTO] to be helpful.
 
Check out the other articles in this series:
*[[Linux Fundamentals, Part 1]]
*[[Linux Fundamentals, Part 2]]
*[[Linux Fundamentals, Part 4]]


In the "Bash by Example" article series, Daniel shows you how to use bash programming constructs to write your own bash scripts. This series (particularly Parts 1 and 2) will be good preparation for the LPIC Level 1 exam:
==== Einhängen der Dateisystemen ====
*[[Bash by Example, Part 1]]: Fundamental programming in the Bourne-again shell
Hänge die neuen Dateisysteme wie folgt ein, erstelle <code>/mnt/funtoo</code> als Einhängepunkt zur Installation:
*[[Bash by Example, Part 2]]: More bash programming fundamentals
*[[Bash by Example, Part 3]]: Exploring the ebuild system


You can learn more about sed in the Sed by Example article series. If you're planning to take the LPI exam, be sure to read the first two articles of this series.
<console>
*[[Sed by Example, Part 1]]
# ##i##mkdir /mnt/funtoo
*[[Sed by Example, Part 2]]
# ##i##mount /dev/sda3 /mnt/funtoo
*[[Sed by Example, Part 3]]
# ##i##mkdir /mnt/funtoo/boot
# ##i##mount /dev/sda1 /mnt/funtoo/boot
</console>
Optional, falls du  separate Dateisysteme für  <code>/home</code> oder alle andere erstellt hast:


To learn more about awk, read the Awk by Example article series.
<console>
*[[Awk by Example, Part 1]]
# ##i##mkdir /mnt/funtoo/home
*[[Awk by Example, Part 2]]
# ##i##mount /dev/sda4 /mnt/funtoo/home
*[[Awk by Example, Part 3]]
</console>


If you're not too familiar with the vi editor, I strongly recommend that you check out my [http://www-106.ibm.com/developerworks/edu/l-dw-linuxvi-i.html Vi -- the cheat sheet method] tutorial. This tutorial will give you a gentle yet fast-paced introduction to this powerful text editor. Consider this must-read material if you don't know how to use vi.
Falls du eine separate Partition für <code>/tmp</code> oder <code>/var/tmp</code> auf einem anderem Dateisystem hast, stelle sicher, dass die Zugriffsrechte des  Einhängepunkt stimmen und er global beschreibbar ist, wie folgt:


__NOTOC__
<console>
[[Category:Linux Core Concepts]]
# ##i##chmod 1777 /mnt/funtoo/tmp
[[Category:Articles]]
</console>
{{ArticleFooter}}

Revision as of 19:23, January 27, 2015


   Note

This is a template that is used as part of the Installation instructions which covers: the process of partitioning and filesystem creation. Templates are being used to allow multiple variant install guides that use most of the same re-usable parts.


Vorbereiten der Festplatte

Diese Sektion handelt über die verschiedenen Möglichkeiten Funtoo Linux auf einer Festplatte zu installieren und zu booten.

Einleitung

Früher gab es nur eine Variante einen PC zu booten, alle Desktop- und Servercomputer hatten einen voreingestellten PC BIOS, alle Festplatten nutzten den Master Boot Record (MBR) um das System zu booten und unsere Festplatten waren mit dem MBR Partitionsschema in verschiedene Regionen partitioniert. Das war einfach wie's gemacht wurde. Und uns gefiel es!

Dann kamen EFI und UEFI, neue firmware designt das System zu booten, gemeinsam mit GTP Partitionstabellen um Partitionen auf Festplatten größer als 2.2TB zu definieren. Plötzlich haben wir eine breite Wahl von Optionen, Linux Systeme zu installieren und zu booten. Damit haben wir nun eine komplexere Situation als damals.

Nehmen wir einen Moment um die verfügbaren Optionen, zur Konfiguration der Festplatte um Linux zu booten, zu besprechen. Diese Installationsanleitung nutzt und empfiehlt die old-school Methode des BIOS bootens mit hilfe des MBR. Es funktioniert und (außer in seltenen Fällen) ist universal unterstützt. Mit dieser Methode ist nichts falsch, solange deine Systemfestplatte nur bis zu 2TB groß ist. Solange wird diese Methode die volle Kapazität deiner Festplatte nutzen.

Es gibt aber einige Situationen, in denen diese old-school Methode nicht optimal ist. Falls du eine Systemfestplatte >2TB hast, dann erlauben dir MBR Partitionen keinen Zugang zum gesamten Speicher. Das ist also ein Grund gegen diese Methode. Ein Weiterer ist, dass es "PC" Systeme gibt, welche das booten via BIOS nicht mehr unterstützen und dich zwingen via UEFI zu booten. Aus Mitleid für die PC-Nutzer, die in diese Zwickmühle geraten, decken wir das Booten via UEFI zusätzlich in dieser Installationsanleitung ab .

Unsere empfehlung ist immer noch die old-school Methode, es seiden du hast Gründe dagegen. Der Bootloader, den wir nutzen um den Linux Kernel zu laden, heißt GRUB. Also nennen wir die Methode BIOS + GRUB(MBR) Methode. Es ist die traditionelle Methode um ein Linux System bootbar zu machen.

Falls du via UEFI booten willst, empfehlen wir dir nicht den MBR zum booten zu nutzen, was nur manche Systeme unterstützen, sondern wir empfehlen UEFI zu nutzen um GRUB zu laden. GRUB wird dann das Linux System booten. Wir referenzieren zu dieser Methode mit UEFI + GRUB (GPT).

Und ja, es gibt noch weitere Methoden, von denen einige auf der Boot Methods Seite dokumentiert sind. Unsere Empfehlung war immer die 'BIOS + GRUB (GPT) Methode, welche allerdings nun nicht mehr konsistent und hardwareübergreifend unterstützt wird.

Die größte Frage ist immer -- Welche Bootmethode sollst du nutzen? Hier ist mein Gedankengang.

Grundsatz 1 - Old School
Falls du verlässlich via System Rescue CD booten kannst und dir ein leicht blaues Menü angezeigt wird, dann bootet die CD via BIOS und es ist sehr wahrscheinlich, das du auch Funtoo Linux via BIOS booten kannst. Also gehe old-school und nutze diese Methode, es sei denn du hast Gründe via UEFI zu booten. Zum Beispiel eine Systemfestplatte >2.2TB In diesem Fall beachte Grundsatz 2, wenn dein System UEFI unterstützt.
Grundsatz 2 - New School
Falls du verlässlich via System Rescue CD booten kannst und dir ein schwarz und weißes Menü, --Glückwunsch, dein System ist konfiguriert UEFI zu unterstützen. Das bedeutet das du bereit bist Funtoo Linux einzurichten um via UEFI zu booten. Dein System könnte immer noch das Booten übers BIOS unterstützen, aber versuch es einfach mal mit UEFI als erstes. Du kannst in deiner BIOS Konfiguration herum stochern und damit spielen.
Was ist der große Unterschied zwischen Old School und New School?
Hier ist der Deal. Falls du mit old-school MBR Partitionen gehst, deine /boot Partition wird ein ext2 Dateisystem haben, und du wirst fdisknutzen um MBR Partitionen zu erstellen. Fallse du mit new-school GPT Partitionen und booten via UEFI gehst, wird deine /boot Partition ein vfat Dateisystem haben, da UEFI dies lesen kann,außerdem wirst du gdisk nutzen um GPT Partitionen zu erstellen. Und du wirst GRUB ein wenig anders installieren. Das ist alles was es zu wissen gibt, für den Fall das du neugierig warst.
Notiere auch
Um Funtoo Linux via new-school UEFI Methode bootbar zu machen ist es notwendig, dass die System Rescue CD via UEFI gebooted wurde -- und du den ursprünglichen schwarz und weißen Bildschirm siehst. Ansonsten wird UEFI nicht aktiv sein und du wirst nicht in der Lage sein Funtoo Linux korrekt zu installieren.
   Note

Einige Motherboards unterstützen UEFI nicht richtig. Informiere dich. Zum Beispiel, das Award BIOS in meinem Gigabyte GA-990FXA-UD7 rev 1.1 hat eine Option das Booten via UEFI für CD/DVD zu aktivieren. Das ist aber nicht ausreichend um UEFI für Festplatten zu nutzen und Funtoo Linux zu installieren. UEFI muss für entfernbare Datenträger und fixierte Datenträger unterstützt werden. (Damit du deine neue Funtoo Installation booten kannst) Tatsächlich haben die neueren Revisionen des Boards(rev 3.0) volle UEFI unterstützung. Das könnte der dritte Grundsatze sein -- kenne die Hardware.

Old-School (BIOS/MBR) Methode

   Note

Falls du via System Rescue CD booten kannst und dir ein leicht blaues Menü angezeigt wird nutze diese Methode. Falls du die new-school Methode nutzen wirst, Klicke hier um direkt zu UEFI/GPT zu springen.

Vorbereitung

Erstens, es ist ein gute Idee sicherzustellen, dass du die richtige Festplatte zum Partitionieren gefunden hast. Versuche es mit diesem Befehl und verifiziere, dass /dev/sda die Festplatte zum Partitionieren ist:

root # fdisk -l /dev/sda

Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


root #         Start          End    Size  Type            Name
 1         2048   1250263694  596.2G  Linux filesyste Linux filesystem

Nun, ist es empfohlen, das du alle existierende MBR oder GTP Partitionstabellen auf der Festplatte, welche das System beim Booten verwirren könnten löschst. Wir machen dies mit sgdisk:

   Warning

Dies wird deine existierende Partitionen unerreichbar machen! Du bist "stark" gewarnt und geraten alle wichtigen/kritischen Daten vorher zu sichern.

root # sgdisk --zap-all /dev/sda

Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.

Diese Ausgabe ist nichts beängstigendes, da der Befehl trotzdem erfolgreich war:

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************
Partitionierung

Nun werden wir fdisk nutzen um die MBR Partitionstabelle und die Partitionen zu erstellen:

root # fdisk /dev/sda

Innerhalb fdisk, folge diesen Schritten:

Leere die Partitionstabelle:

Command (m for help): o ↵

Erstelle Partition 1 (boot):

Command (m for help): n ↵
Partition type (default p): 
Partition number (1-4, default 1): 
First sector: 
Last sector: +128M ↵

Erstelle Partition 2 (swap):

Command (m for help): n ↵
Partition type (default p): 
Partition number (2-4, default 2): 
First sector: 
Last sector: +2G ↵
Command (m for help): t ↵ 
Partition number (1,2, default 2): 
Hex code (type L to list all codes): 82 ↵

Erstelle root Partition:

Command (m for help): n ↵
Partition type (default p): 
Partition number (3,4, default 3): 
First sector: 
Last sector: 

Verifiziere die Partitionstabelle:

Command (m for help): p

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x82abc9a6

Device    Boot     Start       End    Blocks  Id System
/dev/sda1           2048    264191    131072  83 Linux
/dev/sda2         264192   4458495   2097152  82 Linux swap / Solaris
/dev/sda3        4458496 625142447 310341976  83 Linux

Schreibe die Partitionstabelle auf die Festplatte:

Command (m for help): w

Deine neue MBR Partitionstabelle wird nun auf die Systemfestplatte geschrieben.

   Note

Du bist noch nicht fertig mit der Partitionierung! Jetzt, springe zu Creating filesystems.

New-School (UEFI/GPT) Methode

   Note

Falls du verlässlich via System Rescue CD booten kannst und dir ein schwarz und weißes Menü angezeigt wurde, verwende diese Methode. Ansonsten diese Methode wird nicht funktionieren!

Die gdiskBefehle um GTP Partitionstabellen zu erstellen lauten wie folgt. Passe die Große jeweils an, falls notwendig, diese Voreinstellungen werden für die meisten Nutzer funktionieren.Beginne gdisk:

root # gdisk /dev/sda

Innerhalb gdisk, folge diesen Schritten:

Erstelle eine neue leere Partitionstabelle (Dies wird alle Daten löschen!):

Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵

Erstelle Partition 1 (boot):

Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +500M ↵
Hex Code: 

Erstelle Partition 2' (swap):

Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +4G ↵
Hex Code: 8200 ↵

Erstelle Partition 3 (root):

Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector:  (for rest of disk)
Hex Code: 

Während des Prozesses kannst du mit "p" und Enter die aktuelle Partitionstabelle anschauen. Falls du einen Fehler machst "d" eine existierende Partition löschen. Wenn du fertig bist mit deiner Partitionierung kannst du mit "w" die Konfiguration auf die Festplatte schreiben lassen.

Schreibe Partitionstabelle auf die Festplatte:

Command: w ↵
Do you want to proceed? (Y/N): Y ↵

Die Partitionstabelle wird nun auf die Festplatte geschrieben und gdisk wird beendet.

Nun, wurden deine GTP/GUID Partitionen erstellt und sie werden gezeigt wie folgt under block devices unter Linux:


  • /dev/sda1, wird für das /boot Dateisystem genutzt,
  • /dev/sda2, wird für den swap Speicher genutzt, und
  • /dev/sda3, wird für das root Dateisystem verwendet.

Erstelle Dateisysteme

   Note

Dieser Abschnitt behandelt BIOS und UEFI Installationen. Nicht Überspringen!

Bevor du die neuen Partitionen nutzen kannst, müssen die Partitionen mit Dateisystem metadata initialisiert werden. Dieser Prozess ist bekannt als "Erstellen des Dateisystems". Nachdem die Dateisysteme erstellt wurden kann die Festplatte eingebunden werden und Daten speichern.

Lass es uns simple halten. Nutzt du old-school MBR Partitionen? Falls ja, erstellen wir ein ext2 Dateisystem unter /dev/sda1:

root # mkfs.ext2 /dev/sda1

Falls du new-school GPT Partitionen für UEFI nutzt, erstellst du ein vfat Dateisystem unter /dev/sda1, da UEFI dieses lesen kann:


root # mkfs.vfat -F 32 /dev/sda1

Nun, lass uns eine swap Partition erstellen. Die Partition wird genutzt als Überlauf (virtueller Zwischenspeicher) , wenn dein RAM ausgelastet ist oder wenn du dein System in den Ruhezustand versetzen willst.

Du wirst kein Dateisystem auf der swap Partition erstellen, denn swap wird nicht zum Speichern von Datein genutzt, aber es ist notwendig eine swap Partition zu initialisieren via dem mkswap Befehl. Dann werden wir den Befehl swapon ausführen, damit ist die swap Partition sofort aktiv innerhalb deiner aktuellem (live CD) Umgebung. Für den Fall das der swap im späterem Installationsprozess benötigt wird:

root # mkswap /dev/sda2
root # swapon /dev/sda2

Nun, müssen wir das root Dateisystem erstellen. Dort wird das Wurzelverzeichnis von Funtoo Linux leben. Wir empfehlen im allgemeinen ext4 oder XFS als root Dateisystem. Bist du nicht sicher wähle ext4. Hier steht wie man ein ext4 root Dateisystem erstellt:

root # mkfs.ext4 /dev/sda3

...und hier steht wie du ein XFS root Dateisystem erstellen kannst, falls du XFS wählst:

root # mkfs.xfs /dev/sda3

Deine Dateisysteme (und swap) wurden nun initialisiert, so dass sie nun eingehängt werden können (angehängt an deine existierende Verzeichnisstruktur) und zum Speichern genutzt werden können. Jetzt sind wir fertig um mit der Funtoo Linux Installation zu beginnen, auf unseren brand neuen Dateisystemen.

   Warning

Wenn du mit einen OpenVZ Host arbeitest, nutze bitte nur ext4. Das Parallels Entwicklerteam testet ausschließlich mit ext4 und moderne Versionen des openvz-rhel6-stable sind nicht kompatible mit XFS. Es könnten Kernel Bugs auftreten.

Einhängen der Dateisystemen

Hänge die neuen Dateisysteme wie folgt ein, erstelle /mnt/funtoo als Einhängepunkt zur Installation:

root # mkdir /mnt/funtoo
root # mount /dev/sda3 /mnt/funtoo
root # mkdir /mnt/funtoo/boot
root # mount /dev/sda1 /mnt/funtoo/boot

Optional, falls du separate Dateisysteme für /home oder alle andere erstellt hast:

root # mkdir /mnt/funtoo/home
root # mount /dev/sda4 /mnt/funtoo/home

Falls du eine separate Partition für /tmp oder /var/tmp auf einem anderem Dateisystem hast, stelle sicher, dass die Zugriffsrechte des Einhängepunkt stimmen und er global beschreibbar ist, wie folgt:

root # chmod 1777 /mnt/funtoo/tmp