Basics of Linux Basics (iii) file basic operations management and common commands

Source: Internet
Author: User
Tags current time echo command requires time and date touch zip root directory linux

File Basic Operations

The command "CP" is used to copy files or directories:

$ CP [-R] Source (folder) destination file (folder)

-R recursively copies the entire directory, which is used by the Replication folder

-V display details, cp-rv or cp-r-V when copying files more, you can see progress

The command "MV" is used to move or rename a file or directory:

$ MV [-R] Source file (folder) destination directory

Renaming if a filename is specified when moving

Command "Touch" to create a blank file or update the timestamp of an existing file:

$ Touch File name

Command "rm" to delete a file or folder:

RM Files/Folders

-I interactive Delete, each delete a file will be prompted

-R Recursive Delete all files under folder

-F Force Delete, not prompt (cautious)

Command "mkdir", "rmdir" to create or delete a directory

RmDir can delete an empty directory, but you cannot delete a directory that has files

Time and date

Date command: Displays the current time date

Format Display time: +%y--%m--%d

Set: $ date-s Date string, modification requires Superuser privileges

Hwclock command: Show hardware clock, require SU permission

Cal command: displaying calendars

Uptime command: Show system run time

Output, view

echo command: Send the input string to standard output.

For example, echo "ABC", the screen will output ABC.

You can output strings to other files, such as

$ echo "Hello World" > Input.txt

Cat command: View the contents of the specified file

Head command: View the contents of the first 10 lines of the specified file

Head [-n] Specifies how many lines of content to display

Tail command: View 10 lines at the end of the specified file

tail [-n] Specifies how many lines of content to display

tail [-f] tracks the update of the file. Can be used to track logs

More command: View the contents of the specified file as pages (only page DOWN)

Less command: To view the contents of the specified file (page up and down)

View hardware Information

LSPCI command: View PCI device information

-V View more information

LSUSB command: View USB device Information

-V View more information

Lsmod to view loaded modules

Shutdown, reboot

Shutdown command: Shutdown, reboot, hibernate (timed)

-H shutdown (halt)

-R reboot (restart)

For example:

$ shutdown-h Now shutdown

$ shutdown-h +10 10 minutes after shutdown

$ shutdown-h 23:20 23:20 shutdown

$ shutdown-r Now reboot

Reboot command: Reboot now

Poweroff command: Turn off the machine now

Archive, Compress

Zip command: Creating a Zip Compressed file

$ zip zsd.zip myfile myfile compressed into zsd.zip

Unzip command: Extract Zip compressed file

$ unzip Zsd.zip to extract Zsd.zip

gzip command: Create a GZIP formatted compressed file

Tar command: Create an archive (typically used for backup, can be performed with gzip to create archive compressed files)

An archive is a collection of files and directories that are stored in a file. The archive is not compressed----the space it occupies is the sum of all the files and directories in it. A compressed file is also a collection of files and directories, and the collection is stored in a file, but it is stored so that it consumes less disk space than the sum of all the files and directories in it. The archive file is not a compressed file, but a compressed file can be an archive file.

$ TAR-CVF Out.tar myfile1 myfile2 ..., creating a Out.tar archive file

$ TAR-XVF Out.tar to extract Out.tar

$ tar-xvzf out.tar.gz myfile for gzip compression of myfile archived archive files

The-z parameter compresses the archived archive into gzip format to reduce space. Most of the Linux open source files downloaded on the Web are in this format.

Find

Locate command: Quick Find files

$ locate Keyword

Requires specific database support, the database defaults to one more per day, can be manually established through the UpdateDB command, update the database

Find command: Powerful real-time lookup commands that support multiple condition lookups, but slow

Find Lookup Location Lookup parameter

For example: Note that the lookup string must have double quotes

$ find. -name "*filename*" is in the current directory,-name represents a filename lookup based on the filename of the wildcard character

$ find/-name "*.confg" in the root directory, based on file name lookup, to. confg End of File

$ find/-perm 777 Search root directory, all permissions are 777 files

$ find/-type D finding all catalogs

$ find.   -name "A *"-exec ls-l {} \; In addition to Ls-l, all others are in a fixed format, with all filenames starting with a filename as a parameter to the LS-L command

Find supports a wide variety of lookup conditions, commonly used as follows:

-name

-perm

-user

-group

-ctime

-type

-sizep>

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

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.