Linux Common commands

Source: Internet
Author: User
Tags create directory gz file parent directory

Common commands:

---------------------------------------------------------------

Date Time Date +%y 2-bit m-month after year Y


BC Calculator scale=3 shows the 3 digits of the decimal point 2^5 2 of the 5-time Square


Cal Calendar Cal 2015 calendar Cal 4 2015 calendar of a month of the year


Historical History Command View!+ number Quick Reference command


Shutdown-r now restarts Init6

Shutdown-h now shuts down the machine init0


RunLevel look at the current level of operation

Vim/etc/inittab Modifying the default run level


Service Network restart Restart networking service


---------------------------------------------------------------

Directory class commands

---------------------------------------------------------------

CD into the catalog CD. Go to Parent Directory CD ~ Enter home directory

PWD See detailed path

ls Browse file-l details-a hidden file-D directory-H humanized-I node-1 only one file per line

mkdir Create a directory you can create multiple directories with a space-p recursive creation

Du statistics catalog File size-H human-A includes directory files-s only statistical parameter size



---------------------------------------------------------------

File class commands

---------------------------------------------------------------

CP Copy directory or file-R recursive-V procedure-I reminder-f force-p property unchanged

RM Delete-R recursive-F force-I reminder common-RF

MV Rename or cut

which to see where the command is located and list aliases

echo Print

Uname System Version number

Touch Create File

LN creates a connection-s original file hyperlink file Soft link

Do not add s for hard link feature 1 sync Update 2 like Copy 3 original file missing new file not full

4i node same 5 cannot span partition 6 not for directory

Find files and directories-name search by name to add * or? Wildcard characters-user genus of main-group group

-perm 777 According to the authority to find



---------------------------------------------------------------

Output View Processing File command

---------------------------------------------------------------

Cat is viewing the file contents-N Displays the first few lines

TAC Reverse View file contents-N

More view long file content Space page back to the next line on the next line quit quit

Less view long file contents Space page flip-flop Enter

Head view file Top N lines--first few rows

Tail viewing a file after n rows-a few lines

WC statistics-L rows-W number of words-c byte size

Grep finds the line in the file that displays the specified character-I ignores the case-V reverse ^# file that begins with the # sign



---------------------------------------------------------------

Help commands

---------------------------------------------------------------

Man view the usage of the command or view the role and format of the configuration file Q exit

--help view the basic usage of commands such as LS--help



---------------------------------------------------------------

Archive Compression Command

---------------------------------------------------------------

. tar.gz file TAR-ZXVF decompression-ZCVF compression followed by new name and directory

. tar.bz2 file TAR-JXVF decompression-JCVF compression followed by new name and directory

. zip file Zip file unzip unzip-R directory

. gz file gzip compression Gunzip uncompressed compression ratio very large only compressed files

. bz2 file bzip2 compression-K retain original file Unbzip2 extract



---------------------------------------------------------------

Rights Management Commands

---------------------------------------------------------------

Ls-l

What does the drwxr_xr_x mean? 755?


"_" File "D" directory "B" block device file "C" character device file "I" Link file


chmod modification of file permissions 7rwx 5r-x 3-wx 2-w-1--x-r recursion


Permissions for files

R Cat Read

W Vim Write

X execution


Permissions for the Directory

R LS List content

W Touch Create Delete file

X CD into the catalogue


Chown: Genus group/directory or file


Umask view current Value root user 0022 normal user 0002


Umask-s to view permissions for the default built files directory


Directory 777-umask=777-022=755 root Create directory

Directory 777-umask=777-002=775 Normal Create directory

File 666-umask=666-022=644 Root Create File

Directory 777-umask=777-002=664 normal file creation


Special permissions

Suid (commonly used) to file a master execution file chmod u+s

Sgid (red) files are executed in the genus group chmod g+s

Stlcky (blue) users who have W permissions on the directory can only delete files that they own cannot delete other users ' files chmod o+t



---------------------------------------------------------------

Disk Management

---------------------------------------------------------------

Fdisk-l Viewing hardware devices

FDISK/DEV/SDB partition tool ROOT to use


M help

p See partition information

N New

D Delete

T partition type swap=82 linux=83 raid=fd Logical Volume =8e

W Save exit

Q Do not save exit


Logical partitioning order for extended partitions


N new e extended partition NULL Enter n new l logical partition cylinder start +10g W save exit


formatting partitions

MKFS.EXT4/DEV/SDB5 formatted into EXT4 partition


{RAID 0}


Create 2 blocks of logical partitions of the same size as the/DEV/SDB5,SDB6 format for FD

#partprobe notification of the partition table there was an error, ignoring him.

#mdadm-C/dev/md0-ayes-l0-n2/dev/sdb{5..6} made md0 = RAID0

Mdadm:defaulting to version 1.2 metadata

Mdadm:array/dev/md0 started.

#mdadm-D/dev/md0 View md0

#mkfs-T ext4/dev/md0 formatting

#mount/dev/md0/Location Mount use

#vim/etc/fstab Edit boot automatically mount

DEV/MD0/RAID0 EXT4 Defaults 1 2


{RAID 1}

Create 2 blocks of logical partitions of the same size as the/DEV/SDB7,SDB8 format for FD

#partprobe notification of the partition table there was an error, ignoring him.

#mdadm-C/dev/md1-ayes-l1-n2/dev/sdb{7..8} made MD1 = RAID1

Mdadm:defaulting to version 1.2 metadata

Mdadm:array/dev/md0 started.

#mdadm-D/dev/md1 View MD1

#mkfs-T ext4/dev/md1 formatting

#mount/DEV/MD1/Location Mount use

#vim/etc/fstab Edit boot automatically mount

DEV/MD1/RAID1 EXT4 Defaults 1 2



{RAID 5}

Create 3 blocks of logical partitions of the same size as the/DEV/SDB9,SDB10,SDB11 format for FD

#partprobe notification of the partition table there was an error, ignoring him.

#mdadm-C/dev/md1-ayes-l5-n3/dev/sdb{9..11} made MD5 = RAID5

Mdadm:defaulting to version 1.2 metadata

Mdadm:array/dev/md0 started.

#mdadm-D/DEV/MD5 View MD5

#mkfs-T ext4/dev/md5 formatting

#mount/DEV/MD5/Location Mount use

#vim/etc/fstab Edit boot automatically mount

DEV/MD5/RAID5 EXT4 Defaults 1 2




Delete raid


Umount Uninstall

Mdadm-s/DEV/MD5 Delete

Mdadm--zero-superblock/dev/sdb{9..11} Clear Intra-partition Super block



Fstab File Repair


If the hard drive error root password if you can access it can repair

#mount-o REMOUNT,RW/re-mount as read-write permission

#vim/etc/fstab


---------------------------------------------------------------

LVM Logical Volume Management

---------------------------------------------------------------







---------------------------------------------------------------

Network commands

---------------------------------------------------------------

Last look at user login information

Lastlog look at the last login information----with the ID of a user

Tracert win down route tracking

Traceroute Route Tracking

NETSTAT-NTPL look at the local listening TCP port-tlun look at the native listening port

-an See all network connection RN look at the routing table

Nslookup Look at DNS parsing

Mount Mount CD/dev/cdrom/mnt/cdrom umount Uninstall

Mount USB Device/dev/sdc1/mnt/usb fdisk-l See if USB is recognized


Write messages to online users

Wall to send messages to all line users

Mail to email to users

Ping sends an ICMP report




---------------------------------------------------------------

User Group Management commands

---------------------------------------------------------------

Who looks at the current system's user TTY for local login pts/0 remote


Useradd Build user/etc/passwd not login

passwd Create password/etc/shadow to login

Usermod modifying user Properties-l/etc/passwd renaming property

Userdel Delete user-R simultaneously delete the following 6 files


/ETC/PASSWD users

/etc/shadow Password

/etc/group Group

/etc/gshadow Group Password

/var/spool/mail/tao Mailbox

/home/tao Host Directory



Su-root-c "Useradd tao" add user Tao under non-root user



Groupadd Create Group-G Specify group Id/etc/group

Groupmod Modify Group-n Modify group name with old group name

Groupdel Delete Group Initial group cannot delete additional group can be deleted


GPASSWD Add user to group-a Tao root to add Tao users to the root group

-D Tao Root Delete user or manually change/etc/group

-M TAO,TAO1 root add multiple users to the root group at the same time


Groups root shows which group Roo belong to



---------------------------------------------------------------

Vim

---------------------------------------------------------------

Command mode insert mode ESC edit mode:


Insert a line after inserting a cursor after a line end I cursor before I start o cursor Insert line o cursor above


Positioning: Set NU Setting Line number: SEC Nonu cancel line number: N to the first row


Delete the character of the X-deleted NX-delete several characters after the DD-strikethrough several lines after the NDD line include the forward


Copy paste yy copy current line p paste to line below Nyy copy current line following n line DD cut


Search/tao Search Replace:%s/tao/taotao


Save exit: QW or X Save as: w/Position not saved back: q! Save changes Exit: wq!



Vim tips 3yy 4j p copy cursor start after 3 lines of content to line 4th and paste


Import: R/etc/tao Import Tao file contents to the current location

: R!date Import command ls result to current position

:! LS does not exit execute command LS



Define shortcut keys: Map Ctrl + CTRL + Shortcut i#<esc> plus comments

: Map Ctrl + CTRL + Shortcut 00 x minus Comment

: 1,4s/^/#/g 1 to 4 lines plus comments

: 1,4s/#//g 1 to 4 lines minus comments

: 1,4s/^#//g 1 to 4 lines at the beginning of the line minus comments

: AB Youxiang [email protected]

: Set Nu

There's no need to put him in VIM/ROOT/.VIMRC or VIM/HOME/TAO/.VIMRC.



---------------------------------------------------------------

Package Management

---------------------------------------------------------------

RPM-IVH installation Package Full name

RPM-UVH Upgrade Package Full Name

RPM-E Uninstall Package Name


RPM-Q Package name is there any information about installing-QI query

Rpm-qa | grep package name queries whether packages with package name keywords are installed

RPM-QC | grep package Name query for configuration file with package name as key package

RPM-QL Package name look at the installation location of the package-QLP look at the installation location of the installation package

RPM-GF/System file name It's the package that was installed.

Rpm2cpio Package Full Name | Cpio-idv is patching system files | You can also reinstall the secondary package

rpm2cpio/mnt/cdrom/packagos/Package Full Name | Cpio-idv./Extracted files



---------------------------------------------------------------

Online Yum installation package

---------------------------------------------------------------

#yum-y install wget wget download tool with Yum

#cd/root

#pwd

#wget Http://mirrors.163.com/.help/CentOS6-Base-163.repo

#mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.bak

#mv/root/centos6-base-163.repo/etc/yum.repos.d/centos-base.repo

#yum Makecache

#yum Clean All



---------------------------------------------------------------

Local Yum installation source

---------------------------------------------------------------

Mkdir/mnt/cdrom Creating mount Points

Mount/dev/cdrom/mnt/cdrom Hanging on CD

cd/mnt/cdrom/Check to see if it hangs up.

Renaming a yum configuration file back up

Mv/etc/yum.repo.d/centos-base.repo/etc/yum.repo.d/centos-base.repo.bak

Mv/etc/yum.repo.d/centos-debuginfo.repo/etc/yum.repo.d/centos-debuginfo.repo.bak


Vim/etc/yum.repo.d/centos-media.repo Editing a configuration file


[Guangpan] Custom

Name=guangpan Custom

Baseurl=file:///mnt/cdrom Set Mount Path

Gpgcheck=0 Digital Certificate Effective 0 No 1 yes

Enabled=1 enable Yum Source 1 start 0 do not start


: wq! Save exit


Yum Clean all clears the cache



---------------------------------------------------------------

YUM command

---------------------------------------------------------------

Yum-y Install package Name

Yum-y Updeta Package Name upgrade

Yum list looks at those installation packages

Yum Search package name See Install dependency Package


Minimize installation with Yum Uninstall upgrade with a specific package name


Linux Common 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.