Linux Administration for Developers

Preview:

DESCRIPTION

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

Citation preview

Linux Administration for Developersby

Mahmoud Said

2

Outline

● Why

● Linux Basics

● Servers

● WTF

● More monitoring tools

3

Why

● Free

● Hosting Open Source web apps

● Developing Open Source apps

● Robustness

● Development by Community

4

Why

Admin DeveloperCommonKnowledge

5

Linux Basics

6

Filesystem

“Everything is a file” ● Regular files

● Directories

● Symbolic links

● Hard links

● Devices

● Sockets

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

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

9

Shells

● Interface to execute user commands

● Hide the details of the OS

● Text based Commands

● Can be scripted

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.

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

12

Common bash commands

pwdls cp cd man

catlessmorevimnano

findsortwcaliasecho

lnchmodchown

tailheadgrepcrontab

mkdir mv rmrmdir

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

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) “|”

15

Servers

16

ssh access

● Using password

● Public/private key pair

ssh user@35.231.23.120 -p5022 ( default 22)

17

Important paths

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

/var/log/ all important logs

/etc/ system configuration files

/etc/init.d/ startup scripts

18

Uploading/Downloading files

● scp scr_file user@server.com:/dst_path/

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

19

Server Anatomy

Web server

Application server

Database

Memcache

Indexer

20

WTF!!

21

WTF

● Something wrong

● Too few details

● Admin/dev related

22

Identifying the problem

● Browser/Firebug

● Isolating the request

● Logs

– Application logs

– Web server logs

– Other logs

● Rails console

23

System status

● System load/CPU (top)

● IO (iotop)

● Memory (free -m, top)

● Check processes (ps aux | grep ruby)

● ….

24

Monitoring Tools

25

Newrelic.com

● Multiple technologies

● Performance analysis

● Server monitoring

● Traces of errors & slow requests

26

Thank You

Recommended