System operation
| Shutdown and restart
|
User
WHOAMI display the current user name
ID Displays current user information (including user name, UID, group name, GID)
The PWD displays the absolute path to the directory that is currently located.
[Email protected] ~]# [user name @ hostname prefix directory path suffix]#|$ (Root is #, $ for normal user)
Echo $PS 1 shows the current prompt format
ps1= "\[\e[31m\][\[email protected]\h \w]\\$\[\e[0m\]"
echo $SHELL View the current SHELL type
Cat/etc/shells View the shell installed by the current system
|
Command actions
Hash
Hash shows all the hash command paths
hash-l Displays all hash command paths, including aliases
hash-d alias Delete the hash entry for the specified alias
Hash-r empty all the hashes
hash-t Hash path for alias display aliases
hash-p path aliases Add a hash manually
|
Enable
Enable Show all internal commands that have been activated
enable command activating an internal command that is disabled
Enable |wc-l Displays the number of internal commands in the activation
enable-a Show all internal commands
e nable-a |wc-l Displays the number of all internal commands
Enable-n Show all internal commands that are disabled
enable-n Command disable an internal command
|
Type Type command shows the types of commands Help internal command to view helpful information for internal commands
The order of lookups when executing a command Alias Internal command External command Hash PATH Alias Alias displays all of the alias information Alias aliases = ' command-option parameters ' Unalias aliases Unalias-a Cancel All aliases Save NANO/ETC/BASHRC for aliases Ways to make commands unaffected by aliases \command ' Command ' "Command" /path/command |
Internal commands are transferred into memory when the system starts, and are resident in memory, so the execution efficiency is high.
Internal command user input the rate of system calls is fast, not the built-in command, the system will read the environment variable file. bash_profile,/etc/profile to find the path.
Then in the case of a call to the command, some historical commands are used later, it will exist in the hash table, and when you re-enter the command its call will be such a process.
Hash--> built-in command-->path.
Of course, aliases must take precedence over all commands, so the order in which you execute a command is
Alias --hash--> built-in command-->path
Bash common shortcut keys
Basic operations Ctrl+l Clear Screen Ctrl+o executes the current command and displays the command again The ctrl+s is locked, but the command can still be run. CTRL+Q Unlocking CTRL + C Force end Ctrl+d normal termination |
Move Cursor Action Ctrl + A cursor moves to the beginning of the command (Home) Ctrl + e cursor moves to command line end (end) Ctrl + F cursor moves one character to the right Ctrl + b cursor moves one character to the left Alt + F Move one word to the right Alt + b moves one word to the left Ctrl + XX cursor moves between the beginning of the command line and the cursor |
Window operation (not applicable for Xshell software) Ctrl-shift-n Creating a new window Ctrl-shift-q Close the current window CTRL-SHIFT-T Create a tab page Ctrl-shift-w Close a tab page Ctrl-shift-c Copy the selected text Ctrl-shift-v pasting text to the current cursor
|
|
File and directory Operations
Linux directory structure
Absolute path vs. relative path
Linux has two paths, absolute path and relative path, Linux has the concept of the current directory, "/" refers to the root directory, absolute path must start with "/", and the relative path must not start with "/",
At this time in the WWW directory
cd/var/www/html///From the root directory, find the HTML directory, where the end of the "/" is optional, but when the path points to a file, the end must not add "/" CD HTML//Search the current directory of the HTML directory
| CD CD/ Open root directory CD: /Open Parent directory |
-
LS usage
-
Ls-a Show All Files
-
Ls-a displays all files except. 、..
-
Ls-l list -rw-r--r--. 1 root root 2193 Jul 17:28 passwd File type |owner Permissions group permissions other Permissions | Hard link number |owner| group| file Size (bytes) |mtime| file name
-
Ls-r recursive
-
Ls-ld Displays the details of the specified directory.
-
Ls-1 vertical
-
Ls-s by file size descending
-
Ls-t by modification Time (Mtime) from new to old li>
Ls-ut by Access time (Atime) from new to old
-
Ls-u order by file
-
Ls-x Sort by file suffix
-
L S-i display inode number
|
Mkdir -P Create multi-level catalogs at once -V Show details when creating a directory -m setting permissions directly when creating a directory RmDir Delete only empty directories -P Delete multilevel empty directory at once -V Displays the details of the deletion |
Tree -D Show only directories -L n lists only the directories at the specified level -P wildcard lists only matching files and all directories
|
Use of wildcard characters
Move
Mv
-I: Tips before overwriting
-F: Forced override
The MV default will overwrite the previous prompt. If you are sure that the overwrite is performed, use the-f
Delete
Rm-i Prompt before deleting
-F Force Delete
-R Delete Directory
With MV, delete all things under a directory commonly used RM-RF *, RM usually only deletes files in the current directory,-R means recursively deletes all
Common operations for getting started with Linux