Linxu Study notes-basic commands

Source: Internet
Author: User
Tags clear screen egrep

which LS

Set alias on ~/.BASHRC

Modify Path Vi/etc/profile,source/etc/profile

Ctrl U Delete forward

Ctrl K Backward Delete

Ctrl D Exit logout exit

CTRL Z Pause FG Recovery

Ctrl c Cancel, interrupt

CTRL s screen is still, locked, background continues to work, but the screen does not display

CTRL q Screen recovery, unlocking

Ctrl L Clear Screen

CTRL a Beginning

Ctrl e End of line

Mkdir-p

Rmdir-p

Cp-r Copy Directory

Cat-a View txt

MV No R

Less J K, Ctrl+b F, g G,/n N,?

Chmod-r Permission inheritance

chmod u= g= o= which do not carry--the system thinks the minus sign

Chown User:group: Or.

!ls a recent LS command

!301 history's ID

Chown-r Permission inheritance

Chattr +-A cannot delete rm and change VI,MV can only append echo "one" >>1.txt

Chattr +-I protect, nothing can

Lsattr-r

Lsattr-d

chmod U+s S is limited to ordinary users, has root invalid, note o permissions

!$ last command.

G Extension Group Usermod Useradd if the group has users, you can also delete

GID Max one go back

Usermod-l Lock user cannot log on,-u unlocks, usable useradd all parameters u g G s D

mkpasswd Yum install-y expect-l 12-s 0-c 4-c 4-d 4

echo "[email protected]" | passwd--sdtin aming PlainText

Echo-e "123456\n123456" | passwd aming-e recognition \ n for newline, no-e not recognized, new password 123456

Su-C "mkdir/tmp/dir123" aming

Visudo

Root all= (All) all

aming 192.168.1.0/24= (Root) nopasswd:/bin/ls,command

User name & group name Source Role command, absolute path, comma delimited, set no password required

sudo ls/root/require a password, or you can not enter a password

Sudo-l See what permissions you have

Inode attributes (size, path, permissions), Inode allocated even if partition has space, cannot create file

Du-sh file occupies disk space size, block size and LS-LH file itself size, display size is different, due to sub-block 4K

DU-SB and ls-lb show the same size

Cat/etc/filesystems

mke2fs-t/t ext4-b 2048-m 1-l aming/dev/sdb1 more than MKFS.EXT4 parameters

Block Size retention Label

DF-T Viewing partition types

Umount-l forced uninstallation

/etc/rc.local Automatic Mount command

Blkid UUID Label EXT4

defaults= Rw,suid,dev,exec,auto,nouser,async

0 Backing up Log

1 do not back up log, accidental power loss recoverable data

1 fix, only root partition

2 Fix, lower priority

0 not fixed, unimportant or partition too large, otherwise it will affect the boot speed

Mount-a loading all mounts in Fstab

Yum Install-y vim-enhanced

Vim +10!$ cursor on line 10th



General mode

J K under H K 2j down 2 line

Ctrl F Next page CRTL b page PageUp PageDown

GG First line G line end 100G

$ line End 0 beginning (with white space characters at the beginning) ^ Beginning (non-blank)

X Delete x forward delete 4x cut

DD Delete entire line, cut 3DD

P paste down p paste up

U undo, undo up to 50 times CTRL R Anti-undo

yy copy entire row 3yy

V Visual mode left and right up and down selection and X p combined


Edit mode

I insert

ESC exits

I cursor at the beginning of the line

A cursor in the back

A cursor at the end of row

o The next line of the cursor

O one line on the cursor


Command mode

: wq!

: Set NU Displays line number

: Set Nonu Cancel line number

/keyword Find, highlight, n find n

? keyword find, highlight, n find n

: 1, $s/a/b/g no g, replace only the first of each line, $ all lines

:%s/a/b/g%=1,$ entire file

de-symbol \, identify/

#///#///# @///@///@ does not produce ambiguity

: Nohl Cancel Highlight


Gzip file is compressed after the source file is deleted, only the files can be compressed, leaving only file.gz red-1-9 level higher, the slower the rate, the higher the ratio, the default 6

Gzip file.gz extract after source file delete

BZIP2 file compressed After the source files disappear, leaving only file.bz2 Red, default 9

bzip2-d file.bz2 Extract source file Delete

Bzcat and zcat xzcat viewing compressed content

Neither gzip nor bZIP can compress the directory

XZ gzip bZIP Usage almost


Yum install-y xz gzip bzip2 zip unzip


Zip file.zip file Source file exists, can compress files and directories

Zip-r file.zip file1 file2 simultaneous compression of multiple directories

Unzip File.zip


Tar--exclude file3--exclude file4-cvf file.tar file1 file2 dir1 source file exists

TAR-TF File.tar View

TAR-XVF File.tar Unpacking

Tar-c-XVF File.tar specifying the unpacking path


TAR supports gzip bzip2 XZ

TAR-ZCVF 1.tar.gz 111 22 source file exists

Tar-c/tmp/-zxvf 1.tar.gz source file exists, directly covers

TAR-TF 1.tar.gz


TAR-JCVF 1.tar.bz2 111 222

Tar-tf

Tar-jxvf


TAR-JCVF 1.TAR.XZ 111 222

TAR-TJF View

Tar-jxvf


RPM-IVH Full Name

