Linux basic commands

Source: Internet
Author: User

Linux Network configuration Management

Statically configured Ip,ifcfg-eth0 NIC configuration is as follows:

Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 bootproto=static #HWADDR =00:0c:29:52:c7:4eonboot=yes #重启网卡是否激活设备TYPE =ethernetipaddr= 192.168.1.10netmask=255.255.255.0gateway=192.168.1.1

DNS configuration:

vi/etc/resolv.conf add content to a file
NameServer 202.106.0.20nameserver 8.8.8.8

From top to bottom, the primary DNS is represented, and DNS is prepared separately. After the configuration is complete, the network card does not need to be restarted and DNS takes effect immediately.

You can ping www.baidu.com to see the effect

To close the SELinux method:

Modify the Selinux= "" in the/etc/selinux/config file to Disabled, and then restart.

If you do not want to restart the system, use the command Setenforce 0

To turn off the firewall:

Chkconfig iptables off permanently closed

Service Iptables stop temporarily closed


Linux basic commands

mkdir-p Creating a multilevel directory

Find/-perm 645 Lookup permission is 645

Cp-r (recursive) copy directory

Cat/etc/shells Viewing the shell

Wc-l Number of rows

Wc-w number of words

Wc-m characters

View file contents: Cat less more NL tail Head

More view file contents, paging view

LESS/ETC/PASSWD Progressive View

nl/etc/passwd viewing files and displaying line numbers

tail-f Dynamic View file changes after 10 lines

VI Editor:

Main Command mode edit mode bottom row mode

Command mode:

P Paste the previous line

P Next Line

V selected

YW copy a word

DW Delete a phrase

x Delete a single character

d$ Delete cursor to last

d^ D0 are all deleted at the beginning of the line

Undo: U Undo last u undo current All

Edit mode:

A--> starting at a position after the cursor character

A--> starting at the end of the line where the cursor is located

I--> starting from the previous position of the character where the cursor is located

I--> input from the beginning of the line where the cursor is located

O--> jumps to the beginning of the next line in the row where the cursor begins entry

O--> jumps to the beginning of the line where the cursor is at the start of entry

R--> from where the cursor is located

Input mode go to command mode: Press the ESC key

Bottom-line mode:

:w--> Save

:q--> exit

:wq--> Save exit

: Wq!--> Force Save exit

: Q!--> Forced exit

:x--> Save

Find:

/STINGS1 from the back (forward search)? Sting1 from behind (reverse search)

Replace:<sed>

: S/this/that/g replaces this with that if the cursor must be moved to that line

: S/this/that replaces the first occurrence of this in this line with that, which means that only the first one is replaced

Replace All:

: 1,$ s/old/new/g

:%s/old/new/g replaces all old characters in the file with new


User Group Management

/etc/login.defs This profile affects system users 1-499 normal users 500-60000

Up to 32 groups per user

Useradd

-U set UID

-D Specify home directory

-S develop shell environment

-G Master Group

-G subordinate Group

-R System User

Groupadd

Groupmod-n New Old Modify group name

Groupmod-g NEWID oldid modify group ID

Usermod

-L TOM2 Tom Modify user name

-G Group Users

-G Group1,group2,group3 Tom

Userdel–r jfedu1 (delete user's home directory at the same time)


To modify a user's home directory:

usermod-d/oracle Oracle

Disable User login:

1.usermod-s/sbin/nologin Oracle

2.usermod-l Oracle

For users who are already logged on

Violence delete the User: Userdel-r-F XXXX

Tip: Userdel:warning:can ' t remove/var/mail/git:no such file or directory

Userdel:git home Directory (/home/git) not found

It doesn't matter, the user has actually been successfully deleted

prohibit normal user login

Touch/etc/nologin

Kicking out a logged-in user

Pkill-kill-t PTS/1

Skill-9 pts/0

Rights Management:

Chown username filename Modify file user

-R Recursion (inherited permissions)

CHGRP Modifying the owning group

CHGRPJFEDU1 jfedu.net

-R parameter recursively modifies the owning group of all files under the directory

Only you and root delete:

chmod o+t/oracle

Package Management

Check if the software is installed

Rpm-q Software_name

Viewing the Software Installation directory

RPM-QL Software_name

View version information for software installation

Rpm-qi Sotware_name

Software upgrades

RPM-UVH Software_name

Software Uninstall

Rpm-e Software_name

RPM-E Nodeps Software_name Forced uninstallation

See all the packages installed on your computer

Rpm-ql


Decompression Command:

Zip-r all.zip./*

All files and folders under the current directory are compressed into all.zip files, and-R indicates that all files in the subdirectory are compressed recursively.

Unzip-o-d/data All.zip

Unzip + parameters + Extract Directory + Extract Files

Unzip the All.zip file to/data/

-O: Overwrite the file without prompting;

-d:-d/data indicates that the file is extracted to the/data directory;


tar [-cxtzjvfppn] File and directory parameters:

TAR-XF Decompression general will automatically judge Tar.gz tar.bz2

-C: Create a compressed file parameter directive (the meaning of Create);

-x: Unlock the parameter instructions for a compressed file!

-Z: Do you have the properties of gzip at the same time? i.e. do I need gzip compression?

-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?

-V: Files are displayed during compression! This is commonly used, but is not recommended for use in the background execution process!


Disk Management:

Maximum of 4 primary partitions

Creating a logical partition consumes a primary partition

3 primary partitions + logical partitions

SD4 Extended Partition

The logical partition is always starting with the fifth one.

Linux hardware devices are generally stored under/dev/, hard disk format is generally/DEV/SDA/DEV/SDB, disc format is/dev/cdrom

Execution Fdisk-l can see the capacity of the hard disk

Du-sh * can view all files in the current directory large size :

Disk Partitioning command:

1. Fdisk/dev/sdb

2. Press N for new, press p to create primary partition, W for write partition

3. MKFS.EXT3/DEV/SDB1 formatted partition

4. Mount/dev/sdb1/data Mount Partition


UMOUNT/MNT Unloading partitions

Mount-t ntfs-3g/dev/sdc/data1 mounted removable hard drive

MOUNT/DEV/CDROM/MNT Mounting Discs

Mount-t ntfs-3g/dev/sdc/data1 mounted removable hard drive

Hard drive recovery, how to fix it?

Enter Linux rescue mode to execute fsck.ext3/dev/sdb-y


This article is from the "Linux---basics" blog, so be sure to keep this source http://perin.blog.51cto.com/10410663/1669117

Linux basic commands

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.