Article directory
- 1 Introduction
- 2. Commonly used basic commands
- 3. Directory and file management
-
- 3.1 List directory ls (List Files)
- 3.2 Display the current directory pwd (Print Working Directory)
- 3.3 Create a new directory mkdir (Making Directory)
- 3.4 Delete the specified empty directory rmdir (Remove Directory)
- 3.5 Change directory cd (Change Directory)
- 3.6 Copy files or directories cp (Copy File)
- 3.8 Remove files or directories rm (Remove)
- 3.8 Move files or directories, or change the name mv (Move file)
- 4. Text editing related
- 5.Others
- reference
- Daily ancient poetry
1 Introduction
This chapter continues Linux learning and records some commonly used Linux commands. It is mainly divided into the following parts: the first part includes basic commands for some commonly used commands, and the second part includes commands related to directory and file management. Continually updated…
2. Commonly used basic commands
2.1 Restart and shutdown commands
Restarting and shutting down require system administrator user rights.
1) Restart
init6 or reboot
2) Shut down
init 0 or halt
If you do not execute the shutdown command, forcibly power off or close the local virtual machine window, it may cause damage to the Linux system files, and in severe cases, the system may not work properly.
2.2 Clear screen
Be clear about what's on the screen.
clear
2.3 Check the server IP address
ip addr
2.4 Copy and paste operation
1) Copy
Ctrl+Insert
2) Paste
Shift+Insert
The copy and paste here also applies under Windows (generally commonly used under Windows, Ctrl+c/Ctrl+v). Under the Linux operating system, you can use Ctrl+c to terminate the command without deleting and retyping one by one. If you want to type the following command again, just press Ctrl+c.
2.5 Help document viewing command
XX --help XX is the command that needs to be viewed, so that you can view its usage and function. For example, ls --help
or use: man XX
3. Directory and file management
The file system is like a tree, the trunk is the / (root) directory, the branches are subdirectories, there are branches after the branches (subdirectories and subdirectories), the branches are leaves at the end, and the files are at the end of the directory.
1) The full path file name includes the complete directory name and file name, that is, /usr/etc/reademe.txt. There is also another name for " absolute path file name ". reademe.txt is the file name and it is in the /usr/etc directory.
2) The absolute paths of directories and files are calculated from the root (/) and there will be no ambiguity at any time.
3) After logging in to Linux, you must be in a certain directory in the directory tree. This directory is called the current working directory, or the current directory for short . 4) The relative paths
of directories and files are calculated from the current working directory. If the current working directory is /usr, etc/readme/txt is equivalent to /usr/etc/reademe.txt; if the current working directory is /usr/etc, readme.txt is equivalent to /usr/etc/reademe.txt. 5) One dot represents the current working directory, and two dots represent the upper-level directory of the current working directory.
3.1 List directory ls (List Files)
In Linux systems, the ls command may be the most commonly run, which means listing the file names in the current directory. Commonly used options and parameters are:
-a: All files, listed together with hidden files (files beginning with .) (commonly used)
-d: List only the directory itself, not the file data in the directory (commonly used)
-l: Long data string List, including file attributes, permissions and other data; (commonly used)
-la: List all files in the directory (including attributes and hidden files)
3.2 Display the current directory pwd (Print Working Directory)
pwd is the abbreviation of Print Working Directory, which is the command to display the current directory. Selection and parameters:
-p: Show actual work instead of using link paths
3.3 Create a new directory mkdir (Making Directory)
mkdir (make directory) is the command to create a new directory. Selection and parameters:
-p: Create the required directory (including the upper-level directory) recursively.
-m: Permissions of the configuration file, otherwise configure according to the default permissions.
3.4 Delete the specified empty directory rmdir (Remove Directory)
rmdri deletes the specified empty directory. Common parameters: -p Starting from this directory, delete multiple levels of empty directories at one time.
3.5 Change directory cd (Change Directory)
cd is the abbreviation of Change Directory, which is the command used to change the working directory.
cd . . means return to the directory one level above the current directory
3.6 Copy files or directories cp (Copy File)
cp means copying files or directories.
Usage: cp [option] source file target file options include:
-r: recursively copy all contents in the directory and its subdirectories
-l: create a hard link link file instead of copying the file itself
-i: if the target file If it already exists, it will be asked first when overwriting
3.8 Remove files or directories rm (Remove)
rm removes files or directories.
Usage: rm [options] file or directory
-f: Force delete, ignore files that do not exist, do not prompt for confirmation
-i: Prompt for confirmation before each deletion
-r: Recursively delete directories and their contents
-d: Delete empty directories
3.8 Move files or directories, or change the name mv (Move file)
mv moves files or directories.
Usage: mv [options] source file target file
-f: force means to force, if the target file already exists, it will not be asked but directly overwritten
-i: if the target file already exists, it will be asked whether to overwrite
-u: only in The move operation is performed when the source file is newer than the target file, or the target file does not exist.
4. Text editing related
5.Others
reference
Copyright statement: This article is an original article of the blogger, following the CC 4.0 BY-SA copyright agreement, reference link:
1. Explanation of experimental exercises of common Linux commands
2. Rookie tutorial - Linux
3. Common commands of Linux
Daily ancient poetry
——2023.04.03
——2023.04.06