Centos command collection

Source: Internet
Author: User

Centos command collection

1. File Processing Command: ls

Function Description: displays directory files.

Command: list

Command path:/bin/ls

Execution permission: All Users

Syntax: ls option [-ald] [file or directory]

-A: displays all files, including hidden files.

-L detailed information display

-D. view directory properties.

$ Ls-a> dir.txt.pdf output the result of the ls-acommand to the dir.txt file.

$ Ls-a> dir.txt after the ls-acommand execution result is appended to the dir.txt file.

2. File Processing Command: cd

Function Description: Switch directories.

Command: changedirectory

Command path: shell built-in command

Execution permission: All Users

Syntax: cd [Directory]

Example: $ cd/switch to the root directory

$ Cd .. Go back to the upper-level directory

File Processing Command: pwd

Function Description: displays the current working directory.

Printworkingdirectory

Command path:/bin/pwd

Execution permission: All Users

Syntax: pwd

Example: $ pwd

/Etc/rc5.d

File Processing Command: touch

Function Description: creates an empty file.

Command name: touch

Command path:/bin/touch

Execution permission: All Users

Syntax: touch [file name]

Example: $ touchnewfile

File Processing Command: mkdir

Function Description: Creates a directory.

Makedirectories

Command path:/bin/mkdir

Execution permission: All Users

Syntax: mkdir [directory name]

Example: $ mkdirnewdir

File Processing Command: cp

Function Description: copy a file or directory.

Command syntax: copy

Command path:/bin/cp

Execution permission: All Users

Syntax: cp-R [source file or directory] [destination Directory]

-R copy directory

Example: $ cpfile1file2dir1

Copy file1 and file2 to the directory dir1

$ Cp-Rdir1dir2

Copy all files and subdirectories under dir1 to dir2

File Processing Command: mv

Function Description: Move and rename a file

Command: move

Command path:/bin/mv

Execution permission: All Users

Syntax: mv [source file or directory] [destination Directory]

Example: $ mvfile1file3

Rename the file file1 in the current directory to file3.

$ Mvfile2dir2

Move file file2 to directory dir2

File Processing Command: rm

Function Description: delete an object.

Command: remove

Command path:/bin/rm

Execution permission: All Users

Syntax: rm-r [file or directory]

-R: delete a directory.

Example: $ rmfile3

Delete file file3

$ Rm-rdir1

Delete directory dir1

File Processing Command: cat

Function Description: displays the file content.

Concatenateanddisplayfiles

Command path:/bin/cat

Execution permission: All Users

Syntax: cat [file name]

Example: $ cat/etc/issue

$ Cat/etc/services

$Catpreface.txt more

Displays the content of preface.txt on a page-by-page basis;

Extends catpreface.txt> outline.txt

Add preface.txtto the outline.txt file;

Catnew.txtinfo.txt> readme.txt

Combine new.txtand info.txtinto the readme.txt file;

File Processing Command: more

Command path:/bin/more

Execution permission: All Users

Syntax: more [file name]

(Space) or f displays the next page

(Enter) display the next line

Q or Q quit

File Processing Command: head

Function Description: view the first few lines of a file.

Command path:/bin/head

Execution permission: AllUser

Syntax: head-num [file name]

-Num: displays the first num row of the file.

Example: $ head-20/etc/services

File Processing Command: tail

Function Description: view the last few lines of a file.

Command path:/bin/tail

Execution permission: AllUser

Syntax: tail-num [file name]

-Num: displays the last num row of the file.

-F dynamically displays the File Content

Example: $ tail-30/etc/services

File Processing Command: ln

Function Description: generate a link file.

Command: link

Command path:/bin/ln

Execution permission: All Users

Syntax: ln-s [source file] [target file]

-S: Create a soft link

Example: $ ln-s/etc/issue. soft

Create a file/etc/issue soft link/issue. soft

$ Ln/etc/issue. hard

Create a hard link/issue. hard for the file/etc/issue

Permission management command: chmod

Function Description: Change the file or directory permissions.

Command: changethepermissionsmodeofafile

Command path:/bin/chmod

Execution permission: All Users

Syntax: chmod [{ugo} {+-=}{ rwx}] [file or directory]

[Mode = 421] [file or directory]

Example: $ chmodg + wfile1

Grant the write permission to the group to which file1 belongs.

$ Chmod777dir1

Set the directory dir1 to grant all permissions to all users.

Character

Permission

Meaning of a file

Meaning of directory

R

Read Permission

You can view the File Content

List contents in the directory

W

Write Permission

File content can be modified

You can create and delete files in the directory.

X

Execution permission

Executable files

You can enter the Directory

Permission management command: chown

Function Description: Change the owner of a file or directory.

Command: changefileownership

Command path:/bin/chown

Execution permission: All Users

Syntax: chown [user] [file or directory]

