Linux common commands notes -Linux

Article Directory

ls list

  • Long -l command: Show Details
  • -h command mankind: the store is represented as K, M

cd Open Directory

Create a directory mkdir

pwd displays the current path

cp copy a file or directory

  • -f Force
  • -r recursive continuous replication
  • -a copy all

dd copy special file or partition

  • dd if = input file output file of = bs = count = number of bytes

Shear movement mv

grep [options] "Search Content" filename

  • -i ignore case
  • -n output line number
  • -v reverse lookup
  • -color = auto keyword to search out color display

rm delete

  • -r remove inquiry instruction
  • -f Forces deletion

Create a file touch

du -sh view the file size

head displays the first few lines from scratch

  • -n Specifies the number of lines

tail the tail began to show

cat view the file contents

  • -n Display line numbers

tac reverse display file contents

more dynamic display file contents

less dynamic display from the tail to the head

ln link file is generated

  • -s source file destination
  • -s create soft links (shortcuts similar to Windows, permissions are determined by the corresponding source file permissions)
  • Hard links, with attributes similar to the copy (copy cp -p + synchronous update), and can be updated at the same time and source files, even if the source file is missing can also be accessed via a hard link, real-time backup. But the hard links can not span partitions, hard links can not be used for directory

chmod change file or directory permissions

  • chmod [{ugoa} {± =} {rwx}] [file or directory], separated by commas
  • Permissions may represent r-4 w-2 x-1 digital
  • rwx = 7, rw- = 6, r-- = 4 (permission bits <-> digital representation)
  • -R recursive modification
  • chmod 640 filename

RWX permissions

r read permission

  • You can view file contents can list the contents of a directory
  • File: Can cat / more / head / tail / less
  • Directory: ls can

w write permission

  • You can modify the contents of the documents can be created in the directory, delete files
  • File: vim can
  • Directory: You can touch / mkdir / rmdir / rm (you can delete the files in that directory, even if the file does not have write permission, write permission only can modify the contents of the file, whether the file exists nothing to do, as long as the permissions of the directory on the directory can delete files under)

x execute permission

  • You can execute the file into the directory can
  • Files: You can script / command
  • Directory: cd

There are certain there will be x r permission rights

Prerequisites delete the file is not whether you have write access to the file but whether the directory where you have write access

Chown to change the owner of a file or directory

  • chown [user] [file or directory]

Chgrp change group belongs to a file or directory

  • chgrp [User Group] [file or directory]

umask show the default permission settings file

  • 原意:the user file-creation mask
  • umask [-S]
  • -S show the new default file permissions to rwx form
  • The default file is not created enforceability (x)
  • umask -> 0022
  • 0- special permissions 022 - -w- -w-
  • Actually 777--022

find file search

  • find [Search] [matching conditions]
  • -name Search by name (rather than a precise search fuzzy search)
  • ** Fuzzy search
    • The asterisk matches any character
  • ? Question mark matches a single character (for example init ???)
  • -iname not case sensitive
  • -size + n is greater than XX lookup file data blocks, one block = 512 bytes = 0.5K
  • -user Find Owner
  • Find -group according to your group
  • -amin -5
  • -cmin -5 file attributes change, look for the property to be modified within 5 minutes file
  • -mmin modify the file contents
  • -a (and) two conditions are met
  • -o (or) can be any one of two conditions are satisfied
  • -exec / -ok} {command; perform operations on search results (note spaces)
  • -type f Find file d directory l soft link file by file type
  • Find -inum according to the i-node

locate find files (quick search) in the database file

  • locate the file name
  • updatedb update files repository
  • File repositories do not include the / tmp directory under the file
  • -i case-insensitive

which search command directory and alias information

  • which command

whereis command searches the directory path and help documentation

grep search string match in the file and line output

  • -i case-insensitive
  • -v exclude specified string ( representation of the line, such as # you can remove the comment lines with #-led)

man to get help

  • Intent: manual
  • man [commands or configuration file]
  • man ls ls command to view the help information
  • / Options
  • man services View profile services help information

Help Type

  • Help 1 command,
  • 5 configuration help man 5 passwd
  • Priority Displays help command

whatis help get simple information, read only the command name information

apropos direct access to configuration information

Command --help command to obtain general information

help + Shell built-in command command to get help information

man to get help

  • Intent: manual
  • man [commands or configuration file]
  • man ls ls command to view the help information
  • / Options
  • man services View profile services help information

Help Type

  • Help 1 command,
  • 5 configuration help man 5 passwd
  • Priority Displays help command

whatis help get simple information, read only the command name information

apropos direct access to configuration information

Command --help command to obtain general information

help + Shell built-in command command to get help information

gzip compressed file

  • gzip [file]
  • Compressed file format: .gz

gunzip to uncompress .gz compressed files

  • Intent: GNU unzip
  • gunzip [archive]
  • Or use gzip -d
  • And windows compression difference: only compressed files; not retain the source file

tar archive directory

  • tar options [-zcf] [compressed file name] [directory]
  • Compressed file format: .tar.gz
  • package -c
  • -v Show Details
  • -f specify the file name
  • -z compression package at the same time

tar [-zxvf] decompressor

  • -x unpack

zip file

  • zip option [-r] [compressed file name] [file or directory]
  • Compressed .zip file format
  • -r archive directory
  • Features: Retain source files can be compressed directory

unzip decompress .zip compressed files

bzip2 compressed file

  • bzip2 options [-k] [file]
  • After -k produce compressed files retain the source file
  • Amazing compression ratio
  • -cjf packaged and compressed to .tar.bz2 format

bunzip2 decompress .bz2 file

write to users to send information to the end to save Ctrl + D

  • write <user name>

wall send broadcast information

  • Intent: write all
  • wall + information

ping test network connectivity (determines whether there is, the command Capitol)

  • ping IP address option
  • -c + the number of designated communication network
  • packet loss packet loss rate

ifconfig to view and set the NIC (network status)

  • Intent: interface configure
  • ifconfig IP address of the network card name

Send mail to view e-mail

  • mail [username]

last list current user information (query logs) and login to the system of the past

lastlog shows all users and their last login information

  • Last logon information (UID information -u UID specified user

traceroute shows the path between the packet to the host

netstat displays network-related information

  • netstat [options]
  • -t TCP protocol
  • -u UDP protocol
  • -l monitor
  • -r Routing
  • -n displays the IP address and port number
  • netstat -tlun view port of the machine is listening
  • See native netstat -an all network connections
  • netstat -rn view native routing table

configure the network setup

  • Execute permissions: root

mount mount command

  • mount [-t file system] device file name of the mount point

umount uninstall command

  • Unmount the file name or mount point can be, but as long as you can choose a

Shutdown restart command

shutdown shutdown command

  • shutdown [options] time
  • -C Cancel a shutdown command before
  • shutdown -h
  • -r restart

Other shutdown command

  • halt
  • poweroff
  • init 0

Other restart command

  • reboot
  • init 6

System run level

  • 0 Shutdown
  • 1 Single User
  • 2 incomplete multi-user, without NFS service
  • 3 full multiuser
  • 4 Unallocated
  • 5 GUI
  • 6 Restart

runlevel query system run level

exit / logout Log interface

Published 59 original articles · won praise 3 · Views 1753

Guess you like

Origin blog.csdn.net/Felix_hyfy/article/details/104332371