Вы находитесь на странице: 1из 905

Linux Fun

Paul Cobbaut

Linux Fun

Paul Cobbaut

lt-2.0

Publication date Wed 17 Sep 2014 01:02:07 AM CEST

Abstract

This book is meant to be used in an instructor-led training. For self-study, the intent is to read this book next to a working Linux computer so you can immediately do every subject, practicing each command.

This book is aimed at novice Linux system administrators (and might be interesting and useful for home users that want to know a bit more about their Linux system). However, this book is not meant as an introduction to Linux desktop applications like text editors, browsers, mail clients, multimedia or office applications.

More information and free .pdf available at http://linux-training.be .

Feel free to contact the author:

• Paul Cobbaut: paul.cobbaut@gmail.com, http://www.linkedin.com/in/cobbaut

Contributors to the Linux Training project are:

• Serge van Ginderachter: serge@ginsys.be, build scripts; infrastructure setup; minor stuff

• Hendrik De Vloed: hendrik.devloed@ugent.be, buildheader.pl script

We'd also like to thank our reviewers:

• Wouter Verhelst: wouter@grep.be, http://grep.be

• Geert

Goossens:

geertgoossens

mail.goossens.geert@gmail.com,

http://www.linkedin.com/in/

• Elie De Brauwer: elie@de-brauwer.be, http://www.de-brauwer.be

• Christophe Vandeplas: christophe@vandeplas.com, http://christophe.vandeplas.com

• Bert Desmet: bert@devnox.be, http://bdesmet.be

• Rich Yonts: richyonts@gmail.com,

Copyright 2007-2014 Paul Cobbaut

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free

Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled 'GNU Free Documentation License'.

Table of Contents

I. introduction to Linux

1

1. Linux history

3

1.1.

Linux history

4

2. distributions

5

2.1. Red Hat

6

 

2.2. Ubuntu

6

2.3. Debian

6

2.4. Other

6

2.5. Which to choose ?

6

3. licensing

7

3.1. about software licenses

8

3.2. public domain software and freeware

8

3.3. Free Software or Open Source Software

8

3.4. GNU General Public License

9

3.5. using GPLv3 software

9

3.6. BSD license

10

3.7. other licenses

10

3.8. combination of software licenses

10

4. getting Linux at home

11

4.1. download a Linux CD image

12

4.2. download Virtualbox

12

4.3. create a virtual machine

13

4.4. attach the CD image

18

4.5. install Linux

21

II. first steps on the command line

22

5. man pages

24

5.1. man $command

25

5.2. man $configfile

25

5.3. man $daemon

25

5.4. man -k (apropos)

25

 

5.5. whatis

25

5.6. whereis

25

5.7. man sections

26

5.8. man $section $file

26

5.9.

man man

26

5.10. mandb

26

6. working with directories

28

 

6.1. pwd

29

6.2. cd

29

6.3. absolute and relative paths

30

6.4. path completion

31

6.5. ls

31

 

6.6. mkdir

33

6.7. rmdir

33

6.8. practice: working with directories

35

6.9. solution: working with directories

36

7. working with files

38

7.1. all files are case sensitive

39

7.2. everything is a file

39

 

7.3. file

39

7.4. touch

39

7.5. rm

40

7.6. cp

41

 

7.7. mv

42

7.8. rename

42

Linux Fun

7.9.

practice: working with files

44

7.10.

solution: working with files

45

8. working with file contents

47

8.1. head

48

8.2. tail

48

8.3. cat

48

8.4. tac

50

8.5. more and less

51

8.6. strings

51

8.7. practice: file contents

52

8.8. solution: file contents

53

9. the Linux file tree

54

9.1. filesystem hierarchy standard

55

9.2. man hier

55

9.3. the root directory /

55

9.4. binary directories

56

9.5. configuration directories

58

9.6. data directories

60

9.7. in memory directories

62

9.8. /usr Unix System Resources

67

9.9. /var variable data

69

9.10. practice: file system tree

71

9.11. solution: file system tree

73

III. shell expansion

75

10. commands and arguments

78

10.1. arguments

79

10.2. white space removal

79

10.3. single quotes

80

10.4. double quotes

80

10.5. echo and quotes

80

10.6. commands

81

10.7. aliases

82

10.8. displaying shell expansion

83

10.9. practice: commands and arguments

84

10.10.

solution: commands and arguments

86

11. control operators

88

11.1. ; semicolon

89

11.2. & ampersand

89

11.3. $? dollar question mark

89

