The su – @username command is used to switch from a user with high permission to a user with low permission. For example, switch from the root user to a common user.

; A semicolon can isolate a command.

A command consists of commands, options, and parameters. There are some default option parameters.

Date Displays the current date

Passwd Temporarily changes the password.

File Type of the scanned file

Cat less Displays the file type

Head, tail, and wc commands

! Prefix + string, matches the latest command, and executes it

! Prefix + number, match the previous command, (you can use the history command to see before), and execute.

!!!!! Execute the previous command

The Esc +. Shortcut key matches the last parameter of the previous command and is placed under the current command.

Cursor shortcut keys

Linux file system hierarchy

The main directory structures

The CD command

Relative and absolute paths. Relative paths start with a., and absolute paths start with a /

# Assume the initial directory is /home/student


# Use absolute paths

cd /var/log/chrony


# Back to the last working directory
cd -



# Return to the directory above
cd.# Home directory of the current user
cd ~ 


Copy the code

The ls command

# Detailed informationLs minus l, or ll for short.# Show hidden directory
ls -a


# recursively display file directories

ls -R
Copy the code

When a file \ folder has a. Prefix in its name, the file is hidden by default.

Each directory has two special directories, one for.. and the other for..

Create directory/file

Create a directory

To create a directory, you need to have permissions

# relative path, add name directly
mkdir linux

# Absolute path
mkdir /home/student/linux2

If the intermediate directory does not exist, you can use the '-p' parameter and the corresponding directory will be created automatically
# mkdir linux3/test
mkdir -p linux3/test

You can create multiple directories simultaneously
mkdir -p linux4 linux5/testLinux6 / one linux6 / two, linux6 / web,02,03} {01Copy the code

Create a file

# Create file
touch 1.txt

Create multiple files at the same time, if the file exists, only update the file modification dateTouch 1. TXT 2. Md {3, 4}. PNGCopy the code

vi

Delete a directory/file

# Delete directory
rmdir linux

You want to delete this directory and its contentsThen run the rm command and add the -r parameter rm -r linux3# Delete file
rm 1.txt



# Dangerous command
Command redirection may occur in production environments to ensure system security.
rm -rf /*
Copy the code

Copy directories/files

cd

Mkdir BBB # copy file # file path, new file path cp 2.md BBB / # Copy directory cp -r BBB CCCCopy the code

Move a directory/folder

CD mkdir -p DDD /eee/1.txt mv DDD CCCCopy the code

Create/view files

1. TXT # display only a few lines, default 10 lines head -n 5 1. TXT # display only a few lines, default 10 lines head -n 5 1. Default 10 lines tail -n 5 1. TXT # dynamically refresh tail -f 1.txttailCopy the code