25.02.2014 Views

Linux Basic day 1.pdf

Linux Basic day 1.pdf

Linux Basic day 1.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Linux</strong> Administrator ( Fundamental)<br />

Mr.Kriangsak Namkot<br />

Trainer & Director<br />

Jodoi IT&Service Co.,Ltd.<br />

jodoi@jodoi.com<br />

jodoi1819@hotmail.com<br />

http://www.jodoi.com<br />

<strong>Linux</strong> Administrator ( Fundamental)<br />

Day 1<br />

9:00 am - 12.00 am<br />

-Open Source &<strong>Linux</strong><br />

-Installing <strong>Linux</strong> Server<br />

-Lab Test Installing <strong>Linux</strong> Server<br />

-Shutdown & Reboot <strong>Linux</strong> Server & inittab<br />

1:00 pm - 4.00 pm<br />

-<strong>Basic</strong> Shell commands<br />

(man,ls,cd,cp,mv,rm,file,cat,more,tail,grep,locate,etc)<br />

-Backing up your files (tar)<br />

-Lab Test shell command<br />

1


Open Source & <strong>Linux</strong><br />

•The Open Source Definition is used by<br />

the Open Source Initiative to determine<br />

whether or not a software license can be<br />

considered open source.<br />

•<strong>Linux</strong> is an operating system that evolved<br />

from a kernel created by Linus Torvalds<br />

when he was a student at the University<br />

of Helsinki. Finland , it is obvious to most<br />

people what <strong>Linux</strong> is.<br />

Properties of <strong>Linux</strong><br />

• <strong>Linux</strong> is free<br />

• <strong>Linux</strong> is portable to any hardware platform<br />

• <strong>Linux</strong> was made to keep on running<br />

• <strong>Linux</strong> is secure and versatile<br />

• <strong>Linux</strong> is scalable<br />

• Multitasking<br />

• Multiuser<br />

• Text Mode & Graphic Mode (Xwindows)<br />

• Console & Remote<br />

2


<strong>Linux</strong> Kernel<br />

•In computer science, the kernel is the<br />

central component of most computer<br />

operating systems (OS). Its<br />

responsibilities include managing the<br />

system's resources (the communication<br />

between hardware and software<br />

components).<br />

<strong>Linux</strong> Shell<br />

•Shell is a user program or it's environment<br />

provided for user interaction. Shell is an<br />

command language interpreter that<br />

executes commands read from the<br />

standard input device (keyboard) or from a<br />

file.<br />

Kernel Hardware<br />

3


http://distrowatch.com/<br />

http://www.redhat.com/<br />

4


http://www.centos.org/<br />

http://fedoraproject.org/<br />

5


http://www.debian.org/<br />

http://www.ubuntu.com/<br />

6


http://www.opensuse.org/en/<br />

http://www.opentle.org/<br />

7


http://www.nectec.or.th/pub/reviewsoftware/linuxsis/linuxsis.html<br />

Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

by<br />

VMware Workstation<br />

ACE Edition version 6.0.4<br />

8


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

9


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

10


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

11


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

12


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

13


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

14


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

15


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

16


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

17


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

18


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

19


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

20


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

21


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

22


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

23


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

24


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

25


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

26


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

27


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

28


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

29


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

30


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

31


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

32


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

33


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

34


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

35


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

36


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

37


Installing <strong>Linux</strong> Server<br />

Installing <strong>Linux</strong> Server<br />

38


Reboot and basic configuration<br />

• Shutdown<br />

shutdown -bring the system down<br />

# shutdown –h now<br />

• Restart<br />

# shutdown –r now<br />

# shutdown –r +5 ( restart in 5minutes)<br />

# reboot<br />

# vi /etc/inittab<br />

Reboot and basic configuration<br />

# vi /etc/inittab<br />

~<br />

# Default runlevel. The runlevels used by RHS are:<br />

# 0 - halt (Do NOT set initdefault to this)<br />

# 1 - Single user mode<br />

