29
*nix for developers part 1 @mitemitreski http://www.mitemitreski.com/ 8.April.2014 tricode talks

Unix for developers

Embed Size (px)

DESCRIPTION

Unix for developers introduction

Citation preview

Page 1: Unix for developers

*nix for developerspart 1

@mitemitreskihttp://www.mitemitreski.com/

8.April.2014tricode talks

Page 2: Unix for developers

Agenda

Short historyOverview of var commands Demo of simple use cases

Page 3: Unix for developers

Short history

● Ken Thomson● Dennis Ritchie

● unix like systems 1969● official release 1979

"...the number of UNIX installations has grown to 10, with more expected..."

- Dennis Ritchie and Ken Thompson, June 1972

Page 4: Unix for developers
Page 5: Unix for developers

Linux

Page 6: Unix for developers

RMS and GNU/Linux

Page 7: Unix for developers

All the flavours

● Multiprocess● Multi-user● Timesharing● Different command between flavours

Page 8: Unix for developers

Start-up

init tab systemvcrondhttp://en.wikipedia.org/wiki/Init

Page 9: Unix for developers

Runlevel

>runlevel

Operating System Default runlevel

AIX 2

CentOS 3 (console/server) or 5 (graphical/desktop)[5]

Debian 2[6]

Gentoo Linux 3[7]

Mac OS X 3

Mandriva Linux 3 (console/server) or 5 (graphical/desktop)

Red Hat Enterprise Linux / Fedora 3 (console/server) or 5 (graphical/desktop)[8]

Solaris 3[9]

Ubuntu (Server and Desktop) 2[6]

Page 10: Unix for developers

Cron and crontab00 20 * * * /home/oracle/scripts/export_dump.shCron expressions ( * / , -)

# * * * * * command to execute# ┬ ┬ ┬ ┬ ┬# │ │ │ │ │# │ │ │ │ │# │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)# │ │ │ └────────── month (1 - 12)# │ │ └─────────────── day of month (1 - 31)# │ └──────────────────── hour (0 - 23)# └───────────────────────── min (0 - 59)

Page 11: Unix for developers

Entry Description Equivalent to

@yearly (or @annually) Run once a year at midnight in the morning of January 1 0 0 1 1 *

@monthly Run once a month at midnight in the morning of the first day of the

month

0 0 1 * *

@weekly Run once a week at midnight in the morning of Sunday 0 0 * * 0

@daily Run once a day at midnight 0 0 * * *

@hourly Run once an hour at the beginning of the hour 0 * * * *

@reboot Run at startup @reboot

Crontab

Page 12: Unix for developers

Terminals

ttytelnetdsshd

http://en.wikipedia.org/wiki/Computer_terminal

Page 13: Unix for developers

All the different shells

SHsh, csh, ksh, zsh, bashoh my zshBean shellpython java#!/bin/bash

Page 14: Unix for developers

Bash

bashbashrcbash_profile/etc bash related.bash_history

Page 15: Unix for developers

List

ls -alfls -r

Page 16: Unix for developers

pwd/who/whoami

mite tty7 :0 09:55 6:42m 5:55 4.16s i3mite pts/0 :0 16:34 7.00s 0.06s 0.00s wmite pts/2 :0 14:52 2:23 0.23s 0.11s ssh mkooijman@amsjoslpe11mite pts/3 :0 16:35 55.00s 0.32s 7:19 gnome-terminal

Page 17: Unix for developers

cat and tac + basic streams

>>>1>2> 2>12>&1|

0 Standard input STDIN_FILENO stdin

1 Standard output STDOUT_FILENO stdout

2 Standard error STDERR_FILENO stderr

Page 18: Unix for developers

ln and mv and rm

-f-r

Page 19: Unix for developers

Important folders/usr/bin/usr/bin//dev/null/opt/var/tmp/home/proc

http://www.cs.duke.edu/csl/docs/sysadmin_course/sysadm-72.html

Page 20: Unix for developers

Processes

> ps -e> ps -f> ps -ef> ps axvf(interactive)>top>htop

Page 21: Unix for developers

Kill and Killall

>kill PID>killall NAME>kill -9 PID>killall -9 NAME

Page 22: Unix for developers

Job control & Run the command in the background > long_cmd &CTRL-Z Stop the foreground process [Ctrl-z] Stoppedjobs List background processes > jobs%n Refers to the background number n > fg %1bg Restart a stopped background process > bg [2] big_job &fg Bring a background process to the foreground > fg %1kill Kill a process > kill %2CTRL-D logoutCTRL-S, CTRL-Q (scroll lock)

Page 23: Unix for developers

>find

http://en.wikipedia.org/wiki/Find

find . -name 'my*'find . -iname 'my*'find . -name '*.mp3' -exec chmod 644 {} \;

Page 24: Unix for developers

>wget or GNU wget

>wget http://www.example.com/>wget --no-check-certificate https://www.example.com/

Page 25: Unix for developers

>curl

>curl http://www.google.com>curl -L http://www.google.com>curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html

Page 26: Unix for developers

Xargs

find . -iname ‘*.php’ -print0 | xargs -0 svn add

Page 27: Unix for developers

Navigation and customization

Shift + page up/downCtrl + Rvar customizations

Page 28: Unix for developers
Page 29: Unix for developers

Credits

Wikimedia foundation for the images used