Thứ Tư, 15 tháng 10, 2025

các lệnh linux hay dùng

Lấy nội dung trong 1 file:

 cat /home/admin1/pdns-mysql/pdns/pdns.conf | grep api-key 

 grep "Ubuntu" file.txt

rep -i "ubuntu" file.txt 

grep "error" *.log 

grep -r "keyword" /path/to/folder/

 

Tìm và thay thế nội dung trong 1 file: 

 

Thêm nội dung vào cuối file: 

 

- Tạo 1 file mới:  

touch file.txt 

Tạo file mới kèm nội dung ban đầu

 echo "Xin chào Ubuntu!" > file.txt

echo "Dòng mới thêm" >> file.txt

cat >> file.txt <<EOF
Dòng 1
Dòng 2
EOF

Xem nội dung file

1️⃣ Xem toàn bộ file

cat file.txt

2️⃣ Xem 10 dòng đầu

head file.txt

3️⃣ Xem 10 dòng cuối

tail file.txt

4️⃣ Xem 20 dòng đầu/cuối

head -n 20 file.txt
tail -n 20 file.txt

5️⃣ Xem file theo thời gian thực (ví dụ: log)

tail -f /var/log/syslog
 

Dùng sed để thay thế một từ

sed -i 's/cũ/mới/g' file.txt

→ Thay tất cả chữ "cũ" thành "mới" trong file.
2️⃣ Thay thế chỉ dòng đầu tiên khớp

sed -i '0,/cũ/s//mới/' file.txt

3️⃣ Thay thế trong nhiều file

sed -i 's/localhost/127.0.0.1/g' *.conf

🧩 VI. Xóa nội dung / dòng
1️⃣ Xóa toàn bộ nội dung file

> file.txt

hoặc

truncate -s 0 file.txt

2️⃣ Xóa dòng chứa từ khóa

sed -i '/Ubuntu/d' file.txt
Sao chépcp file1 file2cp a.txt b.txt
Di chuyểnmv file.txt /home/user/
Đổi tênmv cũ.txt mới.txt
Xóa filerm file.txt
Xóa có xác nhậnrm -i file.txt
Xóa tất cả file *.logrm *.log

Đếm dòng, từ, ký tự

wc file.txt

→ Kết quả gồm: số dòng, số từ, số ký tự.

Ví dụ chỉ đếm dòng:

wc -l file.txt

Ghép nhiều file thành một

cat file1.txt file2.txt > tong.txt

2️⃣ Lấy dòng cụ thể (ví dụ dòng 5–10)

sed -n '5,10p' file.txt

3️⃣ Lấy dòng chứa từ khóa và lưu ra file mới

grep "Ubuntu" file.txt > ubuntu_lines.txt

🧩 X. Nâng cao
1️⃣ In số dòng kèm nội dung

nl file.txt

2️⃣ Tìm file theo tên

find /home/user -name "*.txt"

3️⃣ Tìm file theo nội dung

grep -rl "keyword" /home/user
Mục đíchLệnh chính
Tạo filetouch, echo >
Thêm nội dungecho >>, cat >>
Xem filecat, head, tail
Tìm kiếmgrep
Thay thếsed
Xóa dòngsed '/.../d'
Ghép filecat file1 file2 > newfile
Đếm dòngwc -l
Tìm filefind, grep -r




 


Thứ Hai, 4 tháng 8, 2025

Tự sự chứng khoán

 Trước khi quyết định đầu tư vào cổ phiếu nào phải tìm hiểu thông tin về doanh nghiệp đó.

Tuỳ thuộc vào ngành nghề kinh doanh mà có phương hướng tìm hiểu khác nhau, nhưng điểm chung vẫn là kinh doanh để tạo ra lợi nhuận.

Ngành chứng khoán:

-Ngành chứng khoán tạo ra lợi nhuận bằng cách cung cấp các dịch vụ tài chính cho nhà đầu tư và tổ chức, tận dụng vốn để đầu tư sinh lời, và kiếm phí từ hoạt động môi giới, tư vấn, bảo lãnh, cho vay,…. Khi đánh giá cổ phiếu trong ngành này, nhà đầu tư nên xem xét hiệu quả sử dụng vốn, tăng trưởng khách hàng, lợi thế cạnh tranh về nền tảng và công nghệ, cũng như mức độ rủi ro trong đầu tư tự doanh và margin.


Ngành bất động sản:

