File management of Linux basic commands

Source: Internet
Author: User



BASH Shell to manage files


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

Create, copy, delete, move, view, edit, Compress, find
Content Summary:
Linux directory structure
File location path
File Management

A: The Linux directory usually organizes files in a single form. /

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 command/bin/ls,/bin/date used by the bin ordinary user

Sbin commands used by super administrators/sbin/service

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

Home directory for normal home users

Lost+found when fsck is repaired, store files or directories that are not linked

ETC configuration file

TMP Global writable (temporary file, temporary file generated by process)

var stores some changes in files, mails, logs, etc.

= = = Mount Directory of storage devices ==========

Mount points that media mobile device mounts by default

MNT mount point for manually mounted devices

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

**************** file Time ******************

ll can see when the file was modified

#stat file to view detailed properties of the file, including the time attribute.

Access time: Atime View file content read

Modified: Mtime Modify the contents of the file, delete and change

Change time: CTime change the file's properties file permissions

Delete Time: Dtime file deletion time

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:-

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

File Type ********************

Method One:

ll filename//See first character

_ Normal files (text files, binaries, 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. The MySQL socket file.

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

P Pipeline File

L Connection File Ln-s * * * * * * * * Soft connection must use absolute road strength

Method Two: File file name

============================================================= Absolute Road strength: from/to the place/opt/cwuser/*

Relative path: The current path is now in the/OPT directory cwuser/*

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

*************** file Management ******************** 1, File Management CD Change directory

Absolute path: cd/opt/cwuser/

Relative path: CD./EN_IVC

2, CD's Special command:

Cd.. =CD-returns to the previous level directory.

3. File management: Create/Copy/move/delete ============================== Create ======================================================== file  touch# touch file1.txt         //is created, there is modification time #  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}           //{} collection, equivalent touch  liua liub liuc=============================== Directory  mkdir==================================== =============# MKDIR DIR1# MKDIR /HOME/DIR2 /HOME/DIR3# MKDIR /HOME/{DIR4, dir5}# mkdir -v /home/{dir6,dir7}             //-v shows # mkdir -pv /hoem/dir8/111/222    //including the creation of their parents, there will be 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 .                               // .    represents the current location    # cp -r /etc /tmp           //   -r    recursively replicates all content within the directory and its subdirectories # cp -rf /etc  /tmp         //-f  If the destination file cannot be opened, remove it and try # \cp -r  /etc /tmp===================================== Mobile  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 renamed to file20# mv  file4 file5           rename File4 to File5 and the current position is renamed ================================== = = Delete  rm===============================================  Example 1: Delete/home/dir1        # cd /home# rm -rf dir1       -r   Recursive-f force Mandatory-v  Detailed procedure Example 2:[[email protected] ~]# mkdir /home/dir10[[email  protected] ~]# touch /home/dir10/{file2,file3,.file4}[[email protected] ~]#  rm -rf /home/dir10/*              //does not include hidden files [[email protected] ~]# ls /home/dir10/ -a.  ..   .file4 Example 3:[[email protected] ~]# rm -rf file*              //Delete all files beginning with [[Email protected] ~]# rm  -rf *.pdf   &nbsp          //Delete all files ending in PDF 





















This article from the "13354145" blog, reproduced please contact the author!

File management of Linux basic commands

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.