Tải bản đầy đủ (.pptx) (61 trang)

systemadministrators HỆ ĐIỀU HÀNH LINUX

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (370.51 KB, 61 trang )

QUẢN TRỊ HỆ THỐNG


Nội dung








Siêu tài khoản người dùng(superuser account)
Quá trình khởi động và thoát khỏi hệ thống
Quản lý tài khoản người dùng
Quản lý hệ thống tập tin
Điều khiển các tiến trình
Quản lý pakage

2


root - Superuser account





Tải khoản có quyền cao nhất trong hệ thống
Không có hạn chế nào được áp đặt trên tài khoản này
Thường dùng để duy trì và quản trị hệ thống


cách thông dụng để chuyển vào tài khoản root là:
$ sudo -i
Password:
#su <username>



khi đang ở tài khoản root, chú ý khi dùng lệnh
# rm -rf / usr/local/*
# rm -rf /*

3


Quá trình khởi động và thoát khỏi hệ thống








Khởi động hệ thống và khởi tạo(System Startup and Initialization)
tập tin /etc/init.d
chuyển đổi mức chạy (runlevel)
các tập tin rc
Chế độ đơn người dùng(Single-user mode)
Thoát khỏi hệ thống(shutdown system)


4


Khởi động hệ thống và khởi tạo







Booting the kernel
Initializing device drivers
Executing init in /sbin
init reading /etc/inittab

(id:3:initdefault)

or /etc/init/rc-sysinit.conf (env DEFAULT_RUNLEVEL)
Executing rc files based on runlevel
(/etc/rc?.d/ )

$grep 'DEFAULT_RUNLEVEL' /etc/init/*

5


Boot loader(LILO,GRUB)

Kernel


S: start

/etc/init.d/syslogd

K: kill

/etc/init/mysqld
….
/etc/cupsd
init
0
1

Symbol link
/etc/inittab

2
3

3

/etc/rc3.d

/etc/rc3.d/[SK]*

5

/etc/rc5.d


/etc/rc5.d/[SK]*

4
5
6

6


/etc/inittab file


File format
code:runlevels:action:command



Runlevels
# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11 (multiuser mode with GUI)
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

7



Switching runlevel





Generally, Linux operates in runlevel 3 or 5
Edit initdefault in /etc/inittab
Running init manually
# init 5 (switch to X11 mode)
# init 3 (switch to multiuser mode)
# init 1 (switch to single user mode)



Finding previous and current system run level
# runlevel
N5
8


Chế độ đơn người dùng(Single-User Mode)







Trong tình trạng khẩn cấp, phục hồi lại hệ thống
No login prompt
Truy cập với người dùng root
Chỉ ở chế console
boot: linux single
boot: linux -s
boot: linux 1
# init 1

9


Services start/stop at boot time






Place in /etc/rc.d/rcN.d (N=runlevel)
Shell scripts
Start script: Snnxxxx
Kill script: Knnxxxx
nn = 00 - 99: enforce executing order
S10network S12syslog S99local K90network K10xfs




S* and K* are symlinks to real scripts

Central directory for real scripts: /etc/rc.d/init.d, /etc/init.d

10


Linux Services
There are 113 deamons, Out of them, the following are most widely used:














apmd : Power Management
crond : Periodic Command Scheduler
cups : Common Unix Printing System
dhcpd : The DHCP server
httpd : Apache Web server
iptables : Kernel based Packet Filtering firewall
mysqld : MySQL server
sendmail : Sendmail Mail Server
squid : Squid Proxy Server

sshd : Open SSH and SFTP server
xinetd : Provides support for telnet, ftp, talk, tftp etc.
ypbind : NIS Server

11


(tt)

12


Start and stop daemon



If a startup script exists in the /etc/init.d directory

13


(tt)



Fedora and Redhat also come with the service command

14



shutdown hệ thống


shutdown - tắt hệ thống
# shutdown -r +10 (reboot after 10 minutes)
# /sbin/shutdown -r +10 "Rebooting to try new kernel"
# shutdown -h now (halt immediately)



Other ways
Ctrl-Alt-Del
# reboot
# halt
# powerof

15


Quản lý tài khoản




Người dùng và nhóm
Tạo, chỉnh sửa, xóa tài khoản người dùng

– /etc/passwd file
– /etc/shadow file




Tạo, chỉnh sửa, xóa nhóm

– /etc/group file

16


Người dùng và nhóm








Tài khoản người dùng và tài khoản hệ thống
Mỗi người dùng sẽ có 1 tên và định danh(id) duy nhất (unsigned number)
Mỗi người dùng thuộc về ít nhất 1 nhóm
Mỗi nhóm có tên và định danh duy nhất (unsigned number)
Tên tài khoản người dùng thường là chữ thường
Tài khoản siêu người dùng luôn có id là 0

17


Thêm tài khoản người dùng
#useradd [-u uid] [-g group]

[-d home] [-s shell] [-c comment] username

# useradd -g students -c "Student 001" stud001
passwd - set user password
# passwd stud001
Chuyển vào tài khoản stud001: su stud001

18


Chỉnh sửa và xóa tài khoản người dùng
usermod [-u uid] [-g group]
[-d home] [-s shell] [-c comment]
[-l new_name] username
# usermod -u 1001 stud001
userdel [-r] username
-r: remove user’s home directory
# userdel -r stud001

19


/etc/passwd file

• File format

username:password:uid:gid:gecos:homedir:shell

username - bất kỳ chuỗi ký tự nào dùng để xác định tài khoản
password - mật khẩu người dùng(mã hóa)

uid - user ID
gid - group ID
gecos - thông tin khác của người dùng
homedir - thư mục home của người dùng
shell - chương trình sẽ chạy khi người dùng login vào, thường
là /bin/bash

• Tăng bảo mật cho mật khẩu: /etc/shadow
20


Ví dụ các mục trong /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/bin/false
student:x:500:500:Student:/home/student:/bin/bash

21


Tập tin /etc/shadow



/etc/shadow chứa thông tin mật khẩu đã được mã hóa cho tài khoản người
dùng

– Login name
– Encrypted password


22


(tt)

23


Khóa tài khoản người dùng




Đặt ! trong trường password của tập tin /etc/shadow
Thay đổi shell đăng nhập thành /user/sbin/nologin

24


Tài khoản nhóm
Adding group
groupadd [-g gid] group
# groupadd students

Modifying group
groupmod [-g gid] [-n name]

group


# groupmod -g 1000 students

Deleting group
groupdel group
# groupdel students

25


×