Common commands for getting started with Linux

Source: Internet
Author: User
Tags printable characters
1. linux: you must enter your account. during system installation, you can create the following two types of accounts: 1. root-super user account (System Administrator), which can be used to do anything in the system. 2. common users-this account is used by common users.

1. Linux entry and exit

Go to Linux:

You must enter your account. you can create the following two accounts during system installation:

1. root-super user account (System Administrator), which can be used to do anything in the system.

2. common users-this account is used by common users and can perform limited operations.

Generally, Linux users are common users, while system administrators generally use superuser accounts to perform system management. If you only need to complete some tasks that can be completed by a common account, we recommend that you do not use a super user account to avoid accidental damage to the system. Affects the normal operation of the system.

User logon is divided into two steps: Step 1: enter the user's login name, and the system recognizes the user based on the login name; Step 2: Enter the user's password, which is a string set by the user, other users are kept confidential and keywords used by the system to identify authentic and false users during logon.

After you enter the user name and password correctly, you can access the system legally. Screen Display:

[Root @ loclhost/root] #

Then you can perform various operations on the system. Note that the super user prompt is "#", and the other user prompt is "$ ".

Change password

To better protect the security of your account, Linux allows you to change your password at any time. the command used to change the password is passwd, which will prompt you to enter the old password and new password, then, the user is asked to confirm the new password again to prevent the user from accidentally pressing the wrong key. If you forget the password, you can apply to the system administrator to reset the password.

Virtual Console

Linux is a real multi-user operating system that allows multiple users to log on at the same time. Linux also allows a user to log on multiple times, because like Linux and UNIX, the Virtual Console access mode is provided, allowing users to log on multiple times from the console at the same time. The choice of the virtual console can be achieved by pressing the Alt key and a function key, usually using the F1-F6 for example, after the user login, click the Alt-F2 key, the user can see "login:" prompt, the user sees the second Virtual Console. Then you just press the Alt-F1 key to go back to the first virtual console. By default, a newly installed Linux system allows users to access the first six virtual consoles with the Alt-F1-to-Alt-F6 key. The Virtual Console allows users to work on multiple consoles at the same time, truly reflecting the characteristics of multiple users in the Linux system. You can switch to another virtual console to start another job when the work on a virtual console has not been completed.

Exit System

If you want to exit the system as a super user or a common user, enter the exit command at the shell prompt.

Commands for copying, deleting, and moving Linux files
Cp command


This command is used to copy the given file or directory to another file or directory. it is very powerful like the copy command in MSDOS.

Syntax: cp [option] source file or directory target file or directory

Note: this command copies the specified source file to the target file or multiple source files to the target directory.

The options of this command are as follows:

-A this option is usually used when copying directories. It retains links and file attributes, and recursively copies directories. Its role is equal to the combination of dpR options.

-D: The link is retained during copy.

-F delete an existing target file without prompting.

-I and f options are opposite. a prompt is displayed asking the user to confirm before overwriting the target file. When the answer is y, the target file will be overwritten, which is an interactive copy.

-P in addition to copying the source file content, cp also copies the modification time and access permissions to the new file.

-If the source file provided by r is a directory file, cp will recursively copy all subdirectories and files in the directory. The target file must be a directory name.

-L do not copy, but only link files.

It should be noted that, in order to prevent the user from using the cp command inadvertently to destroy another file, such as the target file name specified by the user already exists, use the cp command to copy the file, this file will be overwritten by the new source file. Therefore, we recommend that you use the I option when using the cp command to copy the file.
Mv command

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

Syntax: mv [option] source file or directory target file or directory

Note: depending on the type of the second parameter in the mv command (whether it is the target file or the target directory), the mv command renames the file or moves it to a new directory. When the second parameter type is file, the mv command renames the file. at this time, only one source file (or the source directory name) can be used ), it renames the given source file or directory to the given target file name. 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 a file is moved across file systems, the mv copies the file first, and then deletes the original file. the link to the file will also be lost.

The meaning of each option in the command is:

-I interactive operation. If the mv operation will overwrite the existing target file, the system will ask whether to rewrite the file and ask the user to answer y or n. This will avoid overwrite the file by mistake.

-F prohibit interactive operations. When an mv operation overwrites an existing target file, no instructions are given. if this option is specified, the I option will no longer work.