11.4. && double ampersand

90

11.5. || double vertical bar

90

11.6. combining && and ||

90

11.7. # pound sign

91

11.8. \ escaping special characters

91

11.9. practice: control operators

92

11.10.

solution: control operators

93

12. shell variables

94

12.1. $ dollar sign

95

12.2. case sensitive

95

12.3. creating variables

95

12.4. quotes

96

12.5. set

96

12.6. unset

96

12.7. $PS1

97

12.8. $PATH

98

12.9. env

99

12.10. export

99

12.11. delineate variables

100

Linux Fun

12.12. unbound variables

100

12.13. practice: shell variables

101

12.14. solution: shell variables

102

13. shell embedding and options

103

13.1. shell embedding

104

13.2. shell options

105

13.3. practice: shell embedding

106

13.4. solution: shell embedding

107

14. shell history

108

14.1. repeating the last command

109

14.2. repeating other commands

109

 

14.3. history

109

14.4. !n

109

14.5. Ctrl-r

110

14.6. $HISTSIZE

110

14.7. $HISTFILE

110

14.8. $HISTFILESIZE

110

14.9. (optional)regular expressions

111

14.10. (optional)repeating commands in ksh

111

14.11. practice: shell history

112

14.12. solution: shell history

113

15. file globbing

114

15.1. * asterisk

115

15.2. ? question mark

115

15.3. [] square brackets

116

15.4. a-z and 0-9 ranges

117

15.5. $LANG and square brackets

117

15.6. preventing file globbing

118

15.7. practice: shell globbing

119

15.8. solution: shell globbing

120

IV. pipes and commands

122

16. I/O redirection

124

16.1. stdin, stdout, and stderr

125

16.2. output redirection

126

16.3. error redirection

128

16.4. output redirection and pipes

129

16.5. joining stdout and stderr

129

16.6. input redirection

130

16.7. confusing redirection

131

16.8. quick file clear

131

16.9. practice: input/output redirection

132

16.10.

solution: input/output redirection

133

17. filters

134

17.1. cat

135

17.2. tee

135

17.3. grep

135

17.4. cut

137

17.5. tr

137

17.6. wc

138

17.7. sort

139

17.8. uniq

140

 

17.9. comm

141

17.10. od

142

17.11. sed

143

17.12. pipe examples

144

17.13. practice: filters

145

17.14. solution: filters

146

18. basic Unix tools

148

Linux Fun

18.1. find

149

18.2. locate

150

18.3. date

150

18.4. cal

151

18.5. sleep

151

18.6. time

152

18.7. gzip - gunzip

153

18.8. zcat - zmore

153

18.9. bzip2 - bunzip2

154

18.10. bzcat - bzmore

154

18.11. practice: basic Unix tools

155

18.12. solution: basic Unix tools

156

19. regular expressions

158

19.1. regex versions

159

19.2. grep

160

19.3. rename

165

19.4. sed

168

19.5. bash history

172

V. vi

173

20. Introduction to vi

175

20.1. command mode and insert mode

176

20.2. start typing (a A i I o O)

176

20.3. replace and delete a character (r x X)

177

20.4. undo and repeat (u .)

177

20.5. cut, copy and paste a line (dd yy p P)

177

20.6. cut, copy and paste lines (3dd 2yy)

178

20.7. start and end of a line (0 or ^ and $)

178

20.8. join two lines (J) and more

178

20.9. words (w b)

179

20.10. save (or not) and exit (:w :q :q! )

179

20.11. Searching (/ ?)

179

20.12. replace all ( :1,$ s/foo/bar/g )

180

20.13. reading files (:r :r !cmd)

180

20.14. text buffers

180

20.15. multiple files

180

20.16. abbreviations

181

20.17. key mappings

182

20.18. setting options

182

20.19. practice: vi(m)

183

20.20. solution: vi(m)

184

VI. scripting

185

21. scripting introduction

187

21.1. prerequisites

188

21.2. hello world

188

 

21.3. she-bang

188

21.4. comment

189

21.5. variables

189

21.6. sourcing a script

189

21.7. troubleshooting a script

190

21.8. prevent setuid root spoofing

190

21.9. practice: introduction to scripting

191

21.10.

solution: introduction to scripting

192

22. scripting loops

193

22.1. test [ ]

194

22.2. if then else

195

22.3. if then elif

195

22.4. for loop

195

22.5. while loop

196

Linux Fun

22.6. until loop

196

22.7. practice: scripting tests and loops

197

22.8. solution: scripting tests and loops

198

23. scripting parameters

200

23.1. script parameters

201

23.2. shift through parameters

202

23.3. runtime input

202

23.4. sourcing a config file

203

23.5. get script options with getopts

204

23.6. get shell options with shopt

205

23.7. practice: parameters and options

206

23.8. solution: parameters and options

207

24. more scripting

208

24.1.

eval

209

24.2.

(( ))

209

24.3.

let

210

24.4.

case

211

24.5. shell functions

212

24.6. practice : more scripting

213

24.7. solution : more scripting

214

VII. local user management

216

25. users

218

25.1.

identify yourself

219

25.2.

users

220

25.3. passwords

222

25.4. home directories

227

25.5. user shell

228

25.6. switch users with su

229

25.7. run a program as another user

229

25.8. practice: users

231

25.9. solution: users

232

25.10.

shell environment

234

26. groups

237

26.1. about groups

238

26.2. groupadd

238

26.3. /etc/group

238

 

26.4. usermod

239

26.5. groupmod

239

26.6. groupdel

239

 

26.7. groups

239

26.8. gpasswd

240

26.9. vigr

240

26.10. practice: groups

241

26.11. solution: groups

242

VIII. file security

243

27. standard file permissions

245

27.1. file ownership

246

27.2. list of special files

248

27.3. permissions

249

27.4. practice: standard file permissions

254

27.5. solution: standard file permissions

255

28. advanced file permissions

257

28.1. sticky bit on directory

258

28.2. setgid bit on directory

258

28.3. setgid and setuid on regular files

259

28.4. practice: sticky, setuid and setgid bits

260

28.5. solution: sticky, setuid and setgid bits

261

29. access control lists

263

Linux Fun

 

29.1. acl in /etc/fstab

264

29.2. getfacl

264

29.3. setfacl

264

29.4. remove an acl entry

265

29.5. remove the complete acl

265

29.6. the acl mask

265

29.7. eiciel

266

30.

file links

267

30.1. inodes

268

30.2. about directories

269

30.3. hard links

270

30.4. symbolic links

271

30.5. removing links

271

30.6. practice : links

272

30.7. solution : links

273

IX. process management

274

31. introduction to processes

276

 

31.1. terminology

277

31.2. basic process management

278

31.3. signalling processes

282

31.4. practice : basic process management

285

31.5. solution : basic process management

286

32. process priorities

288

 

32.1. priority and nice values

289

32.2. practice : process priorities

292

32.3. solution : process priorities

293

33. background jobs

295

 

33.1. background processes

296

33.2. practice : background processes

298

33.3. solution : background processes

299

X. disk management

301

34. disk devices

304

 

34.1. terminology

305

34.2. device naming

307

34.3. discovering disk devices

308

34.4. erasing a hard disk

313

34.5. advanced hard disk settings

314

34.6. practice: hard disk devices

315

34.7. solution: hard disk devices

316

35. disk partitions

318

 

35.1. about partitions

319

35.2. discovering partitions

320

35.3. partitioning new disks

322

35.4. about the partition table

324

35.5. practice: partitions

325

35.6. solution: partitions

326

36. file systems

327

 

36.1. about file systems

328

36.2. common file systems

329

36.3. putting a file system on a partition

332

36.4. tuning a file system

333

36.5. checking a file system

334

36.6. practice: file systems

335

36.7. solution: file systems

336

37. mounting

337

 

37.1. mounting local file systems

338

37.2. displaying mounted file systems

339

37.3. from start to finish

341

Linux Fun

37.4. permanent mounts

342

37.5. securing mounts

343

37.6. mounting remote file systems

344

37.7. practice: mounting file systems

345

37.8. solution: mounting file systems

346

38. troubleshooting tools

348

38.1. lsof

349

38.2. fuser

350

38.3. chroot

351

38.4. iostat

352

38.5. iotop

353

38.6. vmstat

354

38.7. practice: troubleshooting tools

355

38.8. solution: troubleshooting tools

356

39. introduction to uuid's

357

39.1. about unique objects

358

39.2. tune2fs

358

39.3. uuid

358

39.4. uuid in /etc/fstab

359

39.5. uuid as a boot device

360

39.6. practice: uuid and filesystems

361

39.7. solution: uuid and filesystems

362

40. introduction to raid

363

40.1. hardware or software

363

40.2. raid levels

364

40.3. building a software raid5 array

366

40.4. practice: raid

369

40.5. solution: raid

370

41. logical volume management