Example: $ chownnobodyfile1

Change the owner of file file1 to nobody.

Permission management command: chgrp

Function Description: Change the group to which a file or directory belongs.

Command: changefilegroupownership

Command path:/bin/chgrp

Execution permission: All Users

Syntax: chgrp [user group] [file or directory]

Example: $ chgrpadmfile1

Change the file1 group to adm.

Permission management command: umask

Function Description: displays and sets the default permissions for files.

Command path:/bin/umask

Execution permission: All Users

Syntax: umask [-S]

-S displays the default permissions of new files or directories in the form of rwx

Example: $ umask

$ Umask-S

File SEARCH Command: which

Function Description: displays the directory where the system commands are located.

Command path:/usr/bin/which

Execution permission: All Users

Syntax: which [command name]

Example: $ whichls

File SEARCH Command: find

Function Description: searches for files or directories.

Command path:/usr/bin/find

Execution permission: All Users

Syntax: find [search path] [Search Keyword]

Example: $ find/etc-nameinit

Find the file init In the/etc directory

$ Find/-size + 204800

Search for files larger than MB in the root directory

$ Find/-usersam

Find the file with sam as the owner in the root directory.

$ Find/etc-ctime-1

Search for the files and directories under/etc that have been modified within 24 hours.

$ Find/etc-size + 163840-a-size-204800

Search for files larger than 80 mb and smaller than MB in/etc

$ Find/etc-nameinittab-execls-l {}\;

Search for the inittab file in/etc and display its details

File SEARCH Command: locate

Function Description: Search for files or directories.

Command syntax: listfilesindatabases

Command path:/usr/bin/locate

Execution permission: AllUser

Syntax: locate [Search Keyword]

Example: $ locatefile

List all file-Related Files

File SEARCH Command: updatedb

Function Description: creates a database for the entire system directory file.

Command syntax: updatetheslocatedatabase

Command path:/usr/bin/updatedb

Execution permission: root

Syntax: updatedb

Example: # updatedb

File SEARCH Command: grep

Function Description: searches for matching strings in a file and outputs them.

Command path:/bin/grep

Execution permission: All Users

Syntax: grep [specified string] [source file]

Example: # grepftp/etc/services

$ Greptext *. conf

Secret searches for files with the extension. conf and containing the "text" string in the current directory.

$ Grep: amd. conf: deny operation with invalid Permissions

$ Grep: diskcheck. conf: deny operation with invalid Permissions

$ Grep: grub. conf deny operation that does not meet the permission

$ Grep-stext *. conf deny error messages such as operations that do not conform to the permission

Help Command: man

Function Description: Get help information

Manual

Command path:/usr/bin/man

Execution permission: All Users

Syntax: man [command or configuration file]

Example: $ manls

View ls command help information

$ Manservices

View the help information of the configuration file services

Help Command: info

Function Description: Get help information

Command syntax: information

Command path:/usr/bin/info

Execution permission: AllUser

Syntax: info [any keyword]

Example: $ infols

View help information of ls commands

Help Command: whatis

Function Description: Get Brief description of the index.

Command name: whatisaproposmakewhatis

Command syntax: searchthewhatisdatabaseforstrings

Command path:/usr/bin/whatisapropos

/Usr/sbin/makewhatis

Execution permission: AllUser, AllUser, root

Syntax: whatisapropos [any keyword]

Example: $ whatisls

$ Aproposfstab is equivalent to man-k

# Makewhatis

Create a database for whatis and apropos search. When the two commands are incorrect, whatisdatabase is not created.

Compressed and decompressed command: gzip

Function Description: compress a file.

Command path:/bin/gzip

Execution permission: All Users

Syntax: gzip option [file]

Compressed file format:. gz

Compressed and decompressed command: gunzip

Function Description: Decompress the. GZ compressed file.

Command path:/bin/gunzip

Execution permission: All Users

Syntax: gunzip option [compressed file]

Example: $gunzipfile1.gz

Compressed and decompressed command: tar

Function Description: Package directory

Command path:/bin/tar

Execution permission: All Users

Syntax: tar option [cvf] [Directory]

-C0000.tar

-V: Show Details

-F: Specifies the compressed file name.

-Z package and compress

Compressed file format: .tar.gz

Example: $tar-zcvfdir1.tar.gz dir1

Compress the directory dir1 into a packaged and compressed file.

Tar command decompression Syntax:

-Xunpack the .tar File

-V: Show Details

-F: Specifies the file to be decompressed.

-Z Decompression

Example: $tar-zxvfdir1.tar.gz

Zip

Function Description: compresses a file or directory.

Command path:/usr/bin/zip

Execution permission: All Users

Syntax: zip option [-r] [compressed file name] [file or directory]

-R compression directory

Compressed file format:. zip

Example: unzip zipservices.zip/etc/services