If the target File (not a directory) already exists, the content of the file will be overwritten by the new file. To prevent the user from using the mv command to destroy another file, it is best to use the I option when using the mv command to move the file.

Rm command

You can use the rm command to delete unnecessary files. This command is used to delete one or more files or directories in a directory. It can also delete a directory and all its files and subdirectories. For linked files, the link is closed, and the original file remains unchanged.

The common format of the rm command is:

Rm [option] file...

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

The options of this command are as follows:

-F ignores non-existing files and never gives a prompt.

-R indicates that rm recursively deletes all directories and subdirectories listed in the parameter.

-I.

Be careful when using the rm command. Because once a file is deleted, it cannot be recovered. To prevent this situation, you can use the I option to confirm the files to be deleted one by one. If you enter 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 the md command in MSDOS ).

Syntax: mkdir [option] dir-name

Note: this command creates a directory named by dir-name. The user who creates a directory must have write permission in the current directory (the dir-name parent directory), and the dirname cannot be an existing directory or file name in the current directory.

The meaning of each option in the command is:

-M sets the access permission for the new directory. You can also set it using the chmod command.

-P can be a path name. If some directories in the path do not exist, after this option is added, the system automatically creates those directories that do not exist, that is, multiple directories can be created at a time.

Rmdir command

Function: delete an empty directory.

Syntax: rmdir [option] dir-name

Description: dir-name indicates the directory name. This command deletes one or more sub-directory items from a directory. Note that a directory must be empty before it is deleted. The rm-r dir command can replace rmdir, but it is dangerous. When deleting a directory, you must also have the write permission on the parent directory.

The meaning of each option in the command is:

-P recursively deletes the directory dirname. when the subdirectory is deleted and its parent directory is empty, it is also deleted. If the entire path is deleted or some paths are retained for some reason, the system displays the corresponding information on the standard output.

Cd command

Function: change the working directory.

Syntax: cd [directory]

Note: this command changes the current directory to the directory specified by directory. If no directory is specified, return to the user's home directory. To change to a specified directory, you must have the execution and read permissions on the specified directory.

This command can use wildcards (see Chapter 10 for wildcard meanings ).


Pwd command

In the Linux hierarchical directory structure, you can use the mkdir command in any authorized directory to create a new directory, or use the cd command to convert one directory to another. However, there is no prompt to tell the user which Directory is currently in. To know the current directory, run the pwd command to display the entire path name.

Syntax: pwd

Note: this command displays the absolute path of the current working directory.

Ls command

Ls is short for the English word list. its function is to list the contents of a directory. This is one of the most commonly used commands, because you need to view the contents of a directory from time to time. This command is similar to the dir command in DOS.

Syntax: ls [option] [Directory or file]

For each directory, this command lists all subdirectories and files in the directory. For each file, ls will output its file name and other required information. By default, output entries are sorted alphabetically. When the directory name or file name is not given, the current directory information is displayed.

The meanings of the options in the command are as follows:

-A: displays all subdirectories and files in the specified directory, including hidden files.

-A: displays all subdirectories and files in the specified directory, including hidden files. "." And "..." are not listed.

-B indicates that non-printable characters in the file name are displayed with octal escape characters.

-C is sorted by the file modification time.

-C is divided into multiple columns to display items.

-D if the parameter is a directory, only its name is displayed, and all files under it are not displayed. It is often used together with the l option to obtain detailed information about the directory.

-F is not sorted. This option will invalidate the lts option and make the aU option valid.

-F indicates "/" After the directory name, "*" after the executable file, "@" after the symbolic link, and "|" after the pipeline (or FIFO ", mark "=" after the socket file ".

-I displays the I node number of the file in the first output column.

-L displays detailed information about a file in a long format. This option is the most commonly used.

The information listed in each row is: file type and number of permission links. the name of the time when the file is created or recently modified for the file owner file Group

For a symbolic link file, the displayed file name is "->" and the referenced file path name.

For device files, the "File Size" field shows the master and secondary device numbers, rather than the file size.

The total number of blocks in the directory is displayed at the beginning of the long format list, which contains indirect blocks.

-L if the specified name is a symbolic link file, the file to which the link is directed is displayed.

-M output is in bytes stream format. files are displayed on different pages separated by commas.

-N: the output format is the same as that of the l option. in the output, the file owner and group are represented by the corresponding UID and GID, rather than the actual name.

-O and l options are the same, but do not display the owner information. </

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.