Cd
Role: Switch Directories
Common options:
~ Switch to the current user home directory
.. Switch to Parent directory
-Switch to the previous directory location
Note: When a user logs on to a server, the default directory is the user home directory, and PWD displays the current path. Default normal user's home directory under/home/username, Root's default home directory is/root
Instance:
[[email protected] ~]# pwd/root current directory is/root[[email protected] ~]# cd/boot/grub/[[email protected] grub]# Pwd/boot/grub Enter/ Boot/grub[[email protected] grub]# CD. [[email protected] boot]# Pwd/boot return to the parent directory, that is/boot[[email protected] boot]# CD ~[[email protected] ~]# pwd/root back home directory, CD to Jane For Cd[[email protected] ~]# cd/boot/grub/[[email protected] grub]# Pwd/boot/grub enter/boot/grub[[email protected] grub]# CD- /root[[email protected] ~]# pwd/root return to the directory location before switching directories
LS
Function: View files or directories
Common options:
-f file and directory
-a show hidden files
-l listing details
 -LH Easy to see the total size of the current directory and the size of individual files or directories (units are automatically m or K)
instances:
[[email protected] ~]# cd /boot/[[email protected] boot]# lsconfig-2.6.32-504.el6.x86_64 grub lost+found system.map-2.6.32-504.el6.x86_ 64efi initramfs-2.6.32-504.el6.x86_64.img symvers-2.6.32-504.el6.x86_64.gz vmlinuz-2.6.32-504.el6.x86_64 view the file or directory under/boot (without hidden files) [[email protected] boot]# ls -a. efi lost+found vmlinuz-2.6.32-504.el6.x86_64.. grub symvers-2.6.32-504.el6.x86_64.gz .vmlinuz-2.6.32-504.el6.x86_64.hmacconfig-2.6.32-504.el6.x86_64 initramfs-2.6.32-504.el6.x86_64.img system.map-2.6.32-504.el6.x86_64 view the file or directory under/boot (including hidden files to. Start with hidden files) [[email protected] boot]# ls - fconfig-2.6.32-504.el6.x86_64 grub/ lost+found/ System.map-2.6.32-504.el6.x86_64efi/ initramfs-2.6.32-504.el6.x86_64.img symvers-2.6.32-504.el6.x86_64.gz vmlinuz-2.6.32-504.el6.x86_64* without color, distinguish between files and directories, with names followed by directories [[Email protected] boot]# ls -lhtotal 26m-rw-r--r--. 1 root root 104k oct 15 12:54 config-2.6.32-504.el6.x86_64drwxr-xr-x. 3 root root 1.0k jan 21 01:11 efidrwxr-xr-x. 2  ROOT ROOT 1.0K JAN 21 01:13 GRUB-RW-------. 1 root root   19M JAN 21 01:13 INITRAMFS-2.6.32-504.EL6.X86_64.IMGDRWX------. 2 Root root 12k jan 21 01:03 lost+found-rw-r--r--. 1 root Root 196k oct 15 12:55 symvers-2.6.32-504.el6.x86_64.gz-rw-r--r--. 1 root root 2.5M Oct 15 12:54 System.map-2.6.32-504.el6.x86_64-rwxr-xr-x. 1 Root root 4.0m oct 15 12:54 vmlinuz-2.6.32-504.el6.x86_64 visualize files and directories and total size (ls -LH can be abbreviated as LL -H) [[Email protected] boot]# ls -ltotal 25862-rw-r--r--. 1 Root root 106308 oct 15 12:54 config-2.6.32-504.el6.x86_64drwxr-xr-x . 3 root root 1024 jan 21 01:11 efidrwxr-xr-x. 2 root ROOT     1024 JAN 21 01:13 GRUB-RW-------. 1 root ROOT 19453744 JAN 21 01:13 INITRAMFS-2.6.32-504.EL6.X86_64.IMGDRWX------. 2 root root 12288 jan 21 01:03 lost+found-rw-r--r--. 1 root root 200191 oct 15 12:55 symvers-2.6.32-504.el6.x86_64. Gz-rw-r--r--. 1 root root 2544748 Oct 15 12:54 System.map-2.6.32-504.el6.x86_64-rwxr-xr-x. 1 root root 4152336 oct 15 12:54 vmlinuz-2.6.32-504.el6.x86_64
View details of a file or directory
First column: Type of document and file permissions
D directory file.
L Symbolic Link (pointing to another file, similar to a shortcut under plague).
s socket file.
B-Block device file, binary file.
C-character device file.
P Name the pipe file.
-Ordinary files, or more accurately, do not belong to the above several types of files
Second column: Indicates the number of file links
Column Three: Representing the owner of the file
Column Fourth: The group represented as a file
Column Fifth: expressed as file length (size)
Sixth column: Indicates the last update (modification) time of the file
Seventh column: Indicates the name of the file
Mkdir
Role: Create a directory
Common options:
-M developing directory permissions when creating a directory
-p recursively Create a directory
Instance:
[[email protected] ~]# ls[[email protected] ~]# mkdir 1/2mkdir:cannot Create directory ' ": No such file or directory due No 1 This directory, so cannot create 2 this directory [[email protected] ~]# mkdir-p 1/2[[email protected] ~]# Ls1[[email protected] ~]# CD 1[[email Protect Ed] 1]# LS2 Create directory [[email protected] 1]# mkdir-m 777 Test[[email protected] 1]# lltotal 8drwxr-xr-x. 2 root root 4096 Mar 13:32 2drwxrwxrwx. 2 root root 4096 Mar 13:32 test Create a directory with permissions of 777
Touch
Role: Create a file
Common options:
-A only change access time
-M only changes the change time
-C If the file does not exist, the file is not created
-T uses the specified date time instead of the current time ([yy]mmddhhmm[. SS])
-R Sets the date and time of the specified document or directory to the same date and time as the reference document or directory
Instance:
[[email protected] ~]# touch a b[[email protected] ~]# lltotal 0- Rw-r--r--. 1 root root 0 mar 18 13:39 a-rw-r--r--. 1 root  ROOT 0 MAR 18 13:39 B create two files simultaneously [[email protected] ~]# touch - C c[[email protected] ~]# lltotal 0-rw-r--r--. 1 root root 0 mar 18 13:39 a-rw-r--r--. 1 root root 0 mar 18 13:39 b creating a nonexistent file [[Email protected] ~]# lltotal 4-rw-r--r--. 1 root root 0 mar 18 13:39 a-rw-r--r--. 1 root root 0 mar 18 13:39 b-rw-r--r--. 1 root root 1715 mar 18 13:43 passwd[[email protected] ~]# touch -r a passwd [[ email protected] ~]#&Nbsp;lltotal 4-rw-r--r--. 1 root root 0 mar 18 13:39 a-rw-r--r--. 1 root root 0 Mar 18 13:39 B-rw-r--r--. 1 root root 1715 mar 18 13:39 passwd update passwd timestamp is equivalent to a[[ Email protected] ~]# touch -t 201808070605.05 123[[email protected] ~] # lltotal 0-rw-r--r--. 1 root root 0 Aug 7 2018 123 Create a file with a timestamp of August 07, 2018 06:05 123
RmDir
Role: Delete Empty directory
Common options:
-P is when a subdirectory is deleted and then it becomes an empty directory, and it is deleted by the way
Instance:
[[email protected] ~]# mkdir-p 1/2/3[[email protected] ~]# CD 1/2/[[email protected] 2]# rmdir 3 Delete empty directory 3[[email protected] 2]# Ls[[email protected] 2]# CD [[email protected] ~]# rmdir 1rmdir:failed to remove ' 1 ': Directory not empty cannot delete non-empty directory [[EM AIL protected] ~]# rmdir-p 1/2[[email protected] ~]# ls Delete 1 below 2, because after deleting 2, 1 is empty, so even 11 and delete, this is the function of the-p option
This article is from the "Step Into the Linux World" blog, please be sure to keep this source http://linuxnote.blog.51cto.com/9876511/1621811
Common basic commands for Linux 01