Linux File and directory management

Source: Internet
Author: User
Tags create directory

absolute path vs. relative path :

directory and its related operations :

. Represents this Layer directory

.. Represents a previous level directory

-Represents a previous working directory

~ Represents the home folder where the current user identity resides

1.CD Switch Directory

EG:CD.

2.pwd [-p] shows the current directory,-p for not using link path

3.mkdir New Catalog

-M profile permissions----to the cabinet create directory

Eg:mkdir Test

Mkdir-p Test1/test2/test3/test4

Mkdir-m 711 Test2

4.rmdir [-P]

Delete Empty directory,-p means to delete with upper empty directory together

5.rm-r Test

Delete everything under the test directory

$PATH:

file and directory management :

view files and directories ls:

ls [-aadffhilnrrst] directory name

ls [--color={never,auto,always}] Directory name

ls [--full-time] directory name

Parameters:-A All files are listed together with hidden files to

-d lists only the directory itself and does not list the file data in the directory

-l lists Long data strings, including file attributes and permissions, etc.

Eg:ls-al ~ All files under the home folder

PS: Data related to the properties and permissions of the file is placed in the I-node.

copy, delete, and move CP,RM,MV:

CP [-parameter] source destination

-A corresponds to-PDR to copy file attributes together

-I if the target file already exists, please ask before overwriting

-R Recursive Continuous replication

PS: Replication changes file permissions without parameters

RM [-fir] File or directory delete file or directory

-F ignores nonexistent files and does not appear warning

-I interactive mode, ask the user whether to operate before deleting

-R Recursive Delete

MV [-FIU] source destination moving files and directories, or renaming

-f:force mandatory Meaning, if the target already exists, will not ask and will directly overwrite

-I: If the target file already exists, you will be asked whether to overwrite

-U: If the target file already exists and source is newer, it will be updated (update)

EG:CP ~/.BASHRC Bashrc1

CP ~/.BASHRC BASHRC2

MV Bashrc1 Bashrc2 Mvtest2

get path filename and directory name :

Eg:basename/etc/sysconfig/network

Dirname/etc/sysconfig/network

file content Check :

A. Directly viewing the contents of a file, you can use cat/tac/nl several commands

Cat [-abentv]

-N Prints the travel number, along with a blank line, which also appears.

-B blank line does not print line number

Eg:cat-n/etc/issue

TAC /etc/issue

Reverse Display

NL [-BNW] File

Add line numbers to print

B. Can flip view

More/etc/man.config one page, one page flip

less/etc/man.config One-page flip, including pages that can be used with [page UP]

C. Data read

Head out the first few lines

tail [-N number] file take the following lines

Non-plain text file: OD

Modify file time or create a new file: Touch

Modification Time (mtime):
This time will be updated when the content data of the file is changed!
Status Time (CTime):
When the status of the file changes, it is updated

Access Time (Atime):

Update Atime Read time when file contents are fetched.

File default permissions: unmask

Preset permissions: File 666 directory 777

File Hidden properties:

Chattr setting file-hidden properties

Lsattr Show file Hidden properties

File Special permissions: Suid,sgid,sbit

When Suid:s appears on the file owner's permission x, it becomes SUID, such as-rwsr-xr-x, whose function is

Suid only valid for binary programs

Performer must have X Execute permission on the program

This permission is valid only during the execution of the program

Performer will have change owner permissions

Sgid:s on X of user group

Sgid can be set for files or directories, not only useful for binary programs

Program performer has x permission on the program

The performer needs to be supported by the program user group during the execution.

Sbit: only valid for directory

When a user has w,x permissions on this directory, when Write permission is available:

When a user creates a directory file under this directory, only himself and Root have the right to delete the file

Large s,t, with special permissions set but no x permission

Viewing file types: File files

Command and file query: which looking for "execute file"

which the executable file according to the directory within the path variable set by the user

/sbin is not in Vbird's path.

and cannot find the bash built-in commands

File name lookup: Whereis

Locate

Whereis Locate is a database lookup

UpdateDB: Updating database files

Find

The relationship between permissions and commands:

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.