Linux Foundation Certified System Administrator LFCS v1.3 PDF
Linux Foundation Certified System Administrator LFCS v1.3 PDF
Linux Foundation Certified System Administrator LFCS v1.3 PDF
Administrator (LFCS)
Exam preparation notes
Diarmuid Briain, diarmuid@obriain.com
27 November 2014
Throughout this document I am ably assisted by Luigi Menabrea and Ada Lovelace. Both of
these individuals were key to the development of the famous analytical engine of 1830s and
40s fame from which modern computing can trace its origins. Luigi went on to serve as the 7th
Prime Minister of Italy from 1867 to 1869. His sketch of The Analytical Engine Invented by
Charles Babbage, Esq while a military engineer was translated by Ada Augusta, Countess of
Lovelace in 1842. These notes included additional detail that Lovelace is now widely
recognised as the world's first computer program and therefore Ada is credited as being the
first computer programmer.
Luigi Menabrea
Ada Lovelace
Diarmuid Briain
Table of Contents
1. Local system administration...........................................................................................................5
1.1. Creating backups...............................................................................................................................5
1.2. Managing local users accounts........................................................................................................5
1.3. Managing user accounts...................................................................................................................6
1.4. Managing user account attributes...................................................................................................6
Diarmuid Briain
Notes
-U, --user-group
Diarmuid Briain
Add Ada Lovelace to the babbage group as well as the alovelace group.
$ cat /etc/group | grep babbage
babbage:x:1003:
$ sudo usermod -a -G alovelace,babbage alovelace
$ cat /etc/group | grep babbage
babbage:x:1003:alovelace
:
:
:
:
:
:
:
Set Ada Lovelace's account expiration date to 1st December 2014, the minimum number of
days before password change to ten and the maximum number of days before password
change to twenty.
$ sudo chage -E 2014-12-01 -m 10 -M 20 alovelace
Diarmuid Briain
:
:
:
:
:
:
:
Setting the date of last password change to zero forces a password change at the next login.
$ sudo chage -d 0 alovelace
$ sudo chage -l alovelace
Last password change
Password expires
Password inactive
Account expires
Minimum number of days between password change
Maximum number of days between password change
Number of days of warning before password expires
:
:
:
:
:
:
:
The following sequence of attempts to change the password gives some idea of the general
restrictions.
$ su - alovelace
Password:
You are required to change your password immediately (root enforced)
Changing password for alovelace.
(current) UNIX password: maths
Enter new UNIX password: maths
Retype new UNIX password: maths
Password unchanged
Enter new UNIX password: ada
Retype new UNIX password: ada
You must choose a longer password
Enter new UNIX password: ada123
Retype new UNIX password: ada123
Bad: new password is too simple
su: Authentication token manipulation error
$ su - alovelace
Password:
You are required to change your password immediately (root enforced)
Changing password for alovelace.
(current) UNIX password: maths
Enter new UNIX password: multiply
Retype new UNIX password: multiply
alovelace~$ id
uid=1001(alovelace) gid=1001(alovelace) groups=1001(alovelace)
$ sudo chage -l alovelace
Last password change
Password expires
Password inactive
Account expires
Minimum number of days between password change
Maximum number of days between password change
Number of days of warning before password expires
Diarmuid Briain
:
:
:
:
:
:
:
In practice the group password is not that useful. It was conceived to allow a user who does not
have access to a particular group could use the newgrp command to award such a group
access. In this case the group password would be used in response to the system challenge.
Change the permissions on the directory to give the group Read, Write and eXecute (RWX)
permissions.
$ chmod g+w sandbox
or
Create two files, one owned by Luigi Menabrea and the other by Ata Lovelace in the sandbox
directory.
$ echo "This is a Luigi Menabrea file." > file1.txt
$ su alovelace
Password: maths
sandbox> echo "This is an Ata Lovelace file." > file2.txt
sandbox> exit
Diarmuid Briain
2
6
1
1
lmenabrea babbage
4096 Oct 21 15:55 .
lmenabrea lmenabrea 4096 Oct 21 15:50 ..
lmenabrea lmenabrea
34 Oct 21 15:54 file1.txt
alovelace alovelace
30 Oct 21 15:55 file2.txt
$ cat file1.txt
This is a Luigi Menabrea file.
$ cat file2.txt
This is an Ata Lovelace file.
Why can Ata Lovelace write in the directory ? Well she is part of the babbage group and as the
directory has RW permissions for the babbage group she has rights to Read and Write files.
Adjustable attributes
A - no atime updates
a - append only
C - no copy on write
c - compressed
D - synchronous directory updates
d - no dump
e - extent format
i - immutable (Superuser only)
j - data journalling
S - synchronous updates
s - secure deletion
T - top of directory hierarchy
t - no tail-merging
u - undeletable
h - huge file
E - compression error
Diarmuid Briain
I - indexed directory
X - compression raw access
To demonstrate create a directory and a file and review the associated extended attributes.
Only e is set which indicates that the file is using extents for mapping the blocks on disk.
Remove it and replace it again from the adafile.
$ mkdir adadirectory
$ touch adafile
$ lsattr
-------------e-- ./adadirectory
-------------e-- ./adafile
$ chattr -e adafile
$ lsattr adafile
---------------- adafile
$ chattr +e adafile
$ lsattr adafile
-------------e-- adafile
Now set the immutable attribute on the file. This will prevent deletion or renaming of the file. It
will also prevent all but the superuser from writing date to the file. It can only be set with
superuser privileges.
$ echo "Ada Lovelace file" > adafile
$ cat adafile
Ada Lovelace file
$ sudo chattr +i adafile
[sudo] password for lmenabrea:
$ lsattr adafile
----i--------e-- adafile
$ echo "Change Ada Lovelace" >> adafile
bash: adafile: Permission denied
$ rm adafile
rm: remove write-protected regular file adafile? yes
rm: cannot remove adafile: Operation not permitted
$ mv adafile ADAfile
mv: cannot move adafile to ADAfile: Operation not permitted
To securely delete a file where its blocks are zeroed and written back to the disk set the s
attribute.
$ sudo chattr =es adafile
$ lsattr adafile
s------------e-- adafile
Another interesting attribute is the A which tells the filesystem to NOT update the file's atime.
This cuts down on disk access which is good for extending the life of an Solid State Drive
(SSD) or extending the life of a laptop battery. While this can be done with this extended
attribute the more typical method is to mount the filesystem with the noatime option. Note in
the example that once the A is set the Access time remains constant.
10
Diarmuid Briain
The setfacl utility is used to set ACLs for files and directories. ACLs can be added or modified
using the -m switch option. Here are a number of examples. First get the ACL details for the
sandbox directory using the getfacl sister utility.
$ getfacl sandbox
# file: sandbox
# owner: lmenabrea
# group: babbage
user::rwx
group::rwx
other::r-x
Diarmuid Briain
11
12
Diarmuid Briain
Field
Function
Notes
Device name
Mount point
ext2, ext3, ext4, reiserfs, swap, vfat, ntfs, ISP 9660, auto
Mount options
auto, noauto, exec, noexec, user, nouser, ro, rw, sync, async, suid, nosuid
Dump
fsck option
0 - exclude from fsck check, nonzero value - fsck check in order of value.
$ chmod +x hello.sh
$ ls -la | grep hello.sh
-rwxr-xr-x 1 lmenabrea lmenabrea
$ ./hello.sh
Hello World
Diarmuid Briain
13
Change the group of the script to babbage and give it group eXecute permissions.
$ sudo chgrp babbage hello.sh
$ ls -la | grep hello.sh
-rw-r--r-- 1 lmenabrea babbage
Note that the owner cannot run the script however Ata Lovelace who belongs to the babbage
group can.
$ ./hello.sh
bash: ./hello.sh: Permission denied
$ su alovelace
Password: maths
sandbox> ./hello.sh
Hello World
1.10.1. top/htop
Monitor processes using top.
$ top
top - 17:02:24 up
Tasks: 285 total,
%Cpu(s): 2.0 us,
KiB Mem:
7738224
KiB Swap: 7942140
PID
4940
4941
4942
2817
1
2
3
5
7
8
14
USER
alovela+
alovela+
alovela+
lmenabrea
root
root
root
root
root
root
PR NI
20
0
20
0
20
0
20
0
20
0
20
0
20
0
0 -20
20
0
20
0
VIRT
RES
7308
100
7308
100
7308
100
846300 116420
34024
3328
0
0
0
0
0
0
0
0
0
0
SHR S
0 R
0 R
0 R
14880 S
1496 S
0 S
0 S
0 S
0 S
0 S
%CPU %MEM
95.0 0.0
95.0 0.0
95.0 0.0
6.3 1.5
0.0 0.0
0.0 0.0
0.0 0.0
0.0 0.0
0.0 0.0
0.0 0.0
TIME+ COMMAND
1:34.62 stress
1:34.56 stress
1:34.60 stress
0:58.97 chrome
0:01.92 init
0:00.01 kthreadd
0:00.22 ksoftirqd/0
0:00.00 kworker/0:0H
0:19.93 rcu_sched
0:03.87 rcuos/0
Diarmuid Briain
stress
00:00:00
00:07:42
00:07:42
00:07:42
stress
stress
stress
stress
7308
7308
7308
7308
11744
432 pts/2
100 pts/2
100 pts/2
100 pts/2
912 pts/5
stress
4225 0 17:00 pts/2
4939 99 17:00 pts/2
4939 99 17:00 pts/2
4939 99 17:00 pts/2
4256 0 17:08 pts/5
S+
R+
R+
R+
S+
17:00
17:00
17:00
17:00
17:08
0:00 stress
8:03 stress
8:03 stress
8:03 stress
0:00 grep
--cpu
--cpu
--cpu
--cpu
3
3
3
3
Diarmuid Briain
15
1.10.4. nice/renice
nice is a utility for managing scheduling priority of processes. Nice values range from -19 (very
high priority) to 19 (very low priority) with a value of 0 being the default priority. Looking at the
top output, the column marked NI indicated the current nice value of each process.
$ top
top - 17:28:33 up
Tasks: 280 total,
%Cpu(s): 3.5 us,
KiB Mem:
7738224
KiB Swap: 7942140
PID
5640
5642
5641
5643
2817
3533
USER
alovela+
alovela+
alovela+
alovela+
lmenabrea
lmenabrea
PR NI
VIRT
RES
20
0
7308
100
20
0
7308
100
20
0
7308
100
20
0
7308
100
20
0 846300 113908
20
0 1086508 395052
SHR S
0 R
0 R
0 R
0 R
13676 S
39320 S
%CPU %MEM
84.4 0.0
84.4 0.0
79.1 0.0
79.1 0.0
5.3 1.5
5.3 5.1
TIME+ COMMAND
0:06.04 stress
0:06.03 stress
0:06.04 stress
0:06.04 stress
1:33.87 chrome
1:42.02 chrome
16
USER
alovela+
alovela+
alovela+
alovela+
lmenabrea
PR NI
VIRT
RES
35 15
7308
100
20
0
7308
100
20
0
7308
100
20
0
7308
100
20
0 1094700 402600
SHR S
0 R
0 R
0 R
0 R
39320 S
%CPU %MEM
99.7 0.0
99.7 0.0
99.7 0.0
99.7 0.0
6.2 5.2
TIME+ COMMAND
1:03.97 stress
1:03.96 stress
1:03.92 stress
1:03.97 stress
1:45.17 chrome
Diarmuid Briain
USER
alovela+
alovela+
alovela+
alovela+
root
root
PR
15
15
15
15
20
20
VIRT
7308
7308
7308
7308
34024
0
RES
100
100
100
100
3328
0
SHR
0
0
0
0
1496
0
S %CPU %MEM
R 100.0 0.0
R 100.0 0.0
R 96.2 0.0
R 96.2 0.0
S
0.0 0.0
S
0.0 0.0
TIME+
2:30.70
2:30.64
2:30.63
2:30.71
0:02.25
0:00.01
COMMAND
stress
stress
stress
stress
init
kthreadd
The Basic Input/Output System (BIOS) is the lowest level interface between the
computer and peripherals. On boot it performs integrity checks on memory and seeks
instructions on the Master Boor Record (MBR) on the first drive.
The MBR points to the GRand Unified Bootloader (GRUB).
GRUB lists the Operating System (OS) labels and the user will select, or the default is
selected to identify which kernel to run and which partition, on which drive it is located.
GRUB then loads the GNU/Linux OS.
The GNU/Kernel loads the kernel which executes the init program. init is the
root/parent of all processes executing on Linux.
The first processes that init starts is:
SysV - /etc/inittab.
upstart - /sbin/init.
As part of the upstart initialisation it runs /etc/init/rc.conf to start the
legacy SysV init system.
Based on the appropriate run-level, scripts are executed to start various processes to run the
system and make it functional.
The init process is the last step in the boot procedure and identified by process id "1". init is
responsible for starting system processes.
Diarmuid Briain
17
1.11.2. Runlevels
Runlevels are sets of system configurations. Runlevels for Debian and Ubuntu systems are:
The default runlevel is 2.
Level
Description
System halt.
Single-User mode.
System reboot.
# Halt now
# Halt in 3 minutes
$ sudo telinit 0
18
Diarmuid Briain
SysV init is the first process started during boot and is assigned PID 1.
Init is started by the kernel using a hard-coded filename, and if the kernel is
unable to start it, a kernel panic will result.
This system is in the process of being replaced in GNU/Linux distributions by
systemd.
Upstart is an event-based replacement for the /sbin/init daemon which handles
starting of tasks and services during boot, stopping them during shutdown and
supervising them while the system is running.
It was developed and used by Ubuntu.
When Debian GNU/Linux decided to use systemd as its replacement for
/sbin/init, Ubuntu announced that it would follow.
systemd is a system and service manager for Linux which:
provides aggressive parallelisation capabilities.
uses socket and D-Bus activation for starting services.
offers on-demand starting of daemons.
keeps track of processes using Linux control groups.
supports snapshotting and restoring of the system state.
maintains mount and automount points.
implements an elaborate transactional dependency-based service control logic.
Diarmuid Briain
19
1.11.3.1. SysV
SystemV (SysV) is the traditional UNIX/Linux init system. It is essentially a number of process
management scripts grouped into runlevels.
runlevel 0
runlevel 1
runlevel 2
runlevel 3
runlevel 4
runlevel 5
runlevel 6
rcS.d - The symbolic links in this directory whose names begin with an 'S' are executed
once when booting the system.
The actual scripts are all contained in the /etc/init.d directory. Each of the other rcX.d
directories contain Start and Stop symbolic links to the scripts in /etc/init.d. These scripts are
named either SXX<name> or KXX<name> where:
S - Start
K - Stop
XX - Order number
$ file /etc/rc1.d/K20hddtemp
/etc/rc1.d/K20hddtemp: symbolic link to `../init.d/hddtemp'
If a new script is added to /etc/init.d, manual symbolic links can be created in the various
rcX.d directories or a script called update-rc.d can be used to make links to start the service
in runlevels 2345 and to stop the service in runlevels 016.
$ sudo update-rc.d hddtemp defaults
System start/stop links for /etc/init.d/hddtemp already exist.
20
Diarmuid Briain
Individual scripts can be ran directly from /etc/init.d (or with the service utility described
below). Here is an example stopping the Apache2 Server.
/etc/init.d $ ./apache2
Usage: apache2 {start|stop|graceful-stop|restart|reload|force-reload|starthtcacheclean|stop-htcacheclean}
/etc/init.d $ ./apache2 stop
* Stopping web server apache2
*
/etc/init.d $ ./apache2 status
* apache2 is not running
Diarmuid Briain
21
service
Use of the service utility with command options. Typical options in the scripts are:
start
stop
restart
reload
status
list
show
$ service --status-all
[ + ] acpid
[ - ] anacron
[ + ] apache2
[ + ] atd
[ + ] atop
[ + ] avahi-daemon
[ ? ] binfmt-support
[ + ] bluetooth
[ - ] brltty
[ + ] btsync
[ - ] casper
[ ? ] console-setup
[ ? ] cpufrequtils
22
Diarmuid Briain
1.11.3.2. Upstart
initctl command has a number of command options.
start
stop
restart
reload
status
list
$ initctl list
avahi-cups-reload stop/waiting
avahi-daemon start/running, process 1127
mountall-net stop/waiting
mountnfs-bootclean.sh start/running
nmbd start/running, process 1954
passwd stop/waiting
rc stop/waiting
rsyslog start/running, process 919
startpar-bridge stop/waiting
tty4 start/running, process 1537
udev start/running, process 569
upstart-udev-bridge start/running, process 556
1.11.3.3. systemd
Use of the systemctl utility with command options. Typical options in the scripts are:
start
stop
restart
reload
status
list
show
Diarmuid Briain
23
24
Diarmuid Briain
2. Command-line
2.1. Editing text files on the command line
2.1.1. VI
vim is the Vi IMproved, a programmers text editor.
Save and Exit
:q[uit]
:wq!
Inserting Text
a
Insert text before the first non-blank in the line [count] times.
gI
Begin a new line below the cursor and insert text, repeat [count] times.
Begin a new line above the cursor and insert text, repeat [count] times.
<ESC>
Deleting text
<Del>
d{motion}
dd
Delete the characters under the cursor until the end of the line.
Undo|Redo |Repeat
u
:u[ndo]
CTRL-R
:red[o]
Undo all latest changes on one line. {Vi: while not moved off of it}.
Diarmuid Briain
25
Searching
/{pattern}[/]
/<CR>
?<CR>
Moving Around
Basic motion commands:
h
<Home>
<End>
2.1.2. VIm
Follow the sequence below to practice creating and editing a file using vim.
$ vi file3.txt
[Press i] The quick brown fox jumps over the lazy dog. [Press ESC :wq]
$ cat file3.txt
The quick brown fox jumps over the lazy dog.
$ vi file3.txt
The quick brown fox jumps over the lazy dog. [Press o]
[Press CR]
He is then shot by the farmer. [Press ESC :wq]
$ vi file3.txt
The quick brown fox jumps over the lazy dog. [Press j twice (or scroll down to
last line]
He is then shot by the farmer. [Press l or scroll right until curser is on f]
[Press i][type angry ]
[Press ESC :wq]
$ cat file3.txt
The quick brown fox jumps over the lazy dog.
He is then shot by the angry farmer.
26
Diarmuid Briain
2.2.2. nano
Alternatively use GNU nano. Nano is ANOther editor, an enhanced free Pico clone
$ nano file3.txt
Press Control - X.
Press Y.
Diarmuid Briain
27
2.2.1. tac
The tac command is the inverse of cat. It prints files in reverse.
$ cat users.txt
lmenabrea
cbabbage
alovelace
$ tac users.txt
alovelace
cbabbage
lmenabrea
28
Diarmuid Briain
Well in the first output the first lowercase a instance on each line is replaced by an uppercase
A. In the second example the addition of the g or global flag changes every instance of a to A.
What about special characters ? Lets replace **
$ sed 's/'/"/g' printer2.txt
>
To print put lines in a file found by a pattern and suppress the other lines use the -n quiet
option. The p flag indicates print the lines found.
$ sed -n '/er/p' printer2.txt
My printer will drive me to drink,
I'm always refilling its paper,
to make matters worse,
Diarmuid Briain
29
2.2.3. grep
The grep utility is a powerful pattern search tool. There are numerous options so only some
common ones are listed here.
Option
Meaning
-c
-E
-H
-h
-i
Ignore case
-l
-n
-r
Recursive
-v
Invert match
lmenabrea
30
Diarmuid Briain
Recursively search but supress the filename at the beginning of the line.
$ sudo grep -rh alovelace /etc/
alovelace:!::alovelace
babbage:
$6$Lo92oBZTUm/H$qw5oIp55D.uy3E5xnzZpHKlO3R5sjJwxayizt1vqbFmLzkcnVdD3RJUhC6WbwGyaLsh
Rv6EtofdFDLAbdrp7X/::alovelace
sudo:*::lmenabrea,alovelace
alovelace:!::alovelace
babbage:
$6$Lo92oBZTUm/H$qw5oIp55D.uy3E5xnzZpHKlO3R5sjJwxayizt1vqbFmLzkcnVdD3RJUhC6WbwGyaLsh
Rv6EtofdFDLAbdrp7X/::alovelace
alovelace:231072:65536
alovelace:x:1002:1003:Ada Lovelace:/home/alovelace:/usr/bin/tcsh
alovelace:231072:65536
alovelace:x:1002:27:Ada Lovelace:/home/alovelace:/usr/bin/tcsh
alovelace:
$6$DnyWC4UQ$8bS26d/yiiRdnlj8PTDD8KQpc.bWrDfMCqDcC1FE6XoUDMMDJ6tyn/ZbghwIiUL57kAvcPp
Dd2CoF5bWJl2wA/:0:0:99999:7:::
alovelace:231072:65536
alovelace:
$6$DnyWC4UQ$8bS26d/yiiRdnlj8PTDD8KQpc.bWrDfMCqDcC1FE6XoUDMMDJ6tyn/ZbghwIiUL57kAvcPp
Dd2CoF5bWJl2wA/:16369:0:99999:7:::
sudo:x:27:lmenabrea,alovelace
alovelace:x:1002:alovelace
babbage:x:1003:alovelace
alovelace:231072:65536
alovelace:x:1002:alovelace
babbage:x:1003:alovelace
Diarmuid Briain
31
Recursively search files and output only the files that contain matches.
$ sudo grep -rl alovelace /etc/
/etc/gshadow/etc/gshadow
/etc/subuid
/etc/passwd
/etc/subgid/etc/passwd/etc/shadow
/etc/subuid/etc/shadow/etc/group
/etc/subgid
/etc/group-
Use a regular expression to extract groups where Ada Lovelace is the first listed member.
$ sudo grep '[0-9]*:alovelace' /etc/group
alovelace:x:1002:alovelace
babbage:x:1003:alovelace
2.2.4. cut
The cut command filters out fields or columns. Typical options are:
Option
-d
Meaning
Define field delimiter (default is tab)
-c list
-f list
$ id
uid=1000(lmenabrea) gid=1000(lmenabrea) groups=1000(lmenabrea),4(adm),6(disk),
24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),110(sambashare)
$ id | cut -d ' ' -f1,2
uid=1000(lmenabrea) gid=1000(lmenabrea)
2.2.5. sort
The sort command is used to sort lines of text files. There are a number of options so here are
just some of the most used.
Option
32
Meaning
-b
-f
Ignore case
-r
Reverse order
-R
Random sort
Diarmuid Briain
2.2.6. tr
The tr translate command translates characters in a file from one form to another.
$ cat printer2.txt
My printer will drive me to drink,
I'm always refilling its paper,
it empties my wallet,
to make matters worse,
its usually broken!
$ cat printer2.txt | tr [:upper:] [:lower:]
my printer will drive me to drink,
i'm always refilling its paper,
it empties my wallet,
to make matters worse,
its usually broken!
2.2.7. nl
To write a file to standard output with line numbers added use the nl command.
$ ls /home | nl > users.txt
$ cat users.txt
1
lmenabrea
2
cbabbage
3
alovelace
$
1
2
3
$ ls /home | nl | sed 's/^[ \t]* //g' | sed 's/\t/ /g' > users_list.txt
$
1
2
3
cat users_list.txt
alovelace
cbabbage
johnny
2.2.8. Join
The join command is used to join lines of two files on a common field. In the example the
common field is the line number, the output links these as shown.
$
1
2
3
cat roles.txt
mathematician
inventor
programmer
$
1
2
3
Diarmuid Briain
33
2.2.9. uniq
The uniq utility can be used to filter matching lines from input to output. The -c option prefix
lines by the number of occurrences while the -u switch option only prints unique lines. -w can
be used to compare no more than N characters in lines.
$
1
3
8
cat
2 5
3 4
9 7
numbers.txt
3 3 4 8 9 7 6 5 4 3 2 5 6 7 8 9 1 2 5 3 3 4 8 9 7 6 5 4 3 2 5 6 7 8 9 1 2 5
8 9 7 6 5 4 3 2 5 6 7 8 9 1 2 5 3 3 4 8 9 7 6 5 4 3 2 5 6 7 8 9 1 2 5 3 3 4
6 5 4 3 2 5 6 7 8 9 1
2.2.10. awk
awk is a pattern scanning and processing language. This is a whole language in itself so it is
best analise an example.
$ df -h
Filesystem
/dev/mapper/mint--vg-root
none
udev
tmpfs
none
none
none
/dev/sda1
Size
451G
4.0K
3.7G
756M
5.0M
3.7G
100M
236M
$ df -h | awk '/none/'
none
none
none
none
4.0K
5.0M
3.7G
100M
4.0K
5.0M
3.7G
100M
0%
0%
1%
1%
/sys/fs/cgroup
/run/lock
/run/shm
/run/user
34
Diarmuid Briain
Review a tar archive with the -t or --list option to see a table of contents for the archive.
$ tar -tf sandbox.tar
sandbox/
sandbox/file2.txt
sandbox/file1.txt
sandbox/file3.txt
sandbox/hello.sh
file3.txt
hello.sh
3.1.0.1. Compression
The tar archive can be compressed to reduce file size. For example gzip which reduces the
size of files using Lempel-Ziv coding (LZ77) can be applied to the tarball. tar has the ability to
incorporate compression functions as well as archiving and perform both functions with the
same command.
$ tar sandbox.tar
$ ls -l |grep sandbox.tar
-rw-r--r-- 1 lmenabrea lmenabrea
Diarmuid Briain
35
An alternative approach is to use the bzip2 utility which uses the Burrows-Wheeler block
sorting text compression algorithm, and Huffman coding. bzip2 compression is generally
considerably better that the more conventional LZ77/LZ78-based compressors.
$ bzip2 sandbox.tar
$ ls -l |grep sandbox.tar
-rw-r--r-- 1 lmenabrea lmenabrea
The reverse process is similar to what has been seen for gunzip.
$ bunzip2 sandbox.tar.bz2
$ ls -l |grep sandbox.tar
-rw-r--r-- 1 lmenabrea lmenabrea
Fortunately the tar utility offers the ability to both archive and compress in one operation, here
is an example using gzip. Note the file extension for a gzipped archives is either .tar.gz or
simply .tgz. The z switch in the command instructs that the directory be archived and gzipped.
$ tar -czf sandbox.tar.gz sandbox
$ ls -l |grep sandbox.tar
-rw-r--r-- 1 lmenabrea lmenabrea
$ file sandbox.tar.gz
sandbox.tar.gz: gzip compressed data, from Unix, last modified: Fri Oct 24
13:56:47 2014
A similar process can be achieved for bzip2, the end extension being .tar.bz2 or .tbz2 by
convention. The j switch is used to archive and bzip2.
$ tar -cjf sandbox.tar.bz2 sandbox
$ ls -l |grep sandbox.tar
-rw-r--r-- 1 lmenabrea lmenabrea
$ file sandbox.tar.bz2
sandbox.tar.bz2: bzip2 compressed data, block size = 900k
Comparing the relative sizes of the archive and the two compressed versions. When the
requirement is very fast compression, the gzip is the best option, it has also very small memory
footprint, making it ideal for systems with limited memory. bzip2 creates about 15% smaller
files than gzip on average however it compresses at a slower rate than gzip. For
decompression a similar picture emerges with gzip the fastest. bzip2 is a lot slower taking four
to twelve times more time to decompress than gzip.
36
Diarmuid Briain
To demonstrate create a number of partitions on a device like a USB stick. These would
typically be different devices attached to the one system, i.e. /dev/sdb1, /dev/sdc1, /dev/sdd1.
Change the volume types to LVM (id : df) using fdisk.
$ sudo fdisk /dev/sdb
[sudo] password for lmenabrea:
Command (m for help): p
Disk /dev/sdb: 8004 MB, 8004304896 bytes
247 heads, 62 sectors/track, 1020 cylinders, total 15633408 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 identifier: 0x00000000
Device Boot
/dev/sdb1
/dev/sdb2
/dev/sdb3
Start
2048
4196352
8390656
End
4196351
8390655
12584959
Blocks
2097152
2097152
2097152
Id
83
83
83
System
Linux
Linux
Linux
Diarmuid Briain
37
Start
2048
4196352
8390656
End
4196351
8390655
12584959
Blocks
2097152
2097152
2097152
Id
df
df
df
System
BootIt
BootIt
BootIt
Initialise these disks for use by LVM with the pvcreate command.
$ sudo pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
$ sudo pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
$ sudo pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created
Create as volume group into which the physical volumes are incorporated.
$ sudo vgcreate vg0 /dev/sdb1 /dev/sdb2 /dev/sdb3
Volume group "vg0" successfully created
Now create logical volumes as necessary up to the limits on size imposed by the overall volume
group size. In this way the logical volumes loose the limitations of the physical volumes.
$ sudo lvcreate -L 5G -n lv0 vg0
Logical volume "lv0" created
$ sudo lvcreate -L 500M -n lv1 vg0
Logical volume "lv1" created
38
Diarmuid Briain
vg0
$ sudo lvdisplay
--- Logical volume --LV Path
LV Name
VG Name
LV UUID
LV Write Access
LV Creation host, time
LV Status
# open
LV Size
Current LE
Segments
Allocation
Read ahead sectors
- currently set to
Block device
lvm2
3
2
read/write
resizable
0
1
0
0
3
3
5.99 GiB
4.00 MiB
1533
1280 / 5.00 GiB
253 / 1012.00 MiB
EK76Ui-bH4A-ALHr-0xYJ-7MEh-mUjB-AokyLw
Diarmuid Briain
/dev/vg0/lv0
lv0
vg0
447mNo-2MqY-6AtZ-GdeW-sI6A-y3K9-LoYovm
read/write
Precision-M70, 2014-11-19 20:59:28 +0000
available
0
5.00 GiB
1280
3
inherit
auto
256
252:0
39
/dev/vg0/lv1
lv1
vg0
cPDY8T-CvYl-7dmH-gTo6-ByTR-Kdop-PvLte2
read/write
Precision-M70, 2014-11-19 21:02:19 +0000
available
0
500.00 MiB
125
1
inherit
auto
256
252:1
/dev/vg0/lv0
/dev/vg0/lv0
/dev/mapper/vg0-lv0
/dev/mapper/vg0-lv1
or
Make a filesystem on the logical volumes, create mount points and mount.
$ sudo ls /dev/mapper
control vg0-lv0 vg0-lv1
$ sudo mkfs.ext4 /dev/vg0/lv0
$ sudo mkfs.ext4 /dev/vg0/lv1
$ sudo mkdir /mnt/l-vol0
$ sudo mkdir /mnt/l-vol1
$ sudo mount -t ext4 /dev/vg0/lv0 /mnt/l-vol0
$ sudo mount -t ext4 /dev/vg0/lv1 /mnt/l-vol1
$ df -h
Filesystem
/dev/sda1
none
udev
tmpfs
none
none
none
/dev/mapper/vg0-lv0
/dev/mapper/vg0-lv1
40
Size
91G
4.0K
488M
101M
5.0M
501M
100M
4.8G
477M
Diarmuid Briain
Diarmuid Briain
41
RAID
Type
42
Description
The data is distributed equally between one or more disks without information on parity
or redundancy, without offering fault tolerance. Data is distributed across the disks to
increase storage volume, if the disk fails physically, the information will be lost and will
have to be recovered from backup copies. What does increase is the performance,
depending on the RAID 0 implementation, given that the read and write options will be
divided among the different disks. This is often confused with LVM.
This RAID type creates an exact copy, a mirror on a set of two or more disks in an
array. RAID 1 is useful for the reading performance which can increase lineally with the
number of disks. It also adds fault tolerance where a fault occurs to one of the disks as
the same information is available on each. RAID 1 is usually adequate for High
Availability (HA) where resources are needed critically. This configuration also makes
it possible to hot swap disks. If a fault is detected in any of the disks, it can be replaced
without switching off the system.
Unlike earlier RAID types with RAID 2 the data is divided into bits and redundant
codes are used for error correction. It is not widely used as a large number of disks is
required, one per system bit plus redundancy bits, so for a 32 bit system 39 disks are
required.
RAID3 uses byte divisions with an additional disk dedicated to the parity of blocks.
This is not very widely used type. Depending on the size of the data and the positions,
it does not provide simultaneous accesses.
RAID 4 is similar to RAID 3, however it stripes the data at the block level, instead of
byte level, which means that it is possible to service simultaneous requests when only
a single block is requested.
Block level striping is used, distributing the parity among the disks. It is widely used,
due to the simple parity scheme and due to the fact that this calculation is implemented
simply by the hardware, with good performance levels.
Block level striping like in RAID 5 with the addition of another parity block, i.e. Block
level striping with two parity blocks.
01
A mirror stripe is a nested RAID level where groups of RAID 0 arrays are used in a
RAID 1 array to create a mirror between them. An advantage is that, in the event of an
error, the RAID 0 level used may be rebuilt thanks to the other copy, but if more disks
need to be added, they have to be added to all the RAID 0 groups equally.
10
Striping of mirrors where groups of RAID 1 arrays are used in a RAID 0 array. In each
RAID 1 group if a disk fails there is no loss of data. RAID 10 arrays are used with high
performance databases as they include both fault tolerance and the speed.
Diarmuid Briain
The steps:
Diarmuid Briain
43
44
Diarmuid Briain
You can use the lsblk command to see the physical layout.
$ sudo lsblk
NAME
MAJ:MIN RM
sda
8:0
0
sda1
8:1
0
sda2
8:2
0
sda5
8:5
0
sdb
8:16
1
sdb1
8:17
1
sdc
8:32
1
sdc1
8:33
1
sr0
11:0
1
Another useful tool is the blkid command. This gives the Universally Unique IDentifier (UUID)
label for each device.
$ blkid
/dev/sda1: UUID="3b0a7ce9-55c7-43b1-8c54-96510bbda441" TYPE="ext2"
/dev/sda5: UUID="e619d452-fc36-4022-b0c0-571125787752" TYPE="crypto_LUKS"
/dev/mapper/sda5_crypt: UUID="rnEgUj-16bd-KFYn-MvEP-gkaw-3VOB-1g6XKg"
TYPE="LVM2_member"
/dev/mapper/mint--vg-root: UUID="ef2975f9-eeff-4b5d-82cf-13bc6ed90220"
TYPE="ext4"
/dev/mapper/mint--vg-swap_1: UUID="915e1367-6aec-4a1b-b098-7cf05e7804ff"
TYPE="swap"
/dev/sdb1: UUID="cc0e789a-869f-4999-a231-324bc8203eac" TYPE="ext4"
/dev/sdb2: UUID="9f1730b7-b2c9-4ffc-9ec1-62466b2c9b78" TYPE="ext4"
Start
End
Blocks
Id
System
Diarmuid Briain
45
dev/sdb
$ sudo fdisk /dev/sdc
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdc: 8004 MB, 8004304896 bytes
35 heads, 21 sectors/track, 21269 cylinders, total 15633408 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 identifier: 0x00000000
Device Boot
Start
End
Blocks
Id
System
46
Diarmuid Briain
:
:
:
:
:
:
Major
8
8
Minor
16
32
RaidDevice State
0
active sync
1
active sync
/dev/sdb
/dev/sdc
Diarmuid Briain
47
Add users that require access to the drive to the disk group.
$ sudo vi /etc/group
...
disk:x:100:lmenabrea
...
Make persistent, such that after a reboot the RAID array will reform. The initramfs needs to be
updated so it contains the /etc/mdadm/mdadm.conf settings during boot.
$
#
#
#
sudo -s
echo -e "\n# RAID1 Array of USB Sticks" >> /etc/mdadm/mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
echo -e "\n# Mount for RAID 1\n/dev/md0\t/mnt/raid1-md0\text4\tdefaults\t0\t0"
>> /etc/fstab
# mount -a
# update-initramfs -u
# exit
Size
7.3G
48
Diarmuid Briain
:
:
:
:
:
:
:
:
1.2
Tue May 27 15:28:05 2014
raid1
7812544 (7.45 GiB 8.00 GB)
7812544 (7.45 GiB 8.00 GB)
2
2
Superblock is persistent
Update Time
State
Active Devices
Working Devices
Failed Devices
Spare Devices
:
:
:
:
:
:
Major
8
8
Minor
16
32
RaidDevice State
0
active sync
1
active sync
/dev/sdb
/dev/sdc
During copy stop computer, remove one of the disks and reboot. As the computer reboots the
following message is displayed.
***
***
Press Y and as the computer continues to boot it displays the following message.
Starting the RAID in degraded mode.
Diarmuid Briain
49
Upon reboot review the RAID. Notice that /dev/sdc is marked as removed.
$ sudo mdadm --detail /dev/md0
/dev/md0:
Version
Creation Time
Raid Level
Array Size
Used Dev Size
Raid Devices
Total Devices
Persistence
:
:
:
:
:
:
:
:
1.2
Tue May 27 15:28:05 2014
raid1
7812544 (7.45 GiB 8.00 GB)
7812544 (7.45 GiB 8.00 GB)
2
1
Superblock is persistent
Update Time
State
Active Devices
Working Devices
Failed Devices
Spare Devices
:
:
:
:
:
:
Major
8
0
Minor
16
0
RaidDevice State
0
active sync
1
removed
/dev/sdb
Check failed disk. Note that [2/1] [U_] replaces [2/2] [UU] from the earlier runs of the
command.
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4]
[raid10]
md0 : active raid1 sdb[0]
7812544 blocks super 1.2 [2/1] [U_]
unused devices: <none>
50
Diarmuid Briain
Id
0
0
0
0
System
Empty
Empty
Empty
Empty
Device Boot
Start
End
#sectors Id System
/dev/sdc1
0
0
0 Empty
/dev/sdc2
0
0
0 Empty
/dev/sdc3
0
0
0 Empty
/dev/sdc4
0
0
0 Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table
Re-reading the partition table ...
BLKRRPART: Permission denied
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
Diarmuid Briain
51
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4]
[raid10]
md0 : active raid1 sdc[2] sdb[0]
7812544 blocks super 1.2 [2/2] [UU]
unused devices: <none>
52
Diarmuid Briain
:
:
:
:
:
:
:
:
1.2
Tue May 27 15:28:05 2014
raid1
7812544 (7.45 GiB 8.00 GB)
7812544 (7.45 GiB 8.00 GB)
2
2
Superblock is persistent
Update Time
State
Active Devices
Working Devices
Failed Devices
Spare Devices
:
:
:
:
:
:
Major
8
8
Minor
16
32
RaidDevice State
0
active sync
1
active sync
/dev/sdb
/dev/sdc
Start
1049kB
8193MB
End
8193MB
15.0GB
Size
8191MB
6807MB
File system
ext4
fat32
Name
primary
primary
Flags
(parted) rm 2
Warning: Partition /dev/sdb2 is being used. Are you sure you want to continue?
Yes/No? Yes
Diarmuid Briain
53
Start
1049kB
End
8193MB
Size
8191MB
File system
ext4
Name
primary
Flags
swap
swap
defaults
FSTAB
54
Type
partition
partition
Size
Used
7942140
0
6647804
0
Priority
-1
-2
Diarmuid Briain
swap
swap
defaults
FSTAB
Type
partition
partition
file
Size
Used
7942140
0
6647804
0
131068
0
Priority
-1
-2
-3
Description
Read
Write
eXecute
Diarmuid Briain
55
Description
Read
Write
eXecute
1
1
1
1
2
In this case with a mask of 022 the default permissions will be:
Files
Directories
777
666
022
022
755
644
56
chmod go-w filename - removes write perms for the group as well as others.
Diarmuid Briain
Change the permissions on file1.txt to User and Group having Read and Write access and
others with no access.
$ chmod u+rw,g+rw,o-rwx file1.txt
$ ls -l | grep file1.txt
total 20
-rw-rw---- 1 lmenabrea lmenabrea
Description
no access
eXecute
Write
Read
For example changing file permissions to 660 will give the user
$ chmod 660 file2.txt
$ ls -l | grep file2.txt
total 20
-rw-rw---- 1 lmenabrea lmenabrea
$ whoami
lmenabrea
$ ./hello.sh
When Luigi Menabrea launched the hello.sh script, it has all of the rights of the root user
despite lmenabrea being the owner of the process. Note the s instead of the x in the user
section. This indicates that the setuid is set.
Diarmuid Briain
57
$ whoami
lmenabrea
$ echo "New file data" > more_files/file4.txt
$ ls -l more_files/
total 4
-rw-r--r-- 1 lmenabrea babbage 14 Oct 27 00:48 file4.txt
Note that the other x permission position is replaced by t, the sticky bit.
58
Description
Diarmuid Briain
Using locate is somewhat faster assuming the database it is using is up-to-date. Usually cron
runs the updatedb utility daily which updates a database of filenames in the system. Searching
this database is much faster than searching the actual file-system. The database can be
updated manually with the updatedb command.
$ sudo updatedb
$ locate hello.sh
/home/lmenabrea/Desktop/sandbox/hello.sh
Using GREP to find a string within a file, and list the files containing the string.
grep [OPTIONS] PATTERN FILES-TO-SEARCH
-r
Recursively.
-H
-l
-i
Ignore case.
Diarmuid Briain
1.26
59
Another method to find block devices is with the use of the lsblk command. This command
lists information about all or the specified block devices by reading the information from the
sysfs filesystem.
$ lsblk
NAME
sda
sda1
sda2
sda5
sda5_crypt (dm-0)
mint--vg-root (dm-1)
mint--vg-swap_1 (dm-2)
sdb
sdb1
sdb2
sr0
MAJ:MIN RM
SIZE RO TYPE
8:0
0 465.8G 0 disk
8:1
0
243M 0 part
8:2
0
1K 0 part
8:5
0 465.5G 0 part
252:0
0 465.5G 0 crypt
252:1
0 457.9G 0 lvm
252:2
0
7.6G 0 lvm
8:16
1 14.6G 0 disk
8:17
1
7.3G 0 part
8:18
1
7.3G 0 part
11:0
1 1024M 0 rom
MOUNTPOINT
/boot
/
[SWAP]
Note that the USB Stick is /dev/sdb1. Run the fdisk utility to edit the partition table. If the
existing drive was created with GUID Partition Table (GPT) layout of the partition table on the
disk instead of Master Boot Record (MBR) then the gparted utility must be used.
$ sudo fdisk /dev/sdb
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk
doesn't support GPT. Use GNU Parted.
Command (m for help):
Install gparted.
$ sudo apt-get gparted
$ sudo gparted /dev/sdb
60
Diarmuid Briain
Start
1049kB
End
16.0GB
Size
16.0GB
File system
ext4
Name
Flags
Linux file-system
(parted) rm 1
Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?
Yes/No? Yes
Error: Partition(s) 1 on /dev/sdb have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use. As a
result, the old partition(s) will remain in use. You should reboot now before
making further changes.
Ignore/Cancel? Ignore
(parted) quit
Information: You may need to update /etc/fstab.
Umount the partition /dev/sdb1 and reload by removing the USB drive and plugging it back in.
Now print the partition table for /dev/sdb and you will see the table is empty.
$ sudo umount /dev/sdb1
$ sudo parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: SanDisk Ultra (scsi)
Disk /dev/sdb: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number
Start
End
Size
File system
Name
Flags
(parted)
Start
1049kB
8193MB
End
8193MB
15.0GB
Size
8191MB
6807MB
File system
ext4
Name
primary
primary
Flags
(parted) exit
Diarmuid Briain
61
grep sdb
sdb
sdb1
sdb2
62
Diarmuid Briain
Start
1049kB
8193MB
End
8193MB
15.0GB
Size
8191MB
6807MB
File system
ext4
fat32
Name
primary
primary
Flags
Using Linux Unified Key Setup (LUKS) as the standard for disk encryption on Linux.
luksFormat initialises a LUKS partition and sets the initial passphrase.
$ sudo cryptsetup luksFormat /dev/sdb1
WARNING!
========
This will overwrite data on /dev/sdb1 irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase: secret
Verify passphrase: secret
luksOpen opens the LUKS device and sets up a mapping to a given name (i.e. secret-disk)
after successful verification of the supplied passphrase.
$ sudo cryptsetup luksOpen /dev/sdb1 secret-disk
Enter passphrase for /dev/sdb1: secret
The file /etc/crypttab contains descriptive information about encrypted filesystems. crypttab
is only read by programs like cryptdisks_start and cryptdisks_stop.
$ sudo vi /etc/crypttab
# <target name> <source device>
secret-disk
<key file>
<options>
/dev/sdb1
Diarmuid Briain
63
/mnt/secret
ext4
defaults
Confirm.
$ df -h | grep secret
/dev/mapper/secret-disk
64
7.3G
17M
6.9G
1% /mnt/secret
Diarmuid Briain
This confirms the device is /dev/sdb. Now check the partition table with parted.
$ sudo parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: SanDisk Ultra (scsi)
Disk /dev/sdb: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number
1
2
Start
1049kB
8193MB
End
8193MB
15.0GB
Size
8191MB
6807MB
File system
ext4
fat32
Name
primary
primary
Flags
Two partitions /dev/sdb1, the ext4 partition and /dev/sdb2 the FAT32 (vfat) partition exist.
Create directories as points in the file system to mount the partitions to.
$ sudo mkdir /mnt/ext4fs
$ sudo mkdir /mnt/fat32fs
Diarmuid Briain
65
/mnt/ext4fs
/mnt/fat32fs
ext4
vfat
defaults,users
defaults,users
0
0
0
0
FSTAB
The users option permits users that are part of the disk group to mount and unmount the
drives.
$ sudo usermod -a -G disk lmenabrea
Now mount the two partitions with the mount command, which will read the entries in the
/etc/fstab directory.
$ mount /dev/sdb1
$ mount /dev/sdb2
$ mount | grep sdb
/dev/sdb1 on /mnt/ext4fs type ext4 (rw,noexec,nosuid,nodev)
/dev/sdb2 on /mnt/fat32fs type vfat (rw,noexec,nosuid,nodev)
Create a file on the mounted partition, confirm the file was created. umount the partition and
confirm file is gone. Remount again to see file is back.
$ echo "This is a test file on the ext4 partition." > /mnt/ext4fs/ext4-file.txt
$ ls /mnt/ext4fs/ | grep ext4-file.txt
ext4-file.txt
$ cat /mnt/ext4fs/ext4-file.txt
This is a test file on the ext4 partition.
$ umount /dev/sdb1
$ ls /mnt/ext4fs/ | grep ext4-file.txt
$ mount /dev/sdb1
$ ls /mnt/ext4fs/ | grep ext4-file.txt
ext4-file.txt
Mounts occurred automatically and the file created on the mounted partition is accessible.
66
Diarmuid Briain
Using Linux Unified Key Setup (LUKS) as the standard for disk encryption on Linux.
luksFormat initialises a LUKS partition and sets the initial passphrase.
$ sudo cryptsetup luksFormat /dev/sdb1
WARNING!
========
This will overwrite data on /dev/sdb1 irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase: secret
Verify passphrase: secret
luksOpen opens the LUKS device and sets up a mapping to a given name (i.e. secretdisk) after successful verification of the supplied passphrase.
$ sudo cryptsetup luksOpen /dev/sdb1 secret-disk
Enter passphrase for /dev/sdb1: secret
The file /etc/crypttab contains descriptive information about encrypted filesystems. crypttab
is only read by programs like cryptdisks_start and cryptdisks_stop.
$ sudo vi /etc/crypttab
# <target name> <source device>
secret-disk
<key file>
<options>
/dev/sdb1
Diarmuid Briain
67
7.3G
17M
6.9G
1% /mnt/secret
If the computer reboots, during the reboot the user will be presented with:
Passphrase: secret
68
Diarmuid Briain
Description
rw
sync
Reply to requests only after the changes have been committed to stable storage.
no_subtree_check
This disables subtree checking, which has mild security implications, but can improve
reliability.
linux1:~$ sudo -s
linux1:~# echo -e "\n# /library access" >> /etc/exports
linux1:~# echo "/library linux.obriain.com(rw,sync,fsid=0,no_subtree_check)"
>> /etc/exports
linux1:~# service nfs-kernel-server start
[ ok ] Exporting directories for NFS kernel daemon....
[ ok ] Starting NFS kernel daemon: nfsd mountd.
Diarmuid Briain
69
70
Diarmuid Briain
NFS Client
linux2:~$ id
uid=1001(lmenabrea) gid=1001(lmenabrea) groups=1001(lmenabrea)
29G
3.3G
24G
13% /mnt/library
Create a file on the NFS Share from the Client, use the user lmenabrea.
linux2:~$ echo "This is a client side write test" > /mnt/library/clienttestfile
linux2:~$ cat /mnt/library/clienttestfile
This is a client side write test
Check the file in the /library directory on the Server and create a server side file for test with
the user lmenabrea.
linux1:~$ cat /library/clienttestfile
This is a client side write test
linux1:~$ echo "This is a Server side write test" > /library/servertestfile
linux1:~$ cat /library/servertestfile
This is a Server side write test
Diarmuid Briain
71
Check the servertestfile on the NFS Client from the lmenabrea user.
linux2:~$ cat /mnt/library/servertestfile
This is a Server side write test
Meaning
No errors
Operational error
16
32
128
Shared-library error
Check the EXT4 file-system on /dev/sdb1 partition. Note the echo $? gives the exit status for
the previous command.
$ fsck.ext4 /dev/sdb1
e2fsck 1.42.9 (4-Feb-2014)
/dev/sdb1: clean, 13/499968 files, 68558/1999872 blocks
$ echo $?
0
Check the FAT32 file-system on /dev/sdb2 partition. echo $? returns an exit status of 0.
$ fsck.vfat /dev/sdb2
fsck.fat 3.0.26 (2014-03-07)
/dev/sdb2: 1 files, 1/1658708 clusters
$ echo $?
0
72
Diarmuid Briain
If a file-system has not been cleanly unmounted, the system detects a dirty bit on the filesystem during the next bootup and starts a check. fsck will detect any errors on the file-system
and attempt to fix. You should not interrupt this repair process. If an empty forcefsck file is
created in the root of the root file-system. file-systems that have > 0 specified in the sixth
column of the /etc/fstab will be checked. 0 means do not check. In the case of the extract of
/etc/fstab below, /dev/sdb1 would be checked, however /dev/sdb2 would not.
$ sudo touch /forcefsck
(Extract from /dev/fstab)
# <file system> <mount point>
<type> <options>
/dev/sdb1
/mnt/ext4fs
ext4
defaults
/dev/sdb2
/mnt/fat32fs
vfat
defaults
Diarmuid Briain
<dump>
0
0
<pass>
1
0
73
74
Diarmuid Briain
4. Local security
4.1. Accessing the root account
Substitute User (su) is command is used to change a login session's owner. In this example
the login session of lmenabrea has the ownership of the session change to Ada Lovelace
alovelace.
$ whoami
lmenabrea
$ su alovelace
Password: maths
:/home> whoami
alovelace
:/home> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/
games
In this case Ada Lovelace will maintain the current directory and the environmental variables of
the original user rather than switching to her own account directory and environment variables.
To switch and change the current directory and environmental variables a - is required. To
demonstrate, note the different $PATH values.
$ whoami
lmenabrea
Change to Ada Lovelace account. Trying with and without the '-' or a '-l' switch. Using either of
these switch options provide an environment similar to what the user would expect had the
user logged in directly. This can be seen by noting the $PATH assigned after login.
$ su alovelace
Password: maths
:~> whoami
alovelace
:~> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/
local/games
:~> echo $HOME
/home/alovelace
$ su - alovelace
Password: maths
:~% whoami
alovelace
:~% echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
:~% echo $HOME
/home/alovelace
Diarmuid Briain
75
To change to the root user with Super User privileges. Again note the difference when a '-' or 'l' is used.
$ su
Password: root-pass
~ # whoami
root
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/
local/games
# echo $HOME
/root
$ su Password: root-pass
~ # whoami
root
~ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
~ # echo $HOME
/root
$ ./hello.sh
-bash: ./hello.sh: Permission denied
76
Diarmuid Briain
Now run with sudo, you can see that the process is actually ran by the user root.
$ sudo ./hello.sh
Hello World
Press [CTRL+C] to stop..
Press [CTRL+C] to stop..
Press [CTRL+C] to stop..
root
6248
6247
0 01:00 pts/7
Now try running it as alovelace or the group babbage using sudo. In the latter case the script
is ran by lmenabrea and is allowed because the sudo was supplied the group babbage and
lmenabrea is in the sudo group.
$ sudo -u alovelace ./hello.sh
Hello World
Press [CTRL+C] to stop..
Press [CTRL+C] to stop..
Press [CTRL+C] to stop..
alovela+
6130
6129
$ sudo -g babbage
Hello World
Press [CTRL+C] to
Press [CTRL+C] to
Press [CTRL+C] to
lmenabrea
6402
0 00:58 pts/7
./hello.sh
stop..
stop..
stop..
6401
0 01:02 pts/7
ALL=(ALL:ALL) ALL
%admin
ALL=(ALL) ALL
%sudo
ALL=(ALL:ALL) ALL
Diarmuid Briain
77
The easiest way to give a user sudo rights is to add them to the sudo group. In this example
Ada Lovelace is added to the sudo group and given sudo privileges. (It is possible to directly
edit the /etc/group file either).
$ cat /etc/group | grep ^sudo
sudo:x:27:lmenabrea
$ sudo usermod -a -G sudo alovelace
$ cat /etc/group | grep ^sudo
sudo:x:27:lmenabrea,alovelace
78
Diarmuid Briain
5. Shell scripting
5.1. Basic bash shell scripting
5.1.1. Hello world
#!/bin/bash
echo "Hello World"
Description
Used to add a comment, except when used as \#, or as #! when starting a script
5.1.4. Functions
display () {
echo "This is a sample function"
}
Diarmuid Briain
79
modules.dep.bin
modules.dep.bin
or
VAR=value ; export VAR
Meaning
$0
Script name
$1
First parameter
$*
All parameters
$#
Number of arguments
5.1.9. Redirection
$ wc -l syslog.pdf
1721 syslog.pdf
$ wc -l < syslog.pdf
1721
80
Diarmuid Briain
5.1.10. if statement
if TEST-COMMANDS; then CONSEQUENT-COMMANDS; fi
i.e.
$ cat if.sh
#!/bin/bash
echo -n "ENTER A NUMBER: "
read number
if [ $number -eq 10 ]
then
echo 'It is 10'
else
echo 'It is not 10'
fi
$ ./if.sh
ENTER A NUMBER: 10
It is 10
$ ./if.sh
ENTER A NUMBER: 11
It is not 10
Diarmuid Briain
81
i.e.
$ cat elif.sh
#!/bin/bash
echo -n "ENTER A NUMBER: "
read number
if [ $number -eq 10 ]
then
echo 'It is 10'
elif [ $number -eq 11 ]
then
echo 'It is 11'
else
echo 'It is not 10 or 11'
fi
$ ./elif.sh
ENTER A NUMBER: 10
It is 10
$ ./elif.sh
ENTER A NUMBER: 11
It is 11
$ ./elif.sh
ENTER A NUMBER: 12
It is not 10 or 11
Condition
82
Meaning
-e file
-d file
-f file
-s file
-g file
-u file
-r file
-w file
-x file
Diarmuid Briain
Meaning
-eq
Equal to.
-ne
-gt
Greater than.
-lt
Less than.
-ge
-le
Meaning
==
Is equal to.
!=
-z
String is null.
-n
Using the $((...)) syntax: This is the built-in shell format. The syntax is as follows:
echo $((x+1))
5.1.14. Strings
5.1.14.1. Length of a String
myLen1=${#mystring1}
Diarmuid Briain
83
Here 0 is the offset in the string (i.e., which character to begin from) where the extraction needs
to start and 1 is the number of characters to be extracted.
${string#*.}
Operation
Meaning
&&
AND
The action will be performed only if both the conditions evaluate to true.
||
OR
NOT
commands;;
commands;;
commands;;
commands;;
some default commands or nothing ;;
Example:
#!/bin/bash
echo "ENTER a number between 1 & 5"
read numb
case $numb in
1 ) echo "you selected 1";;
2 ) echo "you selected 2";;
3 ) echo "you selected 3";;
4 ) echo "you selected 4";;
5 ) echo "you selected 5";;
* ) echo "you cheated !! ";;
esac
84
Diarmuid Briain
5.1.17.2. while
#!/bin/bash
num=0
end=15
while [ $num -lt $end ]
do
echo "$num is less than $end"
((num++))
done
echo "$num = $end"
5.1.17.3. until
#!/bin/bash
num=0
end=15
until [ $num -eq $end ]
do
echo "$num is less than $end"
((num++))
done
echo "$num = $end"
Diarmuid Briain
85
set -x
cmd
set +x
Description
File Descriptor
stdout
stderr
stdin
Usage
TEMP=$(mktemp /tmp/tempfile.XXXXXXXX)
TEMPDIR=$(mktemp -d /tmp/tempdir.XXXXXXXX)
$ mktemp passwdXXXX
passwdU9t3
$ mktemp -d passwdXXXX
passwdSjnH
$ ls -l |grep pass
drwx------ 2 lmenabrea lmenabrea
-rw------- 1 lmenabrea lmenabrea
4096 Oct
0 Oct
1 17:49 passwdSjnH
1 17:49 passwdU9t3
86
Diarmuid Briain
random, urandom
1 19:01
$ cat ~/Desktop/random.data.1M
RI;HlX0
VRs.Kes42"MEFebE+)&}D*
IG4FQw
#EfN6ySO\`;;
<}X"IFJo_mVu(vCGH 9XK=rdD`&>t4\.\:7k?
x.RO}+zX8c4NPx55 jE|}M4OrvFk-0
_9v`4=KAi{1S{E
WV=Z_ga'$U B/nGKu-"|4@#
Diarmuid Briain
87
88
Diarmuid Briain
6. Software management
6.1. Installing software packages
Software is installed on Debian based distributions using the APT utility. apt-cache is the tool
used to search for packages in the repositories while apt-get is the APT tool for handling
packages
aptget[options][command][package]
Meaning
update
upgrade
used to install the newest versions of all packages currently installed on the
system from the sources enumerated in /etc/apt/sources.list.
dist-upgrade
install
remove
check
Diagnostic tool; it updates the package cache and checks for broken
packages.
clean
6.1.2. Example
Find a package that acts as a sticky note for the desktop and install.
aptcachesearch<package>
$ apt-cache search sticky
knotes - sticky notes application
labrea - a "sticky" honeypot and IDS
rhinote - virtual sticky-notes for your desktop
xpad - sticky note application for X
$ sudo apt-get install xpad
Diarmuid Briain
89
90
Diarmuid Briain
Meaning
$ tmux list-sessions
Meaning
<Ctrl-b>%
<Ctrl-b>"
<Ctrl-b>x
<Ctrl-b>;
<Ctrl-b><Ctrl-o>
<Ctrl-b>x
<Ctrl-b>[
<Ctrl-b>{
<Ctrl-b>}
Diarmuid Briain
91
7.2. Calculator
bc is a command-line calculator.
$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
34*4
136
23+45
68
10/5
2
66-6
60
quit
92
Diarmuid Briain
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other functional and useful
document "free" in the sense of freedom: to assure everyone the effective freedom to copy and
redistribute it, with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way to get credit for their
work, while not being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative works of the document must
themselves be free in the same sense. It complements the GNU General Public License, which
is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free
software needs free documentation: a free program should come with manuals providing the
same freedoms that the software does. But this License is not limited to software manuals; it
can be used for any textual work, regardless of subject matter or whether it is published as a
printed book. We recommend this License principally for works whose purpose is instruction or
reference.
Diarmuid Briain
93
those of Invariant Sections, in the notice that says that the Document is released under this
License. If a section does not fit the above definition of Secondary then it is not allowed to be
designated as Invariant. The Document may contain zero Invariant Sections. If the Document
does not identify any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or
Back-Cover Texts, in the notice that says that the Document is released under this License. A
Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy, represented in a
format whose specification is available to the general public, that is suitable for revising the
document straightforwardly with generic text editors or (for images composed of pixels) generic
paint programs or (for drawings) some widely available drawing editor, and that is suitable for
input to text formatters or for automatic translation to a variety of formats suitable for input to
text formatters. A copy made in an otherwise Transparent file format whose markup, or
absence of markup, has been arranged to thwart or discourage subsequent modification by
readers is not Transparent. An image format is not Transparent if used for any substantial
amount of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain ASCII without markup,
Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and
standard-conforming simple HTML, PostScript or PDF designed for human modification.
Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include
proprietary formats that can be read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are not generally available, and the machinegenerated HTML, PostScript or PDF produced by some word processors for output purposes
only.
The "Title Page" means, for a printed book, the title page itself, plus such following pages as
are needed to hold, legibly, the material this License requires to appear in the title page. For
works in formats which do not have any title page as such, "Title Page" means the text near the
most prominent appearance of the work's title, preceding the beginning of the body of the text.
The "publisher" means any person or entity that distributes copies of the Document to the
public.
A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely
XYZ or contains XYZ in parentheses following text that translates XYZ in another language.
(Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when
you modify the Document means that it remains a section "Entitled XYZ" according to this
definition.
The Document may include Warranty Disclaimers next to the notice which states that this
License applies to the Document. These Warranty Disclaimers are considered to be included
by reference in this License, but only as regards disclaiming warranties: any other implication
that these Warranty Disclaimers may have is void and has no effect on the meaning of this
License.
94
Diarmuid Briain
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or
noncommercially, provided that this License, the copyright notices, and the license notice
saying this License applies to the Document are reproduced in all copies, and that you add no
other conditions whatsoever to those of this License. You may not use technical measures to
obstruct or control the reading or further copying of the copies you make or distribute.
However, you may accept compensation in exchange for copies. If you distribute a large
enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly
display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of the
Document, numbering more than 100, and the Document's license notice requires Cover Texts,
you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts:
Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers
must also clearly and legibly identify you as the publisher of these copies. The front cover must
present the full title with all words of the title equally prominent and visible. You may add other
material on the covers in addition. Copying with changes limited to the covers, as long as they
preserve the title of the Document and satisfy these conditions, can be treated as verbatim
copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first
ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you
must either include a machine-readable Transparent copy along with each Opaque copy, or
state in or with each Opaque copy a computer-network location from which the general
network-using public has access to download using public-standard network protocols a
complete Transparent copy of the Document, free of added material. If you use the latter
option, you must take reasonably prudent steps, when you begin distribution of Opaque copies
in quantity, to ensure that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an Opaque copy (directly or
through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before
redistributing any large number of copies, to give them a chance to provide you with an
updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions of
sections 2 and 3 above, provided that you release the Modified Version under precisely this
License, with the Modified Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy of it. In addition, you
must do these things in the Modified Version:
Diarmuid Briain
95
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any, be
listed in the History section of the Document). You may use the same title as a previous
version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifications in the Modified Version, together with at least five of the
principal authors of the Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the
publisher.
E. Add an appropriate copyright notice for your modifications adjacent to the other
copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modified Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document's license notice.
I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating
at least the title, year, new authors, and publisher of the Modified Version as given on
the Title Page. If there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as given on its Title Page,
then add an item describing the Modified Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to a
Transparent copy of the Document, and likewise the network locations given in the
Document for previous versions it was based on. These may be placed in the "History"
section. You may omit a network location for a work that was published at least four
years before the Document itself, or if the original publisher of the version it refers to
gives permission.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and in
their titles. Section numbers or the equivalent are not considered part of the section
titles.
M. Delete any section Entitled "Endorsements". Such a section may not be included in
the Modified Version.
If the Modified Version includes new front-matter sections or appendices that qualify as
96
Diarmuid Briain
Secondary Sections and contain no material copied from the Document, you may at your option
designate some or all of these sections as invariant. To do this, add their titles to the list of
Invariant Sections in the Modified Version's license notice. These titles must be distinct from
any other section titles.
You may add a section Entitled "Endorsements", provided it contains nothing but
endorsements of your Modified Version by various partiesfor example, statements of peer
review or that the text has been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25
words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only
one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through
arrangements made by) any one entity. If the Document already includes a cover text for the
same cover, previously added by you or by arrangement made by the same entity you are
acting on behalf of, you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use
their names for publicity for or to assert or imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under the
terms defined in section 4 above for modified versions, provided that you include in the
combination all of the Invariant Sections of all of the original documents, unmodified, and list
them all as Invariant Sections of your combined work in its license notice, and that you
preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant
Sections may be replaced with a single copy. If there are multiple Invariant Sections with the
same name but different contents, make the title of each such section unique by adding at the
end of it, in parentheses, the name of the original author or publisher of that section if known, or
else a unique number. Make the same adjustment to the section titles in the list of Invariant
Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History" in the various original
documents, forming one section Entitled "History"; likewise combine any sections Entitled
"Acknowledgements", and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released under
this License, and replace the individual copies of this License in the various documents with a
single copy that is included in the collection, provided that you follow the rules of this License
for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under
this License, provided you insert a copy of this License into the extracted document, and follow
Diarmuid Briain
97
this License in all other respects regarding verbatim copying of that document.
8. TRANSLATION
Translation is considered a kind of modification, so you may distribute translations of the
Document under the terms of section 4. Replacing Invariant Sections with translations requires
special permission from their copyright holders, but you may include translations of some or all
Invariant Sections in addition to the original versions of these Invariant Sections. You may
include a translation of this License, and all the license notices in the Document, and any
Warranty Disclaimers, provided that you also include the original English version of this License
and the original versions of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice or disclaimer, the original
version will prevail.
If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the
requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly
provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it
is void, and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license from a particular copyright
holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder fails to notify you of the
violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the
copyright holder notifies you of the violation by some reasonable means, this is the first time
you have received notice of violation of this License (for any work) from that copyright holder,
and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who
98
Diarmuid Briain
have received copies or rights from you under this License. If your rights have been terminated
and not permanently reinstated, receipt of a copy of some or all of the same material does not
give you any rights to use it.
11. RELICENSING
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide Web server
that publishes copyrightable works and also provides prominent facilities for anybody to edit
those works. A public wiki that anybody can edit is an example of such a server. A "Massive
Multiauthor Collaboration" (or "MMC") contained in the site means any set of copyrightable
works thus published on the MMC site.
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 license published by
Creative Commons Corporation, a not-for-profit corporation with a principal place of business
in San Francisco, California, as well as future copyleft versions of that license published by that
same organization.
"Incorporate" means to publish or republish a Document, in whole or in part, as part of another
Document.
An MMC is "eligible for relicensing" if it is licensed under this License, and if all works that were
first published under this License somewhere other than this MMC, and subsequently
incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and
(2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on
the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.
Diarmuid Briain
99
100
Diarmuid Briain