# 2 - Multiuser, without NFS (The same as 3, if you do not<br />

have networking)<br />

# 3 - Full multiuser mode<br />

# 4 - unused<br />

# 5 - X11<br />

# 6 - reboot (Do NOT set initdefault to this)<br />

#<br />

id:3:initdefault:<br />

~<br />

39


File in <strong>Linux</strong><br />

• In <strong>Linux</strong>, everything is a file<br />

Looking at the world from the eyes of the <strong>Linux</strong><br />

kernel, everything is a file. Devices like modems,<br />

monitors, CD-Roms, hard drives, even keyboards<br />

and printers are files. You (what you type on the<br />

keyboard, at least) are a file, the data that appears<br />

on your screen in response to what you've typed is<br />

a file, even any error messages that might result<br />

from what you've typed is a file. In fact, those last<br />

three files form something of a trinity that deserves<br />

special attention: standard input, standard output,<br />

and standard error.<br />

File in <strong>Linux</strong><br />

• / Root Partition<br />

The following directories, or symbolic links todirectories, are<br />

required in /.<br />

– /bin Essential command binaries<br />

– /boot Static files of the boot loader<br />

– /dev Device files<br />

– /mnt Mount point for mounting a filesystemtemporarily<br />

– /etc Host-specific system configuration<br />

– /home User home directories (optional)<br />

– /lib Essential shared libraries and kernel modules<br />

– /root Home directory for the root user (optional)<br />

– /var Variable data<br />

40


Hardware in <strong>Linux</strong><br />

• /dev/fd0 First floppy disk (Floppy A:)<br />

• /dev/fd1 Second floppy disk (Floppy B:)<br />

• /dev/hda1/ Partition 1 of first IDE disk<br />

• /dev/hda2/ Partition 2 of first IDE disk<br />

• /dev/hda3/ Partition 3 of first IDE disk<br />

• /dev/hda4/ Partition 4 of first IDE disk<br />

• /dev/hda5 / logical Partition 1 of first IDE disk<br />

Hardware in <strong>Linux</strong><br />

• /dev/hdb1/ Partition 1 of second IDE disk<br />

• /dev/hdb2/ Partition 2 of second IDE disk<br />

• /dev/hdb3/ Partition 3 of second IDE disk<br />

• /dev/hdb4/ Partition 4 of second IDE disk<br />

• /dev/hdb5 / logical Partition 1 of second IDE disk<br />

41


Hardware in <strong>Linux</strong><br />

• /dev/cdrom CD-ROM Drive<br />

• /dev/sda/ SCSI Primary Master<br />

• /dev/sdb/ SCSI Primary Slave<br />

• /dev/sdc/ SCSI Secondary master<br />

• /dev/sdd/ SCSI Secondary Slave<br />

Used Shell Commands<br />

• man - format and display the on-line manual pages<br />

• ls -list directory contents<br />

-a, --all do not ignore entries starting with .<br />

-l use a long listing format<br />

[root@jodoi-server ~]# ls -la<br />

drwxr-x--- 15 root root 4096 Jan 7 11:37 .<br />

drwxr-xr-x 23 root root 4096 Jan 12 08:20 ..<br />

-rw------- 1 root root 1051 Jan 7 17:45 anaconda-ks.cfg<br />

-rw------- 1 root root 347 Jan 8 11:57 .bash_history<br />

-rw-r--r-- 1 root root 24 Jul 13 2006 .bash_logout<br />

42


Used Shell Commands<br />

•Change the current directory<br />

• # cd <br />

Directory<br />

. Current Directory<br />

.. Parent Directory<br />

/ Root Directory<br />

~ Home Directory (/home/)<br />

Used Shell Commands<br />

• cp - copy files and directories<br />

• cp [option] [source file2] […] <br />

• Options<br />

–-p<br />

Preserve permission, owner<br />

–-r Recursive<br />

–-v explain what is being done<br />

–-f force overwriting<br />

