1.7.1 viewing and switching directories
1, Use pwd, cd
1.pwd
Purpose: output the current working directory
2, cd
Purpose: switch working directory
.: current directory
...: parent directory (upper level)
~: user home directory (a directory dedicated to storing user personalized information)
~User: user's home directory
/Root: home directory of administrator root
/Home: store the home directory of all ordinary users
[ root@localhost03 tom]# useradd tom / / create a tom user
[ root@localhost03 ~]#Cd ~ tom / / go to tom's home directory
3, ls lists documents and properties
1.ls-list
Common command options
-l: Display in long format, showing detailed properties
-A: Show all content including hidden data
-d: Displays the properties of the directory itself, not its contents
-h: Provide readable capacity units (K,M, etc.)
-R: Recursive display content
2. Use case
[root@localhost03 ]# ls -l /etc/passwd #Show detailed properties -rw-r--r--. 1 root root 2387 May 25 07:01 /etc/passwd [root@localhost03 ]# ls -lh /etc/passwd #Displays detailed properties plus readable units -rw-r--r--. 1 root root 2.4K May 25 07:01 /etc/passwd [root@localhost03 ]# ls -lhd /etc/passwd #Displays the detailed properties of the directory itself plus readable units -rw-r--r--. 1 root root 2.4K May 25 07:01 /etc/passwd [root@localhost03 ~]# ls -A /root/ #Show hidden data [root@localhost03 ~]# touch /opt/.haha.txt / / create a hidden file [root@localhost03 ~]# ls -R /opt/ #Display itself and all data in the directory [root@localhost03 ~]# du -sh /etc/passwd #Displays the size of the disk space occupied by the file. You can count the size of the file [root@localhost03 ~]# ls -lh /etc/passwd #Displays the size of the file itself
4, Use wildcards
1. Uncertain document names are represented by special characters
-*: any number of arbitrary characters
-?: Single character
-[a-z]: one of multiple characters or consecutive ranges. If none, it will be ignored
-{a,min,xy}: multiple groups of different strings, all matching
[root@localhost03 ~]# ls /etc/*tab #Match the files ending in tab under etc [root@localhost03 ~]# ls /dev/tty? #Match single character after tty [root@localhost03 ~]# ls /dev/tty[1-8] #Files matching tty1 to 8 cannot recognize numbers of 10 and above [root@localhost03 ~]# ls /dev/tty{1,2,5,12,33} / / add the desired match to the braces
5, Definition of alias
Simplify complex commands
1. View the alias that has been set
Alias [alias name]
[root@localhost03 ~]# Alias / / view the system defined alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
2. Define a new alias
Alias alias name = 'actually executed command'
[ root@localhost03 ~]#Alias hn = 'hostname' / / set the alias of hostname to hn
3. Unset alias
unalias [alias name]
[ root@localhost03 ~]#Unalias HN / / unset alias
be careful:
The priority of the alias is higher than that of the system command. When the system command is set to alias yes, the execution command defined by the alias is executed when the system command is entered
1.7.2 new directory
mkdir
-Format: mkdir [-p] [/ path /] directory name
explain:
-p when the parent directory does not exist, the parent directory can be created together
[root@localhost03 ~]# mkdir -p /opt/aa/bb/cc/dd
1.7.3 copy / delete / move
1, cp replication
1. Format: cp [options]... Original file... Destination path
2. Common options
-r: Recursion, copy directory must have this option
3. Use case:
[root@localhost03 ~]# cp /etc/shells /opt / / / copy the file shells to opt [root@localhost03 ~]# cp -r /home/ /opt / / copy home directory to opt [root@localhost03 ~]# cp -r /home/ /opt/ [root@localhost03 ~]# \cp -r /home/ /opt / / this operation temporarily cancels the alias to prevent multiple copies of a directory [root@localhost03 ~]# cp -r /etc/fstab /etc/passwd /etc/hosts /opt / / / copy multiple parameters to a directory at the same time [root@localhost03 ~]# cp -r /home/ /opt/myhome / / copy rename [root@localhost03 ~]# cd /mnt/ [root@localhost03 mnt]# cp /etc/passwd. / / copy the file to the current directory. The current directory uses. Instead
2, rm delete
1. Format
rm [options]... File or directory
2. Common options:
-r: Recursive deletion (including directory)
-f: Force delete
3. Use case
[root@localhost03 ~]# rm -rf /opt/roo@192.168.31.4 //Delete files or directories without prompting before deletion [root@localhost03 ~]# rm -r /opt/1.txt / / delete the 1.txt file rm: remove regular empty file '/opt/1.txt'? y //Ask whether to delete. The default is not to delete [root@localhost03 ~]# ls /opt/1.txt / / check whether the file is deleted
3, mv move / rename
1. Format
mv [options]... Original file... Destination path
2. Use case
[root@localhost03 ~]# touch /opt/a.txt [root@localhost03 ~]# mkdir /opt/xy01 [root@localhost03 ~]# MV / opt / xy01 / / opt / abc01 / / rename [root@localhost03 ~]# mv /opt/a.txt /opt/abc01 / / / move a.txt file