Linux (Centos,ubuntu) common commands for learning notes

Source: Internet
Author: User
Tags parent directory prev disk usage
characteristics of Li Nux

1) free, open source

2) support multithreading/multiuser

3) Good safety

4 Superior memory and file management

Shutdown reboot

sudo shutdown–h now turn off the machine

sudo shutdown–r now reboot

sudo shutdown–h nn minutes later shutdown

sudo shutdown–h 12:00 to 12:00 It's time to turn off the machine.

sudo reboot immediately reboot.

Cancellation

Logout

Enter the graphical interface (log off and back to the console)

StartX

Permissions

Sudo

Activate Admin user root

sudo passwd root

Deactivate administrator user root

sudo passwd-l root

Path, File action

LS Displays the current directory and files below

Ls-a Show hidden files

Ls-l display files in a detailed manner

Ls-al Show hidden and in detail

CD AA into AA catalogue

Cd.. Return to Parent Directory

PWD Show the directory of course

CD-Back to the last directory

CD ~ or CD back to the current user's host directory

CD ~ User name back to the specified user's host directory

mkdir New Directory

RmDir Delete Empty Directory

Touch to create an empty file

RM Delete Files

Cp

Mv

More, less, |

More a.txt display file content as pagination shift+page up prev

Less a.txt display the contents of a file as pagination page UP prev

Ls–help | More "|" For pipe commands, display content as pagination

grep "string"/home/a.txt query content in text

Man LS View the help information for the LS command is similar to Ls–help

Find/-name A.txt "/" represents the root directory (path), locating files A.txt

Fond–size +1000k to find files larger than 1000k

ls > A.txt Saves the results of the LS command execution to the A.txt file (Overrides)

LS >> a.txt will not overwrite (append to end of file)

ENV displays current operating system environment variables

Chsh–s new Shell (/BIN/CSH) Username (omitted to imply current user)

History 10 shows previously used commands

History!10 displays a command with a history number of 10

History!ls shows the last ls command used

Management of users and groups

Cat Etc/group View all Groups

CAT/ETC/PASSWD View All Users

Useradd Create a new user

USERADD–G Group name User name add to XXX Group

Userdel–r User name Delete user everything

Userdel user name Deletes the user, does not delete the user's folder

passwd user name creates password for user

passwd-d Username Delete User password can also log in

PASSWD-L Username Lock Account

Passwd-u User name Unlock Account

USERMOD–G Group name User name to another group

Usermod–d Directory name User name change user Login initial directory

Usermod-l new username old username name for user renamed

Usermod-l to lock user name lock User Login

Usermod–u unlock user name unlock user login

Usermod–u 501 username change user uid

Groupadd to create a new group

Ls–ahl file name View all groups of files

CHGRP Group name File name modify the group where the file/folder is located

chmod 777 Xiaohua Modify Permissions

Groupmod–n new username old username name Group renamed

GROUPMOD–G 501 Group name change Group GID

Groupdel Group name Delete Group

GPASSWD-A User name Group name to add user to group

ID User name Check user information

-rw-r-r-

Permissions are divided into three types: R readable (4); W writable (2); x executable (1 indicates)

-File type-Represents a normal file, D represents a folder

The owner of the RW file has permission to the file, and RW says it can read and write

R permissions for the file in the group

R Permissions for users of other groups on this file

VI Editor

VI into the editor

VI A.txt entered the editor and created a text called A.txt.

I go into insert mode

Enter the ESC key into command mode

W Save

Wq Save and exit

Q! Quit without saving

Set Nu Add line number

Set Nonu Cancel line number

Enter a number and press ESC, and the cursor can jump to the line

C Language Program (VI)

Gcc–o myc1 aa.cpp Compilation

./myc1.out implementation

Run level

0 off the machine

1 single users

2 Multi-user status No NETWORK service

3 multi-user status with network service

4 system not used reserved to user

5 graphical interface

6 system reboot

Modify Run Level:/etc/inittab Id:5:initdefault: The number of this line

Package Installation

. bin format Software Installation./test.bin (execution)

. deb format Software installation (install to specified directory) dpkg–i aa.deb–instdir= directory

Apt-get Install online software installation such as Apt-get install VSFTPD

Dpkg–r aa.deb Uninstall Software

Dpkg–l aa.deb Uninstall software (no retention of configuration files)

Disk Management

Umount/mnt Uninstall

Mount/dev/sda1/mnt loading

Fdisk–l View disk Information

Df/boot See which partition the boot folder belongs to the disk

Df–h View disk usage

Decompression

Zip aa.zip bb.txt Compressed file

Zip aa.zip bb.txt cc.jpg compress multiple files

Zip–r SS.XIP./bb/compressed Folder

Unzip–z Aa.zip View the contents of a compressed file

Unzip Aa.zip Decompression

IP configuration

1. ifconfig eth0 ***.***.***i Address p

Ifconfig eth0 Network ***.***.*** Subnet mask

Features: temporary entry into force

2. Vi/etc/sysconfig/network-scripts/ifcfg-eth0

/etc/rc.d/init.d/network restart

Process

PS–A Displays all process information for the current terminal

Ps–u Display in user format

Ps–x Display background Run process

Ps–aux View full

sudo kill process number terminate process

Kill-9 process number terminates process, higher strength

Killall process number can terminate child processes with related processes

Top monitor memory, process condition

Top–d 5 monitor memory, process condition, 5 seconds Refresh

Date

Date View current date time

Cal 5 2000 View calendar for May 2000

Date Mmddhhmmccyy. The SS month is divided into years every year. seconds seconds

Network Monitoring

Netstat-an View current Network condition

sudo netstat-anp view current network status with the corresponding process number

Traceroute Tracking Routing

MySQL database backup and recovery

First go to the directory where MySQL is installed

Backup:./mysqldump–u root–proot (no spaces) dbname >/home/aa.sql

Recovery: Mysql–u Root–proot dbname

File structure

Solve garbled:

Modify/etc/default/locale

sudo vim/etc/default/locale1

Modify the default
Lang=zh_cn. UTF-8
Language=zh_cn:zh

For:
Lang= "en_US. UTF-8 "
Language= "En_us:en"

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.