Common Linux File Management commands

Source: Internet
Author: User

Preface:

In the previous blogs, we talked about basic linux operations, linux file management, and linux permission management in more theoretical aspects. However, I only talked about theory, but I didn't talk about many commands in detail, I just made a summary and I will review and study it myself.

File Management commands

First, I would like to sum up some commands for file management: ls, cd, pwd, mkdir, rmdir, cp, rm, mv, touch, cat, more, less, head, tail, etc, next we will give a detailed description (only common, not all commands)

 

(1). ls command

-A: All files, together with hidden files (Files starting with.), are listed (commonly used)

-A: All files, together with hidden files, do not include the directories... and

-D: only list the directory itself, rather than list the file data in the directory (commonly used)

-F: directly list the results without sorting them (ls will be sorted by file name by default !)

-H: list the file capacity in a readable way (for example, GB or KB) (commonly used)

-I: List inode numbers. The next chapter will introduce inode numbers (commonly used)

-L: Long data string list, including file attributes and permissions (commonly used)

-N: List UID and GID, rather than the names of users and groups (UID and GID will be mentioned in user management !)

-R: reversely outputs the sorting result. For example, if the original file name is from small to large, the reverse file is from large to small.

-R: It is listed together with the sub-directory content, which means that all files in the directory will be displayed (recursive)

-S: sort by file capacity, rather than by file name

-T: sort by time, rather than by file name

 

(2) cd command

Cd [relative or absolute path]

# The most important thing is the absolute path and relative path of the directory. There are also symbols of some special directories!

[Root @ www ~] # Cd ~ Test

# Indicates to go to the home directory of the user vbird, that is,/home/test

[Root @ www vbird] # cd ~

# Indicates returning to your home directory, that is, the/root directory.

[Root @ www ~] # Cd

# If no path is added, it still means returning to your home directory.

[Root @ www ~] # Cd ..

# Indicates to go to the current upper-level directory, that is, the upper-level directory of/root.

[Root @ www/] # cd-

# Return to the directory just now, that is,/root ~

[Root @ www ~] # Cd/var/spool/mail

# This is the absolute path! Specify the complete path name

[Root @ www mail] # cd ../mqueue

# This is the method of relative path. We will write it in this way from/var/spool/mail to/var/spool/mqueue.

(3). pwd command

Pwd [-P] Options and parameters:
-P: displays the actual path instead of the link path.
Example: pwd
Cd/var/mail

Pwd-P

/Var/spool/mail

Pwd is different from pwd-P!

(4). mkdir command

Mkdir [-mp] Directory Name options and parameters:

-M: permission of the configuration file! Directly configure it. You do not need to check the default permission (umask)

-P: helps you directly create the desired directory (including the upper-level directory!

Example:

Mkdir-p test1/test2/test3/test4 (created together)

Mkdir-m 744 test2

 

(5). rmdir command

Rmdir [-p] Directory Name options and parameters:

-P: deleted together with the "empty" directory at the upper level

Example:

Rmdir-p test1/test2/test3/test4 (delete all)

 

(6). rm command

Rm [-fir] file or directory options and parameters:

-F: indicates force. Ignore non-existing files without warning.

-I: interactive mode. Before deletion, the user is asked for actions.

-R: delete it in a batch! Delete directories (this is a very dangerous option)

We usually use them in combination. rm-rf (delete all files or directories and you must be careful when using them, because they cannot be recovered after being deleted)

  • 1
  • 2
  • Next Page

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.