Nguồn doanh thuGiải thích chi tiếtVí dụ
1. Bán sản phẩm BĐSBán căn hộ, biệt thự, nhà phố, đất nền... khi hoàn thiện dự án hoặc theo tiến độ hợp đồngVinhomes bán căn hộ tại Vinhomes Ocean Park
2. Cho thuê tài sảnCho thuê văn phòng, trung tâm thương mại, shophouse, kho bãi, khu công nghiệpNovaland cho thuê mặt bằng TTTM
3. Dịch vụ quản lý & vận hànhPhí quản lý chung cư, bảo trì, dịch vụ tiện ích trong dự ánVinhomes thu phí quản lý toà nhà
4. Chuyển nhượng dự ánBán lại một phần hoặc toàn bộ dự án cho đối tác khác để thu hồi vốn hoặc ghi nhận lợi nhuận sớmKhang Điền bán lại 1 block dự án
5. Kinh doanh bất động sản đầu tưMua đi bán lại tài sản: nhà phố, đất nền, khu nghỉ dưỡng, khách sạn… như hoạt động lướt sóng hoặc đầu tư dài hạnĐịa ốc Đất Xanh, Tập đoàn FLC
6. Dịch vụ môi giới & sàn giao dịchHưởng hoa hồng từ việc môi giới bán bất động sản của mình hoặc đối tác khácĐất Xanh Services, Cen Land
7. Hợp tác kinh doanh / góp vốnGóp vốn cùng phát triển dự án, chia sẻ lợi nhuận hoặc hưởng tỷ lệ phân chia sản phẩmNam Long hợp tác với đối tác Nhật
8. Doanh thu tài chínhLãi từ tiền gửi, đầu tư cổ phiếu, trái phiếu, chuyển nhượng khoản đầu tư, lãi cho vay (nếu có)Một số công ty dùng vốn nhàn rỗi



Ngành hàng không

HVN, VJC

Chủ Nhật, 27 tháng 7, 2025

Cổ phiếu theo dõi

 Phân tích cơ bản

 https://simplize.vn/co-phieu/VNM/ho-so-doanh-nghiep

 Tổng quan dòng tiền

 https://fwt.fialda.com/dashboard

Tham khảo

https://topinvest.vn/realtime-robot-auto.html

 

Phân tích kỹ thuật:

 https://finance.vietstock.vn/phan-tich-ky-thuat.htm

 

 https://www.finbox.vn/market

-> xem dòng tiền và tín hiệu mua bán dựa trên SuperTrend và Bolinger Bands, MACD

 

 https://24hmoney.vn/phan-tich-ky-thuat?symbol=VNM&object-type=symbol

-> MCDX xem có dòng tiền vào không và gợi ý các tín hiệu kỹ thuật mua bán 

 

 

 

Thứ Ba, 10 tháng 12, 2024

Multiusers remote desktop windows server 2008

 

https://securityzone.vn/t/lab-multiusers-remote-desktop-windows-server-2008.986/
 
Có 2 cách thực hiện:
  • Cho 2 user truy cập đồng thời (hoặc 1 user dùng 2 connection)
  • Cho nhiều user truy cập đồng thời (nhiều user nhiều connection)

1. Cho 2 user truy cập đồng thời
Vào Run, gõ Regedit
 


Vào HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ Terminal Server, chuột đôi vào fSingleSessionPerUser, tại value data thay đổi từ giá trị 1 (1 user) sang giá trị 0 (2 user)

 


Kết nối được tối đa 2 connection

2. Cho nhiều user truy cập đồng thời
Cài đặt Role Remote Desktop Services, mặc định sẽ cho dùng miễn phí 120 ngày

Cài đặt Remote Desktop Session Host

Chọn chứng thực bằng NLA hoặc không

Chọn Configure later
 


Chọn User, nhóm User được cho phép truy cập Remote Desktop đến Server

Chọn Next
 


Cài đặt Role. Sau khi quá trình cài đặt hoàn thành, Restart lại Server

 


Kết nối được nhiều connection
 


Chú ý: Sau khi hạn dùng 120 ngày kết thúc, thực hiện xóa registry lưu thời gian sử dụng Remote Desktop Services để renew thời gian sử dụng RDS


Vào KEY_LOCAL_MACHINE\SYSTEM\ CurrentControlSet\Control\ Terminal Server\RCM\GracePeriod, xóa L$RTMTIMEBOMB


Chọn Yes để xác nhận


Nếu không có quyền xóa registry, thông báo lỗi sẽ xuất hiện


Lúc này, cần cho phép quyền xóa registry này cho user bằng cách, chuột phải
GracePeriod chọn Permission, add thêm user Administrator vào mục Group or user name, chọn quyền Full Control


