Linux File Management, winscp
Linux directory structure:
/Root partition linux File System start point
/Bin commands of common users, which can be used by common users
/Commands used by the sbin administrator, which can only be used by the Administrator
/Home the home Directory of a common user
/Root administrator's home directory
/Boot linux boot files, kernel, grub, and kernel boot files
/Dev file, hard disk, keyboard and mouse, optical drive, etc.
/Usr application/usr/src Source code package storage path
/Etc configuration file
/Opt storage path for additional software installation
/Var log files, emails, etc.
/Proc Virtual File System (Computer kernel information, CPU...), data in the memory
/Lib library file, Driver
/Selinux security mechanisms developed by the US National Security Department
/Tmp temporary file storage directory (public folder)
/Media mount point (/mnt used in redhat9.0)
/Sys system related files
Data Directory to be accessed by the/srv-enabled service
/Mnt temporary file system mount point
Two types of file data:
Metadata: file attributes
Data: File Content
Display the current directory:
[root@bogon ~]# pwd/root
Switch Directory: cd command
Absolute path: uses the root directory "/" as the starting point to accurately represent the location of a directory or file. If the path is too long, it will be cumbersome to input.
Relative Path: start with the current working directory. "." indicates the current working directory, ".." indicates the directory at the upper level, and "~" Indicates the user's home directory.
[Root @ bogon ~] # Cd-# Return to the last working directory and switch between the two working directories/etc [root @ bogon etc] # cd-
File wildcard:
* Matches zero or multiple characters.
? Match any single character
~ Current user's home directory
~ Username user's home directory
~ + Current working directory
~ -Previous working directory
[0-9] match a number range
[A-z] uppercase and lowercase letters
[A-Z] capital letters
[Wxc] matches any character in the list
[^ Wxc] match characters other than all characters in the list
Predefined character classes: # man 7 glob
[: Digit:] any number, equivalent to 0-9
[: Lower:] Any lowercase letter
[: Upper:] Any uppercase letter
[: Alpha:] Any uppercase/lowercase letter
[: Alnum:] any number or letter
[: Space:] space
[: Punct:] punctuation marks
List the contents of a directory or specify a directory:
Ls command: ls [options] [files_or_dirs]
-A contains hidden files
-L is displayed in long format, ll
-R directory recursive display
-D directory and link information
-1 file branch display
-S: Sorting from big to small
-I: displays the file index node.
Display the hidden files and directories in the current working directory:
[root@bogon ~]# ls -d .*. .. .bash_history .bash_logout .bash_profile .bashrc .cshrc .tcshrc .viminfo
Display the following directories in the current working directory:
[root@bogon var]# ls -d */ adm/ crash/ empty/ gopher/ lib/ lock/ mail/ opt/ run/ tmp/cache/ db/ games/ kerberos/ local/ log/ nis/ preserve/ spool/ yp/
Displays all files or directories in the/etc directory ending with. conf and starting with m, n, r, and p.
[root@bogon log]# ll /etc/[mnrp]*.conf -rw-r--r--. 1 root root 5171 Jun 10 2014 /etc/man_db.conf-rw-r--r--. 1 root root 936 Mar 6 2015 /etc/mke2fs.conf-rw-r--r--. 1 root root 1717 May 1 05:40 /etc/nsswitch.conf-rw-r--r--. 1 root root 82 May 1 19:24 /etc/resolv.conf-rw-r--r--. 1 root root 458 Nov 21 2015 /etc/rsyncd.conf-rw-r--r--. 1 root root 3232 Sep 8 2015 /etc/rsyslog.conf
Linux file type:
-Common files
D directory file
Block B Devices
C character device
L symbolic link file
P pipeline file pipe
S socket file socket
View File status: stat
[Root @ bogon ~] # Stat anaconda-ks.cfg File: 'anaconda-ks. cfg 'size: 1401 Blocks: 8 IO Block: 4096 regular fileDevice: fd00h/64768d Inode: 101877942 Links: 1 Access: (0600/-rw -------) Uid: (0/root) gid: (0/root) Context: system_u: object_r: admin_home_t: s0Access: 05:41:12. 625008626 + 0800 # access time, Read File Content Modify: 05:41:12. 630008626 + 0800 # modify time, Change file content (data) Change: 05:41:12. 630008626 + 0800 # Change Time, metadata change Birth :-
Touch command: File Creation and refresh time
Touch [OPTION]... FILE...
-A changes atime
-M: Change mtime
-T STAMP: [[CC] YY] MMDDhhmm [. ss]
-C if the file does not exist, it will not be created
Cp command: Copy
-A archive, equivalent to-dr
-B. If the target file is deleted or overwritten, the target file will be backed up. The backup file ends with the backup string.
-D copy the Symbolic Link
-F force copy
-H force cp to copy the symbolic link. The default value is to follow the symbolic link and copy the file to the point of the symbolic link.
-I interactive mode. Ask before overwriting the target file
-L create a hard link instead of a copy
-Keep the properties of the p Source directory or file
-R processes specified directories and subdirectories
Copy the files in the/root directory to the/data directory, including hiding the files:
[root@bogon ~]# cp -r /root/. /data/[root@bogon ~]# ls -a /data/. anaconda-ks.cfg .bash_logout .bashrc .tcshrc.. .bash_history .bash_profile .cshrc .viminfo
Move and rename:Mv [Option]
-I interactive
-F force: if the target file already exists, directly overwrite it without asking.
-B: If you need to overwrite the file, back up the file before overwriting.
[Root @ bogon ~] # Lsanaconda-ks.cfg file1.txt [root @ bogon ~] # Mv file1.txt/data/file2.txt [root @ bogon ~] # Ls/data/file2.txt # Move file1 to the/data directory and rename file2
Delete an object:Rm [Option]... file...
-I: Interactive
-F: Force Delete
-R: recursively deletes the directory tree.
[Root @ bogon ~] # Ls/data/file2.txt testdir [root @ bogon ~] # Rm-rf/data/* [root @ bogon ~] # Ll/data/total 0 # delete files in the/data Directory
Show directory tree:Tree
-D: displays only directories.
-L level: number of levels displayed
-P pattern: displays only
The "/" directory tree is displayed. Only one layer is displayed:
[root@bogon ~]# tree -L 1 //├── bin -> usr/bin├── boot├── data├── dev├── etc├── home├── lib -> usr/lib├── lib64 -> usr/lib64├── media├── mnt├── opt├── proc├── root├── run├── sbin -> usr/sbin├── srv├── sys├── tmp├── usr└── var
Create directory: mkdir
-P: recursively creates directories and automatically creates directories;
-V: displays details.
-M MODE: Specify the permission directly when creating a directory;
[root@bogon ~]# mkdir -m 700 test[root@bogon ~]# lltotal 4-rw-------. 1 root root 1401 May 1 05:41 anaconda-ks.cfgdrwx------. 2 root root 6 May 2 02:27 test
Rmdir: delete an empty directory.
-P: recursively deletes the parent empty directory.
-V: displays details.
Link file: ln command
Differences between soft connection and hard link:
After the source file is deleted, the soft connection becomes invalid, but the hard link is still available.
Soft connections are applicable to files or directories, but hard links are only applicable to files.
The soft connection and the original file can be located in different file systems, but the hard link must be in the same partition as the original file.
By default, the ln command creates a hard link. The "-s" option must be used to create a soft link.
[root@bogon ~]# ln -s /etc/httpd/conf/httpd.conf /etc[root@bogon ~]# ll /etc/httpd.conf lrwxrwxrwx. 1 root root 26 May 2 02:47 /etc/httpd.conf -> /etc/httpd/conf/httpd.conf[root@bogon ~]# ln /var/log/messages /tmp/test[root@bogon ~]# ll -h /tmp/test-rw-------. 2 root root 574K May 2 02:46 /tmp/test
File command: used to identify the file type and identify the encoding format of some files.
File [options] <filename>...
-B: when listing the file identification results, the file name is not displayed.
-C displays the instruction execution process in detail to facilitate troubleshooting or analyzing Program Execution
-F: list the file types of file names.
-F Replace the default ":" separator after the output file name with the specified separator
-I: Output a mime-type string
-L view the file type of the corresponding soft link file
-Z: try to interpret the compressed file content
-- Help: displays online help for commands.
View the file type of the soft connection:
[root@bogon ~]# file -L /etc/httpd.conf /etc/httpd.conf: ASCII text
Du command: Count the space usage of directories and files
-A counts the files occupied by disk space, not just the directories.
-H is displayed in K and M units.
-S only counts the space occupied by a parameter, rather than counting each subdirectory
[root@bogon ~]# du -sh /var/log/3.3M /var/log/[root@bogon ~]# du -ah /boot/4.0K /boot/grub/splash.xpm.gz4.0K /boot/grub0 /boot/grub2/themes/system0 /boot/grub2/themes4.0K /boot/grub2/device.map12K /boot/grub2/i386-pc/acpi.mod