(...)
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Basic Shell Script In Linux/Ubuntu/CentOS - P1
Trong windows chúng ta có batch file, trong linux có Shell
Script. Nói chung shell là chương trình có thể tương tác người dùng, có
thể input dữ liệu, có thể output ra màn hình, có thể tự động thực thi một nhóm
lệnh do chúng ta tạo ra theo một lịch trình đã thiết lập.
1. Cách tạo và thực thi một chương trình shell
Tạo file hello.sh với nội dung:
#!/bin/bashecho "hello world"
(...)
Network Configuration In Linux/Ubuntu >= 17.4
1. Các file cấu hình:
Network interface
- Debian-based: /etc/network/interfaces- Red Hat-based:
/etc/sysconfig/network-scripts/- Ubuntu (>= 17.04):
/etc/netplan/
DNS server: /etc/resolv.conf
/etc/nsswitch.conf
Ví dụ:
Kiểm tra thông tin IP hiện tại với lệnh:
ip a
khanhvc@ubutu:~$ ip a
(...)
Using Commands Cat, Head, Tail, Less & More In Linux/Ubuntu/CentOS
Mục Lục:
1. Lệnh Cat2. Lệnh Head3. Lệnh Tail4. Lệnh Less5. Lệnh
More
Nội Dung:
1. Lệnh Cat: Dùng để đọc, và xem nội dung của file
Command
Giải Thích
cat /etc/passwd
Hiển thị nội dung file passwd
(...)
AWK Command In Linux/Ubuntu/CentOS
Command
Giải Thích
Kết Quả
echo "Linux commands" | awk '{$2="DONG LENH";print $0}'
Thay đổi nội dung của cột thứ 2 của chuỗi "Linux command" trong lệnh echo thành "DONG LENH"(...)
Sed Command in Linux/Ubuntu/CentOS - Tìm Kiếm & Thay Thế
Mục Lục1. Cài đặt Sed
2. Ví dụ
Nội Dung:
1. Cài đặt Sed
sudo apt-get install sed
Kiểm tra version sau khi cài đặt
sed --version
2. Ví dụ
Command
Giải Thích
sed 1s/thu/THU/g file.txt
Tìm chữ "thu" ở dòng thứ 1 của file có tên file.txt, thay(...)
Security Fundamentals In Linux/Ubuntu/CentOS
Command
Giải Thích
su itsupport
Switch user sang user itsupport, vẫn đứng tại thư mục hiện tại
su - itsupport
(...)
Basic Regular Expression In Linux/Ubuntu/CentOS
Mục Lục1. Regular Expression Căn Bản2. Ví dụ:Nội dung:1. Regular Expression Căn Bản
Ký Hiệu
Giải Thích
.
Bất kỳ ký tự nào
+
(...)
File/Directory Permission In Linux/Ubuntu/CentOS
Account Management In Linux/Ubuntu/CentOS
Mục lục1. Tạo mới Group/User
2. Thêm/xóa user trong group
3. Profiles/Policies cho User
Nội dung:
1. Tạo mới Group, User mới
Commands
Diễn Giải
cat /etc/group
Kiểm tra các group hiện tại đang tồn tại trên hệ thống
(...)
Hard Links & Symbolic Links In Linux/Ubuntu/CentOS
Khi một file hoặc folder được tạo ra trong Linux nó sẽ tạo ra 1 số cho file
hoặc folder đó. Số đó gọi là INODE và đây là dãy số duy nhất trên hệ thống của
Linux nhằm mục đích quản lý.
Ví dụ:
khanhvc@ubutu:~/projects$ ll -i
total 12
2621505 drwxrwxr-x 3 khanhvc khanhvc 4096 Thg 9 23 14:05 ./
(...)
Basic File Editing - Vim In Linux/Ubuntu/CentOS
Regular Expression In Linux/Ubuntu/CentOS
Nội dung:
Tạo Regular Expression (RegEx) đơn giản
Sự khác nhau giữa RegEx căn bản và RegEx extended (Egrep)
Commands
1. Grep - Global RegEx: In ra dòng nếu tìm thấy mẫu (patterns)
Cú Pháp
Ví Dụ
Giải Thích
grep(...)
Using Streams, Pipes & Redirects - STDOUT/STDIN/STDERR In Linux/Ubuntu/CentOS
Nội dung:Redirecting standard input/output/errorPipe: dữ liệu output của command này trở thành dữ liệu input của command khácSử dung output của command như là argument của command khácĐẩy output của command đến stdout và log fileCommand
Lệnh
Giải Thích
Ví Dụ
>
(...)
Basic File Management In Linux / Quản Lý File Căn Bản Trong Linux
Nội dung:
Copy, duy chuyển và xóa file và thư mụcCopy nhiều file, nhiều thư mục với đệ qui (recursively)Xóa file, thư mục đệ quiTìm kiếm
Command
Lệnh
Giải Thích
Ví Dụ
mkdir
tạo thư mục mới
(...)
History Commands In Linux/Ubuntu/CentOS - Lệnh History Trên Linux
Ví Dụ
Giải Thích
history
hiển thị các câu lệnh user đã thực hiện trước đó
history 3
hiển thị 3 câu lệnh gần nhất
!!
Thực hiện lại câu lệnh gần nhất
!101
thực hiện lại câu lệnh có số thứ tự là 101
!systemctl
thực hiện lại câu lệnh cuối cùng bắt đầu bằng chuỗi "systemctl"
history | grep date
hiển thị các câu lệnh đã thực thi có chuỗi "date"
history -w
ghi lịch sử vào file users ~/.bash_history
history -c
xóa lịch sử các câu lệnh đã thực hiện
history -d 101
xóa(...)
Basic Shell Commands In Linux/Ubuntu/CentOS - Các Lệnh Shell Cơ Bản Trong Linux - Ubuntu
CentOS, Cài Đặt Ngày Giờ Trên CentOS
Yêu cầu:
1. Cài đặt thủ công
2. Cài đặt thông qua NTP - Network Time Protocol
Thực hiện:
1. Cài đặt thủ công
Kiểm tra trước khi cài đặt
[root@CentOS ~]# timedatectl status
Local time: Wed 2020-06-17 08:15:01 IST
Universal time: Wed 2020-06-17 01:15:01 UTC
RTC time: Wed 2020-06-17 01:15:01
Time zone: Asia/Kolkata (IST, +0530)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@CentOS ~]#
Noted: Trước khi chỉnh ngày giờ chúng(...)
Subscribe to:
Posts (Atom)