Compressed file

Unzip zip-rtest.zip/test

Compressed directory

Compressed and decompressed command: unzip

Function Description: Decompress the. Zip compressed file.

Command path:/usr/bin/unzip

Execution permission: All Users

Syntax: unzip [compressed file]

Example: unzip unziptest.zip

Compressed and decompressed command: bzip2

Function Description: Extract

Command path:/usr/bin/bzip2

Execution permission: All Users

Syntax: bzip2 option [-k] [file]

-K: the original file is retained after the compressed file is generated

Function Description: compress a file.

Compressed file format:. bz2

Example: $ bzip2-kfile1

Command path:/usr/bin/bunzip2

Execution permission: All Users

Syntax: bunzip2 option [-k] [compressed file]

-K. Extract and retain the original file.

Example: Export bunzip2-kfile1.bz2

Network Communication command: write

Function Description: sends a message to another user, ending with Ctrl + D

Command path:/usr/bin/write

Execution permission: AllUser

Syntax: write <User Name>

Example: $ writewebmaster

Network Communication command: wall

Function Description: broadcasts information to all users.

Command path:/usr/bin/wall

Execution permission: AllUser

Syntax: wall [message] [file name]

Example: $ wallHappyNewYear!

Network Communication command: ping

Function Description: test network connectivity.

Command path:/usr/sbin/ping

Execution permission: root

Syntax: ping option IP Address

Example: # ping192.168.1.1

Network Communication command: ifconfig

Function Description: View network settings.

Command path:/usr/sbin/ifconfig

Execution permission: root

Syntax: ifconfig option [-a] [Nic device ID]

-A: displays information about all NICs.

Example: # ifconfig-

System shutdown command: shutdown

Function Description: Shutdown

Command path:/usr/sbin/shutdown

Execution permission: root

Syntax: shutdown

Example: # shutdown-hnow

System shutdown command: reboot

Function Description: restart the system.

Command path:/usr/sbin/reboot

Execution permission: root

Syntax: reboot

Example: # reboot

Command for attaching a CD: mountumount: Command for detaching a cd

Function Description: attach a CD and a floppy disk.

Command path:/usr/sbin/reboot

Note: to allow normal users to attach a CD or floppy disk, modify the/ect/fstab/configuration file.

/Dev/cdrom/mut/cdromudf, iso9660noauto, owner, kudzu, ro, user

To enable a general user to attach a CD, add the ", user" project here.

Example: # mount/dev/cdrom/mut/cdrom disc

# Unmount the umount/mnt/cdrom disc

Delete a scheduling task: crontab

Example: $ crontab-r tasks: delete jobs in task scheduling.

$ Crontab-1 workers view jobs in Task Scheduling again

History commands used by users: history

1. User Group Management

1. Add a user group

Groupadd

2. delete a user group

Groupdel

3. Modify user groups

Groupmod

4. Switch user groups

Newgrp <groupname>

If a user belongs to multiple user groups at the same time, you can use the newgrp command to switch to the target group so that you can have permissions for the group.

5. View All groups

All groups are filtered by the/etc/group file.

Cat/etc/group | awk-F: '{print $1 }'

6. view the user group

Groups <username>

Ii. User Management

1. Add a user

Useradd <username>-d <path>-m-g-G-p

The common parameters are as follows:

-D: Specifies the user's main directory. If this directory does not exist and-m is used at the same time, the directory will be created.

-M: Create the user's home directory

-G: User Group ID

-G: name of the group to which the user belongs

-P: logon password. Note that the logon password is not in plain text and is the encrypted password.

Useraddtestuser-m-Gmygroup

A user of testuser will be created, and the home directory of/home/testuser will be automatically created, and the user will be added to the mygroup group.

2. delete a user

Userdel-f-r <username>

-R: deletes the user's home directory and emails in the mailbox.

-F: forcibly delete the file, even if the owner is not the user

3. modify a user

Usermod <username>-d <path>-m-g-G-p

The parameter meaning is roughly the same as that of useradd.

4. User Password

Passwd <username>: change the password

Passwd-d <username>: Command to delete the user's password, that is, the next login without a password.

Passwd-l <username>: locks the user so that it cannot log on.

Iii. File owner Management

1. Change owner

Chown-R <username>. <groupname> file

-R: Indicates recursive modification.

Chown-Rtestuser.newgrouptestpath

The above command changes the owner of all files in the testpath to testuser and the owner group to newgroup.

2. Set the file mask

Umask [a1a2a3]

You can use the umask command to set the default file generation mask. The default generated mask tells the system which permissions should not be granted to create a file or directory. If you place the umask command in the environment file. bash_profile, you can control access to all newly created files and directories.

A1 indicates that permissions of the owner are not allowed, a2 indicates that permissions of the same group are not allowed, and a3 indicates that permissions of others are not allowed.

Umask022: indicates that the write permission is not allowed for users in the same group and other users.

Umask: displays the current default generated mask.

The most basic 20 common commands of CentOS

1. man provides help explanations for familiar or unfamiliar commands
For example: manls, you can view the ls-related usage.
Note: Press q or ctrl + c to exit. in linux, you can use ctrl + c to terminate the current program.

2. ls view the directory or file owner * and list the files under any directory
Eg: ls/usr/man
Ls-l

A. d indicates the directory. If it is a "-", it indicates a file. If it is l, it indicates a connection file (link)
B. Permission for file or directory permission. Read (r), write (w), and run (x) respectively ).

3. Copy files using cp
Eg: cpfilename1filename2 // copy filename1 to filename2
Cp1.cnetseek/2.c// copy 1.C to the netseek directory and name it 2.c.

4. rm delete files and directories
Eg: rm1.c // Delete the. c file.

5. Remove the directory or change the file name.
Eg: mvfilename1filename2 // rename filename1 to filename2
Mvqib. tgz ../qib. tgz // move to the upper-level directory

6. Change the current directory pwd on cd to view the complete path of the current directory
Eg: pwd // view the current directory path
Cdnetseek // enter the netseek directory
Cd // exit the current directory

7. cat, more command
Displays the content of a file. The two commands are different: cat prints the file content all the time, and more is displayed on the split screen.
For example; cat> 1.c// you can paste the code into the. c file and press ctrl + d to save the code.
Cat1.c or more1.c // you can view the content in it.
Gcc-o11.c // compile 1.cinto the. exe file, we can use this command to compile the code.

8. Modify the chmod command permission usage: chmod one-digit octal number filename.
Eg: chmodu + xfilenmame // you only want to run the command for yourself.
// U indicates the file owner. g indicates the group of the file. O indicates others; r table readable; w table writable; x table can run
Chmodg + xfilename // the same group of people to execute

9. clear, date command
Clear: clear screen, equivalent to cls in DOS; date: displays the current time.

10. mount a hardware device
Usage: mount [parameter] device load point to be loaded
Eg: mount/dev/cdrom
Cd/mnt/cdrom // enter the cd directory

11. su switches to another person's identity without logging out.
Usage: su-l user name (if the user name defaults, the user name is switched to the root state)
Eg: su-lnetseek (switch to netseek and you will be prompted to enter the password)

12. whoami, whereis, which, id
// Whoami: confirm your identity
// Whereis: queries the directory where the command is located and the directory where the help document is located
// Which: query the directory where the command is located (similar to whereis)
// Id: print your UID and GID. (UID: the unique ID of a user. GID: the unique ID of a user group. Each user can have only one unique UID and GID)
Eg: whoami // display your login user name
Whereisbin: the directory where the bin is located. The directory is/usr/local/bin.
Whichbin

13. grep, find
Grep: Text Content Search; find: file or directory name and permission owner matching search
Eg: grepsuccess */* Find all files in the current directory that contain success characters

14. kill can kill a running or dest process.
Eg; psax

15. passwd can be used to set a password
16. commands used by the history user
17 .!! Execute the last command
18. mkdir command
Eg: mkdirnetseek // create the netseek directory

19.tar decompression command
Eg: tar-zxvfnmap-3.45.tgz // extract this to the nmap-3.45 directory

14. decompress the package
The tar-imo-bunzip2command can decompress the. bz2 file.
Tarxvfjexample.tar.bz2
Tarxvfzexample.tar.gz
Tarxvfzexample. tgz
Tarxvfexample.tar
Unzipexample.zip

15. how to configure which services are enabled (q1208c)
Method 1 run the ntsysv or setup command to enter the menu for configuration
Method 2chkconfig -- list display Service
Chkconfignameon/off enable/disable the "name" Service

16. view the folder size

Du-shuploadfile

17. view disk usage

Df-hl

12. Delete all files in the directory including subdirectories (bjchenxu)
Rm-rf directory name


13. View System Information (bjchenxu)
Cat/proc/cpuinfo-CPU (I. e. vendor, Mhz, flagslikemmx)
Cat/proc/interrupts-interrupt
Cat/proc/ioports-device IO port
Cat/proc/meminfo-memory information (I. e. memused, free, swapsize)
Cat/proc/partitions-all partitions of all devices
Cat/proc/pci-PCI device information
Cat/proc/swaps-information about all Swap partitions
Cat/proc/version-Linux version is equivalent to uname-r
Uname-a-view system kernel and other information

========================

15. how to configure which services to start
Method 1 run the ntsysv or setup command to enter the menu for configuration
Method 2chkconfig -- list display Service
Chkconfignameon/off enable/disable the "name" Service

16. view the folder size

Du-shuploadfile

17. view disk usage

Df-hl

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.