Linux [common instructions (1)]

1. Operating system

1.1 What is the operating system

  • Common operating systems are: Windows, Linux, iOS…
  • The operating system is:
    a software for hardware and software management
  • Why there is an operating system:
    The core job of the operating system is to provide a good (stable, fast, safe) operating or use environment for the upper side by means of managing software and hardware resources from the lower side
  • The measure of a good operating system:
    stable, fast, secure

Summary: All our software behaviors must be self-oriented and run through the computer's hardware and software structure

1.2 Reasons for choosing the order

Linux has the form of command line and graphical interface;
Windows not only has the form of graphical interface, but also has the form of command line (1. cmd, 2. powershell, 3. win + x )

  • Since there is already such a simple and clear tool with a graphical interface, why do you choose to use the command line to learn? The
    most important thing for a computer is to solve the problem of input and output, and then the emergence of input tools (such as keyboards), Then the subsequent operation mode is command operation; the graphical interface is optimized with the emergence of the mouse, so that users can get started more easily. Compared with graphical operation, interface operation is closer to
    operation the system itself.

2. Use tools

  • XShell is a remote terminal software, download from the official website , select "home/school" when downloading and installing, you can download it for free
  • To view the Linux host ip
    , type the "ifconfig" command under the terminal to view the ip address
  • Log in to the host using XShell

SSH user name@cloud server public ip address
Afterwards, you will be prompted to enter the user password, and you can log in correctly if you enter it correctly

  • Copy and paste under XShell Copy
    : ctrl + insert
    Paste: shift + insert
    ctrl + c / ctrl + v will not work
  • XShell's full screen operation
    alt + Enter
  • XShell exit shortcut key
    ctrl + d

3. Linux instruction operation

3.1 mkdir command

describe:

used to create directories

usage:

mkdir directory name: Create a directory under this path
mkdir -p directory 1/ directory 2/ directory 3: create a multi-level directory under this path (recursive)

Example mkdir directory name


ls can view the list of all files in the current directory
cd + directory name, you can enter this directory

Example mkdir -p directory 1/ directory 2/ directory 3

tree . It will be displayed in a tree form starting from the current directory. The location of . is the current directory, and the following content is all the directories or files under this directory. pwd The directory (or path) where the current command line is located
cd
… Fall back to the current directory's parent directory
tree library establishment: Enter yum install -y tree to complete the download

3.2 touch command

describe:

touch is used to create ordinary files (files that cannot be created below, distinguish between empty directories)

usage:

touch file

example touch file

3.2 pwd command

describe:

Display the directory where the current command line is located (the path where it is located)

usage:

pwd

Example pwd

3.4 cd command

describe:

Change the working directory, change the current working directory to the specified directory

usage:

cd … Return to the parent directory
cd /home/username/… use an absolute path to specify access to a file
cd …/filename/ use a relative path to specify access to a file
cd ~ enter the user’s home directory
cd - return to the most recently accessed directory

example cd...

Example cd /home/username/... ...

  1. A directory can contain directories or ordinary files ==> We can deduce that the entire directory structure of Linux is a multi-fork tree. The leaf nodes must be empty directories or non-directory files, and the nodes on the way must be non-empty directories. So all of our The addition, deletion, and modification of files or directories is essentially the addition, deletion, inspection, and modification of this multi-fork tree.
  2. The root directory of this tree is /

Example cd .../filename


Analyze /home/muyu/d1/linux.txt

  • where / is the path separator,
  • The first / is the path separator and the root directory

Because any node has only one parent node, path positioning is unique, so we locate a file, usually by path

  1. The unique path starting from / (root directory) to the specified location is called an absolute path
  2. Use the current path as the starting reference position to locate a specific file. This path is called a relative path.
    Generally, a relative path is used to find a file in the upper-level directory.
    The path we are in has changed. The relative path may fail

How should we choose??

  1. The absolute path is relatively long, but it is fixed. It is generally used in fixed scenarios, file configuration
  2. General command line input, often use relative path

example cd ~

  • Under the centos system, all ordinary users, their user accounts will be placed in /home
  1. Super user root, home directory is /root (another reason, the user name of the super user is also root)
  2. Others (ordinary users), the home directory is /home/username

3.5 ls command

describe:

ls displays a list of all files in the current directory

usage:

ls only displays the list names of all files in the current directory (displays file attributes, but only the file names)
ls -l is equivalent to ll, displays detailed information of all files in the current directory
ls -a displays all files in the current directory , including hidden files
ls -d displays the detailed information of the current directory
ls -F appends a character after each file name to describe the type of the file, "*" means executable ordinary file; "/" means directory; "@" means symbolic link; "|" means FIFOs; "=" means sockets. (directory type identification)

example


Replenish:

  • Commands can have options
  • file = file content + file attributes
  • ls related operations are related to file attributes

3.6 rm command

describe:

The rm command can delete files or directories (thieves)

usage:

rm -r deletes the directory and all files below it.
rm -f Even if the file attribute is read-only (that is, write-protected) [generally, the super user will be reminded], it can also be forced to delete
rm -i Ask for confirmation one by one before deleting [for ordinary User, the super user will have it by default]

example:


Notice:

  • The deletion of Linux is a permanent deletion, unlike Windows, which has a recycle bin that can be used again!! Be careful
  • If you encounter an instruction that cannot be exited normally, remember to use ctrl + z

insert image description here

Guess you like

Origin blog.csdn.net/qq_67549203/article/details/130438199
Recommended