Linux Learning Note 3-File and directory management one

Source: Internet
Author: User
Tags file copy

Related Operations for Directories

The CD command is used to switch working directory, can be used relative directory, also can use absolute directory, ~ represents the current user's home directory,-represents the previous working directory, a bit like Windows back,. Represents the current directory,. Represents the upper-level directory.

The PWD command is used to display the current working directory, and the-p parameter can display the path of a non-connected file.

MkDir is used to create a new directory,-m parameter can directly specify the permissions of the new directory without looking at the default, the-p parameter can be recursively created each layer of the directory once.

Mkdir-m 711 Test2

Mkdir-p Test1/test2/test3/test4

RmDir is used to delete empty folders if the destination folder is not empty and will report directory not empty error.

Environment variable Path

In the case of the LS command, when the LS command is executed, the system will query the executable file named LS according to the path's setting, and if there are more than one, the first query is executed.

Echo is the meaning of the display, $ means the following is a variable, perform echo $PATH can see the value of path, different from Windows, partition, the path path of Linux between: Split, the paths are sequential.

Path= "$PATH":/root This can add a new directory for PATH.

The default path for users of different identities is different, so the commands that can be executed by default are naturally different.

When you want to execute a file with an absolute path, such as/root/liuty/test.sh, you need to use a relative path if you want to execute a file under the current working directory./test.sh, if it will. (that is, the current directory) to join the path, you can directly execute the file under the current working directory, directly test.sh, but it is not safe, because it is possible to execute to unexpected files, if you go into a directory under the directory there is a LS file, you execute LS can be executed to this LS.

File and Directory Management

The LS command is used to view files and directories, parameter-A To view all files, including hidden files;-A includes hidden files, but removes. and. ;-H Displays the file size shown in KB,GB, and the-l displays detailed information, including file properties and permissions, and many distributions such as CentOS will set LL to Ls-l.

CP command is used to copy files and directories, parameter-i if the target file already exists, the first query when overwriting;-D if the source file asks the properties of the connection file, copy the connection file properties instead of the file itself;-P along with the properties of the file copy the past instead of the default property;-r recursive copy, for directory ;-A is equivalent to-pdr;-l used to create a hard connection file and-S is used to create a soft connection file.

In the default condition, CP's source file and destination file permissions are different, the owner of the destination file is usually the command operator itself. This is the meaning of the-p and-a parameters.

The RM command is used to delete files or directories, and the-I parameter is queried before deletion;-r recursively deletes all files and directories within the directory.

The MV command is used to move directories or files.

BaseName and dirname are used to obtain the last file name and directory name in a full path, which is commonly used in the shell.

Linux Learning Note 3-File and directory management one

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.