Linux Basic Command Exercise (1) __linux

Source: Internet
Author: User
Tags create directory mkdir parent directory file permissions

Reference Experiment Building Course Linux Command Instance Practice

ls command:

ls command is the most commonly used under Linux commands, ls command is the abbreviation of the list. LS is used to print out the list of current directories. If LS specifies a different directory, the list of files and folders in the specified directory is displayed. The LS command allows you to view not only the files contained in the Linux folder, but also the file permissions (including directories, folders, file permissions) to view directory information, and so on.

Command format:

ls [options] [directory name]

Common parameters:

Parameters

Description

-A

–all lists all files in the directory, including hidden files that begin with.

-L

In addition to the filename, the file's permissions, owner, file size, and other information are listed in detail

-D

–directory Displays the directory as a file, not the file below it

-H

–human-readable the file size in an Easy-to-understand format (for example, 1K 234M 2G)

-T

Sorting by file modification time

For example: ls–l/home/d* lists the size of all file directories in the/home directory that start with "D"


CD command

CD commands can be said to be the most basic Linux command statements, other command statements to operate, are based on the use of the CD command. The CD command is the abbreviation for change directory, switching the current directory to the specified directory. command format:

CD [Directory name]

Common examples:

Cd.. Enter the parent directory from the current directory

CD ~ from current directory into current user home directory

CD-from current directory into last directory


PWD command

Linux uses the PWD command to view the full path of the current working directory. Simply put, every time you operate on a terminal, you have a current working directory. When you are unsure of the current position, you use PWD to determine the exact location of the current directory within the file system. The PWD command is the abbreviation for print working directory. command format:

PWD [options] Common parameters:

Parameters

Description

-P

Show the actual physical path instead of using the connection (link) path

-L

Displays the connection path when the directory is a connection path

mkdir command

The mkdir command is used to create a directory of the specified name, requiring the user who created the directory to have write permission in the current directory, and the specified directory name cannot be a directory already in the current directory. The mkdir command is the abbreviation for Make directory. command format:

mkdir [Options] directory common parameters:

Parameters

Description

-M--mode= mode

Set Permissions < Patterns >

-P--parents

Can be a path name. If some directories in the path do not already exist, plus this option, the system will automatically establish those directories that do not yet exist, that is, you can build multiple directories at once

-V--verbose

Display information each time a new directory is created

Common examples:

Mkdir–p test/txt recursively Create multiple directories

Mkdir–m 777 test Create a directory with permissions of 777 (read to execute permission)

MKDIR–VP Test Create directory display information


RM command

RM is a commonly used command that deletes one or more files or directories in a directory, and it can delete a directory and all of its files and subdirectories. For linked files, only the link is deleted and the original file remains unchanged.

RM is a dangerous command to be particularly careful when used, especially for beginners, otherwise the entire system will be destroyed in this command (for example, under/(root directory) to perform RM *-RF). So, before we do RM, we'd better make sure which directory you want to delete, and maintain a high level of sanity in the operation.

The RM command is the abbreviation for remove. command format:

RM [Options] File or directory common parameters:

Parameters

Description

-F--force

Ignore files that don't exist and never give a hint

-I.--interactive

For interactive deletion

-R--recursive

Instructs RM to recursively delete all directories and subdirectories listed in the parameters

-V--verbose

To show the steps in detail

MV Command

MV Command function is used to move files or change the file name, is commonly used in Linux system commands, often used to back up files or directories. The MV command determines whether to rename the file or move it to a new directory based on the second parameter type (whether it is the destination file or the target directory). When the second parameter type is a file, the MV command completes the file rename, at which point the source file can have only one (or a source directory name) that renames the given source file or directory to the given target filename. When the second argument is a directory name that already exists, the source file or directory parameter can have multiple, and the MV command moves the source files specified by each parameter to the destination directory. MV command is the abbreviation for move. command format:

MV [option] source file or directory target file or directory common parameters:

Parameters

Description

-B--back

Overwrite the file before overwriting

-F--force

If the destination file already exists, it is not queried and is directly overwritten

-I.--interactive

If the destination file already exists, it asks if the overwrite

-U--update

If the target file already exists and the source file is newer, it will update

-T--target

This option applies to moving multiple source files to a directory where the target directory is before the source file is

The rename command can rename files in batches. You need to use regular.

CP command

The CP command is used to copy files or directories and is one of the most commonly used commands in Linux systems. Typically, the shell sets an alias, and when the file is copied at the command line, if the target file already exists, it asks if it is overwritten, regardless of whether or not you use the-i parameter. However, if the CP is executed in a shell script, there is no-I argument without asking whether or not to overwrite. This shows how the command line and shell scripts are executed differently. The CP command is a copy abbreviation. command format:

CP [Options] source file directory CP [option]-T directory source files Common parameters:

Parameters

Description

-T--target-directory

Specify target directory

-I.--interactive

Ask before overwriting (invalidates the previous-n option)

-N--no-clobber

Do not overwrite files that already exist (invalidate the previous-i option)

-S--symbolic-link

Create symbolic links to source files, not copy files

-F--force

Forcibly copying a file or directory, regardless of whether the destination file or directory already exists

-U--update

After this parameter is used, the file is copied only when the source file is modified more than the destination file, or if the corresponding destination file does not exist

Common examples:

Cp-i test1/* test2 Copy all files in the Test1 directory to the Test2 directory, and ask before overwriting

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.