Linux: Command Line and Common commands

Source: Internet
Author: User
Tags dell r710

Linux: Command Line and Common commands
1.1 command line operations
1.1.1 Shell Introduction
Before learning shell, let's first understand what Shell is, what functions can Shell complete, and what are common shell types? Why use Shell?
Shell is an interface between a user and a Linux operating system. In the encyclopedia, shell is commonly known as a Shell (used to distinguish it from a core). It refers to a command parser that provides a user interface. Similar to command in DOS and cmd in windows. It is used to receive user commands and then call corresponding applications.
Here we are talking about Shell under Linux. There are many types of Shell in Linux, and bash is commonly used.
The servers deployed in the enterprise, or the linux White Paper, basically use the minimal installation in the Linux system used by Daniel, completely discard the graphics, and install yum as needed. Therefore, as the external core of the operating system, Shell provides users with an interface for using the operating system. It can be called a command language interpreter and has its own built-in shell command set. When we use the tab key, the completion command prompt is displayed. Shell allows the shell to explain the commands entered at the prompt and then pass them to the Linux core.
 
Shell is the most basic tool for interaction between users and the operating system in UNIX systems. In fact, shell not only has the function of command interpretation and execution, but also has other functions: 1) Setting of the system environment 2) input/Output redirection 3) shell programming language design
Different shells have their own advantages in applications. Below are several common types of shells.
1) The Bourne Shell is the original shell used by UNIX and can be used on every Unix. The Bourne SHell is excellent in programming, however, it is not as good as other shells in dealing with user interaction interfaces. Now we often say bash (Bourne Agair Shell ), it adds many features based on the Bourne Shell.
2) C shell is a programming shell. Its syntax is similar to that of C. Linux provides Tcsh for people who like C shell. Tcsh is an extension of C shell. Tcsh includes command line editing programmable word completion, spelling correction, historical command replacement, Job control, and C-language-like syntax, it is not only compatible with Bash shell, but also provides more prompt parameters than Bash shell.
3) The Korn shell combines the advantages of the C shell and the Bourne shell and is fully compatible with the Linux system to provide the pdkshksh extension. It supports task control and can suspend, execute, wake up, or terminate programs in the background on the command line.

3) The Korn shell combines the advantages of the C shell and the Bourne shell and is fully compatible with the Linux system to provide the pdkshksh extension. It supports task control and can suspend, execute, wake up, or terminate programs in the background on the command line.

In Redhat Linux, the default Shell is Bash shell, which is used by the Super User # As a prompt (root is equivalent to the windows administrator user, with a high permission and a high risk of use. It is best for enterprises and ordinary users in learning ). In Linux, common users use $ as a prompt. You can enter commands on the root user and general accounts to complete the tasks and learning we want to achieve.

1.1.2Redhat release

Common linux distributions use RPM to install software systems, including Red Hat, Fedora, SuSE, and Centos systems. In addition, Debian dpkg is used to install software, including Ubuntu, Debain, and B2D. Because Redhat-like environments are used in China, I used the Centos system when I went to school. Therefore, the following learning environments are all completed in Centos.

Centos7.2

[root@kvm ~]# uname -aLinux kvm 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Next, let's take a look at how shell is implemented. In shell, enter the following command: ls-al

[Root @ kvm ~] # Ls-altotal 88dr-xr-x ---. 22 root 4096 Oct 31. dr-xr-x. 17 root 4096 Oct 30 .. -rw -------. 1 root 1619 Oct 22 anaconda-ks.cfg ................................ ................ drwxr-xr-x. 2 root 6 Oct 23 20:48 download drwxr-xr-x. 2 root 6 Oct 23 20:48 public drwxr-xr-x. 2 root 6 Oct 23 images drwxr-xr-x. 2 root 6 Oct 23 20:48 document drwxr-xr-x. 3 root 33 Oct 31 19: 30 desktop drwxr-xr-x. 2 root 6 Oct 23 20:48 template drwxr-xr-x. 2 root 6 Oct 23 20:48 video drwxr-xr-x. 2 root 6 Oct 23 20:48 music
Ls-al: This command can output all files and subdirectories in the current directory.

When we log on to linux, the system will read the/etc/passwd file to determine which shell to use. For example, if the root user is used

[root@kvm ~]# cat /etc/passwd  |grep rootroot:x:0:0:root:/root:/bin/bash
The test user displays
test:x:1001:1001::/home/test:/bin/bash
The command su is used for switching between users.
[Test @ kvm root] $ su # entering su separately will switch to the root user Password: # enter the root Password [root @ kvm ~] # Su test # Switch to test user [test @ kvm root] $ # Switch to test user successfully

We can use the up and down arrows to view which commands we use. If there are many commands, we can also use history to view historical commands.

[root@kvm ~]# history    1  vim /etc/locale.conf    2  reboot    3  ls    4  netstat -antp |grep 5901    5  systemctl status vncserver@:1.service    6  systemctl restart vncserver@:1.service    7  vim /etc/libvirt/qemu    8  vim /etc/libvirt/qemu.conf     9  systemctl restart vncserver@:1.service   10  systemctl restart firewalld.service   11  systemctl status firewalld.service   12  systemctl restart firewalld.service   13  systemctl restart vncserver@:1.service

If you only want to display the last n rows, you can use history-n.
[root@kvm ~]#  history 10

1.1.3Linux is a real multi-user operating system that allows multiple users to log on to Linux at the same time and allows one user to log on multiple times. Like my Dell R710 server, we have two users who can remotely access the Console System Using putty or Xshell. We can use whoami to see who controls the system.

[root@kvm ~]# whoamiroot[root@kvm ~]# su test[test@kvm root]$ whoamitest
Use last to view information about users currently logged on and logged on in the past
root     pts/3        :1               Mon Oct 23 13:29 - down   (00:01)    root     pts/2        192.168.0.2           Mon Oct 23 13:24 - down   (00:06)    root     pts/1        :0               Mon Oct 23 20:56 - down   (-7:-25)   root     pts/0        :0               Mon Oct 23 20:56 - down   (-7:-25)   root     :0          :0               Mon Oct 23 20:56 - 13:31  (-7:-25)      reboot   system boot  3.10.0-327.el7.x Mon Oct 23 20:55 - 13:31  (-7:-24)   root     pts/1        :0               Mon Oct 23 20:49 - crash  (00:06)    root     pts/0        :0               Mon Oct 23 20:48 - crash  (00:06)    root     :0          :0               Mon Oct 23 20:48 - 20:49  (00:01)     reboot   system boot  3.10.0-327.el7.x Mon Oct 23 20:47 - 13:31  (-7:-16)   reboot   system boot  3.10.0-327.el7.x Mon Oct 23 20:41 - 13:31  (-7:-10)       reboot   system boot  3.10.0-327.el7.x Mon Oct 23 20:25 - 20:32  (00:06)    reboot   system boot  3.10.0-327.el7.x Sun Oct 22 02:06 - 02:07  (00:01)    reboot   system boot  3.10.0-327.el7.x Sun Oct 22 02:01 - 02:07  (00:05)

Common remote methods generally include talent remote Logon (Insecure transmission plain text). ssh remote connection and VNC connection are often used. I will talk about it later.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.