Linux Getting Started directory
? Root user
? terminal
? Interactive interface (graphical interface and command line)
? What is shell (bash)
? Command prompt
? internal commands and external commands Enable,hash
? Command aliases
? Command format
? Nano (a simple editor)
? Some commands
Root user
Permissions: Infinite size
This is a special administrative user, in the Linux system, he has unlimited permissions, large enough to delete the system itself, therefore, this account is quite dangerous, the general user can only give them ordinary users account, only the very individual must use root permissions, will give ordinary users part of the root authority, And immediately take back root privileges.
Terminal
For the computer, the terminal I have been divided into two, one is input, keyboard, mouse, display, etc., we call them terminal equipment. There is also a computer control interface, in Linux, the terminal is we can manipulate its operating system interface. Including:
Physical Terminal:
/dev/console
When we switch to single-user mode, we can see the prompt of the physical terminal
Virtual Terminal:
TTY (teletypewriters)/dev/tty/n n=1-6
The virtual terminal is still the port on the physical machine, in Linux, we can use ctrl+alt+ "F1-F6" to switch between the virtual terminal, in order to facilitate our use.
Graphical interface:
As we know, on Windows and iOS, after powering on, we see all the beautiful interfaces, not the dark command line. Similarly, Linux also has an image interface, and we can switch between graphical and command terminals: startx,xwindows switch to graphical interface
Serial Terminal:
Now we don't have a serial terminal, so I'm not going to introduce it here.
Pseudo Terminal:
Pty (Pseudo-tty)/dev/pts/n N=number
Is the way we usually use the remote connection, it will show the pseudo-terminal, because it is not a real terminal, just because of the use of remote control of the analog terminal
To see what terminal to use :
Command: TTY
Interactive interface Graphical interface
Gui:graphic User Interface
The graphical interfaces we use in Linux are:
? GNOME (c, graphics library GTK)
? KDE (c + +, graphics library GT)
? XFCE (Lightweight desktop)
Command line
Cli:command Line Interface
As shown here is the interactive interface we use as a Linux worker. Because the desktop environment will open a program, will occupy our memory and CPU resources, more importantly, many operations we can no longer be seen directly on the desktop, so we will almost adopt the CLI mode interactive interface.
What is shell (bash)
The Shell is the user interface of the Linux system and provides an interface for users to interact with the kernel. It receives the command entered by the user and feeds it into the kernel to execute
The shell is also known as the Linux command interpreter (interpreter)
The shell is a high-level programming language . As a command language, it interactively interprets and executes user-entered commands or automatically interprets and executes a predetermined set of commands; As a programming language, it defines variables and parameters and provides many control structures in high-level languages, including loops and branches.
The GNU Bourne-again Shell (bash) is one of the most important tool software in the GNU program and is currently the Linux standard Shell, compatible with SH
Displays the currently used Shell:echo ${shell}
Displays all shell:cat/etc/shells used by the current system
Every time we log in to the machine, we're already using the shell, and in the CentOS system we're using now, bash is used, and the following are the benefits of bash:
1. Use the UP and DOWN ARROW keys to adjust the previously executed Linux commands.
2. Commands or parameters only need to enter the first few can be used to complete the TAB key.
3. Powerful batch-processing scripts.
4. Practical environment variables.
Command prompt
The command prompt is a prompt we see when we log on to the operating system:
Command prompt: Prompt
[Email protected] ~]#
# admin
$ normal User
Show prompt format
[[Email protected] ~] #echo $PS 1
Modify the prompt format
Ps1= "[\[email protected]\h \w]\\$"
\H Host name abbreviation
\w Current Working Directory
\ t 24-hour time format
\! Number of command history
\u Current User
\h Host Name
\w Current working Directory base name
\ t 12-hour time format
\# number of command history after boot
Internal command and external command Enable,hash
In CentOS, Bash comes with a subset of common commands, which are resident in memory so that we don't have to find them from the hard disk when we use them, which we often call built-in commands, such as:
But the built-in command does not mean that it does not exist in the hard disk file, and that he is simply setting up some of the commonly used commands as built-in commands for ease of use. So the built-in command still exists in the hard disk file.
Determine the type of a command:
Type COMMAND.
External Command View path:
Which-a |--skip-alias; Whereis
Internal commands are enabled and not enabled use the Enable command to set the built-in command
Show all enabled internal commands: enable
Enable | WC-L statistics enabled number of internal commands
Enable command to start an internal command
Enable-n command to disable an internal commands
Enable–a Show all built-in commands (whether or not prohibited)
Enable-n Show all internal commands that are disabled
Enable-n |wc-l Statistics The number of internal commands that are disabled
How are external commands used? I can see that there is path in the system, that is, the path, all of the external commands we use are searched from left to right in the path, but we do this first:
Now we are using an external command, PWD, which we use once the PWD, is shown as shown:
We found the picture is different from the above, why is it? This is because when we use an external command, the hash will store the command path we used in the hash table so that we can improve the efficiency of the search when we use it next time. Here is the operation of the hash table:
Hash shows the current hash of the external command,
-l Displays the external command currently being hashed, including the alias
-P/.../.... Name add a hash cache manually
-D name Delete a hash
-R Clears all hashes
In our actual operation, the execution priority level of the hash is higher than the command in path, and here is a sort of priority in the operation:
Alias > Internal command > Hash > PATH > Command not find
Command aliases
Displays all available command aliases for the current shell process: Alias
Defines the alias name, which is equivalent to executing the command
Alias Name= ' VALUE '
aliases defined on the command line, valid only for the current shell process
If you want to be permanently valid, define it in the configuration file
For the current user only: ~/.BASHRC
Valid for all users:/ETC/BASHRC
The new configuration given by the edit configuration does not take effect immediately
Bash process re-reading configuration file
Source/path/to/config_file
. /path/to/config_file
Undo Alias: Unalias
Unalias [-A] name [name ...]
-A cancels all aliases
If the alias has the same name as the original command, if you want to execute the original command, you can use
"\command"
' COMMAND '
/path/command: External command
Command format
COMMAND [OPTIONS ...] [ARGUMENTS ...]
Options: One or some of the features used to enable or disable commands
Short options:-C For example:-L,-H
Long options:--word For example:--all,--human-readable
Parameters: The object of the command, such as file name, user name, etc.
Attention:
Multiple options and separating between multiple parameters and commands using white space characters
Cancel and End command execution: CTRL + C, Ctrl+d
Multiple commands can be separated by symbols.
A command can be divided into multiple lines with \
Nano (a simple editor)
There is a simple editor on Linux, but we only know that there is an editor on the line, because later we will learn the more powerful Vim,nano interface as shown below:
Some commands and files
File:
/etc/gdm/custom.conf Automated Login To change the graphical interface
/etc/isue Show pre-logon information
/ETC/MOTD Display post-login information
Command:
RZ to internal copy file
SZ to external copy file
Wall broadcast to users who are logged on natively
PWD View your directory
Cat View File Contents
File View Files Type
Which viewing command paths
Whereis viewing the path to a file or command
Getting Started with Linux _1