Sau đó thực hiện xóa L$RTMTIMEBOMB

Sau đó restart lại dịch vụ RDS, chúng ta sẽ có lại 120 ngày sử dụng RDS multiuser


Kiểm tra
Chỉnh lại thời gian của hệ thống quá 120 ngày

Tắt chế độ đồng bộ thời gian từ Internet


Remote Desktop không thực hiện được do quá ngày sử dụng


Đăng nhập local vào máy server, xóa registry như đã hướng dẫn ở trên

Vào
Services của Windows


Stop các Services Remote Desktop đang chạy như hình vẽ, sau đó Start các Services này lên lại



Remote thành công vào server, có thông báo gia hạn số ngày sử dụng Remote Desktop Services



Những thay đổi của Linux 6 và Linux 7 Linux 8

 

Những thay đổi của Linux 6 và Linux 7 Linux 8

Khi nâng cấp từ CentOS/RHEL 6 lên CentOS/RHEL 7 và sau đó là CentOS/RHEL 8, có nhiều thay đổi lớn về cách quản lý và các lệnh hệ thống do sự thay đổi của các thành phần hệ điều hành. Dưới đây là những thay đổi chính trong các phiên bản này:

1. Quản lý dịch vụ - Từ init sang systemd

  • CentOS/RHEL 6 sử dụng SysV init để quản lý dịch vụ.

  • CentOS/RHEL 7 và 8 sử dụng systemd.

    CentOS/RHEL 6CentOS/RHEL 7 và 8Chức năng
    service <tên dịch vụ> startsystemctl start <tên dịch vụ>Khởi động một dịch vụ
    service <tên dịch vụ> stopsystemctl stop <tên dịch vụ>Dừng một dịch vụ
    service <tên dịch vụ> statussystemctl status <tên dịch vụ>Kiểm tra trạng thái dịch vụ
    chkconfig <tên dịch vụ> on/offsystemctl enable/disable <tên dịch vụ>Bật/tắt dịch vụ khi khởi động hệ thống
    chkconfig --listsystemctl list-unit-filesLiệt kê tất cả các dịch vụ

2. Cấu hình mạng

  • CentOS/RHEL 6 sử dụng ifconfig và cấu hình trong /etc/sysconfig/network-scripts/.

  • CentOS/RHEL 7 chuyển sang dùng ipNetworkManager.

  • CentOS/RHEL 8 dùng NetworkManager là mặc định cho tất cả cấu hình mạng.

    CentOS/RHEL 6CentOS/RHEL 7 và 8Chức năng
    ifconfigip addrHiển thị thông tin địa chỉ IP
    ifconfig <tên thiết bị> up/downip link set <tên thiết bị> up/downKích hoạt/vô hiệu hóa thiết bị
    routeip routeQuản lý bảng định tuyến
    netstat -tulnpss -tulnpLiệt kê các kết nối đang lắng nghe
    service network restartsystemctl restart NetworkManagerKhởi động lại dịch vụ mạng

3. Quản lý tường lửa

  • CentOS/RHEL 6 sử dụng iptables.

  • CentOS/RHEL 7 và 8 chuyển sang firewalld.

    CentOS/RHEL 6 (iptables)CentOS/RHEL 7 và 8 (firewalld)Chức năng
    service iptables start/stopsystemctl start/stop firewalldBật/tắt tường lửa
    iptables -Lfirewall-cmd --list-allLiệt kê tất cả các quy tắc
    iptables -A INPUT -p tcp --dport 80 -j ACCEPTfirewall-cmd --permanent --add-port=80/tcpMở cổng 80
    N/Afirewall-cmd --reloadÁp dụng lại cấu hình tường lửa

4. Quản lý thời gian

  • CentOS/RHEL 6 dùng ntp.

  • CentOS/RHEL 7 và 8 chuyển sang chrony.

    CentOS/RHEL 6 (NTP)CentOS/RHEL 7 và 8 (Chrony)Chức năng
    service ntpd startsystemctl start chronydKhởi động đồng bộ thời gian
    ntpdate <server>chronyc sourcesKiểm tra nguồn đồng bộ
    chkconfig ntpd onsystemctl enable chronydBật dịch vụ đồng bộ khi khởi động

