[Introduction to Linux]---Linux instructions ①

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 ①: xshellAfter opening, click the "New" symbol in the upper left corner.
Insert image description here
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 ③:
Insert image description here
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.
Insert image description here
Step ④: Enter the user name that needs to be logged in.
Insert image description here
Step ⑤: After entering the password for the login account, click "OK".
Insert image description here
Step ⑥: When you see the following interface, the account login is successful.
Insert image description here

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:
Insert image description here
mkdir You can create a directory. ls -lWhen 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 dletter 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:
Insert image description here

touch command

Syntax :touch [选项] 文件
Function: touchThe 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:
-aor --time=atimeor --time=accessor --time=usechange only the access time.
-cor --no-createno documentation is created.
-dUse the specified date and time instead of the current time.
-fThis 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.
-mor --time=mtimeor --time=modifychange only the change time.
-rSet 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.
-tUse the specified date and time instead of the current time.
Example:
Insert image description here
mkdir You can create an ordinary file. ls -lWhen 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:
-aList all files in the directory, including implicit files starting with .
-dDisplay the directory as a file, rather than displaying the files below it. For example: ls –dspecify the directory
-ito output the index information of the i node of the file. For example, ls –aispecifying a file
-kindicates the size of the file in k bytes. ls –alkSpecify file
-lLists details of file attributes.
-nUse numbers UIDinstead GIDof names. (Introduction UID, GID)
-FAttach 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)
-rSort directories in reverse order.
-tSort by time.
-sOutput the size of the file after the l file name. (Size sorting, how to find the largest file in a directory)
-RList files in all subdirectories (recursively).
-1Only 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 -ldemonstration:
Insert image description here
ls -l Instruction, lists the file (directory) size, creation time, creation user and other attributes, ls -linstruction abbreviation for ll.
ls -a -lCommand demonstration:
Insert image description here

① 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 -lInstructions can be equivalent to ls -alinstructions; ③ .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
Insert image description here

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.
Insert image description here

The directory structure of ① Linuxis 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 in xshell, the directory we were in was the user 家目录
Insert image description here
cdcommand demonstration: return to the upper-level path, and finally
Insert image description here
cd ..return to the root directory. /Continue to roll back, except for the root directory , /the other path separators are/Linux
Insert image description here
Insert image description here

rmdir command&&rm command

rmdir is a mkdircommand corresponding to . mkdirIt is to create a directory, rmdirbut 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.
Insert image description here
rmdir -p 目录名It can delete empty multi-level directories.
Insert image description here
rmdirThe command cannot delete ordinary files. We need to learn rmthe commands together.
Insert image description here

Syntax: rm [-f-i-r-v][dirName/dir]
Applicable objects: All users
Function: Delete files or directories
Common options : Delete
-fdirectly even if the file attribute is read-only (i.e. write-protected)
-iAsk for confirmation one by one before
-rdeleting Delete a directory and all files under it
rm demonstration:
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/m0_74288306/article/details/132916847