System Day67 Linux Getting Started

Source: Internet
Author: User
Tags clear screen parent directory

Linux System Quick Start



1 Linux Introduction:

1) Linux is a free-to-use and free-spread UNIX-like operating system, a multi-user, multi-tasking, multi-threaded and multi-CPU operating system. The core of Linux comes from UNIX, so it can run major UNIX tools software, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the design idea of Unix as the core of network, and is a stable multi-user network operating system.

2) What is the difference between Linux and Windows?

Linux: More applications are used as servers in the enterprise

Windows: Apps on Volkswagen PC, of course there is also server edition

Linux is a free and open-source operating system with many different versions of Linux, but they all use the Linux kernel. Linux can be installed in a variety of computer hardware devices, such as mobile phones, tablets, routers, desktop computers

3) Common Linux Systems


CentOs (Learning to use):

1) Mainstream: The current Linux operating system is mainly used in production environments, mainstream enterprise Linux systems are still redhat or CentOS

2) Free: Redhat is chargeable. CentOS is free, and CentOS is the equivalent of cloning a redhat system, operating in the same way as Redhat.

3) Easy to update: the CentOS exclusive yum command supports online upgrades, updates the system instantly, and does not require money to purchase support services like Redhat!

2 Linux System Installation

Download the Linux distribution disc image

Install a Linux system on a physical machine or virtual machine

Virtual machines: Virtual machines that are simulated with software

Virtual machine software: A software used to create and run a virtual machine

Steps:

1. Start VMware

2. Click New Virtual Machine

3, to the virtual computer to do a variety of hardware configuration, wherein the virtual network mode must choose:

4. After all hardware equipment configuration is complete, tick power on

3 Remote login for Linux system

* * How to Telnet to a Linux server

1. To know the IP address of the target Linux server

2, the client and the target server should be able to network

3, to have an SSH login client software

4. Start the SSH client software to log in

L Virtual Network Configuration

Virtual Linux servers can be networked through a virtual network provided by VMware, and there are two main ways to set up a network:

1. Nat Mode

2. Bridging mode

NAT is recommended, and NAT networking is as follows:

Important: VMware will virtual out a "virtual Switch", all the virtual hosts and host physical machines are connected to the switch via a virtual network card:


Nat Mode



Bridging mode





Configuration steps :

First, to select Virtual Network mode NAT for virtual machines in VMware

Next, configure the virtual gateway address for the NAT virtual network in VMware

1 Select the NAT entry in the popup window

2 Click Nat Settings, pop up a virtual gateway Address configuration window and fill in the virtual gateway address you want

3 then go back to the Linux server, configure the IP address of the Linux server, first through the graphical interface configuration

4 Select Manual to manually specify the IP address:

The gateway address here is consistent with the address of the virtual Switch that VMWARE simulates

After the configuration is complete, to "disable" the Network on the Small Network connection icon and then "enable" the network for the configuration to take effect

5 when the IP address of the Linux server is configured, the IP address of the physical host Windows is also configured.

Enter the network connection configuration and select the VMNET8 network card (a NAT mode Nic from VMware virtual)

6 Right-click on VMNET8, pop up the Properties configuration window

7 Configure the IP address:

After the IP address is well-equipped, you can log on to the server for Operation Management


remote login Software :

The management of the server is through remote login, remote login Common software has the following 3 sections:

Xshell

Putty

SECURECRT ----recommend recommendations

These software are based on a communication protocol for remote login: SSH protocol

(This protocol requires the remote login to authenticate

There are two authentication methods-"User name + password" mechanism < default mechanism, the key mechanism < need to be configured prior to >)

Start the CRT Telnet software and click on the lightning bolt icon for connection configuration (port 22)

In the Connection Configuration window that pops up, add the address to the address of our virtual Linux server

* * prompt after login :

[Email protected] ~]$

Where renwoxing is the user name of the current login

LocalHost is the host name of this server

~ is the directory where the lander is currently located, ~ refers to the user's home directory/home/renwoxing


