Linux Related commands collation

Source: Internet
Author: User
Tags get ip

First, what is Linux

Linux generally refers to a Linux system, Linux is an operating system, and Windows, Mac OS X.

Linux is a set of free-to-use and free-spread Unix-like operating system, is a POSIX and Unix-based multiuser, multitasking, multi-threaded and multi-CPU operating system.

Second, the Linux Foundation

1.linux Remote Login Tool Recommendation: Xshell,securecrt,putty,ssh, and so on, the specific use of the method does not make a specific description.

2.linux Upload Download file

(1) xftp, FileZilla, WINSCP and other tools upload and download

(2) RZ, sz command

Rzsz command installation, using Yum installation, yum-y install LRZSZ, compiling and installing: http://blog.chinaunix.net/uid-20639775-id-154615.html

RZ upload Local files to the server (only upload files cannot upload folders)

After executing the command, select the file you want to upload in the pop-up box.

SZ download file to local

3.linux shutdown, restart, graphics and text interface

(1) Common shutdown command: Init 0 shutdown-h Now (shut down immediately) shutdown-h delay minutes "prompt" (how often to shut down)

(2) Restart: Reboot shutdown-r now (restart immediately) shutdown-r delay minutes "message" (how often restarts)

(3) Graphics and text interface (provided that Linux is installed with graphics and text interface)

Modify the Initdefault parameter in the/etc/inittab file can modify the default start graphical interface or text interface, 3 is the default to enter the text interface, 5 is the default to enter the graphical interface

Text interface/graphical interface switch: Text interface under the input INIT5 or startx switch graphical interface graphical interface input INIT3 switch text interface general default into the text

4.linux Users, Groups

(1) Add user

Useradd-d Home Directory-G Group name-group set (comma interval)-p password-S user Shell program user name Example: useradd-d/usr/local/nginx/-G nginx-g nginx,oracle-p123 456-s/bin/bash test4

You can add a user without parameters directly useradd test, using bash shell by default, home directory

Set password for User: passwd user name

(2) Delete user

Userdel-r User name-R for deleting home directories and all of their files

(3) Adding a group

GROUPADD-G Group ID-R Group name Example: Groupadd–g 455–r besttest

-R: Establish system Group, group ID less than 499 new group ID between 500-60000, less than 500 for system group all parameters can be saved (except Group name) Groupadd test

(4) Delete a group

Groupdel Group name Groupdel test

(5) Switch user su and sudo get super user privileges

Root user switch to normal user does not require a password, normal user switch to root need to enter a password

$ and #,$ represent ordinary users, #代表root用户

  

sudo: for example: sudo reboot

There are some commands that ordinary users do not have permission to manipulate, so use sudo to get superuser privileges

If the normal user wants to use the sudo command, it needs to be configured in the/etc/sudoers file, for example, to test the user can use sudo to get root user rights, use root user to edit/etc/sudoers file, find root all= (All) All this line, add bestest all= (All) below it Nopasswd:all

Then save it. NOPASSWD does not enter a password when using sudo on behalf of the user

5.linux Network Configuration

(1) command to view IP: ipconfig or ip a

(2) Auto Get IP command: dhclient

(3) Restart, start, stop Network command: Service network Restart/start/stop

(4) Turning the firewall on and off

1) After reboot, open: Chkconfig iptables on off: chkconfig iptables off

2) immediate effect, fail-Open after reboot: Service iptables start off: Service iptables stop

6.VI Editor and Common commands

(1) VI two modes: Command mode and edit mode

Command mode: When entering, default this mode, command enters edit mode: I (current position), a (next position), O (next line) exit Edit Enter Command mode: ESC

(2) VI common commands

Cursor Positioning: 0 Move cursor to beginning $ (SHIFT+4): Move cursor to end of line G: Move cursor to last line

Undo and Redo: U revert to the previous action. Repeat the previous action

Copy, paste, delete: nyy copy cursor down n line content p Paste the copied content at the cursor DD Delete Bank contents set number display line numbers Set Nonu suppress line number display

Search string:/Search String For example:/besttest If the result contains more than one besttest, press N to find the previous, press N to find the next

Exit Vi:wq Save Exit q! do not save exit

7.linux Common file commands

(1) LS file View command For example: Ls-l ls-a

(2) CD switch directory for example: Cd/tmp cd-cd~ CD.

(3) CP copy file CP source file target file For example: CP HHF Hhf.txt

(4) MV Move file or modify file name MV Source file destination file For example: MV HHF AA (source files and directory files in the same directory as the modified file name) move files: MV Hhf/tmp/hhf/test

(5) RM Delete files/folders For example: Delete a folder and its directory under the RM-RF aa.txt

(6) PWD view current working directory

(7) Create folder: mkdir Test Create file: Touch Test Delete folder: mkdir Test (some commands only apply to delete empty folders)

(8) Cat view file contents cat/dev/null hhf file redirection more/less split screen view file contents: More Access.log

(9) Tail dynamic View file display content Tail-rf Access.log

Chmod used to grant permissions to files or folders three basic permissions R (4) W (2) X (1) Change permissions: chmod +x test.sh chmod 765 test.sh

(one) chown change file user chgrp change user group

Find searches file system for a file Find/-name hhf.txt Find/-name *aa*.sh

grep Displays matching rows | Pipe command Ps-ef|grep Tomcat |grep-v grep

PS View Process Command Ps-ef ps-aux View all Processes

(a) WC statistics command wc-l hhf.txt statistics hhf.txt file line count

(+) who shows online login user WhoAmI display current operation user who am I display login user identity w display details of the logged-on user

(+) hostname Display host name

Help for example: LS--help

Directory size for du du-h DF view disk size Du-h

Kill kill Process Command kill-9 process PID When a service has multiple processes, you can use Xargs to kill a process: Ps-ef | grep Process Name | Grep-v grep | awk ' {print $} ' | Xargs kill-9

8. File compression and decompression

(1) zip/unzip zip file.zip file1,file2 file1,file2 compression to File.zip unzip file.zip-d/directory File.zip extract to xx directory

(2) tar tar[parameter] destination file source directory or file

Tar zcvf hhf.tar hhf# Compressed tar zxvf hhf.tar #解压缩

9. Software Installation Commands

(1) Yum online installation yum-y install Lrzsz

(2) RPM source installation RPM-IVH jdk.rpm# installation JDK

10.crontab Scheduled Tasks

Crontab-e Edit timed Tasks crontab-l View Scheduled Tasks list

Linux Related commands collation

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.