371

41.1. introduction to lvm

372

41.2. lvm terminology

373

41.3. example: using lvm

374

41.4. example: extend a logical volume

376

41.5. example: resize a physical Volume

378

41.6. example: mirror a logical volume

380

41.7. example: snapshot a logical volume

381

41.8. verifying existing physical volumes

382

41.9. verifying existing volume groups

384

41.10. verifying existing logical volumes

385

41.11. manage physical volumes

386

41.12. manage volume groups

388

41.13. manage logical volumes

390

41.14. practice : lvm

392

41.15. solution : lvm

393

42. iSCSI devices

397

42.1. iSCSI terminology

398

42.2. iSCSI Target in RHEL/CentOS

398

42.3. iSCSI Initiator in RHEL/CentOS

400

42.4. iSCSI target on Debian

402

42.5. iSCSI target setup with dd files

403

42.6. ISCSI initiator on ubuntu

405

42.7. using iSCSI devices

407

42.8. practice: iSCSI devices

408

42.9. solution: iSCSI devices

409

43. introduction to multipathing

410

43.1. install multipath

411

43.2. configure multipath

411

43.3. network

412

Linux Fun

43.4. start multipathd and iscsi

412

43.5. multipath list

414

43.6. using the device

415

43.7. practice: multipathing

416

43.8. solution: multipathing

417

XI. boot management

419

44. bootloader

421

44.1. boot terminology

422

44.2. grub

425

 

44.3. grub2

430

44.4. lilo

431

44.5. practice: bootloader

432

44.6. solution: bootloader

433

45. init and runlevels

434

45.1. system init(ialization)

435

45.2. daemon or demon ?

440

45.3. starting and stopping daemons

440

45.4. chkconfig

441

45.5. update-rc.d

443

45.6. bum

444

45.7. runlevels

445

 

45.8. systemd

447

45.9. practice: init

452

45.10.

solution : init

453

XII. system management

455

46. scheduling

457

46.1.

one time jobs with at

458

46.2.

cron

460

46.3.

practice : scheduling

462

46.4.

solution : scheduling

463

47. logging

464

47.1.

login logging

465

47.2.

syslogd

468

47.3.

logger

471

47.4.

watching logs

471

47.5.

rotating logs

472

47.6.

practice : logging

473

47.7.

solution : logging

474

48. memory management

476

48.1. displaying memory and cache

477

48.2. managing swap space

478

48.3. monitoring memory with vmstat

480

48.4. practice : memory

481

48.5. solution : memory

482

49. resource monitoring

483

49.1. four basic resources

484

49.2. top

484

49.3. free

484

 

49.4. watch

485

49.5. vmstat

485

49.6. iostat

486

 

49.7. mpstat

487

49.8. sadc and sar

487

49.9. ntop

488

 

49.10. iftop

488

49.11. iptraf

488

49.12. nmon

489

49.13. htop

489

Linux Fun

50.

package management

490

50.1. package terminology

491

50.2. deb package management

493

50.3. apt-get

495

50.4. aptitude

498

50.5. apt

499

50.6. rpm

500

50.7. yum

502

50.8. alien

509

50.9. downloading software outside the repository

510

50.10. compiling software

510

50.11. practice: package management

511

50.12. solution: package management

512

XIII. network management

513

51. general networking

516

 

51.1. network layers

517

51.2. unicast, multicast, broadcast, anycast

520

51.3. lan-wan-man

522

51.4. internet - intranet - extranet

524

51.5. tcp/ip

525

52. interface configuration

526

 

52.1. to gui or not to gui

527

52.2. Debian/Ubuntu nic configuration

528

52.3. Red Hat/Fedora nic configuration

530

52.4. ifconfig

532

52.5. hostname

534

52.6. arp

535

52.7. route

536

52.8. ping

536

52.9. optional: ethtool

537

52.10. practice: interface configuration

538

52.11. solution: interface configuration

539

53. network sniffing

541

 

53.1. wireshark

542

53.2. tcpdump

544

53.3. practice: network sniffing

545

53.4. solution: network sniffing

546

54. binding and bonding

547

 

54.1. binding on Redhat/Fedora

548

54.2. binding on Debian/Ubuntu

549

54.3. bonding on Redhat/Fedora

550

54.4. bonding on Debian/Ubuntu

552

54.5. practice: binding and bonding

554

54.6. solution: binding and bonding

555

55. ssh client and server

556

 

55.1. about ssh

557

55.2. log on to a remote server

559