Linux directory structure:


bin (binaries) storing binary executable files

Sbin (Super User binaries) holds binary executable files, only root can access

etc (etcetera) storing system configuration files

usr (Unix shared resources) is used to store shared system resources

Home Store The root directory of user files

root Super User directory

Dev (devices) for storing device files

Lib (library) The shared libraries and kernel modules required to run the program in the file system

mnt (Mount) system administrator installs the temporary file system installation point

boot holds various files used for system boot

tmp (temporary) for storing various temporary files

var (variable) for storing files that need to change data at run time (log logs)

4 Linux File System common administrative operations commands
4.1 Daily File Management commands

Tips

Command format: command-option parameter

Use the TAB key to complete the command when you enter it

CTRL + C (stop current process)

CTRL + R (view command history)

CTRL + L (clear screen, same as clear command) View Help documentation? Internal command: Helper + command (helps CD)? External command: Man + command (man ls)

List

LS view directory information (LS/)

Common parameters:-L (Long)-A (all) note hidden files, special directories. -T (Time)

Ls-l equivalent to ll <l is the lowercase of l, not the number 1>

pwd View the absolute path of the directory currently in place

CD Switch directory (CD/), switch to user home directory if without parameters ~

--paths are represented by "relative paths" and "absolute paths"

For example, if the current directory is/home/angelababy, you can view the information in the/home directory in two ways:

Ls.. /

Ls/home


make dirEctoriy

mkdir Creating a folder

Mkdir-p A/B/C If the parent directory of the folder you want to create does not exist, it is created automatically


remove

RmDir Delete empty folders (only empty folders can be deleted)

Rm-r/a/b (Delete non-empty folders)

deleting files

RM filename (rm-r Delete folder Rm-rf forcibly delete files or folders )

Create a file

Touch A.avi Create an empty file

echo Write file contents

echo "Angelababy,zhen de hen Xihuan ni" > qingshu.txt put the left output in the file on the right.

echo "Huangxiaoming,gun cu" >> qingshu.txt append content to existing files


move

Move file Modify file name

MV A/wenjian1.txt B/file1.txt (also modified file name when moving files)


copy

copy files , such as:

CP./a/srcfile./b/destfile


catenate

View Text file contents

Cat Wodeqingshu.txt Displays entire file contents on screen at once

More Wodeqingshu.txt can be paged (page: space, turn back: B, exit: Q or CTRL + C)

Less wodeqingshu.txt not only can be paged, but also easy to search, rewind and other Operations (page: space, back page: B back line: ↑, line down: ↓, exit: Q or CTRL + C)

tail-10 Wodeqingshu.txt View 10 lines at the end of a file

Program-typed logs have an extraordinary debug significance in production practice

tail-f User.log Real-time refresh displays the end of the file

head-20 wodeqingshu.txt View the file header 20 lines

4.2 File Archive Compression (1: Pack-archive; 2: Compress)

1. Archive

Packaging :

TAR-CVF Testdir.tar testdir/

Parameter explanation: C:create v:verbose Show Progress F:file

Unpacking :

TAR-XVF Testdir.tar

Parameter explanation: X:extract


2. Compression

Gzip Testdir.tar compressed file suffix GZ

gzip file

bzip2 file zip suffix is bz2

decompression : gzip-d testdir.tar.gz

TarCommand-C Create a parameter directive for a compressed file (Create)-X unlocks a compressed file parameter directive (Extract)-Z Whether you need to use gzip compression-j whether you need to use BZIP2 compression-V compression in the process of displaying the file (verbose)-F with the filename, after F to immediately pick up the name (file)

Archive compression Done once:

TAR-CZVF testdir.tar.gz testdir/

TAR-XZVF testdir.tar.gz extract to current directory

TAR-XZVF testdir.tar.gz-c downloads/extracted to the specified Downloads directory


4.3 File Rights Management

R Read permission (READ) W Write permission (WRITE) x Execute permissions (ExEcute)

The description mechanism of file permissions in Linux system :


