26 commands for beginners of CentOS

Source: Internet
Author: User

26 commands for beginners of CentOS
Beginner's Guide: 26 commands that Linux Beginners should know

When you enter the Linux World, download and install a Linux release, experience the Linux desktop and install some of your favorite and needed software, we should explain the true charm of Linux:Command line. Every Linux Command is actually a program. With these commands, we can do a lot of things. The following describes several common commands.

How to seek help?

In Linux,The most important thing is to seek help by yourself. Below are three ways to seek help.

Man

manIs the help manual for Linux, that ismanual. Because most programs have their own manuals, you can usemanCommand to get help. After executionOn the man page, pressqExit.

ObtainlsHelp

$manls

View the number of manuals with the same name (for different purposes)

$man-flsls(1)-listdirectorycontentsls(1p)-listdirectorycontents

View specific manuals

$man1pls

Info

AndmanThe difference is that you can jump to each node as you browse a Web page.

Browse from the document Homepage

$info

Get help from a specific program

$infoprogram

Help

In addition to the above two methods, there is also a simple way to use, that is--helpParameter. this parameter is generally provided by the program, and the simplest and most useful introduction is provided.

$ Man -- help ### get man help $ info -- help ### get info help $ ls -- help ### get ls help

How to perform simple operations?

InTerminal)There are a lot of Operation Skills. Here we will introduce a few simple ones.

Cursor
  • Up (on the direction key) can call up the input history execution record to quickly execute commands

  • Down (under the direction key) with up select a historical execution record

  • Home move the cursor to the beginning of the line

  • End move the cursor to the End of the row

  • PgUp page up

  • PaDN flip down

  • Ctrl + c terminate the current program

Tab completion

TabComplementing is a very useful function that can be used to automatically complete commands or file names, saving time and accuracy.

  • PressTwiceTabList all available commands

  • If you have entered some command names or file names, pressTabYou will certainly like it if you use it.

Common commands

The following commands are arranged according to the general usage frequency.

Cd

cdIs the command to open a path, that is, to open a folder and jump to this place.

$ Cdpath ### path indicates the path you want to open.

Path can be an absolute path or a relative path./The path. Compared with the current path, assume that the current home directory hasetcFolder (the absolute path should be/home/username/etc), If you directlycd etcEnter this folder, but ifcd /etc/Is to enter the systemetcYou can understand it after a while. In Linux,.Indicates the current directory,..Indicates the parent directory. Therefore, the parent directory can be returned.cd ...

Ls

lsThat isList to list objects.

$ Ls ### only list visible files in the current directory $ ls-l ### list details of visible files in the current directory $ ls-hl ### list details and display them in readable size file Size $ ls-al ### list all files (including hidden files) detailed information

Note: in Linux.Files or folders starting with are hidden files or hidden folders.

Pwd

pwdReturns the name of the current working directory, which is an absolute path name.

$pwd/home

Mkdir

mkdirUsed to create a folder.

$ Mkdirfolder $ mkdir-pfolder/subfolder ### the-p parameter is ignored when the parent directory exists. If the parent directory does not exist, a multi-level folder can be created using this parameter.

Rm

rmThat isRemove: delete an object.

$ Rmfilename ### Delete filename $ rm-ifilename ### prompt before deleting filename, if multiple files exist, $ rm-rffolder/subfolder/### recursively delete all files and folders under subfolder, including subfolder $ rm-dfolder ### Delete empty folders

Cp

cpThat isCopy: copy an object.

$ Cpsourcedest ### copy source to dest $ cpfolder/* dest ### copy all files under folder (excluding files in subfolders) copy to dest $ cp-rfolderdest ### copy all files (including all files in subfolders) under the folder to dest

Mv

mvThat isMove: move a file.

$ Mvsourcefolder ### move source to folder, and then it is folder/source $ mv-isourcefolder ### when moving, if the file already exists, the system prompts ** overwrite ** $ mvsourcedest ### rename source to dest if the dest is not a directory.

Cat

catOutput file content to Terminal.

$ Cat/etc/locale. gen ### output content of locale. gen $ cat-n/etc/locale. gen ### output content of locale. gen and display the row number

More

moreAndcatSimilarly, you can view the file content. The difference is that when a document is too long,catOnly the last screen-filled content can be displayed, and the previous content is invisible. Available at this timemoreDisplays content row by row.

$ More/etc/locale. gen $ more + 100/etc/locale. gen ### display from row 100

Less

lessAndmoreSimilar,lessYou can scroll up or down to view the content.moreOnly line-by-line display is supported.

$less/etc/locale.gen$less+100/etc/locale.gen

Nano

nanoIs a simple and practical text editor that is easy to use.

$ Nanofilename ### edit the filename file. If the file does not exist, a new file is opened. If the file is saved when it exits, the file is created.

After editing,ctrl + XPrompt whether to save, pressyAre you sure you want to save it.

Note: available during usectrl + GObtain help.

Reboot

rebootRestart command.

# Reboot ### the difference between '$' and '#' Is that '$' can be executed by normal users ### while '#' can be executed only by root users, or a common user uses 'sudo'
Poweroff

poweroffCommand.

# Poweroff ### immediate shutdown

Ping

pingIt is mainly used to test network connectivity. It sends data packets to the target machine to test whether the two hosts are connected and the latency.