55.3. executing a command in remote

559

55.4. scp

560

55.5. setting up passwordless ssh

561

55.6. X forwarding via ssh

562

55.7. troubleshooting ssh

563

55.8. sshd

564

55.9. sshd keys

564

55.10. ssh-agent

564

55.11. practice: ssh

565

55.12. solution: ssh

566

56. introduction to nfs

568

Linux Fun

 

56.1. nfs protocol versions

569

 

56.2. rpcinfo

569

 

56.3. server configuration

570

56.4. /etc/exports

570

 

56.5. exportfs

570

 

56.6. client configuration

571

56.7. practice: introduction to nfs

572

 

57.

introduction to networking

573

 

57.1. introduction to iptables

574

57.2. practice : iptables

575

57.3. solution : iptables

576

57.4. xinetd and inetd

577

57.5. practice : inetd and xinetd

579

57.6. network file system

580

57.7. practice : network file system

582

XIV.

kernel management

 

583

58. the Linux kernel

585

 

58.1. about the Linux kernel

586

58.2. Linux kernel source

589

58.3. kernel boot files

593

58.4. Linux kernel modules

595

58.5. compiling a kernel

600

58.6. compiling one module

603

 

59. library management

605

 

59.1. introduction

606

59.2. /lib and /usr/lib

606

59.3. ldd

606

59.4. ltrace

607

59.5. dpkg -S and debsums

607

59.6. rpm -qf and rpm -V

608

59.7. tracing with strace

609

XV. backup management

 

610

 

60.

backup

612

 

60.1.

About tape devices

612

60.2.

Compression

613

60.3.

tar

613

60.4.

Backup Types

615

60.5.

dump and restore

616

60.6.

cpio

616

60.7.

dd

617

60.8.

split

618

60.9.

practice: backup

618

XVI.

apache and squid

620

61.

apache web server

622

 

61.1. introduction to apache

623

61.2. port virtual hosts on Debian

630

61.3. named virtual hosts on Debian

633

61.4. password protected website on Debian

635

61.5. port virtual hosts on CentOS

636

61.6. named virtual hosts on CentOS

640

61.7. password protected website on CentOS

642

61.8. troubleshooting apache

644

61.9. virtual hosts example

645

61.10. aliases and redirects

645

61.11. more on .htaccess

645

 

61.12. traffic

645

 

61.13. self signed cert on Debian

646

61.14. self signed cert on RHEL/CentOS

648

Linux Fun

 

61.15.

practice: apache

650

62.

introduction to squid

651

 

62.1. about proxy servers

651

62.2. installing squid

652

62.3. port 3128

652

62.4. starting and stopping

652

62.5. client proxy settings

653

62.6. upside down images

655

62.7. /var/log/squid

657

62.8. access control

657

62.9. testing squid

657

62.10.

name resolution

657

XVII. mysql database

659

63.

introduction to sql using mysql

661

 

63.1. installing mysql

662

63.2. accessing mysql

663

63.3. mysql databases

665

63.4. mysql tables

667

63.5. mysql records

669

63.6. joining two tables

672

63.7. mysql triggers

673

XVIII. dns server

 

675

64. introduction to DNS

677

 

64.1. about dns

678

64.2. dns namespace

680

64.3. caching only servers

685

64.4. authoritative dns servers

687

64.5. primary and secondary

687

64.6. zone transfers

687

64.7. master and slave

688

64.8. SOA record

688

64.9. full or incremental zone transfers

689

64.10. DNS cache

690

64.11. forward lookup zone example

691

64.12. Practice: caching only DNS server

692

64.13. Practice: caching only with forwarder

695

64.14. Practice: primary authoritative server

697

64.15. Practice: reverse DNS

699

64.16. Practice: a DNS slave server

700

65. advanced DNS

 

701

 

65.1. DNS round robin

702

65.2. DNS delegation

703

65.3. DNS load balancing

704

65.4. DNS notify

704

65.5. testing IXFR and AXFR

704

65.6. DDNS integration with DHCP

704

65.7. reverse is forward in-addr.arpa

704

65.8. ipv6

705

65.9. split-horizon dns

705

65.10.

DNS security : file corruption

705

65.11.

DNS security : zone transfers

705

65.12.

DNS security : zone transfers, ip spoofing

705

65.13.

DNS security : queries

705

65.14.

DNS security : chrooted bind

706

65.15.

DNS security : DNSSEC

706

65.16.

DNS security : root

706

XIX. dhcp server

707

66.

