Notebook LPI Nhat Nghe

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Notebook thực hành LPI Linux Nhất Nghệ (LPI I)

I. Cài đặt Centos 7.1:

Gắn thêm card Lan:


B21: # nmtui
B22:
Đổi tên profile ( connection )
Khai báo thông tin cho Lan Card, chọn OK:

B4:
# systemctl restart network
#mv /etc/sysconfig/network-scripts/ifcfg-Wire_connection_1/ect/sysconfig/network-
scripts/ifcfg-eno33554984
Chú ý: có thể đổi tên thành ifcfg-eth0, ifcfg-eth1 …
B5: Kiểm tra thông tin cấu hình các card mạng:
#ifconfig

B5: Dừng và vô hiệu hoá tường lửa trên CentOS 7:


Stop and Disable Firewall on CentOS 7:
Disable Firewalld:
#systemctl disable firewalld
Stop Firewalld
#systemctl stop firewalld
Check the status of Firewalld:
#systemctl stop firewalld

SELinux (Security-Enhanced Linux) là một hệ thống bảo mật được tích hợp sâu vào hệ điều hành Linux. Nó được
phát triển bởi Cục Tình báo Quốc phòng Hoa Kỳ (NSA) và được phát hành dưới giấy phép mã nguồn mở. SELinux
cung cấp một cơ chế kiểm soát truy cập dựa trên chính sách bảo mật để giữ cho hệ thống an toàn và đảm bảo tính
toàn vẹn của dữ liệu.

SELinux có ba chế độ hoạt động chính: Enforcing, Permissive và Disabled. Mỗi chế độ có mục đích và
tác động khác nhau đến việc kiểm soát truy cập của hệ thống.

--Disable SELinux CentOS 7 –


[root@localhost ~] # sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
Current mode: enforcing

Mở file /etc/selinux/config, sửa SELINUX = disabled


Hoặc
[root@localhost~]# sed -i ‘s/enforcing/disabled/g’ /etc/selinux/config
[root@localhost~]# reboot
[root@localhost~]# sestatus
 …
Change default runlevel in CentOS 7

Cách 1:
B1: xem runlevel hiện tại :
[root@localhost ~] # systemctl get-default
..

B2: Xem các target có sẵn


[root@localhost~]# systemctl list-units –type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
….

B3: Change default to runlevel 3


#systemctl set-default multi-user.target
rm ‘/etc/systemd/system/default.target’
ln -s ‘/usr/lib/systemd/system/multi-user.target’ ‘/etc/systemd/system/default.target’
B4: Kiểm tra :
# systemctl get-default multi-user.target
B5: Reboot
Cách 2:
B1: Check the current level
#systemctl get-default multi-user.target
B2: Xem lại các runlevel
[root@locahost~] ls /lib/systemd/system/runlevel*target-1

B3: chuyển runlevel từ 3 sang 5:


In -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
Hoặc
In -sf /lib/systemd/system/graphical.target /etc/systemd/system/defalilt.target

B4: Kiểm tra


# systemctl get-default runlevel5.target
# reboot

INSTALLING SOFTWARE
- Redhat Package Manager (RPM) là công cụ dùng để installing, uninstalling, upgrading
software cho hệ thống Linux.
- Một RPM package là một file chứa các chương trình thực thi , các scripts, tài liệu , và
một số file cần thiết khác. Cấu trúc của một RPM package như sau:
- package – 1.0 -2 . i386 .rpm

1. Quản lý Package bằng The Package Manamant Tool ( dùng giao diện đồ hoạ ):

2. Quản lý Package bằng RPM ( dùng command line)


2.1. Xem cú pháp lệnh rpm: man rpm
Truy vấn các thông tin liên quan đến gói đã cài:
Các tham số thông thường:
#rpm -qa mc
#rpm -qa mc*
#rpm -qa|grep mc
#rpm -qd httpd
#rpm -qi mc

#rpm -qc samba


#rpm -qa | grep samba

2.3 Gở bỏ một package (Erase)


# rpm -e me
# rpm -e samba-common
error: Failed dependencies:
samba-common = 4. l .12-21.el7 1 is needed by (installed) libsmbclient-0:4. l .12-21.el7 1.x86_64
libpopt_ samba3.so()( 64bit) is needed by (installed) samba-0:4. l .12-21.el7 l .x86 64
libpopt samba3.so(SAMBA 4. l.12)(64bit) is needed by (installed) samba-0:4. l.12-21.el7 l.x86 64

 Lỗi do samba-common phụ thuộc vào gói samba 0:4. l .12-21.el7 1.x86_64