$ Pinglocez.com ### ping by domain name. If DNS is not set, you may not be able to ping $ pinglinux.cnPINGlinux.cn (211.157.2.94) 56 (84) bytesofdata.64bytesfrom211.157.2.94. static. in-addr.arpa (211.157.2.94): icmp_seq = 1ttl = 53 time = 41.5ms64bytesfrom211.157.2.94.static.in-addr. arpa (211.157.2.94): icmp_seq = 2ttl = 53 time = 40.4ms64bytesfrom211.157.2.94.static.in-addr. arpa (211.157.2.94): icmp_seq = 3ttl = 53 time = 41.9ms ^ C --- linux. cnpingstatistics --- 3 packetstransmitted, 3 received, 0% packetloss, time2002msrttmin/avg/max/mdev = 40.406/41.287/41.931/0.644 ms $ ping211.157.2.94 ## ping by IP address, if the ping fails, the network connection may fail.

Grep

grepIt is mainly used to return matched items and supports regular expressions.

$ GrepPATTERNfilename ### return all rows with PATTERN $ grepzh_CN/etc/locale. gen ### return all rows with zh_CN

Mount

mountTo mount a file system, you mustrootUser execution. A disk can be divided into several partitions, and a file system can be created on the partition. A mount point provides an access portal to mount the file system of a partition to a directory, this directory is called a mount point and can be used to access the content in the file system.

For example, a hard disk is represented/dev/sdaThe partition above it should be expressed/dev/sda1,/dev/sda2.

# Mount ### current mounting information of the Output System # mount/dev/sda1/mnt ### mount sda1 to/mnt # cd/mnt ### directly pass/mnt access Content # mount-oremount, rw/mnt ### remount sda1 to/mnt and set it to read/write # mount-a ### mount the file system configured by the fstab file

Umount

umountAndmoungInstead, detach a mount point to cancel the entry.

# Umount/mnt ### unmount the file system of the mount point/mnt # umount-a ### unmount all mounted file systems

Tar

tarIt is mainly used to create archive files and decompress archive files. It does not have the compression function, but can be calledgzip,bzip2For compression.
Parameter description:

  • -cCreate an archive

  • -xDecompress Archive

  • -vDisplay processing process

  • -fTarget file, which must be followed by the target file

  • -jCallbzip2Extract

  • -zCallgzipExtract

  • -tList Archived Files

Upload to the current folder $ tar-tffilename ### only view files in the filename archive.

Ln

lnIt is mainly used to create links in two files. links are dividedHard Links(Hard link) andSymbolic Links(Symbolic or soft link), which is created by defaultHard link, use-sThe parameter specifies to create a soft link.

  • Hard links mainly increase the number of links to a file, as long as the number of links to the file is not0This file will not be physically deleted. Therefore, to delete a file with multiple hard links, you must delete all its hard links to delete it.

  • A soft LINK creates a shortcut for a file. You can use this link to access the file and modify the file, but it does not increase the number of links to the file, deleting a soft link does not delete the source file. Even if the source file is deleted, the soft link exists. When you create a new source file with the same name, the soft link points to the new file.

  • Hard links can only link two files, but cannot link directories. Soft links can link directories, so soft links are very flexible.

$ Lnsourcedest ### create a hard link named dest for source $ ln-ssourcedest ### create a soft link named dest for source

Chown

chownUsed to change the owner and group of a file.

# Chownuserfilename ### change the filename owner to user # chownuser: groupfilename ### change the filename owner to user, group: group # chown-Rrootfolder ### change the folder and its sub-file owner to root

Chmod

chmodChange the permissions of a file forever, mainly includingRead,Write,Execution, three permissions, of whichOwner,User Group,The other accounts for three, sols -lThe following information is displayed:

-rwxr--r--1locezusers154Aug3018:09filename

Wherer=read,w=write,x=execute

# Chmod + xfilename ### add execution permissions for user, group, and others # chmod-xfilename ### cancel user, group, others execution permission # chmod + wfilename ### add write permission to user # chmodugo = rwxfilename ### set user, group, others has read, write, and execute permissions # chmodug = rwfilename ### set user and group to add read and write permissions # chmodugo = --- filename ### cancel all Permissions

Useradd

useraddUsed to add a common user.

# Useradd-m-gusers-Gaudio-s/usr/bin/bashnewuser ###-m create the home Directory and the main group to which-g belongs, -G specifies the user's additional groups,-s sets the default shell, newuser is the new user name

Passwd

passwdUsed to change the user logon password.

$ Passwd ### change the current user password without parameters # passwdnewuser ### change the user password of the newly created newuser

Whereis

whereisUsed to find files and manuals.

$ Whereisbashbash:/usr/bin/bash/etc/bash. bashrc/etc/bash. bash_logout/usr/share/man/man1/bash.1.gz/usr/share/info/bash.info.gz $ whereis-bbash ### only search for binarybash: /usr/bin/bash/etc/bash. bashrc/etc/bash. bash_logout $ whereis-mbash ### search for manualbash only:/usr/share/man/man1/bash.1.gz/usr/share/info/bash.info.gz

Find

findIt is also used to find files, but is more powerful. It supports regular expressions and can pass the search results to other commands.

$ Find. -namePATTERN ### search for PATTERN-compliant files from the current directory $ find/home-namePATTERN-execls-l {}\; # search for all PATTERN-compliant files from the/home file, and submit it to ls to output detailed information

Wget

wgetIs a simple and powerful download tool.

$ Wget-Onewname.mdhttps: // others

Congratulations, you have learned 26 basic Linux commands. Although this is just some of the most basic commands, you can use these commands to start your first step to become a Linux player from a new Linux player!

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.