introduction to dhcp

709

Linux Fun

 

66.1. four broadcasts

710

66.2. picturing dhcp

711

66.3. installing a dhcp server

712

66.4. dhcp server on Red Hat

712

66.5. dhcp options

712

66.6. client reservations

712

66.7. example config files

713

66.8. older example config files

713

66.9. advanced dhcp

715

66.10.

Practice: dhcp

716

XX. iptables firewall

717

67. introduction to routers

719

 

67.1. router or firewall

720

67.2. packet forwarding

720

67.3. packet filtering

720

67.4. stateful

720

67.5. nat (network address translation)

721

67.6. pat (port address translation)

721

67.7. snat (source nat)

721

67.8. masquerading

721

67.9. dnat (destination nat)

721

67.10. port forwarding

721

67.11. /proc/sys/net/ipv4/ip_forward

722

67.12. /etc/sysctl.conf

722

67.13. sysctl

722

67.14. practice: packet forwarding

723

67.15. solution: packet forwarding

725

68. iptables firewall

 

728

 

68.1. iptables tables

729

68.2. starting and stopping iptables

729

68.3. the filter table

730

68.4. practice: packet filtering

735

68.5. solution: packet filtering

736

68.6. network address translation

737

XXI. selinux

 

740

69.

introduction to SELinux

742

 

69.1. selinux modes

743

69.2. logging

743

69.3. activating selinux

743

69.4. getenforce

744

69.5. setenforce

744

69.6. sestatus

745

69.7. policy

745

69.8. /etc/selinux/config

745

69.9. DAC or MAC

746

69.10. ls -Z

746

69.11. -Z

746

 

69.12. /selinux

747

69.13. identity

747

 

69.14. role

747

69.15. type (or domain)

748

69.16. security context

749

69.17. transition

749

69.18. extended attributes

750

69.19. process security context

750

69.20. chcon

750

69.21. an example

751

69.22. setroubleshoot

753

Linux Fun

69.23.

booleans

755

XXII. Introduction to Samba

756

70. introduction to samba

759

70.1. verify installed version

760

70.2. installing samba

761

70.3. documentation

762

70.4. starting and stopping samba

763

70.5. samba daemons

764

70.6. the SMB protocol

765

70.7. practice: introduction to samba

766

71. getting started with samba

767

71.1. /etc/samba/smb.conf

768

71.2. /usr/bin/testparm

769

71.3. /usr/bin/smbclient

770

71.4. /usr/bin/smbtree

772

71.5. server string

773

71.6. Samba Web Administration Tool (SWAT)

774

71.7. practice: getting started with samba

775

71.8. solution: getting started with samba

776

72. a read only file server

778

72.1. Setting up a directory to share

779

72.2. configure the share

779

72.3. restart the server

780

72.4. verify the share

780

72.5. a note on netcat

782

72.6. practice: read only file server

783

72.7. solution: read only file server

784

73. a writable file server

785

73.1. set up a directory to share

786

73.2. share section in smb.conf

786

73.3. configure the share

786

73.4. test connection with windows

786

73.5. test writing with windows

787

73.6. How is this possible ?

787

73.7. practice: writable file server

788

73.8. solution: writable file server

789

74. samba first user account

790

74.1. creating a samba user

791

74.2. ownership of files

791

74.3. /usr/bin/smbpasswd

791

74.4. /etc/samba/smbpasswd

791

74.5. passdb backend

792

74.6. forcing this user

792

74.7. practice: first samba user account

793

74.8. solution: first samba user account

794

75. samba authentication

795

75.1. creating the users on Linux

796

75.2. creating the users on samba

796

75.3. security = user

796

75.4. configuring the share

797

75.5. testing access with net use

797

75.6. testing access with smbclient

797

75.7. verify ownership

798

75.8. common problems

798

75.9. practice : samba authentication

800

75.10.

solution: samba authentication

801

76. samba securing shares

802

76.1.

security based on user name

803

Linux Fun

 

76.2. security based on ip-address

803

76.3. security through obscurity

804

76.4. file system security

804

76.5. practice: securing shares

806

76.6. solution: securing shares

807

77. samba domain member

809

77.1. changes in smb.conf

810

77.2. joining an Active Directory domain

811

77.3. winbind

812

 

77.4. wbinfo

812

77.5. getent

813

 

77.6. file ownership

814

77.7. practice : samba domain member

815

78. samba domain controller

816

78.1. about Domain Controllers

817

78.2. About security modes

817

78.3. About password backends

818

