Must be! Management of Linux Files

Source: Internet
Author: User
Tags syslog

1.1 Creating a directory/data

[[Email protected] ~] # Mkdir/data

1.2 To see if the directory was created successfully "data can be found to create success"

[[Email protected] ~] # ls/bin  boot  data  dev  etc  Home  Lib  lib64  lost+found  Media  MNT  opt  proc  root  sbin  selinux  SRV  sys  tmp  usr  var

1.3 Create Linxu,txt below/data Create a view

[[Email protected] ~] # Touch/data/linux.txt [[Email protected] ~] # ls-l/data/ Total 0-rw-r--r--. 1 root root 0 Jul  4 02:42~]#

1.4 Writing content in Linux.txt I am studying Linux

Method one Vim

[[Email protected] ~] #
After entering vim, click the keyboard letter I enter the edit mode input what you want to write ESC exit edit mode: Wq  exit Editor If you do not need to save the direct return: q! Direct return does not save  the note all symbols need to be done in English

View Content

[[Email protected] ~] # ~]#

Method two Echo

[[Email protected] ~] #

View

[[Email protected] ~] # ~]#

Method Three Cat

[[Email protected] ~] # cat >>/data/linux.txt<<eof> 123> 456>~]#

View

[[Email protected] ~] #  I am stduying linuxi am studying linux123456~]#

1.5.1 Copy the Linux.txt to the/tmp directory

[[Email protected] ~] # cp/data/linux.txt/tmp/

View

[[Email protected] ~] # ls-l/tmptotal 4-rw-r--r--. 1 root root  4 03:04 linux.txt-rw-------. 1 root root  0 Jul  3 18:33~]#

1.5.2 Copy the/data directory to the/tmp directory

[[Email protected] ~] # cp-r/data//tmp/ [[Email protected] ~] # ls-l/tmp/total 8drwxr-xr-x.  2 root root 4096 Jul  4 03:18 data-rw-r--r--. 1 root root  4 03:04 linux.txt-rw-------. 1 root root    0 Jul  3 18:33~]#

-R is a recursive parameter to copy the directory and all the files under it

1.5.3 Backup Files

[[Email protected] ~] # Cp/data/linux.txt/data/linux.txt.bak [[Email protected] ~] # ls-l/data/ Total 0-rw-r--r--. 1 root root 0 Jul  4 03:13 linux.txt-rw-r--r--. 1 root root 0 Jul  4 03:22~]#

1.6 Move the/data to the/root directory

[[Email protected] ~] # mv/data//root/ [[Email protected] ~] # ls-l/root/Total 44-RW-------. 1 root root  1073 Jul  3 18:38 anaconda-ks.cfgdrwxr-xr-x. 2 root root  4096 Jul  4 03:22 data-rw-r--r--. 1 root root 21736 Jul  3 18:38 install.log-rw-r--r--. 1 root root  5890 Jul  3 18:36~]< c15>#

-A =-PDR

-P = property is not changed

-R = Recursive

1.7.1 Delete linux.txt under/data directory under/root

[[Email protected] ~] # rm/root/data/linux.txtrm:remove Regular empty file '/root/data/linux.txt'? y[email Protected] ~]#

Use RM command to delete, prompt whether to delete, enter Y return can delete do not want to delete Ctrl + C

1.7.2 do not prompt for deletion of delete directly

[[Email protected] ~] #

1.7.3 Delete the data directory under the root directory

[[email protected] data]#pwd/root/Data[[email protected] data]#cd/root/[[Email protected] ~]#rm-rf/root/data/[[Email protected] ~]#ls/root/anaconda-ks.cfg install.log install.log.syslog[[email protected]~]#ls-l/root/Total 40-RW-------. 1 root root 1073 Jul 3 18:38 anaconda-ks.cfg-rw-r--r--. 1 root root 21736 Jul 3 18:38Install.log-rw-r--r--. 1 root root 5890 Jul 3 18:36Install.log.syslog[[email protected]~]# 

Using RM for deletion

-F Forced Delete,-R recursion

Must be! Management of Linux Files

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.