File Management of Linux Basic Commands

Posted by jnuneznyc on Tue, 21 May 2019 02:29:07 +0200


     

BASH Shell manages files


=============================================================

Create, copy, delete, move, view, edit, compress, find
Summary:
Linux directory structure
File Location Path
file management

First: Linux directories usually organize files as a single root. /

Root directory structure of Linux

ls /

ivcapp-1:~ # ls /

backup  bin  boot  dev  etc  home  lib  lib64  lost+found  

media  mnt  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var


The commands / bin/ls,/bin/date used by ordinary users

Commands / sbin/service used by sbin superadministrators

Dev device file / dev/sd*,/dev/zero,/dev/null...

home directory for ordinary users

When lost + found fsck is repaired, files or directories without links are stored  

etc configuration file    

tmp global writable (temporary file, temporary file generated by process)

var stores changed files, mail, logs, etc.

==== Mount directory for storage devices==========

media) The default mount point for mobile devices

Manual mount point

===========================================================

************************** Document Time********************************************** 

ll can see the modification time of the file as much as possible

# stat file. You can view the detailed properties of the file, including the time properties.   

Access time: atime view file content

Modification Time: mtime Modify File Content    

Change time: ctime changes file attributes

Delete time: Delete time of dtime file

ivcapp-1:~ # stat accessiot.log 

  File: `accessiot.log'

  Size: 133288    Blocks: 272        IO Block: 4096   regular file

Device: ca02h/51714dInode: 615308      Links: 1

Access: (0640/-rw-r-----)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2017-07-26 06:25:36.000000000 +0000

Modify: 2017-07-26 06:25:14.000000000 +0000

Change: 2017-07-26 06:25:14.000000000 +0000

 Birth: -

=============================================================

********************* Document Type************************************************ 

Method 1:

ll File Name: // Look at the first character

_ Ordinary files (text files, binary files, compressed files, pictures, videos...)

d directory file (folder) blue

b Device file (block device) storage device hard disk, U disk/dev/sda, /dev/sda1 

c Device file (character device) printer, terminal/dev/tty1

s socket file. MySQL socket file.   

srwxrwxrwx 1 mysql mysql 0 Sep 22 07:53 /var/lib/mysql/mysql.sock

p Pipeline File

Link file Ln-S *** *** * Soft links must use absolute strength

Method 2: file name

============================================================= Absolute Strength: Where to Start/opt/cwuser/*

Relative path: relative to the current path/*

=============================================================

*********************** Document Management*********************************** 1. cd Change Directory of Document Management

    Absolute path: cd/opt/cwuser/

    Relative path: cd. / en_ivc

2. The special command of cd:

    Cd. = CD - > Returns to the previous directory.

3,File Management: Create/copy/move/delete
==============================Establish========================================================
//Document touch
# touch file1.txt
# touch file3 file4
# touch /home/file10.txt
# touch /home/file5 file6
# touch /home/{zhuzhu,gougou}
# touch file{1..20}
# touch file{a..c}
# touch liu{a,b,c} //{} set, equivalent touch liua liub liuc
===============================Catalog mkdir=================================================
# mkdir dir1
# mkdir /home/dir2 /home/dir3
# mkdir /home/{dir4,dir5}
# Mkdir-v/home/{dir6, dir7} and //-v display
# Mkdir-pv/hoem/dir8/111/222// Including the creation of their parents, no message output
# mkdir -pv /home/{yang/{dir1,111},tianyun}
=================================copy cp==================================================
Usage: cp [OPTION]... [-T] SOURCE DEST
# cd
# mkdir /home/dir{1,2}
# cp -v install.log /home/dir1
# cp -v install.log /home/dir1/yang.txt
# cp -rv /etc /home/dir1
# Cp-v install.log/home/dir90//no/home/dir90
# cp -v install.log /home/dir2
# cp -v anaconda-ks.cfg !$
# cp -rv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/passwd /etc/grub.conf /home/dir2  
                              //Copy multiple files to the same directory
# cp -rv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/passwd /etc/grub.conf /etc/hosts .
                              // Represent the current position   
# Cp-r/etc/tmp *// R * Recursively copy all contents of directories and their subdirectories
# Cp-rf/etc/tmp*/-f. Remove and retry the target file if it cannot be opened
# \cp -r /etc /tmp
=====================================move mv==============================================
Usage: mv [OPTION]... [-T] SOURCE DEST
# mv file1 /home/dir3 * Move file2 to / home/dir3
# mv file2 /home/dir3/file20 * Move File2 to / home/dir3 and rename it file20
# mv file4 file5. Rename file4 to file5, and the movement of the current location is renamed
====================================delete rm=============================================== 
//Example 1: Delete / home/dir1       
# cd /home
# rm -rf dir1       
-r recursion
-f force force
-v Detailed process

//Example 2:
[root@tianyun ~]# mkdir /home/dir10
[root@tianyun ~]# touch /home/dir10/{file2,file3,.file4}
[root@tianyun ~]# Rm-rf/home/dir10/*// excluding hidden files
[root@tianyun ~]# ls /home/dir10/ -a
.  ..  .file4

//Example 3:
[root@tianyun ~]# Rm-rf file* // Delete all files that begin with the file
[root@tianyun ~]# Rm-rf*.pdf * // Delete all files at the end of PDF





















Topics: MySQL Linux socket network