Tải bản đầy đủ (.ppt) (76 trang)

The Basic Commands On 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 (3.8 MB, 76 trang )

2nd Chapter

THE BASIC COMMANDS ON
LINUX

Updated 25.08.2008

Computer Sciences Div. @ 2008

1


Contents
Tổng quan về lệnh trên Linux
Các lệnh thao tác với ổ đĩa
Các lệnh thao tác với thư mục
Các lệnh thao tác với tập tin
Các lệnh quản lý tài khoản người dùng trên hệ
thống tập tin
Các lệnh thao tác với hệ thống

Updated 25.08.20

Computer Sciences Div.

2


Overview of commands on Linux
Command Line Interface in Linux called CLI (Command
Line Interface).


Command syntax:
Command names [-option] [argument 1] [argument 2] ....
[argument n]
Examples:
mount -t ntfs /dev/sda1 /mnt/sda1
Với:






Tên lệnh: mount
Tuỳ chọn: -t ntfs
Đối số 1: /dev/sda1
Đối số 2: /mnt/sda1

Updated 25.08.20

Computer Sciences Div.

3


Overview of commands on Linux
Some errors often appear when you type commands
on Linux:
Command does not exist or can not be found:

Updated 25.08.20


Computer Sciences Div.

4


Overview of commands on Linux
Some errors often appear when you type commands
on Linux:
Type the command syntax incorrectly:

Updated 25.08.20

Computer Sciences Div.

5


Command operation with drives: :
List and partition drives
Check capacity of drives
Attached partitions
Cancel attach partitions

Updated 25.08.20

Computer Sciences Div.

6



List and partition drives
Command name: fdisk
Function: Liệt kê các phân vùng ổ đĩa trên Linux
Syntax : fdisk [-l]
Example:

Updated 25.08.20

Computer Sciences Div.

7


Check capacity of drives
Command name: df (disk free)
Function: Check capacity of drives.
Syntax: df [-a]
Example:

Updated 25.08.20

Computer Sciences Div.

8


Attached partitions
Command name: mount
Function: Thực hiện gắn kết phân vùng vào FileSystem.

Syntax: mount -t type dev dir
Type: Loại phân vùng mà ta muốn gắn kết vào hệ thống
Dev: Tên phân vùng hiện có trên hệ thống. Dùng lệnh fdisk để xem
hệ thống máy tính đang dùng có những phân vùng nào
Dir: Thư mục được chỉ định để gắn kết vào

Example:

Updated 25.08.20

Computer Sciences Div.

9


Cancel attached partitions
Command name: umount (unmount)
Function: Hủy bỏ gắn kết phân vùng.
Syntax: Umount dir
Dir: Thư mục được chỉ định để gắn kết vào.

Example:

Updated 25.08.20

Computer Sciences Div.

10



Command operation with folder
Change the current folder
View/ check the current working folder
Create new folder
Display the structure of folder tree
List folder contents
Delete folder
Rename folder

Updated 25.08.20

Computer Sciences Div.

11


Change the current folder
Command name: cd
Function: Chuyển đổi thư mục hiện hành.
Syntax: cd <Đường dẫn thư mục mới>
Example:

Updated 25.08.20

Computer Sciences Div.

12


Change the current folder

Note: If cd command does not contain path> , the program will move to a separate folder
from any folder.

Updated 25.08.20

Computer Sciences Div.

13


Change the current folder
Note: String ".." and "." represent for Parent
folder and current one.

Updated 25.08.20

Computer Sciences Div.

14


View/ check the current working folder
Command name: pwd
Function: Xem thư mục và đường dẫn của thư mục
làm việc hiện hành.
Syntax: pwd
Example:
Thư mục hiện hành: khmt
Đường dẫn hiện hành: /home/giaovien/khmt


Updated 25.08.20

Computer Sciences Div.

15


Create new folder
Command name: mkdir
Function: Tạo mới thư mục.
Syntax: mkdir <Tên thư mục mới cần tạo>
Example:
Tạo thư mục viethan trong thư mục home.
Chuyển đến thư mục hiện hành viethan.
Tạo trong thư mục viethan các thư mục con: khmt, laptrinh và
hethongtt.

Updated 25.08.20

Computer Sciences Div.

16


Display the structure of folder tree
Command name: tree
Funstion: Hiển thị cấu trúc cây thư mục.
Syntax: tree <tham số>
Tham số -d: Chỉ hiển thị thư mục.

Tham số -f: Hiển thị đầy đủ đường dẫn các tập tin.

Updated 25.08.20

Computer Sciences Div.

17


List folder contents
Command name: ls
Funtion: Hiển thị nội dung trong thư mục.
Syntax: ls [- Tùy chọn] [Thư mục]
[- Tùy chọn]:
-a: Liệt kê tất cả các thư mục và tập tin kể cả các thư mục và tập
tin có thuộc tính ẩn.
-R: Liệt kê tất cả các thư mục và tập tin trong các thư mục con.
-l: Liệt kê thuộc tính các tập tin.
[Thư mục]: Là thư mục cần liệt kê nội dung

Updated 25.08.20

Computer Sciences Div.

18


Delete folder
Command name: rmdir
Function: Delete folder.

Syntax: rmdir <Tên thư mục>
Example:

Updated 25.08.20

Computer Sciences Div.

19


Remove folder
Notes:
Delete only empty folders
Not delete the current folders
Many empty folders can be deleted at the same time by showing the
paths to those folders are separated by spaces

Updated 25.08.20

Computer Sciences Div.

20


Rename folder
Command name: mv
Function: Đổi tên thư mục.
Syntax: mv <Tên thư mục cũ> <Tên thư mục mới>
Example:


Updated 25.08.20

Computer Sciences Div.

21


Copy folder
Command name: cp
Function: Sao chép thư mục.
Syntax: cp <Thư mục nguồn> <Thư mục đích>
Example:

Updated 25.08.20

Computer Sciences Div.

22


Command operation with folders
Tạo tập tin
Sao chép tập tin
Di chuyển tập tin
Tạo liên kết với tập tin
Tìm kiếm tập tin
Xóa tập tin
Hiển thị nội dung tập tin
Nối các tập tin
Nén và giải nén tập tin

Xem hướng dẫn sử dụng lệnh
Xuất nội dung thông báo
Xem loại tập tin
Đếm số dòng, số từ và ký tự
Chia một tập tin lớn thành nhiều tập tin nhỏ
Updated 25.08.20

Computer Sciences Div.

23


Creating files
Command name: vi hoặc gedit (graphic edit)
Function: Tạo mới tập tin.
Syntax: vi <Tên tập tin> hoặc gedit <Tên tập tin>

Updated 25.08.20

Computer Sciences Div.

24


Creating files
Create a file with vi command
Vi là trình soạn thảo cơ bản của các hệ thống Linux
Cú pháp để soạn thảo một tập tin như sau:
#vi <Tên tập tin>
Ví dụ: vi test


Khi sử dụng vi, ta có thể chọn một trong hai chế độ thao
tác: chế độ câu lệnh (command mode) và chế độ soạn
thảo (editor mode).
Nếu ta đang ở chế độ soạn thảo, nhấn phím ESC + lệnh
sẽ chuyển sang chế độ lệnh. Ngược lại, nếu ta đang ở chế
độ lệnh thì nhấn phím lệnh để chuyển sang chế độ soạn
thảo.
Updated 25.08.20

Computer Sciences Div.

25


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×