• Ex cp xxx.txt yyy.txt<br />

43


Used Shell Commands<br />

• mv - move (rename) files<br />

• mv [option] [source2] […] <br />

• Options<br />

-f, --force<br />

• Ex mv file1.txt file2.txt<br />

[root@jodoi-server tmp]# mv test1.txt test2.txt<br />

Used Shell Commands<br />

• rm -remove files or directories<br />

• rm [options] … Ex rm file1.txt<br />

• Options:<br />

-f, --force<br />

,ignore nonexistent files, never prompt<br />

-i, --interactive<br />

,prompt before any removal<br />

-r, -R, --recursive<br />

,remove directories and their contents recursively<br />

44


Used Shell Commands<br />

Ex<br />

[root@jodoi-server ~]# ls -la |more<br />

[root@jodoi-server ~]# ls -la |grep log<br />

[root@jodoi-server ~]# cat /etc/ssh/sshd_config |grep Port<br />

[root@jodoi-server ~]# cat /etc/passwd |grep root<br />

Used Shell Commands<br />

locate - find files by name<br />

Updatedb - update a database for mlocate<br />

Ex<br />

[root@jodoi-server ~]# cp /tmp/test2.txt test3.txt<br />

[root@jodoi-server ~]# locate test3.txt<br />

[root@jodoi-server ~]# updatedb<br />

[root@jodoi-server ~]# locate test3.txt<br />

/root/test3.txt<br />

45


Used Shell Commands<br />

• file -determine file type<br />

• cat -concatenate files and print on the<br />

standard output<br />

• more -file perusal filter for crt viewing<br />

• tail -output the last part of files<br />

[root@jodoi-server ~]# man -k copy |more<br />

[root@jodoi-server ~]# ls --help |more<br />

Used Shell Commands<br />

| (A pipe) - is a means by which the output fromone<br />

process becomes the input to a second. In technical<br />

terms, the standard output of one command is sent<br />

to the standard input of a second command.<br />

Grep -searches the named input FILEs (or standard<br />

input if no files are named, or the file name - is<br />

given) for lines containing a match to the given<br />

PATTERN. By default, grep prints the matching<br />

lines.<br />

46


System log<br />

root@jodoi-server ~]# tail -f /var/log/messages<br />

[root@jodoi-server ~]# tail -10 /var/log/secure<br />

[root@jodoi-server ~]# tail -f /var/log/secure<br />

Aug 16 13:48:52 jodoi-server su: pam_unix(su-l:auth):<br />

authentication failure; logname=jodoi uid=500 euid=0<br />

tty=pts/0 ruser=jodoi rhost= user=root<br />

Aug 16 13:48:58 jodoi-server su: pam_unix(su-l:auth):<br />

authentication failure; logname=jodoi uid=500 euid=0<br />

tty=pts/0 ruser=jodoi rhost= user=root<br />

Aug 16 13:49:03 jodoi-server su: pam_unix(su-l:session):<br />

session opened for user root by jodoi(uid=500)<br />

Backing up your files<br />

tar -The GNU version of the tar archiving utility<br />

Operations:<br />

[-]c --create<br />

[-]x --extract --get<br />

--delete<br />

Common Options:<br />

-C, --directory DIR<br />

-f, --file F<br />

-j, --bzip2<br />

-v, --verbose<br />

-z, --gzip<br />

47


EXAMPLES<br />

Backing up your files<br />

tar -xvf foo.tar<br />

tar -xzf foo.tar.gz<br />

verbosely extract foo.tar<br />

extract gzipped foo.tar.gz<br />

tar -cjf foo.tar.bz2 bar/ create bzipped tar archive<br />

of the directory bar called foo.tar.bz2<br />

tar -xjf foo.tar.bz2 -C bar/ extract bzipped<br />

foo.tar.bz2 after changing directory to bar<br />

tar -xzf foo.tar.gz blah.txt<br />

from foo.tar.gz<br />

extract the file blah.txt<br />

48

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!