Introduction to Linux Operation and Maintenance Course 03-02 (Browsing, Management and Maintenance of Directory Files (2))

Please indicate the source " Old Boy IT Education "
Source URL: http://www.sholdboyedu.com/new/324.html

This chapter mainly introduces the browsing, management and maintenance of catalog files, and introduces the operation logic and methods of use. Those who need to learn should pay attention to the collection~~~

1. Use pwd and cd commands to determine and switch directories (see linux system management P43-P46 ​​for details)

1) Master the function of the pwd command: determine the current working directory

2) Master the function of the cd command: switch the current directory

3) Master the "cd .." command: enter the upper level directory

4) Master the "cd ~" command: switch to the user's home directory

5) Master the "cd" command: same as cd ~, you can also switch to the user's home directory

6) Master the "cd -" command: switch to the user's previous working directory

7) Master the "cd directory name" command: switch to the specified directory.

a) For example: the command to switch to the /home/dog directory is: cd /home/dog

2. Use the ls command to list the contents of the directory (see linux system management P47-P50 for details)

1) Master the function of the ls command: list the contents of the current directory (default is the current directory) or the specified directory

2) Master the ls -a command: List all files in the directory, including hidden files beginning with "."

a) For example: List all files in the /home/dog directory, including the command to hide files: ls -a /home/dog

3) Understand the ls -all command: the same as ls -a

4) Master the ls -l command: list the detailed information of each file in a certain directory

For example: a command to list the details of all non-hidden files in the /home/dog directory:

a) ls –l /home/dog

3. Use the cp command to copy files and directories (see linux system management P50 for details)

1) Master the function of the cp command: copy files (can be multiple) into a specified destination file or copy to a specified destination directory.

2) Master the common options of the cp command:

Cp source file target file

a) -r (recursive, recursive): Copy directories recursively. When copying a directory, copy all the contents of the directory, including all the contents of the subdirectories.

i) For example: Copy all the contents in the /home/dog directory. The command in the directory /home/cat is:

cp –r /home/dog /home/cat

b) -f (force, compulsory): when the target file already exists, do not ask to directly force the copy

4. Use the mv command to move and modify file and directory names (see linux system management P54 for details)

1) Master the function of the mv command: you can move files and directories between different directories, and you can also rename files and directories.

2) Master the usage examples of mv command:

a) Examples of moving files and directories:

The command to move the lists file in the current directory to its subdirectory babydog:

mv lists babydog

b) Examples of renaming files and directories:

The command to change the name of the bigdog directory to babydog:

mv bigdog babydog

5. Use the mkdir command to create a directory (see linux system management P55 for details)

1) Master the function of the mkdir command: create a new directory

2) Grasp the usage example of mkdir command:

Command to create the directory daddog: mkdir dadgog

6. Use the touch command to create a file (see linux system management P56 for details)

1) Master the function of the touch command: you can create an empty file, or you can create multiple files at the same time.

2) Master the usage example of touch command:

The command to create a file named babydog1 in the current directory:

touch babydog1

7. Use the rm command to delete the file (see linux system management P57 for details)

1) Master the function of the rm command: permanently delete files or directories in the file system.

2) Master the commonly used options of the rm command:

a) -r (recursive, recursive): delete directories recursively. When deleting a directory, delete all the contents in the directory, including all the contents in the sub-directories.

b) -f (force): The system does not ask but deletes it forcefully, that is, delete the original file directly.

3) Master the usage example of rm command:

The command to delete the babydog1 file in the current directory: rm babydog1

8. 使用rmdir或rm –r命令删除目录(详见linux系统管理P59)

1) 掌握rmdir命令的功能:删除空目录。

2) 掌握rmdir命令的用法举例:

删除空目录 mumdog/girldog/babydog的命令:

rmdir mumdog/girldog/babydog

3) 掌握rm –r命令的功能:删除包含文件和子目录的目录。

4) 掌握rm –r命令的用法举例:

删除非空目录mumdog的命令:

rm –r mumdog

9. 使用cat命令浏览正文文件的内容(详见linux系统管理P73)

5) 掌握cat命令的功能:将一个或多个文件的内容显示在屏幕上,该命令会不停的以只读的方式显示整个文件的内容。

6) 掌握cat命令的用法举例:

a) 浏览game.txt文件中的全部内容的命令:

cat game.txt

10. 使用head命令浏览文件中的内容(详见linux系统管理P75)

1) 掌握head命令的功能:默认将显示一个文件的前10行。

2) 掌握head命令的常用选项:

-n 改变显示的行数

3) 掌握head命令的用法举例:

a) 查看/etc/passwd文件中前10行的详细信息的命令:

head /etc/passwd

b) 查看/etc/passwd文件中前5行的详细信息的命令:

head –n 5 /etc/passwd

11. 使用tail命令浏览文件中的内容(详见linux系统管理P76)

1) 掌握tail命令的功能:默认显示文件最后10行的内容。

2) 掌握tail命令的常用选项:

-n 显示从文件末尾算起的n行

3) 掌握tail命令的用法举例:

a) 查看/etc/passwd文件中最后10行的详细信息的命令:

tail /etc/passwd

b) 查看/etc/passwd文件中最后5行的详细信息的命令:

tail –n 5 /etc/passwd

12. 使用more命令浏览文件(详见linux系统管理P78)

1) 掌握more命令的功能:使用more命令之后,每次在屏幕上显示一屏(一页)的文件内容,并且在屏幕的尾部将会出现“—More--(n%)”的信息,其中,n%是已经显示文件内容的百分比。

2) 灵活应用more命令

a) 分页浏览learning.txt文件内容的命令:

more learning.txt

13. 课后作业(用时60分钟)

1) 开启Linux操作系统,要求以root用户登录GNOME图形界面,右击桌面打开终端

2) 使用命令切换到root用户的家目录

3) 确定当前用户所在的工作目录

4) 创建目录wg

5) 使用绝对路径的方法在wg目录下新建文件a.txt

6) 进入wg目录

7) 使用相对路径的方法在当前目录下新建wg01目录和b.txt文件

8) 以长列表格式列出当前目录下的内容

9) 删除空目录wg01

10) 进入上一级工作目录

11) 强制删除非空目录wg

12) 复制/etc/passwd到当前目录,名为file1

13) 不停的以只读的方式查看file1文件的内容

14) 查看file1文件的前3行内容

15) 查看file1文件的后2行内容

16) 以百分比的方式分页查看file1文件的内容

17) 以上下翻页的方法分页查看file1文件的内容


Guess you like

Origin blog.51cto.com/15064427/2664562