78.4. [global] section in smb.conf

818

78.5. netlogon share

819

78.6. other [share] sections

819

78.7. Users and Groups

820

 

78.8. tdbsam

820

 

78.9. about computer accounts

821

78.10. local or roaming profiles

821

78.11. Groups in NTFS acls

822

78.12. logon scripts

823

78.13. practice: samba domain controller

824

79. a brief look at samba 4

825

79.1.

Samba 4 alpha 6

827

XXIII.

introducing git

829

80.

git

831

80.1. git

832

80.2. installing git

833

80.3. starting a project

833

80.4. git branches

836

80.5. to be continued

837

80.6. github.com

838

80.7. add your public key to github

838

80.8. practice: git

839

XXIV.

ipv6

840

81.

Introduction to ipv6

842

81.1. about ipv6

843

81.2. network id and host id

843

81.3. host part generation

843

81.4. ipv4 mapped ipv6 address

844

81.5. link local addresses

844

81.6. unique local addresses

844

81.7. globally unique unicast addresses

844

 

81.8. 6to4

844

 

81.9. ISP

845

81.10. non routable addresses

845

 

81.11. ping6

845

 

81.12. Belgium and ipv6

846

81.13. other websites

846

81.14. 6to4 gateways

848

81.15. ping6 and dns

848

81.16. ipv6 and tcp/http

848

81.17. ipv6 PTR record

848

Linux Fun

81.18. 6to4 setup on Linux

848

XXV. Appendices

851

A. certifications

853

A.1. Certification

853

B. keyboard settings

855

B.1. about keyboard layout

855

B.2. X Keyboard Layout

855

B.3. shell keyboard layout

855

C. hardware

857

C.1. buses

857

C.2. interrupts

858

C.3. io ports

859

C.4. dma

859

D. installing linux

861

D.1. about

861

D.2. installation by cdrom

861

D.3. installation with rarp and tftp

861

D.4. about Red Hat kickstart

862

D.5. using kickstart

862

E. disk quotas

864

E.1. About Disk Quotas

864

E.2. Practice Disk quotas

864

F. introduction to vnc

865

F.1. About VNC

865

F.2. VNC Server

865

F.3. VNC Client

865

F.4. Practice VNC

866

G. cloning

867

G.1. About cloning

867

G.2. About offline cloning

867

G.3. Offline cloning example

867

H. License

869

Index

876

List of Tables

20.1. getting to command mode

176

20.2. switch to insert mode

176

20.3. replace and delete

177

20.4. undo and repeat

177

20.5. cut, copy and paste a line

177

20.6. cut, copy and paste lines

178

20.7. start and end of line

178

20.8. join two lines

178

 

20.9. words

179

20.10. save and exit vi

179

20.11. searching

179

 

20.12. replace

180

20.13. read files and input

180

20.14. text buffers

180

20.15. multiple files

181

20.16. abbreviations

181

25.1.

Debian User Environment

236

25.2.

Red Hat User Environment

236

27.1.

Unix special files

248

27.2.

standard Unix file permissions

249

27.3.

Unix file permissions position

249

27.4.

Octal permissions

252

34.1.

ide device naming

307

34.2.

scsi device naming

307

35.1.

primary, extended and logical partitions

319

35.2.

Partition naming

319

64.1.

the first top level domains

682

64.2.

new general purpose tld's

682

67.1.

Packet Forwarding Exercise

723

67.2.

Packet Forwarding Solution

725

Part I. introduction to Linux

Table of Contents

1. Linux history

3

1.1.

Linux history

4

2. distributions

5

 

2.1. Red Hat

6

2.2. Ubuntu

6

2.3. Debian

6

2.4. Other

6

2.5. Which to choose ?

6

3. licensing

7

3.1. about software licenses

8

3.2. public domain software and freeware

8

3.3. Free Software or Open Source Software

8

3.4. GNU General Public License

9

3.5. using GPLv3 software

9

3.6. BSD license

10

3.7. other licenses

10

3.8. combination of software licenses

10

4. getting Linux at home

11

4.1. download a Linux CD image

12

4.2. download Virtualbox

12

4.3. create a virtual machine

13

4.4. attach the CD image

18

4.5. install Linux

21

Chapter 1. Linux history

This chapter briefly tells the history of Unix and where Linux fits in.

If you are eager to start working with Linux without this blah, blah, blah over history, distributions, and licensing then jump straight to Part II - Chapter 6. Working with Directories page 26.

Linux history

1.1. Linux history

