Linux common commands detailed

  
 

1.Linux entry and exit system

Enter Linux system:

You must enter the user's account. You can create the following two accounts during system installation:

1. Root--Superuser account (system administrator), use this account to do anything in the system.

2. Ordinary user--This account is for ordinary users and can be used for limited operations.

The average Linux user is a normal user, and the system administrator generally uses the super user account to complete some system management tasks. If you only need to complete some tasks that can be completed by a normal account, it is recommended not to use a super user account to avoid inadvertently destroying the system. Affect the normal operation of the system.

User login is divided into two steps: the first step is to enter the user's login name, the system identifies the user according to the login name; the second step is to enter the user's password, which is a string set by the user. It is confidential to other users and is the keyword used by the system to identify true and false users when logging in.

Once the user enters the username and password correctly, they can enter the system legally. The screen displays:

[root@loclhost /root] #


At this point, you can do various operations on the system. Note that the super user's prompt is “#”, the prompts of other users are “$”.


Modify Password

In order to better protect the security of user accounts, Linux allows users to modify their passwords at any time. The command to change the password is passwd, which will prompt the user. Enter the old password and the new password, and then ask the user to confirm the new password again to avoid the user accidentally pressing the wrong key. If the user has forgotten the password, he can apply to the system administrator to reset one for himself.


Virtual Console

Linux is a true multi-user operating system
that can accept multiple users at the same time. Linux also allows a user to log in multiple times, because Linux, like UNIX, provides access to the virtual console, allowing users to log in multiple times from the console at the same time. The selection of the virtual console can be achieved by pressing the Alt key and a function key. Usually, F1-F6 is used. For example, after the user logs in, press the Alt-F2 key, and the user can see the "login:" prompt. Explain that the user saw the second virtual console. Then just press the Alt-F1 key to go back to the first virtual console. A newly installed Linux system by default allows users to access the first six virtual consoles using the Alt-F1 to Alt-F6 keys. The virtual console allows users to work on multiple consoles at the same time, truly embodying the multi-user nature of Linux systems. Users can switch to another virtual console to start another job when the work done on one of the virtual consoles is not over yet.

Exiting the System

Whether you are a superuser or a normal user, you need to exit the system. At the shell prompt, type the exit command.


Linux file copy, delete and move commands

cp command


The function of this command is given Copying a file or directory to another file or directory is as powerful as the copy command under MSDOS.

Syntax: cp [options] source file or directory object file or directory

Description: This command copies the specified source file to the target file or copies multiple source files to the target directory. .

The options for this command have the following meanings:

- a This option is usually used when copying directories. It preserves links, file attributes, and recursively copies the directory, which acts as a combination of dpR options.

- d Keep the link when copying.

- f Delete existing target files without prompting.

- The opposite of the i and f options will give a prompt to the user to confirm before overwriting the target file. The target file will be overwritten when answering y, which is an interactive copy.

- p In addition to copying the contents of the source file, cp will also copy its modification time and access rights to the new file.

- r If the given source file is a directory file, cp will recursively copy all subdirectories and files in that directory. The target file must be a directory name at this time.

- l No copy, just a link file.

It should be noted that in order to prevent users from using the cp command to destroy another file inadvertently, if the user-specified target file name already exists, the file will be new after copying the file with the cp command. The source file is overwritten, so it is recommended that users use the i option when copying files using the cp command.


mv Commands


Users can use the mv command to rename a file or directory or move a file from one directory to another. This command is like the combination of ren and move under MSDOS.

Syntax: mv [options] Source file or directory object file or directory

Description: Depending on the second parameter type in the mv command (is the target file or the target directory), the mv command Rename the file or move it to a new directory. When the second parameter type is a file, the mv command completes the file renaming. At this time, the source file can only have one (or the source directory name), and it renames the given source file or directory to the given one. The name of the target file. When the second parameter is an existing directory name, there may be multiple source files or directory parameters. The mv command moves the source files specified by each parameter to the target directory. When moving a file across a file system, mv copies first, then the original file is deleted, and the link to the file is lost.

The meaning of each option in the command is:

- I Interactive mode operation. If the mv operation will result in an overwriting of the existing target file, the system asks whether to rewrite, and asks the user to answer y or n, so as to avoid accidentally overwriting the file.

- f Prevents interaction. No indication is given when the mv operation wants to overwrite an existing target file. After this option is specified, the i option will no longer work.

If the given target file (not the directory) already exists, the contents of the file will be overwritten by the new file. To prevent users from using the mv command to destroy another file, it is best to use the i option when moving files using the mv command.


rm command

Users can use the rm command to delete unwanted files. The function of this command is to delete one or more files or directories in a directory. It can also delete a directory and all files and subdirectories under it. For linked files, just the link is broken and the original file remains unchanged.

The general form of the rm command is:

rm [options] File …

If the -r option is not used, rm does not delete the directory.

The options for this command have the following meanings:

- f Ignore files that do not exist and never give hints.

- r Instructs rm to recursively delete all directories and subdirectories listed in the parameter.

- i Perform an interactive delete.

Be careful with the rm command. Because once the file is deleted, it cannot be recovered. To prevent this from happening, you can use the i option to confirm the files you want to delete one by one. If the user enters y, the file will be deleted. If you enter anything else, the file will not be deleted.


Linux directory creation and deletion commands

mkdir command


Function: Create a directory (similar to md under MSDOS) command).

Copyright © Windows knowledge All Rights Reserved