Welcome to add QQ Group: 414835967 Exchange Linux Technology and download the relevant software package and accompanying notes in the group sharing file
Knowledge Points:
Linux system directory structure
Relative/absolute path
Set the time
Create/copy/delete files
RM-RF/accident
View File Contents
Restore Linux files that were deleted
First, the Linux system directory structure
# inverted tree structure/commonly referred to as the root partition. All files and directories begin with this. Only the root user has write access to this directory. #---/etc configuration file contains the configuration files for all applications, and also contains scripts to start and close a particular program, such as/etc/passwd,/etc/init.d/network. #---/boot stores the files that the Linux system needs to load when booting. (usually saved in another disk partition) Kernel, grub and other files are stored here. #---Home/home user all data is stored in this directory #---/var is an extensible directory that contains very often variable files. For example,/var/log (System log),/var/lib (Pack documentation) #---/root all data for the administrator. Root user's home directory #---/tmp temporary file storage location #---/usr usr represents the UNIX software source#---/bin command This directory contains a binary executable file. #---The/sbin system command, the commands in this directory are primarily for system administrators to use for system maintenance. For example, Iptables, reboot, Fdisk, and so on. #/mnt-mount a directory mount point, which the system administrator can use to temporarily mount the file system. #---/dev contains device files. In Linux, everything is considered a file. Terminal devices, USB, disks, and so on are all considered files, such as/DEV/SDA.
two, absolute path/relative path
# cd/etc/sysconfig/network-scripts/# relative path: [[email protected] ~]# cd/etc[[email protected] etc]# cdsysconfig/ network-scripts/. (represents the current directory) ... (indicates a parent directory)
III. Create/view/copy/delete files and folders
Creating Files and Directories
1 Touch
Function: Often used to create empty files
Syntax: Touch file name
[[email protected]/]# toucha.txt[[email protected]/]# ls a.txta.txt
2 mkdir
Role: Create a directory
Syntax: mkdir directory Name
# Mkdir/tmp/test
-P is created along with the parent directory
# mkdir/path/to/dirname# Mkdir-p
# "Example" creates a directory with-p [[email protected] ~]# mkdir-p/a/b/c/d[[email protected] ~]# CD!$ #!$ represents the last parameter of the previous command cd/a/b/ C/d[[email protected] d]# CD. /.. /[[email protected] b]# pwd/a/b
View File methods
3 Cat
Function: View the contents of a file
Syntax: Cat file name
Cases:
# CAT/ETC/PASSWD
4 more
"Example" to view the contents of a file
# MORE/ETC/PASSWD
Q exit
5 Less
"Example" to view the contents of a file
# LESS/ETC/PASSWD
Q exit
Use the cursor keys to page UP
The difference between more and less in Linux:
MORE: Does not support back, but almost no need to add parameters, the space bar is the page down, the ENTER key is down the line, in the case of no need to back the situation is convenient.
Less: Supports rollover, either up (PageUp button) or down (pagedown button). , the SPACEBAR is a page down, and the ENTER key is a downward-turning line
6 Head
Function: Starting from the first line, viewing the file, showing the first 10 rows by default
-N numbers show how many rows
Cases
# head/etc/passwd# Head-n 3/etc/passwd
7 tail
Function: Starting from the first line, viewing the file, the last 10 lines are displayed by default
-N shows how many rows
-F Dynamic Display data (not closed) often used to view logs
[[email protected] tmp]# tail-f/var/log/messages[[email protected] ~]# service Networkrestart
See who modified the DNS server address in/etc/resolv.conf.
Delete files and folders
8 RM
Action: Delete a file or directory
Syntax: RM-RF file or directory name
[Email protected] ~]# rm-rf/tmp/test[[email protected] ~]# rm-rf/tmp/test11
-R Recursive Delete (can delete things in directory and directory)
-F forcibly Delete non-interactive
Rename or move
9 MV
Action: Move, Cut, rename
Syntax: MV Source: File or directory name destination: file or directory name
1. Change the name of the 1 file to Suifeng
[Email protected] ~]# mv 1suifeng[[email protected] ~]# Lssuifeng
2. Move the file 1 to the A directory
[[Email protected] ~]# mv 1a/[[email protected] ~]# LS A1
Work experience: Use the Delete command carefully, use MV command frequently
Copy files and copy directories
Ten CP
Role: Copying files
Syntax: CP source file Destination file
[Email protected] ~]# cp/etc/passwd/tmp/[[email protected] ~]# ls/tmp/passwd/tmp/passwd
Copy directory:
[[email protected] ~]# cp/etc//tmp/cp:omitting (Ignore) directory '/etc/' #-R contains subdirectories and files (recursive replication). [Email protected] ~]# cp-r/etc//tmp/
Iv. about the date command, date
Effect: 1. Printing time, date, or setting time
2. Print the current year
1. Date print time, date, or set time
2. Print the current year
[Email protected] ~]# date+%y2014
3. Print the current month
[Email protected] ~]# DATE+%M12
4. Print the current minute
[Email protected] ~]# date+%m05
5. Print the current hour
[Email protected] ~]# date+%h05
6. Print the current number of days
[Email protected] ~]# date+%d07
7. Set the system time and date, format: Month day hour minute year. seconds
2014 12 07 21 18 40
[[email protected] ~]# date120721082014.402014 December 07 Sunday 21:08:40 CST
8. Set the year and month directly
[[email protected] ~]# date-s 2014/12/092014 December 09 Tuesday 00:00:00 cst# If the year is set directly, the time default is 00:00:00
9. Set the month and time of the year directly
[[email protected] ~]# date-s "2014/12/0920:20" # Date and time required "" to enclose December 09, 2014 Tuesday 20:20:00 cst[[email protected] ~]# Date 120,721,152,014 December 07 Sunday 21:15:00 CST
10. Setting the time directly
[[email protected] ~]# date-s 20:012014 December 09 Tuesday 20:01:00 CST [[email protected] ~]# date-s 2007 # No Need: To separate December 09, 2014 Tuesday 20:07:00 CST
11. Convert Timestamps to Dates
# date-d "1970-01-01 16066 Days"
12. Convert dates to timestamps
# echo $ (($ (Date--date= "2015/01/12" +%s)/86400+1))
Interaction:
1. Create a file with the same name first #touch/tmp/test11
Create a directory with the same name again #mkdir/tmp/test11
Result cannot create directory
2. Create a directory with the same name first #mkdir/tmp/test11
Create a file with the same name again #touch/tmp/test11
The result is only the directory and the created file is unsuccessful.
That the same directory cannot have a file name or directory name with the same name
Welcome to add QQ Group: 414835967 Exchange Linux Technology and download the relevant software package and accompanying notes in the group sharing file
This article is from the "Learning God It-linux lecturer-mk" blog, please be sure to keep this source http://xuegod.blog.51cto.com/9708186/1639886
Linux Basic file Management