D r W x r W x r-x

The owner belongs to the group others

can be represented as binary: 111 111 101

Can also be expressed as decimal: 7 7 5

Modify Permissions


change mode Parameters:-R The following files and subdirectories do the same permissions operation (REcursive recursive)

chmod u+rwx file Adds or cancels the permissions of the owning user for file

(U represents a member user of the owning group, O on behalf of other users)

chmod 567 file with a number can also represent permissions

5---> 101---> R-x

6--->---> rw-

7---> 111---> rwx

the owner of the modified file (can only be manipulated by root permission)

Chown root:root file #将file的所有者改成hadoop用户, the owning group is changed to the Hadoop group

Meaning of the RWX permission:

R: The file---can read the contents of the file cat

To folders--you can view the child node information for a folder ls

W: To file--can modify the contents of the file

For folders--you can add or subtract child nodes (files or subfolders) in a folder

X: To file--whether it can be run

To folder--whether CD entry is possible

5 User Management
Super User: (root,uid=0)Systems and services related to: Bin, daemon, shutdown, etc. Normal User: (UID 500 to 60000)Process-Related: Mail, news, games, etc. Pseudo User: (UID 1 to 499)The user cannot log on to the system, and there is no host directory


5.1 Adding users

Useradd itcast0830

You must set a password to log in properly passwd itcast0830

5.2 Deleting a user

Userdel itcast0830----The user's home directory is retained when this is deleted

Userdel-r itcast0830-----Delete the user's home directory while deleting the user

5.3 Modifying user properties (****** understanding *******)

Usermod-l itcastitcast0508 to change itcast0508 's login name to Itcast

Usermod-g Rootitcast To change the group of Itcast to the root group

Usermod-g hadoop,hellogrp itcast Add two groups to Itcast

usermod-d/home/itcast itcast Change itcast0830 's home directory to/home/itcast

(To create the Itcast directory in advance and copy the environment variable file)

----* * * *----Modify user's password

passwd itcast0830

5.4 User Group Management

Each user belongs to at least one user group each user group can contain more than one user in the same user group with permissions shared by the group


Create a user group

Groupadd heros

Delete a user group

Groupdel Beauties

Modify User Group Properties

Groupmod

Check the identity of the current user

WhoAmI


To view groups to which the user belongs

Groups Angelababy



6 Common system Management

(Always use the root permission if the modification is involved)

It is easy not to use Su to switch to root identity

Commands that ordinary users use sudo to perform root permissions

For example, add the Heima16 user to the sudoers file vi/etc/sudoers

Root all= (All) all

Heima16 all= (All) all


6.2 Disk Space Information view

Df-h Viewing disk space status information

Du-sh * View the total size of all subdirectories and files in the specified directory

6.3 Process Management

PS Display instantaneous process status-e/-a Show all processes, environment variable-F full format-a show all processes of all users (including other users)-U displays the process in the order of user name and start time-X displays the process with no control terminal


Free view memory usage can take units, for example, show M, free-m

Top viewing system process information for real-time refreshes

Ps-ef View snapshot of process information for the current instant in the system

Ps-ef | grep myshell.sh Search for Myshell process information

Kill-9 PID Kill Process (-9 means forced kill)

6.4 Network Management

View IP Address

Ifconfig


Modifying the configuration of IP addresses

Vi/etc/sysconfig/network-scripts/ifcfg-eth0 Modify the configuration file to change the IP address

Or, under root authority, use the Setup command to modify a pseudo-graphical interface with hints

Modify Host Name

sudo vi/etc/sysconfig/network Modify the hostname configuration items in them

[Email protected] ~]# vi/etc/sysconfig/network

Networking=yes

Hostname=heima16-server-01

To take effect immediately, you can execute the instructions.

[Email protected] ~]# hostname heima16-server-01

After the execution of the landing can immediately see the effect


View information about the current process connection network

NETSTAT-NLTP gets the process that the system is currently listening on the Port TCP protocol


Netstat Displaying network status information

