26
Linux Administration for Developers by Mahmoud Said

Linux Administration for Developers

Embed Size (px)

DESCRIPTION

Linux administration background needed for Open Source developers. specifically those using RubyOnRails

Citation preview

Page 1: Linux Administration for Developers

Linux Administration for Developersby

Mahmoud Said

Page 2: Linux Administration for Developers

2

Outline

● Why

● Linux Basics

● Servers

● WTF

● More monitoring tools

Page 3: Linux Administration for Developers

3

Why

● Free

● Hosting Open Source web apps

● Developing Open Source apps

● Robustness

● Development by Community

Page 4: Linux Administration for Developers

4

Why

Admin DeveloperCommonKnowledge

Page 5: Linux Administration for Developers

5

Linux Basics

Page 6: Linux Administration for Developers

6

Filesystem

“Everything is a file” ● Regular files

● Directories

● Symbolic links

● Hard links

● Devices

● Sockets

Page 7: Linux Administration for Developers

7

Filesystem - Filenames

● Case sensitive

● Can contain any character except “/”

● Extensions are only used for user convenience

● Examples:README .bashrc index.htmlMy World conf.old database.yml.bak

Page 8: Linux Administration for Developers

8

Filesystem – File pathes

● Sequence with nested directories ending with or without a file

● Relative: config/database.yml

● Absolute: /etc/nginx/nginx.conf

● Special pathes: ~/ #home of current user/ # root.. # parent directory

Page 9: Linux Administration for Developers

9

Shells

● Interface to execute user commands

● Hide the details of the OS

● Text based Commands

● Can be scripted

Page 10: Linux Administration for Developers

10

Famous Shells

● sh The Bourne shell (obsolete)Traditional, basic shell found on Unix systems, by Steve Bourne.

● csh The C shell (obsolete)Once popular shell with a C-like syntax

● bash The Bourne Again shell (most popular)An improved implementation of sh with lots of added features.

Page 11: Linux Administration for Developers

11

Scripting

● Commands to the shell can be scripted

● The script can be passed to the interpreter, or it can be executed by specifying the interpreter at the beginning

#!/bin/bashecho “bash script...”

#!/usr/bin/rubyputs “ruby script...”

bash init.sh.old./init.sh.old

ruby setup.rb./setup.rb

Page 12: Linux Administration for Developers

12

Common bash commands

pwdls cp cd man

catlessmorevimnano

findsortwcaliasecho

lnchmodchown

tailheadgrepcrontab

mkdir mv rmrmdir

Page 13: Linux Administration for Developers

13

Bash Keyboard commands

● TAB # auto completion

● CTRL+R # search commands history

● CTRL+D # exit the current shell

● CTRL+P # previous command (also “up”)

● CTRL+N # next command (also “down”)

● CTRL+L # clear screen

Page 14: Linux Administration for Developers

14

Standard I/O & piping

● Redirect output to a file using “>”

● Append output to a file using “>>”

● Obrain input from a file using “<”

● Redirect output as input to another process (piping) “|”

Page 15: Linux Administration for Developers

15

Servers

Page 16: Linux Administration for Developers

16

ssh access

● Using password

● Public/private key pair

ssh [email protected] -p5022 ( default 22)

Page 17: Linux Administration for Developers

17

Important paths

/usr/local/project Root directory (capistrano convension)

/var/log/ all important logs

/etc/ system configuration files

/etc/init.d/ startup scripts

Page 18: Linux Administration for Developers

18

Uploading/Downloading files

● scp scr_file [email protected]:/dst_path/

● wget http://www.akhbarak.net/traces.log.gz

Page 19: Linux Administration for Developers

19

Server Anatomy

Web server

Application server

Database

Memcache

Indexer

Page 20: Linux Administration for Developers

20

WTF!!

Page 21: Linux Administration for Developers

21

WTF

● Something wrong

● Too few details

● Admin/dev related

Page 22: Linux Administration for Developers

22

Identifying the problem

● Browser/Firebug

● Isolating the request

● Logs

– Application logs

– Web server logs

– Other logs

● Rails console

Page 23: Linux Administration for Developers

23

System status

● System load/CPU (top)

● IO (iotop)

● Memory (free -m, top)

● Check processes (ps aux | grep ruby)

● ….

Page 24: Linux Administration for Developers

24

Monitoring Tools

Page 25: Linux Administration for Developers

25

Newrelic.com

● Multiple technologies

● Performance analysis

● Server monitoring

● Traces of errors & slow requests

Page 26: Linux Administration for Developers

26

Thank You