First display: related commands ls, pwd
Ls commands are very powerful and commonly used, but they are hard to remember.
1-1. For non-Internal commands (such as ls, rm, and mkdir), you cannot use help to view help.
1-2, ll = ls-l // display in long format
[Root @ localhost ~] # Ls
Anaconda-ks.cfgDesktopinstall.loginstall.log.syslog
[Root @ localhost ~] # Ll
Total 56
-Rw ------- 1rootroot100902-1021: 03anacon1_ks.cfg
Drwxr-xr-x2rootroot409602-1021: 35 Desktop
-Rw-r -- 1rootroot3203602-1021: 02install. log
-Rw-r -- 1rootroot364262-1020: 59install. log. syslog
[Root @ localhost ~] #
1-3, ls options:
-D (display directory)
-L (long format display)
-F (if it is a folder, it indicates)
-R (recursively viewing Directories)
-A (display all files except the Directory and the parent directory, including hidden files)
-A (display all files, including hidden files and the directories and parent Directories)
-H (display the size of the file or folder in an easy-to-read manner (if a folder is displayed, it must be used with the-d parameter)
1-4, classic instance
[Root @ localhostdata] # ll-hd // hd combination. The attributes of the current folder are displayed in long format.
Drwxr-xr-x4rootroot4.0K02-1021: 49.
[Root @ localhostdata] # ll // only the content in this directory is displayed in long format. Two folders are displayed. ll //-F is better displayed as a folder, which is marked /.
Total 20
Drwx ------ 2rootroot1638402-1104: 45 lost + found
Drwxr-xr-x3rootroot409602-1021: 50 VMtools
[Root @ localhostdata] # ll-F // long format to view the documents in this folder. If it is a folder, it is marked at the bottom right of the folder. The folder // package contains two folders.
Total 20
Drwx ------ 2rootroot1638402-1104: 45 lost + found/
Drwxr-xr-x3rootroot409602-1021: 50 VMtools/
[Root @ localhostdata] # cdVMtools // enter the VMtools folder
[Root @ localhostVMtools] # ll // The difference between-h and-h is not added below, and the font is bold...
Total 60668
-R-xr-xr-x1rootroot196102-1021: 50manifest.txt
-R -- 1rootroot184702-1021: 50run_upgrader.sh
-R -- 1rootroot6063846502-1021: 50vmwarw.ls-9.6.1-1378637.tar.gz
Drwxr-xr-x7rootroot409610-1809: 26vmware-tools-distrib.
-R-xr-xr-x1rootroot68945602-1021: 50vmware-tools-upgrader-32
-R-xr-xr-x1rootroot70247202-1021: 50vmware-tools-upgrader-64
[Root @ localhostVMtools] # ll-h // check the file size in this folder. The-h Parameter indicates the display size in easy-to-understand format, and the bold font indicates the difference. //
Total 60 M
-R-xr-xr-x1rootroot2.0K02-1021: 50manifest.txt
-R -- 1rootroot1. 9K02-1021: 50run_upgrader.sh
-R -- 1rootroot58M02-1021: 50vmwarw.ls-9.6.1-1378637.tar.gz
Drwxr-xr-x7rootroot4.0K10-1809: 26vmware-tools-distrib.
-R-xr-xr-x1rootroot674K02-1021: 50vmware-tools-upgrader-32
-R-xr-xr-x1rootroot687K02-1021: 50vmware-tools-upgrader-64
[Root @ localhost ~] # Ls-R/boot // The-R parameter indicates recursive display of the/boot directory
/Boot /:
Config-2.6.18-348.el5lost + foundvmlinuz-2.6.18-348.el5
Grubsymvers-2.6.18-348.el5.gz
Initrd-2.6.18-348.el5.imgSystem.map-2.6.18-348.el5
/Boot/grub:
Device. mapgrub. confminix_stage1_5stage2
E2fs_stage%5iso9660_stage%5reiserfs_stage%5ufs2_stage%5
Fat_stage%5jfs_stage%5splash.xpm.gzvstafs_stage%5
Ffs_stage00005menu.lststage1xfs_stage00005
/Boot/lost + found:
2. pwd command
Simply display the current path
[Root @ localhostnetwork-scripts] # pwd
/Etc/sysconfig/network-scripts
[Root @ localhostnetwork-scripts] # cd ..
[Root @ localhostsysconfig] # pwd
/Etc/sysconfig
[Root @ localhostsysconfig] #
Second: Create mkdir
Usage: mkdir [Option] Directory...
If the directory does not exist, create a directory.
Long Options are required when short options are used.
-M, -- mode = mode: Set the permission <mode> (similar to chmod), instead of rwxrwxrwx minus umask
-P, -- create the upper-level directory when parents is required. If the directory already exists, it is not treated as an error.
-V, -- verbose displays information every time a new directory is created
-- Help: displays the help information and exits.
-- Version: Output version information and exit
After-p is added, no error will be prompted, no matter whether you repeat the same directory of your resume or you have created two directories under the directory:
[Root @ localhost ~] # Ls
Anaconda-ks.cfgDesktopinstall.loginstall.log.syslog
[Root @ localhost ~] # Mkdira
[Root @ localhost ~] # Ls
Aanaconda-ks.cfgDesktopinstall.loginstall.log.syslog
[Root @ localhost ~] # Mkdira
Mkdir: the directory "a" cannot be created. The file already exists.
[Root @ localhost ~] # Mkdir-pa
[Root @ localhost ~] # Mkdira/aa/aaa
Mkdir: the directory "a/aa/aaa" cannot be created: the file or directory does not exist.
[Root @ localhost ~] # Mkdir-pa/aa/aaa
[Root @ localhost ~] # Ls
Aanaconda-ks.cfgDesktopinstall.loginstall.log.syslog
[Root @ localhost ~] # Ls-R
.:
Aanaconda-ks.cfgDesktopinstall.loginstall.log.syslog
./:
Aa
./A/aa:
Aaa
./A/aa/aaa:
./Desktop:
[Root @ localhost ~] #
Third: Create the ln of the linked file
1. When no parameter is added, it creates a hard link and cannot be used across partitions.
[Root @ localhost ~] # Ln/etc/passwd./passwd // create a hard link for/etc/passwd in the root directory
Ln: creating a hard link "./passwd" pointing to "/etc/passwd": The file already exists.
[Root @ localhost ~] # Ll
Total 60
Drwxr-xr-x3rootroot409602-1200: 08a.
-Rw ------- 1rootroot100902-1021: 03anacon1_ks.cfg
Drwxr-xr-x3rootroot409602-1200: 25 Desktop
-Rw-r -- 1rootroot3203602-1021: 02install. log
-Rw-r -- 1rootroot364262-1020: 59install. log. syslog
Lrwxrwxrwx1rootroot1102-1200: 11passwd->/etc/passwd
[Root @ localhost ~] # Ls
Aanaconda-ks.cfgDesktopinstall.loginstall.log.syslogpasswd
[Root @ localhost ~] # Cd/boot // go to the boot directory
[Root @ localhostboot] # ln/etc/passwd. /passwd // create a hard link of/etc/passwd in the boot Directory, which cannot be created, the disk/space attached to the/boot directory is independently divided into disk space. Hard links cannot be connected across devices, so they cannot be created.
Ln: creating a hard link "./passwd" pointing to "/etc/passwd": Invalid cross-device connection
[Root @ localhostboot] # ln-s/etc/passwd./passwd // you can see that the soft connection created by ln-s can be cross-partition.
[Root @ localhostboot] # ll
Total 6333
-Rw-r -- 1rootroot678572012-11-29config-2.6.18-348.el5
Drwxr-xr-x2rootroot102402-1021: 03 grub
-Rw ------- 1rootroot283762602-1021: 54initrd-2.6.18-348.el5.img
Drwx ------ 2rootroot1228802-1104: 45 lost + found
Lrwxrwxrwx1rootroot1102-1212: 44passwd->/etc/passwd
-Rw-r--r--1rootroot1186262012-11-29symvers-2.6.18-348.el5.gz
-Rw-r -- 1rootroot12316242012-11-29system.map-2.6.18-348.el5
-Rw-r -- 1rootroot21256602012-11-29vmlinuz-2.6.18-348.el5
[Root @ localhostboot] #
2. The-s parameter indicates creating a shortcut (soft connection)
[Root @ localhost ~] # Ln-s/etc/passwdpasswd
[Root @ localhost ~] # Ll
Total 60
Drwxr-xr-x3rootroot409602-1200: 08a.
-Rw ------- 1rootroot100902-1021: 03anacon1_ks.cfg
Drwxr-xr-x2rootroot409602-1021: 35 Desktop
-Rw-r -- 1rootroot3203602-1021: 02install. log
-Rw-r -- 1rootroot364262-1020: 59install. log. syslog
Lrwxrwxrwx1rootroot1102-1200: 11passwd->/etc/passwd
[Root @ localhost ~] #
Fourth: Copy cp
Common Command Options:
-I: if the same file exists, the system prompts whether to overwrite the file.
-R: recursively copy the entire directory (add the r parameter when copying a directory)
-F: Force overwrite, no prompt (relative to-I)
-P: Keep the attribute of the source file unchanged.
Note: When using cp, You can first check the alias command. The default cp command is cp-I, that is, when using cp, it actually uses cp-I, that is, if you want to cancel the message with cp-f, you must first cancel cp = cp-I; or add an escape character # \ cp-ffile1.txt/host/test/
Common Commands include:
[Root @ localhost ~] # Cp-r/boot/grub/etc/host. confDesktop // copy the grub directory and host. conf file to the // Desktop directory
[Root @ localhost ~] # LsDesktop/
Grubhost. conf
[Root @ localhost ~] # Cp-rf/boot/grub/etc/host. confDesktop // at this time, the overwriting will not be reminded. If the f parameter is not added, a reminder will be sent one by one.
[Root @ localhost ~] # Ls-FDesktop/
Grub/host. conf
[Root @ localhost ~]
Fifth: Move and rename music videos
[Root @ localhost ~] # Ls
Aanaconda-ks.cfgDesktopinstall.loginstall.log.syslogpasswd
[Root @ localhost ~] # Touchfile1
[Root @ localhost ~] # Mvfile1file2 // change the name of file1 to file2
[Root @ localhost ~] # Ls
Aanaconda-ks.cfgDesktopfile2install.loginstall.log.syslogpasswd
[Root @ localhost ~] # Mvfile2Desktop // move file2 to the Desktop directory under this directory
[Root @ localhost ~] # LsDesktop/
File2grubhost. conf
[Root @ localhost ~] #
Sixth: delete rm and rmdir
The rm parameter is similar to the cp parameter, mainly r and f.
-F indicates no reminder
-R: recursively deletes a directory (add-r to delete the Directory)
[Root @ localhostDesktop] # rm-rgrub // Add the-r parameter to delete a directory recursively
Rm: Do you want to go to the "grub/" directory /"?
[Root @ localhostDesktop] # rmgrub // The directory cannot be deleted without the-r parameter.
Rm: the directory "grub/" cannot be deleted: it is a directory.
[Root @ localhostDesktop] # rm-rgrub/
Rm: Do you want to go to the "grub/" directory /"?
// Enter "y" to delete the object one by one. A message indicating whether to confirm the deletion is required for each step is displayed. In this case, the-f parameter is added to cancel the reminder.
[Root @ localhostDesktop] # rm-rfgrub //-rf Delete directory without reminder, force recursive Delete
[Root @ localhostDesktop] # The ls // grub directory is deleted.
File2host. conf
[Root @ localhostDesktop] #
Rmdir can only delete one empty directory, so you don't need to use it. You know rm-rf can delete any directory, but it is dangerous.
I will remember simple commands, but I often forget the parameters!