Linux bash shell basic commands 1

First, the manual command

1. Quick Reference Example man command man man or a man ls

   unknown command, using the man -k See Example man -k terminal keyword related command terminal

   SUMMARY man number command selection command Example man 3 intro

2. Help option information command -help / - help

3. info page information such as info info info command

Second, the file system commands

1. Where do you want to traverse the directory e.g. cd cd / home / user name or user directory cd to

   '.' Symbol represents a single point of the current directory '..' symbol represents a single point of two parent directory of the current directory

2. Display the location of the current working directory pwd

3. Review the files and directories ls command options: -F distinguish between files and directories in the file name by /; -a show hidden files

   -R recursively all the files in the subdirectory; -l display more information in the form of a long list; -i number display innode

   Into the heart through a regular expression pattern matching string matching ls -l e.g. ls -l z *

4. Create an empty file or change the file modification time touch filename such as touch helloworld.c

   Change file access time touch -a filename

5. Copy the file cp source destination embodiment cp a.txt b.txt

   Note: source and destination can be a directory or file, the source file may be a whole directory or file, or specify the next destination may be a new file name directory

   Covering the destination file: destination will be overwritten when the destination source already exists

   Options: -i open reminder; -R recursively copy the entire directory

6. link files ln ln -s into symbolic links and hard links ln; ln source destination

   A symbolic link is pointing to the file already exists file, the contents of the source file are different. No different innode

   The virtual file hard links to create a separate source file that contains the location information already exists, the same number innode

7. Move the file or rename a file mv time and the same number innode

   Rename mv oldfilename newfilename embodiment mv fall fzll 

   Example moved mv source destination mv fall / home /

   Example mv fall while moving can rename / home / zed / fzll

8. Delete file rm filename option: -i prompt; -f force the deletion does not prompt; -r recursively delete the directory containing the files

9. Create an empty directory mkdir directoryname options: -p create the missing parent directory

10. Remove empty directories rmdir directoryname

11. Review the directory tree structure tree directoryname

12. Review the contents of the file

   1) Check the file type and file filename descriptive information such as file a.txt

   2) to view the entire contents of the file cat filename options: -n show line numbers; -b show a non-empty line number; -T does not display tabs

   3) view the entire contents of the file more filename / less filename

   4) to view the file head or tail head filename / tail filename options: -n select the number of lines to display, the default is 10; -f real-time monitoring

Third, the process control commands

1. The detection process is currently used information ps ps -ef / ps l / ps --forest

2. Continued top display process information

3. End the process kill PID options: -s specifies the signal according kill -s HUP 3940

4. End all processes killall, often used in conjunction with regular expressions

Fourth, the disk control command

1. Mount the device to display a list of virtual directory mount equipment mounted on the current system

   Mount the device sudo mount -t type device directory, type specified file system, for example, mount -t vfat / dev / sdb1 / media / disk

2. unloading equipment umount, remove the device when you must uninstall, umount directory / device, using the device if you can not uninstall process

3. See mounted devices using spatial information df, options: -h, units to M / G and the like easily readable

4. Display of files in the case of using the disk in Example du du display the current directory / du / home / zed / display user directory

Fifth, data processing command

1. Sort command sort filename, default sorted by ASCII, numeric figures are not the order of options: -n numeric sort by value

   ; -M month sorting; -t specified data delimiter; -k specifies the first few fields; -R & lt descending sort, the default is ascending

2. The data search grep [Options] pattern [File] , pattern is the pattern string, output lines comprising the matching pattern Example grep three file1

   Options: -v reverse search, the output ratio matching line; -n display the matching line number; -C matching the number of lines; a plurality of specified patterns -e

   Example  grep -et -ef file1, or two pattern string is a relationship, the regular expression is a UNIX-style

3. Data in search egrep, supports POSIX extended regular expressions, more powerful

4. fgrep search string with the data file is present in a large file search mode

The compressed data compressed file gzip filename, filename string pattern can be used for batch compression

6. gunzip decompressed data decompressed file filename string filename available batch mode decompress

7. archived data  tar function [options] object1 object2 ...

   Common function options: -z gzip command to redirect the output of compressed data; -c to create an archive; -v displays the file; -f output to the specified file

   -x extract the archive

   常用 takes -cvf test.tar test / test2 /

   Common Command unzip tar -zxvf filename

Released five original articles · won praise 3 · Views 4237

Guess you like

Origin blog.csdn.net/weixin_42686673/article/details/104595821
Recommended