All modern operating systems have their roots in 1969 when Dennis Ritchie and Ken Thompson developed the C language and the Unix operating system at AT&T Bell Labs. They shared their source code (yes, there was open source back in the Seventies) with the rest of the world, including the hippies in Berkeley California. By 1975, when AT&T started selling Unix commercially, about half of the source code was written by others. The hippies were not happy that a commercial company sold software that they had written; the resulting (legal) battle ended in there being two versions of Unix in the Seventies : the official AT&T Unix, and the free BSD Unix.

In the Eighties many companies started developing their own Unix: IBM created AIX, Sun SunOS (later Solaris), HP HP-UX and about a dozen other companies did the same. The result was a mess of Unix dialects and a dozen different ways to do the same thing. And here is the first real root of Linux, when Richard Stallman aimed to end this era of Unix separation and everybody re-inventing the wheel by starting the GNU project (GNU is Not Unix). His goal was to make an operating system that was freely available to everyone, and where everyone could work together (like in the Seventies). Many of the command line tools that you use today on Linux or Solaris are GNU tools.

The Nineties started with Linus Torvalds, a Swedish speaking Finnish student, buying a 386 computer and writing a brand new POSIX compliant kernel. He put the source code online, thinking it would never support anything but 386 hardware. Many people embraced the combination of this kernel with the GNU tools, and the rest, as they say, is history.

Today more than 90 percent of supercomputers (including the complete top 10), more than

half of all smartphones, many millions of desktop computers, around 70 percent of all web servers, a large chunk of tablet computers, and several appliances (dvd-players, washing

machines, dsl modems, routers, system in the world.

) run Linux. It is by far the most commonly used operating

Linux kernel version 3.2 was released in January 2012. Its source code grew by almost two hundred thousand lines (compared to version 3.1) thanks to contributions of over 4000 developers paid by about 200 commercial companies including Red Hat, Intel, Broadcom, Texas Instruments, IBM, Novell, Qualcomm, Samsung, Nokia, Oracle, Google and even Microsoft.

http://en.wikipedia.org/wiki/Dennis_Ritchie http://en.wikipedia.org/wiki/Richard_Stallman http://en.wikipedia.org/wiki/Linus_Torvalds http://kernel.org

http://lwn.net/Articles/472852/

http://www.linuxfoundation.org/ http://en.wikipedia.org/wiki/Linux http://www.levenez.com/unix/ (a huge Unix history poster)

Chapter 2. distributions

This chapter gives a short overview of current Linux distributions.

A Linux distribution is a collection of (usually open source) software on top of a Linux kernel. A distribution (or short, distro) can bundle server software, system management tools, documentation and many desktop applications in a central secure software repository. A distro aims to provide a common look and feel, secure and easy software management and often a specific operational purpose.

Let's take a look at some popular distributions.

distributions

2.1. Red Hat

Red Hat is a billion dollar commercial Linux company that puts a lot of effort in developing Linux. They have hundreds of Linux specialists and are known for their excellent support. They give their products (Red Hat Enterprise Linux and Fedora) away for free. While Red Hat Enterprise Linux (RHEL) is well tested before release and supported for up to seven years after release, Fedora is a distro with faster updates but without support.

2.2. Ubuntu

Canonical started sending out free compact discs with Ubuntu Linux in 2004 and quickly became popular for home users (many switching from Microsoft Windows). Canonical wants Ubuntu to be an easy to use graphical Linux desktop without need to ever see a command line. Of course they also want to make a profit by selling support for Ubuntu.

2.3. Debian

There is no company behind Debian. Instead there are thousands of well organised developers that elect a Debian Project Leader every two years. Debian is seen as one of the most stable Linux distributions. It is also the basis of every release of Ubuntu. Debian comes in three versions: stable, testing and unstable. Every Debian release is named after a character in the movie Toy Story.

2.4. Other

Distributions like CentOS, Oracle Enterprise Linux and Scientific Linux are based on Red Hat Enterprise Linux and share many of the same principles, directories and system administration techniques. Linux Mint, Edubuntu and many other *buntu named distributions are based on Ubuntu and thus share a lot with Debian. There are hundreds of other Linux distributions.

2.5. Which to choose ?

When you are new to Linux in 2012, go for the latest Ubuntu or Fedora. If you only want to practice the Linux command line then install one Ubuntu server and/or one CentOS server (without graphical interface).

redhat.com

ubuntu.com

debian.org

centos.org

distrowatch.com

Chapter 3. licensing