Article directory
1.xshell account quick login
When logging in previously Xshell
, the following commands will be used:
ssh 你的用户名@你购买的云服务器地址
You have to enter it like this every time you log in, and sometimes you forget it, which will be very troublesome. Next, we will set it up a little to make our login more convenient.
Step ①:xshell
After opening, click the "New" symbol in the upper left corner.
Step ②: In the pop-up "New Properties Dialog Box", you can fill in the following information in the "Name", "Host" and "Description" boxes, and finally click OK Step ③:
When you see your new creation in "All Sessions" on the left The session attribute name, and the following window will pop up when logging in, click to link.
Step ④: Enter the user name that needs to be logged in.
Step ⑤: After entering the password for the login account, click "OK".
Step ⑥: When you see the following interface, the account login is successful.
2. Instruction learning
mkdir command
Syntax:mkdir
[选项]
dirname
...
Function:“dirname”
Create a directory named in the current directory
. Common options:
-p (即--parents)
can be a path name. At this time, if some directories in the path do not exist yet, after adding this option, the system will automatically create those directories that do not yet exist, that is, multiple directories can be created at one time.
Example:
mkdir
You can create a directory. ls -l
When we use the command to view the properties of the files in the current directory (this command will be explained later, don’t worry, friends), you can see a d
letter at the front, indicating that this is a directory!
If we need to create a directory in a directory, as usual we need to use the cd command (I will explain it later~) to enter the directory before creating it. Now we can use the following command to create it
# mkdir -p test/test1/test2...//递归建立多个目录
tree command
tree 目录名//以该目录为根目录,然后以树状的形式显示该目录下的文件(目录)
You need to use the following command to install the tree command
# yum install -y tree//需要使用root账户才能创建
The result of the demonstration is:
touch command
Syntax :touch [选项] 文件
Function: touch
The command parameters can change the date and time of a document or directory, including access time and change time, or create a new file that does not exist.
Common options:
-a
or --time=atime
or --time=access
or --time=use
change only the access time.
-c
or --no-create
no documentation is created.
-d
Use the specified date and time instead of the current time.
-f
This parameter will be ignored and will not be processed. It is only responsible for solving the compatibility issue of the BSD version of the touch command.
-m
or --time=mtime
or --time=modify
change only the change time.
-r
Set the date and time of the specified document or directory to be the same as the date and time of the reference document or directory.
-t
Use the specified date and time instead of the current time.
Example:
mkdir
You can create an ordinary file. ls -l
When we use the command to view the properties of the file (directory) in the current directory, we can see a -
letter at the front, indicating that this is an ordinary file!
ls command
Syntax: ls [选项][目录或文件]
Function: For a directory, this command lists all subdirectories and files in the directory. For files, the file name is listed along with other information.
Common options:
-a
List all files in the directory, including implicit files starting with .
-d
Display the directory as a file, rather than displaying the files below it. For example: ls –d
specify the directory
-i
to output the index information of the i node of the file. For example, ls –ai
specifying a file
-k
indicates the size of the file in k bytes. ls –alk
Specify file
-l
Lists details of file attributes.
-n
Use numbers UID
instead GID
of names. (Introduction UID
, GID
)
-F
Attach a character after each file name to indicate the type of the file. "*" represents an executable ordinary file; represents a “/”
directory; “@”
represents a symbolic link; “|”
represents FIFOs; “=”
represents a socket ( sockets
). (Directory Type Identification)
-r
Sort directories in reverse order.
-t
Sort by time.
-s
Output the size of the file after the l file name. (Size sorting, how to find the largest file in a directory)
-R
List files in all subdirectories (recursively).
-1
Only one file is output per line.
File data = file content + file attributes, operation on file = operation on file content + operation on file attributes Instruction
ls -l
demonstration:
ls -l
Instruction, lists the file (directory) size, creation time, creation user and other attributes, ls -l
instruction abbreviation for ll
.
ls -a -l
Command demonstration:
① In Linux,
.
files starting with (a dot) are called hidden files. There are two hidden files in any directory in Linux, that is,.
(a dot) represents the current path, and..
(two dots) represents the superior path of the current path; ②ls -a -l
Instructions can be equivalent tols -al
instructions; ③.
The meaning of file existence is to help users locate a file in the current directory. For example, when executing certain executable files, you need to add the path in front so that the compiler cannot find the executable file. .
pwd command
Syntax: pwd
Function: Display the directory where the user is currently located
cd command
In the Linux system, the files and directories on the disk are organized into a directory tree, and each node is a directory or file.
The directory structure of ①
Linux
is a multi-tree as a whole. Its leaf nodes must be empty directories or non-empty directories, and the nodes on its way must be non-empty directories. Therefore, our addition, deletion, and modification of all files are actually Add, delete, check and modify this multi-fork tree; ② Each node can have multiple child nodes, but its parent node has only one, so rewinding from this node finally returns to the root directory; ③ Absolute path: from the root directory to the/
current The full path of a directory (file) is often relatively long. It is used in some scenarios such as configuration files. Relative paths: use the current path as the starting reference path to locate specific files (or other files (directories) ) relative to.
the path of the current file (directory)), more commonly used
Syntax: cd
Directory name
Function: Change the working directory. Change the current working directory to the specified directory.
cd ..
: Return to the upper-level directory
cd /home/litao/linux/
: Absolute path
cd ../day02/
: Relative path
cd ~
: Enter the user's home directory
cd -
: Return to the recently visited directory (目录
) When
we first logged inxshell
, the directory we were in was the user家目录
cd
command demonstration: return to the upper-level path, and finally
cd ..
return to the root directory./
Continue to roll back, except for the root directory ,/
the other path separators are/
Linux
rmdir command&&rm command
rmdir is a
mkdir
command corresponding to .mkdir
It is to create a directory,rmdir
but to delete the command.
Syntax:rmdir [-p][dirName]
Applicable objects: All users with permission to operate the current directory
Function: Delete empty directories
Common options:-p
When the subdirectory is deleted, if the parent directory also becomes an empty directory, the parent directory will be deleted together. The rm command can delete files or directories at the same time. It
rmdir 目录
can only delete empty directories.
rmdir -p 目录名
It can delete empty multi-level directories.
rmdir
The command cannot delete ordinary files. We need to learnrm
the commands together.
Syntax: rm [-f-i-r-v][dirName/dir]
Applicable objects: All users
Function: Delete files or directories
Common options : Delete
-f
directly even if the file attribute is read-only (i.e. write-protected)
-i
Ask for confirmation one by one before
-r
deleting Delete a directory and all files under it
rm demonstration: