Mkdir,rmdir,cp,rm,mv,cat,touch usage

Source: Internet
Author: User

First, mkdir new directory

1. Go to the TMP directory and look at the subdirectories below the directory

[Email protected] ~]# cd/tmp
[[email protected] tmp]# ls
Hsperfdata_root Ks-script-3cwmoc SYSTEMD-PRIVATE-810F661CB5D247129113C096F86D7DB2-CUPS.SERVICE-FEKFSX Vitest Yum.log

2. mkdir create the test directory and view

[Email protected] tmp]# mkdir test
[[email protected] tmp]# ls
Hsperfdata_root Ks-script-3cwmoc SYSTEMD-PRIVATE-810F661CB5D247129113C096F86D7DB2-CUPS.SERVICE-FEKFSX Test vitest Yum.log

3. Create catalogs in batches

[Email protected] tmp]# mkdir-p test1/test2/test3/test4

[[email protected] tmp]# ls
hsperfdata_root Ks-script-3cwmoc SYSTEMD-PRIVATE-810F661CB5D247129113C096F86D7DB2-CUPS.SERVICE-FEKFSX test test1 vitest yum.log
[[email  Protected] tmp]# CD test1
[[email protected] test1]# ls
test2
[[email protected] test1]# CD test2
[[email protected] test2]# ls
test3
[[email protected] test2]# cd test3
[[email  Protected] test3]# ls
test4
4, new directory with permissions of Rwx--x--x

[Email protected] tmp]# mkdir-m 711 Test2
[Email protected] tmp]# ls-l
Total 4
Drwxr-xr-x. 2 root root (DEC) 01:18 Hsperfdata_root
-RWX------. 1 root root 827 Dec 01:26 Ks-script-3cwmoc
DRWX------. 3 root root Dec 20:52 systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fekfsx
Drwxr-xr-x. 2 root root 6 Dec 03:36 test
Drwxr-xr-x. 3 root root 03:38 test1 permissions for the original directory
Drwx--x--x. 2 root root 6 Dec 03:40 test2 new directory Permissions
Drwxr-xr-x. 2 root root (DEC) 02:18 vitest
-RW-------. 1 root root 0 Dec 01:06 yum.log

Second, rmdir delete directory

1. Delete Catalog test

[Email protected] tmp]# rmdir test

2. View the results of the deletion

[Email protected] tmp]# ls-l
Total 4
Drwxr-xr-x. 2 root root (DEC) 01:18 Hsperfdata_root
-RWX------. 1 root root 827 Dec 01:26 Ks-script-3cwmoc
DRWX------. 3 root root Dec 20:52 systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fekfsx
Drwxr-xr-x. 3 root root 03:38 test1
Drwx--x--x. 2 root root 6 Dec 03:40 test2
Drwxr-xr-x. 2 root root (DEC) 02:18 vitest
-RW-------. 1 root root 0 Dec 01:06 yum.log

3. Delete the other directories below the test directory in bulk

[Email protected] tmp]# rmdir-p test1/test2/test3/test4
[Email protected] tmp]# ls-l
Total 4
Drwxr-xr-x. 2 root root (DEC) 01:18 Hsperfdata_root
-RWX------. 1 root root 827 Dec 01:26 Ks-script-3cwmoc
DRWX------. 3 root root Dec 20:52 systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fekfsx
Drwx--x--x. 2 root root 6 Dec 03:40 test2
Drwxr-xr-x. 2 root root (DEC) 02:18 vitest
-RW-------. 1 root root 0 Dec 01:06 yum.log

Ii. usage of CP

1. Copy the Install.log to the TMP directory.

[email protected] tmp]# CP ~/install.log/tmp/install.log
[[email protected] tmp]# ls
Hsperfdata_root Install.log Ks-script-3cwmoc SYSTEMD-PRIVATE-810F661CB5D247129113C096F86D7DB2-CUPS.SERVICE-FEKFSX Test2 vitest Yum.log

2, if the directory already exists, then +I coverage CP

[Email protected] tmp]# cp-i ~/install.log/tmp/install.log
Cp:overwrite '/tmp/install.log '? Y

3. RM Delete Directory

[Email protected] tmp]# RM install.log
Rm:remove regular empty file ' Install.log '? Y
[[email protected] tmp]# ls
Hsperfdata_root Ks-script-3cwmoc systemd-private-810f661cb5d247129113c096f86d7db2-cups.service-fekfsx test2 vitest Yum.log

4. Rm+i Avoid deleting errors

[Email protected] tmp]# rm-i Install.log
Rm:remove regular empty file ' Install.log '? Y

5. Forcibly Delete Empty directory

[Email protected] tmp]# RM etc
Rm:cannot Remove ' etc ': is a directory
[Email protected] tmp]# Rm-r etc
Rm:remove directory ' etc '? Y

Three, MV usage

1. Create the Install folder and move the Install.log file to the directory below

[Email protected] ~]# cd/tmp
[email protected] tmp]# CP ~/install.log Install.log
[[email protected] tmp]# mkdir Install
[[Email protected] tmp]# mv Install.log Install
[Email protected] tmp]# Cd/tmp/install
[[email protected] install]# ls
Install.log

Four, cat file lookup usage

[Email protected] ~]# cat/etc/issue
\s
Kernel \ r on an \m

Five, Touch usage

1. Create 1 files and view this file

[email protected] tmp]# Touch Testtouch
[Email protected] tmp]# Ls-al Testtouch
-rw-r--r--. 1 root root 0 Dec 04:02 Testtouch

Mkdir,rmdir,cp,rm,mv,cat,touch usage

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.