Báo cáo - Quản trị hề điều hành mạng Linux Ubuntu Serve. Ubuntu là hệ điều hành máy tính nguồn mở tuân theo giấy phép GNU general Public Licence có tính năng tương tự như hệ điều hành Window của Microsoft. Tổng quan kiến thức về Ubuntu: các phiên bản, ưu - nhược điểm. Hệ điều hành Ubuntu Serve. Cách cài đặt và các thao tác quản trị
TỔNG QUAN VỀ ĐỀ TÀ
Lịch sử phát triển
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Các phiên bản Linux
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Tên bản phân phối Trang web chính thức Các bản tương tự
Ubuntu http://www.ubuntu.com/
Linux http://www.debian.org/
Ultimate Edition http://ultimateedition.info/
Enterprise Linux http://www.redhat.com/rhel/
Chrome Linux http://getchrome.eu/
Fedora http://www.fedoraproject.org/
Desktop http://vi.opensuse.org/
Linux Mint http://linuxmint.com/
Knoppix http://www.knoppix.org/
PCLinuxOS http://www.pclinuxos.com/
Mandrake http://wiht.link/mandrivalinux Mandriva
CentOS http://www.centos.org/
Gentoo http://www.gentoo.org/
Slackware http://www.slackware.com/
SLAX http://www.slax.org/
Sabayon http://www.sabayon.org/
Dreamlinux http://www.dreamlinux.info/
OpenSolaris http://www.opensolaris.org/
Hồng kỳ linux http://www.redflag-linux.com/
Puppy linux http://puppylinux.org/
Hacao Linux http://www.hacao.com/
Asianux http://www.asianux.vn/ Asianux Server
SliTaz http://www.slitaz.org/ GNU/Linux
Linpus http://www.linpus.com/ Linpus Linux
Super Ubuntu http://hacktolive.org/wiki/
Ubuntu, Zorin OS, Linux Mint,
Zorin OS http://zorin-os.com/
Ubuntu, SuperUbuntu, Linux Mint
Ưu, nhược điểm của Linux
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Thích hợp cho quản trị mạng
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
1.3.2 Nhược điểm Đòi hỏi người dùng phải thành thạo:
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
HỆ ĐIỀU HÀNH MẠNG
Phân biệt hệ điều hành mạng và hệ điều hành máy trạm
1.1.1 Giống nhau giữa hệ điều hành mạng và hệ điều hành máy trạm
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
1.1.2 Khác nhau giữa hệ điều hành mạng và hệ điều hành máy trạm
- Giao diện đồ họa người dùng:
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Tìm hiểu về hệ điều hành Ubuntu Server
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
1.2.2 Phân biệt Ubuntu Server và Ubuntu Desktop o Giống nhau : Đều là những hệ điều hành cung cấp một phần mềm mã nguồn mở tự do cho phép người dùng được tự do chạy, sao chép, phân phối, nghiên cứu, thay đổi và cải tiến phần mềm. o Khác nhau :
- Cung cấp cho người dùng một giao diện đồ họa
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
- Cài đặt Ubun Desktop giống như việc cài đặt phần mềm.
- Không cung cấp cho người dùng giao diện đồ họa
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
- Cài đặt bản Server khác với cài đặt bản Ubuntu Desktop, thay vào đó bạn phải dùng một menu qui trình điều khiển.
1.2.3 Lợi ích khi sử dụng Ubuntu Server
- Ít tốn tài nguyên phần cứng
- Ubuntu Server có tính bảo mật cao
- Khả năng tương thích cao
- Kho ứng dụng miễn phí khổng lồ
- Chạy được nhiều ứng dụng trên Windows
CÁCH TẢI VÀ CÀI ĐẶT HỆ ĐIỀU HÀNH UBUNTU SERVER.13 2.1 Cách tải về và các bước cài đặt hệ điều hành Ubuntu Server
Yêu cầu chuẩn bị
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
- CPU sử dụng bộ vi xử lý Intel x86, AMD64 hoặc ARM
- Đường truyền internet tốc độ cao
- Yêu cầu phần cứng tối thiểu: +1 GHz CPU
+ 512 MB RAM + 2.5 GB hard drive
- Download bộ cài Ubuntu Server 20.04.3 LTS từ trang web www.ubuntu.com
- Download VirtualBox/VM-Ware hoặc có thể ghi file iso ra đĩa và cài trên máy tính thật
Tiến hành cài đặt
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
+ Chọn ngôn ngữ English - > Update to the new installer -> Done
+ Cấu hình IP tĩnh: Sử dụng các phím di chuyển của bàn phím để thao tác
Nhập thông tin IP: Tùy theo cấu hình mạng máy đang sử dụng
+ Save -> Done hết ( để cài đặt tự động) -> Continue
+ Tích vào Install OpenSSH server -> Done -> Done -> Reboot Now
Bước 1: Truy cập trang web https://ubuntu.com/ để tải ubuntu
- tìm mục download vào tải ubuntu về máy của bạn.
- Máy ảo VirtualBox hoặc VMWare hoặc có thể tạo USB Boot để cài trực tiếp trên ổ cứng
- Truy cập trang web : https://www.virtualbox.org/ để tải virtualbox ( là phần mềm chạy hệ điều hành ảo của ubuntu)
- Đầu tiên, sẽ kiểm tra ổ đĩa của bạn Để loại bỏ bước này bấm tổ hợp phím [ Ctrl +
C ] Tuy nhiên bước kiếm tra này diễn ra khá nhanh, nhanh hơn các phiên bản khác nên các bạn cứ để nó chạy.
Bước 2: ở màn hình Welcome, chúng ta có 2 tùy chọn là:
Try Ubuntu: Sử dụng thử Ubuntu mà ko phải cài đặt
Install Ubuntu: Cài Ubuntu lên ổ đĩa để sử dụng
=> Chúng ta bấm Install Ubuntu để thực hiện việc cài đặt.
Bước 3: Chọn loại bàn phím để sử dụng, mặc định là US Keyboard =>
Bấm [ Continue ] để tiếp tục
Bước 4: tùy chọn cài đặt phần mềm để sử dụng
Normal Installation: Ở chế độ cài đặt bình thường sẽ tích hợp nhiều phần mềm, trình duyệt, tiện ích, game, trình chơi nhạc
Minimal Installation: Ở chế độ cài đặt tối thiếu chỉ có trình duyệt FIrefox và 1 số tiện ích cơ bản
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Bước 5: ở tùy chọn cài đặt này Nếu là người mới bắt đầu, các bạn nên để nguyên rồi bấm nút cài đặt [ Install Now ]
Còn nếu bạn muốn cài đặt nâng cao thì bấm vào [ Advanced Features ] Đây cũng là 1 điểm mới của Ubuntu 20.04 LTS
Bước 6: Khi bấm vào [ Advanced Features ], chúng ta có 2 tùy chọn nữa là:
Use LVM with the new Ubuntu installation
EXPERIMENTAL: Erase disk and use ZFS
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Bước 8: Chọn địa điểm của bạn, nó sẽ cấu hình thời gian, timezone cho hệ thống
Bước 9: Nhập các thông tin về user Thông tin này sẽ được sử dụng để đăng nhập vào Ubuntu
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Kiểm tra sau cài đặt
- Vào Setting của Ubuntu Server -> Netwwork -> Attached to: Bridged Adapter -
- Đăng nhập username và password vừa setup bên trên
- Gõ lệnh: ip a để kiểm tra IP mà ban đầu đã setup
CÁC THAO TÁC QUẢN TRỊ TRÊN UBUNTU SERVER
Các thao tác về mạng
3.1.1 Cài IP tĩnh cho Ubuntu Server Đã setup trong bước cài đặt Ubuntu Server ở chương 2
3.1.2 Cài đặt dịch vụ DHCP
- Cập nhật file cài cấu hình /etc
Sudo apt-get install isc-dhcp-server
- Cài đặt dịch vụ DHCP cho Ubuntu Server
Sudo nano /etc/dhcp/dhcpd.conf
Sudo nano /etc/default/isc-dhcp-server
- Cấu hình mạng cố định
sudo service isc-dhcp-server restart
sudo service isc-dhcp-server status
- Cài đặt bản Ubuntu Desktop (client) để nhận cấp phát địa chỉ IP từ Ubuntu Server
- Cài đặt SSH máy cliente kết nối tới máy chủ:
- Tải lại toàn bộ file sang server
Sudo apt-get install openssh-server
- Kiểm tra trạng thái SSH
- Tạo SSH KEY giúp bảo mật cơ chế SSH tốt hơn
ssh-copy-id username_server@IP
- Chuyển public key sang server, sau đó nhập password server
Các thao tác với file và thư mục
- Tạo cây thư mục: /D14QTANM2/ mkdir D14QTANM2 -> cd D14QTANM2 -> mkdir
- Tạo một tệp tin có tên là tailieu.txt trong thư mục nêu trên touch tailieu.txt
- Xem lại cấu trúc cây thư mục ls –l
- Nhập một đoạn văn bản cho file tailieu.txt và lưu lại nano tailieu.txt -> Nhập…
- Mở file tailieu.txt để xem nội dung cat tailieu.txt
- Copy file tailieu.txt sang thư mục khác cp + [file1] [file2]
- Đổi tên một thư mục mv
- Xóa một thư mục rm –r [file]
- Di chuyển một thư mục sang vị trí mới mv [file1] [file2]
Phân quyền truy cập tài nguyên
3.3.1 Tạo user, group và quản lý thuộc tính user
- Trên Server tạo 2 nhóm là KinhDoanh và KyThuat sudo addgroup kinhdoanh sudo addgroup kythuat
- Tạo 2 user nvkd và nvkt sau đó đưa vào nhóm tương ứng sudo adduser nvkd -> sudo adduser nvkd kinhdoanh sudo adduser nvkt -> sudo adduser nvkt kythuat
- Cách reset mật khẩu của 2 user sudo passwd
- Cách đặt thời hạn có hiệu lực cho mật khẩu
3.3.2 Tìm hiểu về cách phân quyền cho file trên Server Ubuntu
Có thể tham khảo đường link sau: https://quantrimang.com/phan-quyen-truy-cap-file-bang-lenh-chmod-59672 https://help.ubuntu.com/community/FilePermissions
3.3.3 Chia sẻ và phân quyền truy cập cho user
- Trên Server tạo 3 thư mục: ChiaSeChung, TaiLieuKyThuat, TaiLieuKinhDoanh và tạo các file nằm trong 3 thư mục
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
sudo chmod –R g-x,o-rx TaiLieuKinhDoanh (Phân quyền)
+ Chỉ có nhân viên nhóm KyThuat được phép truy cập vào thư mục TaiLieuKyThuat với quyền Read+Write.
* Tương tự như phần phân quyền cho TaiLieuKinhDoanh
3.3.4 Kiểm tra từ máy client truy cập tới tài nguyên chia sẻ dùng NFS
sudo apt-get update ( Tải lại toàn bộ file trên server)
sudo apt-get install nfs-kernel-server (cài đặt NFS)
sudo mkdir -p /share/data (tạo thư mục để chia sẻ tài nguyên)
- Trao quyền và phân quyền cho tất cả được phép truy cập (chown, chmod)
sudo chown -R nobody:nogroup /share/data/ (Trao toàn quyền cho tất cả mọi người)
sudo chmod -R 777 /share/data (Phân toàn quyền cho tất cả mọi người)
sudo mv ChiaSeChung /share/data
sudo mv TaiLieuKinhDoanh /share/data
sudo mv TaiLieuKyThuat /share/data
Cấp quyền chia sẻ cho máy khách:
Chạy lại NFS và kiểm tra trạng thái:
Sudo systemctl restart nfs-kernel-server.service
Sudo systemctl status nfs-kernel-server.service
Sudo apt install nfs-common
+ Cài đặt NFS bên máy khách
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Sudo mount 192.168.1.20:/share/data /share/data_client/
+ Mount thành công và đây là thành quả:
Cài đặt tường lửa bảo vệ máy chủ
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Lập trình Bash Shell
Tạo 1 file với đuôi là sh với lệnh touch + [tên file].sh
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
- 1 số biến trong Bash Shell:
$0- Tên của file Bash script.
$1 - $9 - lần lượt là các đối số truyền vào cho file Bash script
$# - Số lượng các arguments chúng ta truyền vào cho file the Bash script
$@ - Tất cả các đối số cung cấp cho file Bash script.
$? - Trạng thái của câu lệnh thực hiện gần nhất (0 -> true, 1 -> false) $$ - ID của script hiện tại
- Cấu trúc shebang sẽ chỉ cho OS chạy chương trình #!bin/bash để thực hiện các nội dung của script và nhập câu lệnh.
- Chương trình hỏi bạn tên gì? Sau khi bạn nhập tên thì chương trình in ra màn hình câu: Xin chào {tên_vừa_nhập}.
Phân Quyền thực thi với file vừa tạo :
Sau khi cấp quyền t có thể dùng 2 cách để chạy file bash shell vừa tạo :
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Lập trình Python
- Tải lại toàn bộ file sang server:
Sudo apt-get install python
Sau khi cài xong chúng ta có thể kiểm tra phiên bản python 2.x bằng lệnh :
Tiếp tục nếu muốn kiểm ra phiên bản 3.x ta tiếp tục dùng lệnh :
Chạy Demo và nhập print(‘hello’ ) và Enter để ra dòng lệnh
Và màn hình đã hiện ra chữ hello đã nhập trong print ( print là biến khai báo) Để thoát file Bash Shell t ấn Ctrl + D
Tiếp tục cài pip cho python : pip (python package manager) là một trình quản lý module, thư viện của python.
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Sudo apt-get install pip or pip3 đều được
Bước 3 : Cài đặt vào tạo môi trường riêng cho python
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Sudo apt install -y python3-venv :
- Tiếp theo tạo môi trường và truy cập vào môi trường : mkdir environments và cd environments
- Khi bạn ở trong thư mục mà bạn muốn môi trường tồn tại, bạn có thể tạo môi trường bằng cách chạy lệnh sau: python3 -m venv my_env
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Bước 1: tạo 1 file có đuôi py bằng câu lệnh : nano + [file.py]
Bước 2: khi văn bản mở t nhận chương trình của mình :
Bước 3: Khi bạn thoát ra khỏi nano và quay trở lại shell của mình, hãy chạy chương trình: python + [file.py]
Các bài tập về python:
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
Bước 1: Mở cliente cà vài Terminal
Bước 2: tạo 1 file.txt điền nội dung là các user và mật khẩu
Bước 3: tạo 1 file.py và nhập code add nhiều user:
Chạy code lệnh python sudo python3 [file.py] [file.txt] :
Nhập code add user tự động:
Add user tự động : tạo 1 file.py vào điền chương trình vào : sudo [file.py]
Như vậy đã add user tự động thành công
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared
502 Bad GatewayUnable to reach the origin service The service may be down or it may not be responding to traffic from cloudflared