Some basic Linux commands and Primary network configuration methods

Source: Internet
Author: User
Tags ftp parent directory touch touch command ssh nameserver ping network

Basic commands

Uname-a-S

Hostname Display host name

To be permanently effective, edit the following file

#vim/etc/sysconfig/network

SSH remote Login

#ssh 10.1.1.54 (logged in as root)

#ssh tom@10.1.1.54 (log in as Tom)

#ssh-y 10.1.1.54 (remote login that can start the graphical interface)

SCP Remote Copy

#scp 10.1.1.54:/etc/passwd/tmp/test (copy/etc/passwd file on 10.1.1.54 of destination address to local/tmp/test)

#scp/tmp/test 10.1.1.54:/etc/passwd (on the contrary)

-R can copy folders

File View Files Properties

#file passwd

Init

Configuration file/init/inittab

Level 0 shutdown

1 single user mode, mainly used to modify admin password

2 text mode with no network support

3 text mode with network support

4 Retention

5 Graphical interface mode

6 reboot

Sync Sync Data

Synchronizes data that has not yet been synchronized to the disk to disk (generally refers to in-memory data)

Shutdown

-R reboot

-P Direct Power off

-H 14.09 "Hurry Up,the system is shutting down"

-C Cancel Shutdown plan

Firefox &

Start Firefox in the background

[Root@dns 03]# Jobs

[1]-Running gedit Ule_02.txt &

[2]+ Running Firefox &

[Root@dns 03]# FG%1

The job that is still running in the background---gedit ule_02.txt is transferred to the foreground run

CTRL + Z put the foreground process in the background and suspend the operation

BG runs a background paused process in the background

CTRL + C to end a foreground process

Date Day command

#date +%x

03/17/2010

#date +%m/%d/%y

03/17/2010

#date +%y-%m-%d

2010-03-17

#date "+%y-%m-%d%h:%m:%s"

2010-03-17 14:26:45

#date 031714282010

The date of the month "-------modification time

# echo $ (($ (date +%s)/86400) calculates the current number of days from 1970-01-01

# echo $ (($ (Date--date= ' 2010-03-18 00:00:00 ' +%s)/86400))

echo $LANG View the current language environment

Export Lang=en_us. UTF-8 Change the language environment

Network configuration

Network card Configuration

#ifconfig

Ifconfig eth0

Eth0 Link encap:ethernet hwaddr 00:25:86:91:3d:34

inet addr:10.1.1.72 bcast:10.1.1.255 mask:255.255.254.0

Inet6 ADDR:FE80::225:86FF:FE91:3D34/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 Metric:

RX packets:51873478 errors:0 dropped:0 overruns:0 frame:0

TX packets:51390710 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:747618634 (712.9 MiB) TX bytes:3903334584 (3.6 GiB)

interrupt:177 Base address:0xac00

Configuring Sub-interfaces (temporarily effective)

#ifconfig eth0:1

#mii-tool

Check whether the network card link is up

Modify the configuration file for the network card

# Vim/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0 <---equipment name

Bootproto=static <---How to configure the network adapter at startup: Static | Dhcp

Onboot=yes

ipaddr=192.168.1.110

netmask=255.255.255.0

gateway=10.1.1.1

#service Network Restart "---# vim/etc/sysconfig/network (configuration file)

# route del default GW 10.1.1.1 <---Temporarily change the default gateway

# route add default GW 10.1.1.1

# route del-net 169.254.0.0 netmask 255.255.0.0 <---Temporary management of routing entries

# route add-net 169.254.0.0 netmask 255.255.0.0 Dev eth0

Configure the address of a DNS server

Configuration file/etc/resolv.conf

NameServer 10.1.1.1

NameServer 202.96.128.166 <--Telecom

NameServer 210.21.196.6 <---netcom

How to get the computer online:

1, configure the correct IP address

2, the correct gateway

3, the correct DNS

The wrong steps:

1,ping 127.0.0.1 <----------TCP/IP protocol stack

2,ping Network card Address <----------network card failure

3,ping DNS Address <----------Ping 10.1.1.1

4,ping www.163.com<----------If the IP address of the domain name cannot be returned, then the DNS configuration error

Practice:

1, familiar with the use of special positions, try to describe its use. Requirements: Each user uses the Touch command to create the file, the owner belongs to Tom, owns the group is Nokia. Finish the experiment, don't forget to recover.

2, the establishment of a folder/ftp, required to store files only file owners can be deleted. And all the files and subdirectories under that directory have group attributes that belong to Tom.

3, how to achieve so that each account in the text terminal login, all on the terminal display Welcome to UPL information?

4, the realization of global command alias Mnts, automatic mount Mount 10.1.1.20:/share/ftp_source/class/03

5, let Tom account to establish a folder permissions mode is 755, the permission to establish a file is 644.

6, let the host ping www.baidu.com when the IP address returned is 10.1.1.20, how should it be implemented?

7, according to the network configuration of several steps, their own deliberate destruction, intentional configuration errors, and then the table between the wrong.

1: The idea: a privileged position is the root given that a command is executed in a specific capacity at the time of execution

Step One: Create users Tom, user group Nokia and general user AAA #useradd Tom

#groupadd Nokia

#useradd AAA

Step Two: View the location of the touch command, and more information #which touch

#ls-l ' which touch '

Step three: Change the owner of the touch command with all groups #chown Tom:nokia ' which touch '

Fourth step: Give the touch command to the user and user group privilege bit #chomd u+s,g+s ' which touch '

Step Fifth: Switch to a regular user and create a file with the Touch command #su-tom

$touch file1

Step Sixth: Use Ls-l to view the owner of the file created with all groups $ls-l FILE1

Results: The other account cannot use touch <----------------------reason: Because the user created the file in the path of the parent directory does not have write permission, to the directory can be access to the permission to execute the command

2: The idea: The first step: Create a folder FTP #mkdir/ftp

Step two: Recursively modify the owning group of FTP #chown-r: Tom/ftp

Step three: Give ftp paste bit #chmod o+t/ftp

3: Thinking: Each account in the login will automatically run the account corresponding to the home directory of the. bashrc file, so as long as in the corresponding. BASHRC add echo "" Welcome to UPL

such as: #vim/HOME/INOKIA/.BASHRC

Add echo "Welcome to Up1"

#su-nokia

$ There will be welcome information

4: The idea: The overall meaning is valid for all accounts. You can change the/ETC/BASHRC.

Add alias mnts= ' 10.1.1.20:/share/ftp_source/class/03/mnt ' at the end

5: Thinking: To modify the default permission mode, you can try to modify the default Umask

Enter $umask 022 at the prompt after you log in to Tom Account

You can modify the configuration file if you need to reboot or do so/ETC/BASHRC

6: The idea: only in the local parsing library to specify www.baidu.com resolution address of 10.1.1.20 can

#vi/etc/hosts

Add 10.1.1.20 www.baidu.com

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.