Getting Started with Linux basics

Source: Internet
Author: User
Tags aliases clear screen echo command echo display

Linux Terminal type:

/dev/console: Physical Terminal

/dev/tty#: Virtual Terminal

/dev/ttys#: Serial Terminal

/dev/pts/#: Pseudo Terminal

Switching terminals:

CTRL+ALT+F[1-6]: Switch terminal

CTRL+ALT+F1: Switch to the graphical interface

CHVT #: Switch to # # terminal

Init 3: Turn off the graphical interface

Init 5: Start the graphical interface

TTY command: View the type of terminal currently logged in

WHO: See which endpoints are running on the current system

echo $SHELL: Output Current interface program

Cat/etc/shells: View all shells on the current system

Gui:graphic User Interface

Gnone

Kde

Cli:command Line Interface

Bash

Sh

Csh

Ksh

Zsh

...

Command prompt:

[[Email protected]~]# COMMAND

Root: Currently logged in User name

localhost: System host name

~: Current system path

#: User type

#: Super Admin

$: Normal user


Command run Format:

COMMAND [OPTIONS ...] [ARGUMENTS ...]

short option:-C

long option:--all

CTRL + C to cancel command execution

Multiple commands to run with;

A command can be divided into multiple lines with \



System-related commands:

System shutdown:

poweroff

Halt

Shutdown-h Now

To view the current system version:

lsb_release-a

Cat/etc/centos-release

View current host Name: hostname

View current kernel version: Uname-r

Shell interpreter: Provides an interface between the user and the kernel to convert a user-entered command into a system-aware binary format

Command type:

Internal command: Shell inline command

External command: Executable program file under a path on the current system

To view the command type:

Type COMMAND

View command hash:

Hash

- R: Empty hash Table

- D: Delete the specified hash entry

To disable internal commands:

Enable-n COMMAND

To enable internal commands:

Enable COMMAND

Find the path to the external command:

Which COMMAND

List the path and help documentation for the program

Whereis COMMAND

To define a command alias:

Alias Name= ' COMMAND '

To delete a command alias:

Unalias NAME

Ignore aliases to execute the original command:

/path/to/somefile

\command

' COMMAND '

Command execution Priority:

aliases------> Internal------> Hash------> External commands

Date: Displays the system day and time

System time: Run by the Linux kernel through the CPU's operating frequency

Hardware time: Motherboard

Hwclock,clock: Display hardware time

-S: Synchronize the system time to the hardware, whichever is the hardware time

-W: Synchronizes hardware time to hardware, whichever is the system time

Cal: Show Calendar

Screen: Multiple terminal logins for the same host for shared sessions

To create a new screen session:

screen-s SESSION

Show all screens that are open:

Screen-ls

Join session:

screen-x SESSION

Split session:

ctrl+a,d

To resume a session:

screen-r SESSION

To exit and close the session:

Exit

echo Command: Echo

-N: Do not wrap.

-E: Special handling If the following characters are present, but not as string output

\ t: Insert tab

\a: Warning Sounds

\b: Delete the previous character

\c: Finally, no line break symbol is added

\ n: Wrap and move the cursor to the beginning of the line

\ r: The cursor moves to the beginning of the line, but does not wrap

\ \: Insert \ Character

\0nnn: Inserting ASCII characters with a table in octal

\xhh: Inserting the ASCII characters represented by hexadecimal

echo display with color display, echo display with color, need to use parameter-E

Format: echo-e "\033[word background color; text color m string \033[0m

Word Color: 30-37

Echo-e "\033[30m Black character \033[0m"

Echo-e "\033[31m Red word \033[0m"

Echo-e "\033[32m Green word \033[0m"

Echo-e "\033[33m Yellow word \033[0m"

Echo-e "\033[34m Blue word \033[0m"

Echo-e "\033[35m Purple word \033[0m"

Echo-e "\033[36m sky blue Word \033[0m"

Echo-e "\033[37m White character \033[0m"

Word Background color: 40-47

Echo-e "\033[40;37m Black Bottom White \033[0m"

Echo-e "\033[41;37m Red bottom White \033[0m"

Echo-e "\033[42;37m Green bottom White \033[0m"

Echo-e "\033[43;37m Yellow \033[0m"

Echo-e "\033[44;37m Blue bottom White \033[0m"

Echo-e "\033[45;37m Purple \033[0m"

Echo-e "\033[46;37m sky blue Bottom White \033[0m"

Echo-e "\033[47;30m black character \033[0m on white background"

Control Option Description:

\33[0m Close All Properties

\33[1m Setting High brightness

\33[4m Underline

\33[5m Flashing

\33[7M Reverse Display

\33[8m blanking

\33[30m-\33[37m Setting the foreground color

\33[40m-\33[47m Setting the background color

\33[na the cursor to move n rows

\33[NB cursor down n rows

\33[NC cursor right shifts n rows

\33[nd cursor left n rows

\33[Y;XH Setting the cursor position

\33[2J Clear Screen

\33[k clears the contents from the cursor to the end of the line

\33[s Save Cursor position

\33[u Restore cursor Position

\33[?25l Hide Cursor

\33[?25h Display cursor

To view the colors defined by the Create file:

Cat/etc/dir_colors


"": weak reference, will do variable substitution

": Strong references, all as strings, no variable substitution

' or $ (): command substitution, referencing the execution result of a command

For example:

echo "$VAR": Output values from $var variables

Echo ' $VAR ': Output $var string

Echo ' echo $USER ': output echo $USER command run result

Curly braces expand: {}

Print a simplified form of a repeating string

Touch file{1,3,5}

RM-RF file{1,3,5}


Command completion: Tab key

Bash finds commands from left to right, depending on the path defined in the PATH environment variable

If a user-given string has only one unique command, the direct complement

Otherwise, tab again to the list of commands

Path Completion:

A user-given string that starts with a path and searches for a file at the beginning of a specified string under its specified ancestor directory

If only: the direct complement

Otherwise: Eat tab and give the list

Get help:

Internal Command help:

Help COMMAND

Mans COMMAND

External command help:

COMMAND--help

command-h

Mans COMMAND

Info COMMAND

Whatis: View the function of a command and the chapter in which it resides

Makewhatis: Build Database (CentOS 6)

MANDB: Build Database (CentOS 7)


Getting Started with Linux basics

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.