Linux does not delete files, empty the contents of the file command _linux

Source: Internet
Author: User

At some point, the contents of the file need to be emptied without deleting the file. Analogy some log files (log.txt); the commands under Linux are:true >log.txt

Test results:

Touch Log.txt → #新建文件log. txt

VI log.txt → #编辑 file

Whatever you want to enter.

: wq! return → #保存退出;

Cat Log.txt → #查看 The contents of the document;

true >log.txt → #查看 the contents of the document;

Report:

Rm-r Delete directories, regardless of whether there are files in the directory

RM-RF forced deletion, no hint

Generally used in these two, delete files can be used rm-f, the same is forced to delete

RM-RF File Man RM also has the option of using/etc/null, which is also equivalent to the Recycle Bin in Windows!

CAT/ETC/PASSWD |cut-f 1-d: View all Users

SU Switch User

Userdel Delete User Name

AddUser username New User

The above Linux does not delete files, empty the contents of the file command is small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.

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.