-a displays all connections and listening ports-t (TCP) only shows TCP-related options-U (UDP) only displays UDP-related options-n rejects display aliases, which can show all numbers converted to numbers. -P Displays the program name that establishes the associated link

Network Service Management (under root authority)

Restart Network Service servicenetwork restart

Shut down the Firewall service serviceiptables stop

Turn off firewall auto-start chkconfigiptables off

View Firewall health status: Serviceiptables status

To view the auto-start configuration for the firewall: chkconfig iptables--list

6.5 Modifying the system's default boot level (* * * learn ******)

Vi/etc/inittab

# 0-halt (do not set Initdefault to this)

# 1-single User mode

# 2-multiuser, without NFS (the same as 3, if you don't have networking)

# 3-full Multiuser mode

# 4-unused

# 5-x11

# 6-reboot (do not set Initdefault to this)

#

Id:3:initdefault:

~

Start the full-featured character interface with LEVEL3

Note: in command line mode, use StartX to manually start the graphical interface (operating on the server)

Linux does not start the graphical interface:

Vi/etc/inittab

Id:3:initdefault:----------This line modified to 3 for terminal, 5 for graphical interface

7 Common tool directives

WC #统计文本信息 (number of lines, number of words, characters)

Find specified file in file system? find/etc/-name "AAA" grep finds the specified string in the specified text file date #查看或者修改系统的日期和时间

Date-s 2007-08-03

Date-s 14:15:00

Date-s "2007-08-03 14:15:00"

Write system time to CMOS

Clock-w

Echo #输出字符串或者变量的值

VI #linux系统中最通用的文本编辑器

Vi/vim is the most commonly used text editor on Unix/linux and is very powerful.

Only commands, no menus.



Operation Flow:

VI Hello.world into the file editor

In the non-editing mode, when you enter insert mode by pressing an I

In insert mode , you can edit content just like a normal text editor

After editing is complete, press ESC to exit Insert mode and enter non-edit mode

Then press : enter the bottom line command mode, type Wq in the bottom line command and enter, you can save

(another mode of saving the file: Press ESC to exit Insert mode, and then press the shortcut key to save--shift + zz)

If not saved, the bottom line command is used q!


VI Edit location using command:

: Set NU Displays line number

: Set Nonu Cancel line number

GG to the first line of text

G to the last line of text

: N to the nth line of text

U undo, cancel the previous action

Ctrl + R Redo, before returning to undo


8 Software Installation in Linux
8.1 Java Software Installation

JDK Installation

Unzip the installation package to your installation path

Then modify the environment variables

Vi/etc/profile

Add at the end of the file:


Export java_home=/usr/java/jdk1.7.0_55/

Export path= $JAVA _home/bin: $PATH

After modifying the Save Exit VI Editor, execute the command:

Source/etc/profile #用以让环境配置生效

Eclipse installation

Select the correct version (32OR64) and drag it to the Linux system to perform the decompression.


8.2 RPM Package Installation

Redhat Company's RPM approach to package management is also a very common package Manager

Example: MySQL Installation

Delete the surviving MySQL library from the system first

Rpm-qa | grep MySQL #查看系统中已有的mysql相关的库

Rpm-e mysql-libs-5.1.66-2.el6_3.i686--nodeps #删除老的库 (remove dependency forcibly uninstall)

RPM-IVH mysql-server-5.1.73-1.glibc23.i386.rpm #安装mysql服务器

RPM-IVH mysql-client5.1.73-1.glibc23.i386.rpm #安装mysql客户端

Start: Service mysqld start

First boot change root initial password as prompted

Login Mysql:mysql-u root-p exit: Quit;


8.3 Web version rpm----Yum (Yellow dog Updater)

1. List all packages that can be installed, from which to find Tomcat-related packages

Yum List | grep Tomcat

or yum search xxx

2. Install packages (e.g. Tomcat)

Yum-y Install tomcat6.i686

3. Update package

Yum Update Tomcat

System Day67 Linux Getting Started

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.