RPM-IVH--nodeps full name, no reliance, less use

RPM-IVH--force full name, forced installation

RPM-E Package Name

When dependent, install or uninstall at the same time

RPM-UVH Full Name, upgrade


RPM-Q Package Name

RPM-QA Query all installed

Rpm-qa the full name of the package name query package

Rpm-qa | grep vim exception, can be checked keyword

Rpm-qa | grep ' vim* '

RPM-QI package Name, detailed information

RPM-QL package name, which files are installed

RPM-QF absolute path, which package the file belongs to

RPM-QF ' which vim '


Yum list Yum Source/etc/yum.repos.d/centos-base.repo

Yum List | grep vim @ symbol belongs to an already installed

Yum Search ' vim '


Yum Remove package name does not recommend adding Y to prevent dependency deletion

Yum Update package name is not recommended for upgrade

Yum Upgrade Package Name


Yum Groupinstall "package name" Installation Kit

Yum Grouplist | Grep-i Chinese

Yum Groupremove "Package name"


Yum install-y yum-plugin-downloadonly Download Plugin

Yum install VTE--downloadonly--downloaddir=/tmp/download RPM packages that have not been installed

Yum Reinstall VTE--downloadonly--downloaddir=/tmp/download installed RPM packages


SOURCE Package Installation

Yum install-y wget

/usr/local/src

wget http

Tar

Cd

Cat Install

Cat Readme

./configure--help See configuration parameters, module

./configure--prefix=/usr/local/apache2 specifying the installation path

echo $? Return code 0 means OK

Make compile, turn source into language

Make install translates into system-recognized files

Ls/usr/local/apache2 Viewing the build directory


Rm-rf/usr/local/apache2 Uninstall, reinstall, preferably delete the compressed directory, re-unzip


History

Cat ~/.bash_history User Operation command history, different user, history, default 1000 bar

Echo $HISTSIZE

!! Previous command

!$ last argument on a command

!n Run nth Command

!c the last command to start with C


? Any one character


Jobs View Ctrl-Z commands

FG Priority call + sign, front desk

BG Backstage


Env View System Variables

Set view system variables, including custom variables, in more detail

Custom variable a=1;b=2, valid only at the current shell

Variable name cannot start with a number, can contain _, can start _, do not recommend capitalization, avoid command, keyword, system variable capitalization

C= ' ls/tmp/', * #也需要用单引号

D= ' which vim ' command uses anti-quotes, referencing the result of the command

E= "$a" 8 variable with double quotation marks

Export A=1 Global Declaration, in effect in other Bash,shell

unset e Cancel Variable


Vim/etc/profile Global Configuration

Source/etc/profile declares that all *.sh under/etc/profile.d/are loaded, and custom environment variables are not recommended to directly modify the profile


VIM/ETC/BASHRC PS1 UMASK Global Configuration

Echo $PS 1 W: Absolute path


The VIM ~/.bash_profile user profile is called. BASHRC

Vim ~/.BASHRC user profile alias user login, open new shell when executing


[0-9a-za-z]


Cut-d:-F 3,4/etc/passwd split, showing third to fourth paragraph

Cut-c 1-10/etc/passwd display first to 10 characters


Sort default ASIC sorting

Sort-t:-k3-nr/etc/passwd n by the number 3,5 3 to 5,r reverse, the letter is smaller than the number,-U go to Heavy


Wc-l Number of rows

Wc-w word number, blank delimited

Wc-m number of characters, including line breaks, spaces


Uniq must be adjacent to the row to go to the heavy

Uniq-c Repeat Count

Sor File | Unqic-c


Tee redirection

echo "123456" | Tee 1.txt will show the difference between results and >


TR Replacement

echo "ABCD" | Tr ' A-Z ' A-Z ' one by one corresponds to ' AB ' AB '


Split cut

Split-b 50m 1.txt by size default unit B, can omit (x) AA Xab

Split-l 1.txt per row


&& and success-execution unsuccessful-do not execute

|| or success-not performing unsuccessful-execution

; (not) Success-execution


grep--color ' root '/etc/passwd highlight

echo "Alias cg= ' grep--clort '" >> ~/.BASHRC

-N Display number of rows

-C counts a few rows

-V does not contain keyword

-A 2 shows the next two lines

-B More than 2 shows the last two lines

-C 2 more display the upper and lower lines

-R ' root '/etc/* directory search keywords, with file directory name, content

-RH does not show the front directory path

CG ' [0-9] ' 1.txt

CG ' [a-za-z] ' 1.txt

Cg-v ' [a-za-z] ' 1.txt does not contain

CG ' ^[a-z] ' 1.txt starts with a letter

CG ' [^0-9] ' 1.txt does not contain a pure number, does not contain a blank line

CG ' ^[^0-9] ' 1.txt lines that do not start with a number, do not contain blank lines

CG ' ^$ ' 1.txt show Blank line

CG ' R.O ' 1.txt any one character, including spaces, special symbols

CG ' R*o ' 1.txt 0 or more front character O also conforms to

CG ' R.*o ' 1.txt R starts with an O result count, no matter what, any character in the middle

CG ' R\?o ' 1.txt de-semantic characters ==cg-e ' r?o ' 0 or 1 preceding characters

Grep-e ==egrep


Egrep ' R+o ' 1.txt 1 or more preceding characters








































Linxu Study notes-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.