Linux common commands and common knowledge

Linux common commands and common knowledge (learning)

  • Absolute path representation, such as: /etc/http.d

  • Current directory: ./

  • Parent directory: ../

  • Home directory: ~ /

  • Change directory: cd

  • View the current path: pwd

  • View the current process: ps

  • Show all processes: ps -ef (system v output) / ps -aux bsd output format

  • View information about specified process: ps -ef | grep pid

  • An exit: exit

  • Clear screen: clear

  • Exit the current command: ctrl + c (completely out)

  • Execution sleep: ctrl + z (suspend the current process to restore the background)

  • View the current user id: "id" (shows the current login account uid, gid and Group-owned and user name)

  • View Help: man + command (such as the man who)

  • ls Function: Lists the specified directory of directories, files

  • Soft link: ln -s slink source

  • Hardwired: ln link source

  • Create a directory: mkdir

  • Create a file: touch, vim

  • Copying files: cp

  • Together with a copy folder: cp -r

  • Move files: mv

  • Delete: rm

  • Delete the directory and file directory: rm -r

  • Delete empty folders: rmdir

  • Modify file permissions: chmod
    • chmod u + x file is the main file to execute permissions increase
    • Permissions chmod 751 file permissions assigned to the owner of the file to read, write, execute permissions (7), assigned to the file where the group is read, execution (5), and performs assignment to another user (1)
    • chnod u = rwx, g = rx, o = x file on another form of embodiment of
    • chmod = r file all users are assigned read permissions
    • chmod 444 file above cases
    • chmod a-wx, a + r file supra Example
    • chmod -R u + r directory recursively assigned to the owner of all files and subdirectories under the directory read directory permissions
  • View the contents of the file command:
    • vi filename # editing view, modify
    • cat filename # show all file contents
    • more filename # distribution display file contents
    • less filename # and more similar, and you can page forward
    • tail filename # see only the tail, you can also specify the number of rows
    • head filename # see the head only, you can also specify the number of rows
  • Note with spaces blank screen output to a string: echo hello world!

  • Terminal file: / dev / tty

  • Black Hole file: / dev / null

  • Several Linux wildcard
    • ? You can replace a single character
    • * Can replace any number of characters
    • [Abc] abc set can replace any single character
  • File Content Statistics: wc -c (count the number of bytes) -l (count the number of lines) -w (word count)

  • grep command: powerful text search tool, you can use regular expressions, and to print out match

  • Linux processes in several states
    • Not interrupt status: The process is sleeping, but at the moment the process is not interrupted; not interrupt means that the process does not respond to asynchronous signals
    • Suspend state / status tracking: transmitting a signal SIGSTOP process, it will in response to the state signal into TASK_STOPPED; when the process is being tracked, it is in this particular state TASK_TRACED; refers being tracked process pauses, waiting for the tracking it processes to operate it
    • Ready state: the state of the queue run_queue
    • Running state: the state of the queue run_queue
    • Interruptible sleep state: in this state because the process waiting to happen certain events (such as socket, wait semaphore) is suspended
    • zombie state (zombie): The father did not wait by the way, the series of system call the corpse of the child process (tast_struct) also freed
    • Exit Status
  • ps print out the symbolic representation of process information
    • D uninterruptible state (uninterruptible) (usually IO)
    • R is running or in the queue process
    • S dormant state
    • T stopped or track
    • Z Zombie state
    • W into the kernel (invalid from the beginning of a kernel 2.6)
    • X dead process
  • Command run in the background: general use &at the end of the program to automatically run the command (command can not append blanks)

  • View background tasks: job -l

  • Background tasks to the foreground: fg

  • Stop to execute background tasks in the background: bg

  • Terminate the process: kill [-s <message name or number>] [program] or kill [-l <message number>] or kill -9 pid

  • View system supports all signal: kill -l

  • Search for files
    • find <specified directory> <specified condition> <action specified>
    • whereis file name plus parameters
    • locate an increase of only file names
    • find direct search disk, slow
    • find / -name "sring*"
  • Check their terminal location information: who am i

  • See who's currently in use that host: who

  • View a list of commands used: history

  • View Disk space: df -hl

  • Check whether the network connectivity: netstat

  • Check ip and interface information: ifconfig

  • See all environment variables: env (view a: env $ HOME)

  • Specifies the command prompt
    • \ U: Displays the current user account
    • \ H: Displays the current hostname
    • \ W: only displays the current directory path to the final
    • \ W: Displays the current absolute path (current user directory will be replaced by ~)
    • $ PWD: Displays the current full path
    • $: Displays the command line '$' or '#'
    • \ #: The first few commands issued
    • \ D: represents the date in the format: week day month date
    • \ T: display time for the 24-hour format HH: MM: SS
    • \ T: 12-hour time display format
    • \ A: display time for the 24-hour format HH: MM
    • \ V: bash version information
  • Find the executable command:
    • whereis [-bfmsu] [- B <directory> ...] [- M <directory> ...] [- S <directory> ...] [... File]
    • whereis command to find qualified specified file in a specific directory, the properties of these files belong to the source code, binary files or help file
    • -b find only binary files
    • -B <directory> find only binary files in the directory set
    • -f does not display the file name path name
    • -m find only documentation
    • -M <catalog> Find documentation only in the directory settings
    • -s only to find the original code files
    • -S <Directory> only to find the original code files in the directory settings
    • Find -u does not contain the specified type of file
    • instruction which specifies the path, search for a location in the PATH variable system commands, and returns the first search result
    • -n specify a file name length, specified length must be greater than or equal to the longest of all file names in the file name
    • -n -p same parameters, but here, including the path to the file
    • -w field specifies the width of the output
    • -V Display version information
  • Check executable files: which

  • Check binaries, documentation, source files: whereis

  • Alias ​​command: alias la = 'ls -a'

  • du, df definitions and differences
    • du displays the size of a file or directory
    • display information for each df <file> is the file system, the default is to display all file system (file system allocates disk blocks, some of which is used to record some of its own profile data, such as i-node, the disk, the collision block, superblock, usually is not visible to the user, called Meta Data); du commands are user-level programs, it does not consider Meta Data, df command to view the file system disk allocation map and consider Meta Data.
    • df command to get real file system data, du command can only view partial information of the file system
  • View a list of all the Linux command: compgen -c

  • Print the directory stack: dirs

  • Without restart the machine without removing the running processes: disown -r

  • It manages a number of built-in hash table records the full path of the command has been executed, can use this command to print out the commands you've used and executed: bash shell hash role in

  • See your file system's disk space quota: repquota (only the root user)

Guess you like

Origin www.cnblogs.com/tzsh1007/p/11532663.html