5. Gói cài đặt

  • CentOS/RHEL 6 và 7 sử dụng YUM.

  • CentOS/RHEL 8 giới thiệu DNF thay cho YUM, mặc dù lệnh yum vẫn tồn tại như một alias của DNF.

    CentOS/RHEL 6 và 7 (YUM)CentOS/RHEL 8 (DNF)Chức năng
    yum install <package>dnf install <package>Cài đặt gói phần mềm
    yum updatednf updateCập nhật hệ thống
    yum remove <package>dnf remove <package>Gỡ cài đặt gói

6. Filesystem Layout

  • CentOS/RHEL 7 và 8 sử dụng xfs làm hệ thống file mặc định thay cho ext4 trên CentOS/RHEL 6.
  • CentOS/RHEL 8 hỗ trợ thêm StratisVDO (Virtual Data Optimizer) để quản lý lưu trữ tiên tiến hơn, bao gồm snapshot và deduplication.

7. LVM (Logical Volume Manager)

  • Các lệnh LVM vẫn không thay đổi giữa các phiên bản.
  • Tuy nhiên, trong CentOS/RHEL 8, có thể sử dụng Stratis như một hệ thống quản lý volume hiện đại hơn so với LVM truyền thống.

8. Kernel Live Patching

  • CentOS/RHEL 6 và 7 không hỗ trợ kernel live patching mặc định.
  • CentOS/RHEL 8 có tính năng kpatch để cập nhật kernel mà không cần khởi động lại, phù hợp cho môi trường cần tính sẵn sàng cao.

9. Podman thay thế Docker

  • CentOS/RHEL 7 hỗ trợ Docker làm công cụ container chính.

  • CentOS/RHEL 8 thay thế Docker bằng Podman cho quản lý container mà không cần daemon, an toàn hơn và dễ tích hợp với môi trường hệ thống.

    CentOS/RHEL 7 (Docker)CentOS/RHEL 8 (Podman)Chức năng
    docker run <container>podman run <container>Chạy một container
    docker pspodman psLiệt kê container đang chạy
    docker stop <container>podman stop <container>Dừng container

10. Các lệnh tiện ích khác

  • Một số lệnh tiện ích khác cũng có sự thay đổi, đặc biệt liên quan đến cấu trúc và công cụ của hệ thống.

    CentOS/RHEL 6CentOS/RHEL 7CentOS/RHEL 8Chức năng
    df -hdf -hdf -hXem dung lượng ổ đĩa
    crontab -ecrontab -ecrontab -eChỉnh sửa cron job
    shutdown -h nowsystemctl poweroffsystemctl poweroffTắt máy
    rebootsystemctl rebootsystemctl rebootKhởi động lại hệ thống

Tổng kết

  • Từ CentOS/RHEL 6 đến 8, nhiều lệnh quản lý đã chuyển đổi để phù hợp với systemd và các công cụ mới như firewalld, NetworkManager, DNF và Podman.
  • Các thay đổi này nhằm cải thiện tính linh hoạt, bảo mật và quản lý hệ thống, nhưng cũng đòi hỏi người quản trị cần làm quen với các công cụ và cú pháp mới.

Thứ Hai, 18 tháng 11, 2024

Giảm kích thước file log LDF

 USE [TênCơSởDữLiệu] GO DBCC SHRINKFILE (N'TênLogicCủaFileLog', 100); -- 100 là kích thước mong muốn sau khi thu nhỏ (MB) GO


---------------------------------------------------

Hướng dẫn chính xác sử dụng DBCC SHRINKFILE

  1. Xác định tên logic của file cần thu nhỏ Để xác định tên logic (logical name) của file log (LDF) trong cơ sở dữ liệu, bạn có thể sử dụng câu lệnh SQL sau:USE [TênCơSởDữLiệu]

    GO

    SELECT name AS LogicalName, physical_name AS PhysicalName, type_desc

    FROM sys.database_files;

    GO

  2. Sử dụng tên logic với DBCC SHRINKFILE

    Sau khi biết tên logic của file log cần thu nhỏ, bạn có thể sử dụng lệnh DBCC SHRINKFILE với tên logic đó:

USE [TênCơSởDữLiệu]
GO
DBCC SHRINKFILE (N'TênLogicCủaFileLog', 100); -- 100 là kích thước mong muốn sau khi thu nhỏ (MB)
GO
-------------------------------------------------
USE [TênCơSởDữLiệu]
GO
DBCC SHRINKFILE (N'TênLogicCủaFileLog', 100); -- 100 là kích thước mong muốn sau khi thu nhỏ (MB)
GO
----------------------------------------------------
Ví dụ: Nếu tên logic của file log là StockBoard_Hist_1_log, lệnh sẽ như sau:
USE [TênCơSởDữLiệu]
GO
DBCC SHRINKFILE (N'StockBoard_Hist_1_log', 100);
GO

