Linux Basic Command Parsing (1)

Source: Internet
Author: User
Tags parent directory

The previous blog briefly describes the format of the Linux commands and how to get help, and the familiar use of HELP commands is an effective way to quickly master Linux command-line operations in unfamiliar situations with Linux. Now, let's take a brief look at some common commands under Linux command-line operations.

How to use common commands:

1.PWD: Internal command

Function: The command displays the absolute path of the current working directory.

Format:pwd [-l| P]

Common options:

-L IF the $PWD variable captures the name of the current working directory, the value of the variable is displayed.

-P Displays the actual physical path, not the symbolic link.

Note: the-l option is specified as the default behavior for the PWD command. The command does not take any options or parameters. Use the PWD command to know which directory is currently working.

Example:

[Email protected] ab]$ pwd

/home/wjq/ab

[Email protected] ab]$ pwd-p

/home/wjq/ab

[Email protected] ab]$

2.CD: Internal command

Function: Enter the shell working directory

Format:CD [-l|-p] [dir]

Common options:

-L forces follow symbolic links. (That is, if the parameter of the CD command is a symbolic link to a directory, after you change the directory, the result that is displayed with the Pwd-l command is the path to the symbolic link, not its actual physical path.) )

-P uses a physical directory structure without following symbolic links.

Attention:

CD: Go directly to the default home directory when no parameters are added;

CD dir: Switches the working directory to the directory represented by DIR;

CD-: Switch The working directory to the working directory of the first time; switch between two directories;

CD ~: Switch working directory to home directory

CD ~usename: Switch The working directory to the home directory of the specified user "Usename", limited to the root user;

Example:

[email protected] wujunqi]# CD ~WJQ

[[Email protected] wjq]# CD AB

[Email protected] ab]# CD-

/home/wjq

[Email protected] wjq]#


3.LS: External command

Function: Displays the contents of the catalog as a list.

Format:ls [OPTION] [FILE ...]

Common options:

-A: Displays all files, including hidden files;

-A: Displays except "." and ".." The other files

-D: The contents of the directory are not displayed and only the directory name is displayed;

-L: Displays the detailed properties of the file in a long format;

-H: Easy to read (automatic conversion) easy to read file size format, usually using 1024 binary unit conversion;

-F: Classify, add different symbols after different types of files;

-r: Reverse output (originally by Ascall code order);

-R: Recursively displays the contents of the directory and subdirectories;

Ls–r/(Display the contents of all directories)

-S: Sort by file size;

-1: A file is displayed per line;

-Z: Displays the security context of the file SELinux;

(only some of the common options are listed here)

Note: In the example below, there is a similar to drwxrwxr-x. 4 WJQ WJQ 25 March 09:26 AB

The form in which the meaning represented was

D: File type identification;

rwxrwxr-x: Permission settings for files;

RWX: The document is the owner of the Authority;

rwx (three): attributes of the genus Group of the file;

R-w: The permissions that other users have on the file;

.: Indicates whether the file has a special attribute;

4: The number of times the file was hard-linked;

WJQ (1): denotes the owner of the document;

WJQ (2): Represents a group of documents;

25 March 12 09:26: Time when the file was last modified;

Example:

[Email protected] wjq]# ls-l

Total dosage 10392

-rw-rw-r--. 1 wjq wjq 0 March 14:21 A

Drwxrwxr-x. 4 WJQ WJQ 25 March 09:26 AB

Drwxr-xr-x. 2 root root 6 March 6 22:21 Bin

Drwxrwxr-x. 2 WJQ WJQ 6 March 6 22:05 Boot

-RW-------. 1 wjq wjq 5304320 March 4 08:22 core.3441

-RW-------. 1 wjq wjq 5312512 March 2 20:30 core.9543


4.mkdir: External command

Function: Used to create a directory;

Format:mkdir [OPTION] ... DIRECTORY ...

Common options:

-P: Continuous creation of the directory, the parent directory if it does not exist first create the parent directory;

-V: Displays the execution of the entire command when the command is executed;

-M,--mode=mode: Set the permissions for the directory as you would with the chmod command, rather than using the A=rws-umask method;

--help: Display Help menu information

Example:

[Email protected] wjq]# mkdir-p ab/bbb/bb

[[Email protected] wjq]# CD AB

[[email protected] ab]# ls

ABQ BBB SS

[[Email protected] ab]# CD BBB

[[email protected] bbb]# ls

Bb

[Email protected] bbb]# MKDIR-PV./ss/s

mkdir: Created directory "./ss"

mkdir: Created directory "./ss/s"

[Email protected] bbb]#


5.rmdir: External command

Function: Delete directory, can only delete empty directory;

Format: rmdir [OPTION] ... DIRECTORY ...

Common options:

-P,--parents: If the directory is removed and its ancestral directory is empty, it is removed;

-V,--verbose: outputs the operation result of each directory processed for execution;

--help: Display short help information;

Note: only empty directories can be deleted, non-empty directories cannot be deleted, and non-directory files cannot be deleted;

Example:

[Email protected] bbb]# RMDIR-PV./ss/s

RMDIR: Deleting directory "./ss/s"

RMDIR: Deleting directory "./ss"

[[email protected] bbb]# ls

Bb


6.RM: External command

Function: delete files or directories;

Format: RM [OPTION] ... FILE ...

Common options:

-I: Prompt before each delete operation;

-F: Forced deletion, without any hint; (use sparingly);

-R: Recursively delete the sub-files of the directory and erase the directory itself;

-V: Displays the deletion process;

Example:

[email protected] bbb]# Rm-ir BB

RM: Do you want to delete the directory "BB"? Y

[[email protected] bbb]# ls

[Email protected] bbb]#














Linux Basic Command Parsing (1)

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.