LAB2OSG SE180556 TranQuangHuy

You might also like

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

Part 1

Cú pháp: man [tên_lệnh]


Mục đích: Hiển thị tài liệu hướng dẫn cho lệnh chỉ định
Example ;
1. View the manual page for the man command
man man

Man -f kill
man ls

Cú pháp:
bg [job_spec]
fg [job_spec]
Mục đích:
bg: Tiếp tục chạy một công việc bị dừng (trong nền).
fg: Đưa một công việc bị dừng trở lại nền trước.

1.3. who
Cú pháp: who
Mục đích: Hiển thị danh sách người dùng hiện đang đăng nhập vào hệ
thống.
Ví dụ:
1.4. chown, chgrp, chmod
Cú pháp:
chown [người_dùng] [tệp/tập_tin]
chgrp [nhóm] [tệp/tập_tin]
chmod [chế_độ] [tệp/tập_tin]
Mục đích:
chown: Thay đổi chủ sở hữu của tệp hoặc thư mục.

chgrp: Thay đổi nhóm sở hữu của tệp hoặc thư mục.
chmod: Thay đổi quyền truy cập của tệp hoặc thư mục.
Ví dụ:
1.5. date
Cú pháp: date [tùy_chọn]
Mục đích: Hiển thị hoặc đặt thời gian và ngày tháng hệ thống.
Ví dụ:
su, top, kill, jobs
Cú pháp:
su [người_dùng]
top

kill [PID]
Jobs

Mục đích:
su: Đổi sang người dùng khác.
top: Hiển thị thông tin hệ thống theo thời gian thực.
kill: Kết thúc một tiến trình.
jobs: Hiển thị danh sách các công việc đang chạy hoặc bị dừng trong nền.
Part 2

The grep command is used to print out the line in the text file that
matches a specified
pattern.
In this context, the file and the pattern are thoca.txt and “thai son”. After
entering the
grep command, it processed the text in thoca.txt line by line to find the
line that have
the string “thai son” in it.

Duong Tan Thinh SE160970 | 15


Finally, it printed out the result, which is the line “cong cha nhu nui thai
son” with
“thai son” in red.

Part 3
The system() function in C is used to pass the commands that can be
executed in the
command processor or the terminal of the operating system. Then, it
executes the
command and finally returns the status of the command, or -1 if there is
an error.

In this case, we passed the man ls command in the system() function.


Then, the
computer executed the command and printed out the manual page of ls
command in
the output. After that, the system() function returned the status of the
executed
command, which was 0 for success. Next, the ret variable stored the
return value of
the system() function. Finally, the program returned the value of variable
ret, which
was 0.

The program was executed successfully and exited


The system() function in C is used to pass the commands that can be
executed in the
command processor or the terminal of the operating system. Then, it
executes the
command and finally returns the status of the command, or -1 if there is
an error.

In this case, we passed the man ls command in the system() function.


Then, the
computer executed the command and printed out the manual page of ls
command in
the output. After that, the system() function returned the status of the
executed
command, which was 0 for success. Next, the ret variable stored the
return value of
the system() function. Finally, the program returned the value of variable
ret, which
was 0.

The program was executed successfully and exited


The system() function in C is used to pass the commands that can be
executed in the
command processor or the terminal of the operating system. Then, it
executes the
command and finally returns the status of the command, or -1 if there is
an error.

In this case, we passed the man ls command in the system() function.


Then, the
computer executed the command and printed out the manual page of ls
command in
the output. After that, the system() function returned the status of the
executed
command, which was 0 for success. Next, the ret variable stored the
return value of
the system() function. Finally, the program returned the value of variable
ret, which
was 0.

The program was executed successfully and exited

You might also like