Cách 1: xoá gói samba-0:4.1.12-21.el7_.x86_64 trước, sau đó xoá samba-common.
Cách 2: xoá gói samba-common dùng vói option –nodeps

rpm -e samba-common –nodeps


dùng lệnh rpm –qa|grep samba để kiểm tra kết quả.

2.4 Cập nhật một package (upgrade):


rpm -Uvh /media/Packages/ samba-4. l.12-21.el7 l.x86_64.rpm

3.Sử dụng lệnh yum :


Lệnh yum cho phép tìm kiếm và cài đặt các phần mềm thư viện trực tiếp từ INTERNET,
cú pháp:
Yum [options] [command][package…]

Cài đặt từ INTERNET:


Cài đặt mc:
# yum install mc -y
# yum info mc
# yum remove mc
# man rpm
Khái niệm tập tin trong Linux được chia ra làm 3 loại chinh:
+ Tập tin chứa du liệu binh thucmg.
+ Tập tin thư mục.
+ Tập tin thiết bị.
Ngoài ra Linux con dùng các Link va Pipe như là các tập tin đặc biệt khác
Xem cấu trúc tập tin hệ thống:

# ll /

Xem danh sách các files:


_ trên thư mục gốc:
# ls -l /
1. Nhóm lệnh quản lý thư mục:
a. Tạo thư mục: #mkdir
[root@localhost ~]# tree /data/
/data/
└── os
└── unix
├── AIX
├── FreeBSD
└── Solaris

5 directories, 0 files
[root@localhost ~]# cd /data/
[root@localhost data]# ls -l
total 0
drwxr-xr-x. 3 root root 18 Feb 18 07:06 os
[root@localhost data]# cd os
[root@localhost os]# mkdir linux
[root@localhost os]# mkdir windows
[root@localhost os]# cd
[root@localhost ~]# mkdir -p /data/os/linux/{Fedora,Redhat,Ubuntu}
[root@localhost ~]# tree /data
/data
└── os
├── linux
│ ├── Fedora
│ ├── Redhat
│ └── Ubuntu
├── unix
│ ├── AIX
│ ├── FreeBSD
│ └── Solaris
└── windows

10 directories, 0 files

[root@localhost ~]# cd windows


-bash: cd: windows: No such file or directory
[root@localhost ~]# cd /data/os/windows
[root@localhost windows]# mkdir winxp win7 win2k8 win2k19
[root@localhost windows]# tree /data
/data
└── os
├── linux
│ ├── Fedora
│ ├── Redhat
│ └── Ubuntu
├── unix
│ ├── AIX
│ ├── FreeBSD
│ └── Solaris
└── windows
├── win2k19
├── win2k8
├── win7
└── winxp

14 directories, 0 files

Xem cây thư mục:


# yum install tree -y
# tree

Chuyển đổi thư mục hiện tại:


Đường dẫn tuyệt đối: được tính từ root.
Đường dẫn tương đối: được tính từ vị trí hiện tại.
2 thư mục mặc định:
. : thư mục hiện tại
.. : thư mục cha
Gõ lệnh :
[root@localhost data]# cd /data/os/windows/win7/
[root@localhost win7]# cd ../
[root@localhost windows]# cd ../../
[root@localhost data]# tree

Xem thư mục hiện hành:


#pwd

Đổi tên thư mục:


VD: đổi tên os -> hdh
# mv /data/os/ /data/hdh/
Xoá thư mục rỗng:
# rmdir /data/hdh/unix/AIX
Xem đường dẫn hiện hành:

Xem thông tin thư mục:

2. Nhóm lệnh quản lý tập tin:


Tạo tập tin:
_ Tạo tập tin với nội dung “Noi dung ben trong tap tin la day” trong tập tin “Tentaptin1”
và đặt trong thư mục data:
# echo “Noi dung ben trong tap tin la day” /data/Tentaptin1.txt
# echo “Lop hoc Linux” /data/Tentaptin1.txt
_ Tạo tập tin rỗng:
Quản trị user group
Xem thông tin người dùng
_ Tập tin /etc/passwd: là cơ sở dữ liệu tài khoản người dùng trên Linux dưới dạng tập tin văn
bản.

You might also like