Linux basic commands on file operations (in case)

Source: Internet
Author: User
  1. Create a directory test mkdir/test under the root directory (/)
  2. Change the current directory to/test
    In this directory, create an empty file with the abbreviation of your own name, and then create two subdirectories (-XH) and (AH ); mkdir-P/test/ycy/AH mkdir/test/ycy/-XH
  3. Go to the (-XH) subdirectory and create an empty file text1;

Touch/test/ycy/-XH/text1

  1. Go to the (AH) subdirectory, create a new subdirectory (ABC), and create an empty file text2;

Mkdir test/ycy/AH/ABC

Touch/test/ycy/AH/text2

  1. Move the newly created text1 file to the newly created ABC sub-directory, change it to text3, and copy the text2 file to the-XH sub-directory;

MV/test/ycy/-XH/text1/test/ycy/AH/ABC/text3

CP/test/ycy/AH/text2/test/ycy/-XH

  1. Delete the text3 file, the-XH sub-directory, and the files in the directory, and the ABC sub-directory;

Rm/test/ycy/AH/ABC/test3

Rm-RF/test/ycy/-XH
Delete A non-empty directory

Rmdir/test/ycy/AH/ABC

  1. Clear screen;

Clear

  1. Create a new directory test1 under the root directory (/), copy/etc/passwd to/test1 and/test respectively, and change the name to file1 and file respectively;

Mkdir/test1

CP/etc/passwd/test1/file1

CP/etc/passwd/test/File

  1. View and record the first two and last two lines of the file1 file;

Head-2/test1/file1>/fish

Tail-2/test1/file1>/fish

  1. View the files in the/etc/directory and record the names of the first two files;

Ls/etc | head-2> fish2

  1. View and record all files in the/etc/directory that contain the Sys letter;

Find-name/etc/* sys *> fish3

  1. View the first two files in the/etc/directory that contain Conf;

Ls/etc/* conf * | head-2

  1. Compress the file to/test1and name it file.gz.

Zip/test1/file.zip/test/File

  1. Package the file1 file into file.tar.gz and unpack it to/test;

Tar-zcvf file.tar.gz file1

Tar-zxvf file.tar.gz/test

  1. Create a soft link file named file. Soft to/test1;

Ln/test/file/test1/file. Soft

  1. Clear screen;

Clear

 

 

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.