Introduction to Shell in Linux __linux

Source: Internet
Author: User
Tags server port ssh server
1, shell overview

Each person after successfully logged on to Linux, the system will appear a different hint symbol. For example, $, ~, #等, and then you can start typing the command you want, and if the command is correct, the system will execute according to the requirements of the command until you log off the system, and every command you enter will be interpreted and executed frequently during logon to logoff. and the responsible mechanism is the shell. 2. Shell Programming

The fact that the command language interactively interprets and executes user input commands is only one aspect of shell functionality, and the shell can also be used for programming. It provides a means to define variables and parameters and a rich program control structure. Using shell programming is similar to a DOS processing file, called a shellscript, or shell program or shell command file. The shell is similar to a batch file under Windows. 3. Shell Classification

There are a lot of shells, but there are several commonly used:

Shell name

Developer

command name

Bourne

S.r.bourne

/bin/sh

C

Bill Joy

/bin/csh

Kom

David

/bin/ksh

1, to see what kind of shell is currently in use. Command: Env (this command can display environment variables for the current operating system).

2, the shell modification. Command: chsh-s/bin/[shell filename] (different shells do not interpret the command). 4. Shell command

Command completion: Refers to the user Input command, do not need to enter the full command, and the system will automatically find the most suitable name. This feature saves you the time to enter commands frequently. Directly enter "MK" and press the "tab" key, two or two letters "MK" command. Cat P and then press the "tab" key to show all files or directories with the beginning letter "P".

Under Linux, we may sometimes want to know or use recently executed commands, history may be helpful.

1, History 5: This description will display the most recently used 5 commands.

2,! 5: This description executes the command with a history number of 5.

3,!ls: This note to perform the last time "LS" to start the command. 5, the magic of SSH

Overview: SSH (Securt shell) is a set of remote operating Linux and file upload and download software, it is quite easy to use, in software companies almost all Linux programmers will be using SSH. Security, convenience is its biggest feature.

Installation: The Linux SSH server is automatically installed with Linux when installing a sshd and is started by default. The SSH server port is 22. Install the SSH client under Windows. Use an SSH client to log on to Linux (provided the SSHD service starts under Linux). 6. Shell Use

Command history and interactivity: Use the UP and DOWN ARROW keys to repeat the previously entered command.

Command completion function: The TAB key can automatically complete the relevant commands, press TAB again to get the list.

Shell script file: is a text file/command set/has EXECUTE permission chmod744 filename, execution method (./filename)/(. sh suffix name file is Shell file).

Shell script files that are executed automatically after a user logs on: 1. BASHRC is located in the home directory, before it executes the system scripts/ETC/BASHRC primarily basic configuration data (/ETC/BASHRC equivalent to automatic batch file Autoexec.bat under Windows). 2. Bash_profile is located in the home directory, before it executes the system's script/etc/profile mainly configures the environment change.

When you want to join a path temporarily in your environment, you can use export to $PATH with export:path=: $HOME/bin:/root/test/tl

The output environment variable path refers to the original value $path, $HOME represents the working home directory,: is the path separator.

Some of the defined environment variables:

Shell: Default shell

Path: Paths

User: The username of the currently logged-on user

Display variable content: Echo $PATH

Echo $USER

Echo $SHELL


Wildcard character: * represents multiple letters or numbers

? Represents a letter or a number

LS A * ls a?   ls? at? LS f080[1-6].tif

Escape character: \

Ls/mnt/winl/my\ Documents

Quotes: Export Name-michael

Echo Welcome $NAME, the date is date.

Echo ' Welcome $NAME, the date is date ': Single quote-Shell does not handle any variables and commands;

echo "Welcome $NAME, the date is date": double quotation marks-handles the variable but does not process the command;

echo "Welcome $NAME, the date is ' date ': Inverted quotation mark-each word in quotation marks as a command and, if it is a variable, evaluated first and then treated as a command.

Alias command: Alias displays all aliases currently defined by the system

Alias alias = ' command or command group '

aliascp= ' Cp-i '

Aliasll= ' Ls-l--color=tty '

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.