Chạy lại lệnh và kiểm tra kết quả

Sau khi chạy lệnh, hãy kiểm tra kết quả thu nhỏ bằng cách sử dụng:

DBCC SQLPERF(LOGSPACE);

GO

-----------------------------------------

Tóm lại

  • Tên file logic cần sử dụng thay vì đường dẫn đầy đủ.
  • Kiểm tra tên logic của file bằng cách dùng sys.database_files trước khi sử dụng DBCC SHRINKFILE.

Thứ Năm, 31 tháng 10, 2024

Fix lỗi remote desktop

 

https://learn.microsoft.com/en-us/troubleshoot/windows-server/remote/rdp-error-general-troubleshooting#check-whether-a-group-policy-object-gpo-is-blocking-rdp-on-a-local-computer




Windows Components/Remote Desktop Services/Remote Desktop Session Host/Connections
Allow users to connect remotely by using Remote Desktop Services      Enabled

Check the status of the RDP protocol on a local computer

Check the status of the RDP protocol on a remote computer

To check and change the status of the RDP protocol on a remote computer, use a network registry connection:

  1. First, go to the Start menu, then select Run. In the text box that appears, enter regedt32.

  2. In the Registry Editor, select File, then select Connect Network Registry.

  3. In the Select Computer dialog box, enter the name of the remote computer, select Check Names, and then select OK.

  4. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server and to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services.

    Screenshot of the Registry Editor showing the fDenyTSConnections entry.

    • If the value of the fDenyTSConnections key is 0, then RDP is enabled.
    • If the value of the fDenyTSConnections key is 1, then RDP is disabled.
  5. To enable RDP, change the value of fDenyTSConnections from 1 to 0

Check whether a Group Policy Object (GPO) is blocking RDP on a local computer

gpresult /H c:\gpresult.html

Check whether a GPO is blocking RDP on a remote computer

gpresult /S <computer name> /H c:\gpresult-<computer name>.html

Modifying a blocking GPO

To modify the blocking policy, use one of the following methods:

  • In GPE, access the appropriate level of GPO (such as local or domain), and navigate to Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections > Allow users to connect remotely by using Remote Desktop Services.
    1. Set the policy to either Enabled or Not configured.
    2. On the affected computers, open a command prompt window as an administrator, and run the gpupdate /force command.
  • In GPM, navigate to the organizational unit (OU) in which the blocking policy is applied to the affected computers and delete the policy from the OU.

Check the status of the RDP services

On both the local (client) computer and the remote (target) computer, the following services should be running:

  • Remote Desktop Services (TermService)
  • Remote Desktop Services UserMode Port Redirector (UmRdpService)

Check that the RDP listener is functioning

To connect to a remote computer, run the following cmdlet:

PowerShell
  • Enter-PSSession -ComputerName <computer name>
    
  • Enter qwinsta.

    Screenshot of the qwinsta command that lists the processes listening on the computer's ports.

  • If the list includes rdp-tcp with a status of Listen, the RDP listener is working. Proceed to Check the RDP listener port. Otherwise, continue at step 4.

  • Export the RDP listener configuration from a working computer.

    1. Sign in to a computer that has the same operating system version as the affected computer has, and access that computer's registry (for example, by using Registry Editor).

    2. Navigate to the following registry entry:

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

    3. Export the entry to a .reg file. For example, in Registry Editor, right-click the entry, select Export, and then enter a filename for the exported settings.

    4. Copy the exported .reg file to the affected computer.

  • To import the RDP listener configuration, open a PowerShell window that has administrative permissions on the affected computer (or open the PowerShell window and connect to the affected computer remotely).

    1. To back up the existing registry entry, enter the following cmdlet:

      PowerShell
  • cmd /c 'reg export "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-tcp" C:\Rdp-tcp-backup.reg'
    
  • To remove the existing registry entry, enter the following cmdlets:

    PowerShell
  • Remove-Item -path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-tcp' -Recurse -Force
    
  • To import the new registry entry and then restart the service, enter the following cmdlets:

    PowerShell
    1. cmd /c 'regedit /s c:\<filename>.reg'
      Restart-Service TermService -Force
      

      Replace <filename> with the name of the exported .reg file.

    2. Test the configuration by trying the remote desktop connection again. If you still can't connect, restart the affected computer.

  • If you still can't connect, check the status of the RDP self-signed certificate.