Linux basic Commands (i)

Source: Internet
Author: User
Tags clear screen parent directory

Goal

Be familiar with the commands commonly used by Linux

Ls

Clear

Cd

Pwd

Mkdir

Touch

Rm

Cp

Mv

Tree

chmod

Find

Grep

redirect

Soft connections, hard links

Compression

Shutdown

Reboot

W.H.O.

Exit

passwd

Sudo

1> viewing file information: ls

LS is the abbreviation of the English word list, its function is to list the contents of the directory, is one of the most commonly used commands, it is similar to the dir command under DOS.

A Linux file or directory name can have a maximum of 265 characters, "." Represents the current directory, "..." Represents the previous level of the directory, with "." The file at the beginning is a hidden file and needs to be displayed with the-a parameter.

LS Common parameters:

Parameter meaning

-a displays all subdirectories and files in the specified directory, including hidden files

-l display file details in list mode

-H Mate-L displays file size in a humane way





The information listed in the figure has the following meanings:


Similar to file operations under DOS, in the Unix/linux system, it is also possible to use special characters to refer to multiple filenames simultaneously, which are called wildcards.

Wildcard meaning

* File represents all characters in the file name

LS te* find files that start with Te

LS *html find the file ending with HTML

? Represents any character in a file name

Ls?. C only find the first character arbitrarily, the suffix is. c file

LS A.? Only 3 characters are found, the first 2 characters are a., the last character arbitrary file

[] and "] enclose a group of characters, indicating that any one of the group of characters can be matched. "-" is used to represent the range of characters.

[ABC] matches any of a, B, c

[A-f] matches any character in the range from a to F

LS [a-f]* find a file that starts with any one of the characters from a to F range

LS a-f find file named A-f, when "-" outside the square brackets lose the role of wildcards

\ If you want to use wildcards as normal characters, you can precede them with escape characters. “?” and "*" in square brackets without the use of escape characters to lose the role of a wildcard character.

LS \*a find file with file name *a

2> Clear Screen: Clear

The clear function is to clear the display on the terminal (similar to the DOS CLS Clear screen feature), or you can use the shortcut key: Ctrl + L ("L" for the letter).

3> Switch working directory: CD

When using Unix/linux, it is often necessary to change the working directory. The CD command helps the user to switch the working directory. Linux all directories and filenames are case sensitive

The CD can be followed by an absolute path, or with a relative path. If you omit the directory, the default is to switch to the current user's home directory.

Command meaning

The CD switches to the current user's home directory (the/home/user directory), and when the user logs in, the default directory is the user's home directory.

CD ~ Switch to the current user's home directory (/home/user directory)

CD. Switch to the current directory

Cd.. Switch to Parent directory

CD-access to the last directory





Attention:

If the path starts from the root path, the path is preceded by a "/", such as "/mnt", which usually goes to a folder in a directory that is not preceded by "/".

4> Display current path: pwd

The PWD command allows you to display the current working directory, which is simple and can be entered directly into PWD without parameters.


5> Creating a directory: mkdir

You can create a new directory by using the mkdir command. Parameter-p to create a directory recursively.

Note that the name of the new directory cannot be the same as the directory or file already in the current directory, and the directory creator must have write access to the current directory.



6> Delete Files: RM

You can delete files or directories from RM. Use the RM command with caution because the file cannot be recovered after it is deleted. To prevent files from being mistakenly deleted, you can use the-I parameter after RM to confirm the files that you want to delete individually.

Common parameters and meanings are shown in the following table:

Parameter meaning

-I for interactive execution

-F Force Delete, ignore nonexistent files without prompting

-R recursively deletes the contents of the directory, which must be added when deleting a folder





7> copy: CP

The function of the CP command is to copy the given file or directory to another file or directory, equivalent to the Copy command under DOS.

Common Options Description:

Option meaning

-A This option is typically used when replicating a directory, preserving links, file attributes, and recursively copying directories, simply to preserve the original properties of the file.

-F already exists target file without prompting

-I interactive replication, which prompts the user to confirm before overwriting the target file

-R If the source file is a directory file, the CP will recursively replicate all subdirectories and files in that directory, and the destination file must be a directory name.

-V Show Copy Progress






8> mv: Move, rename

Users can use the MV command to move files or directories, or to rename files or directories.

Common Options Description:

Option meaning

-F disables interactive operation and does not prompt if overwrite is available

-I confirm the interactive operation, if the MV operation will result in overwriting the existing target file, the system will ask whether to rewrite, ask the user to answer to avoid overwriting the file by mistake

-V Show Move Progress



9> Creating files: Touch

Users can create an empty file via touch, with the following demo:

Touch Hello.txt

Description

An empty file named Hello.txt is created under the current path

There is no strict suffix (format) in the Linux system, so you can name any file name when you create it

==================================================================

Note: The above course notes for the study of the teachers in the classroom study notes, if necessary to reprint, if you need full notes, please contact me privately.

Featured Python Updates My study notes every day. The above content and class notes, more details to see the original link, my public number of dry goods continue to update

Original link: Python Developer Exchange Platform

Linux basic Commands (i)

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.