The shell is known as the system administrator's choice for its stability, efficiency, and flexibility. The basic shell commands are described below, including directory switching, locating and viewing files, viewing user information, and more.
1. Shell Introduction
The shell is a program that provides a line-oriented, interoperable interface between the user and the operating system. The user enters a command at the command line and the shell running in the background converts the command into a script to the operating system.
2. Printing conventions
$: Indicates user input
#: Indicates that the command is being executed as root
3. Browse your hard drive
-- Enter the root directory (CD command) and view the directory structure under the root directory (ll command) csv-cbweb01-cbossweb%cd /directory: /csv-cbweb01-cbossweb%ll total usage 220drwxr-xr-x 2 root root 4096 5 month 5 2010 selinux/drwxr-xr-x 2 root root 4096 5 Moon 5 2010 mnt/drwx------ 2 root root 16384 7 Month 30 2013 lost+found/drwxr-xr-x 13 root root 4096 7 Month 30 2013 usr/drwxr-xr-x 4 root root 4096 7 Month 30 2013 srv/drwxr-xr-x 15 Root root 4096 7 Month 30 2013 var/drwxr-xr-x 3 root root 4096 7 Month 30 2013 opt/drwxr-xr-x 4 rOot root 4096 7 Month 31 2013 home/drwxr-xr-x 13 root root 4096 9 Month 10 2015 lib/drwxr-xr-x 8 root root 12288 9 Month 10 2015 lib64/drwxr-xr-x 2 root root 4096 9 Month 10 2015 bin/ Drwxr-xr-x 3 root root 12288 9 Month 10 2015 Sbin/drwxr-xr-x 4 root root 4096 9 Month 10 2015 boot/drwxr-xr-x 2 root root 4096 9 Month 11 2015 media/drwxr-xr-x 18 1000 1000 4096 9 Month 16 2015 Python-2.7.10/drwxr-xr-x 24 root root 4096 12 Month 21&nbsP;01:31&NBSP, .... /drwxr-xr-x 24 root root 4096 12 Month 21 01:31 ./ Dr-xr-xr-x 164 root root 0 12 Month 21 09:31 proc/drwxr-xr-x 12 root root 0 12 Month 21 09:31 sys/drwxr-xr-x 16 root root 4160 12 Month  21 09:32 DEV/DRWX------ 22 root root 4096 2 Month 18 10:42 root/drwxr-xr-x 5 root root 4096 2 Month 18 11:05 app/drwxr-xr-x 107 root root 12288 2 Month 18 11:05 etc/drwxrwxrwt 1792 root root 102400 5 Month 27 12:30 tmp/csv-cbweb01-cbossweb%cd /homedirectory: / Homecsv-cbweb01-cbossweb%ll Total Dosage &NBSp;16drwxr-xr-x 5 bsm users 4096 7 Month 30 2013 bsm/ Drwxr-xr-x 6 zjwg users 4096 7 Month 30 2013 zjwg/drwxr-xr-x 4 root root 4096 7 Month 31 2013 ./drwxr-xr-x 24 root root 4096 12 month 21 01:31 /csv-cbweb01-cbossweb%-- Automatic Completion with TAB tab
4. viewing directories and files
--Show current directory pwdcsv-cbweb01-cbossweb%cd/usr/local/bin/directory:/usr/local/bincsv-cbweb01-cbossweb%pwd/usr/local/ bin--Change System directory Cdcsv-cbweb01-cbossweb%cd/usr/local/bin/directory:/usr/local/bincsv-cbweb01-cbossweb%pwd/usr/local/ bincsv-cbweb01-cbossweb% CD. /directory:/usr/localcsv-cbweb01-cbossweb%pwd/usr/local--listing directory contents ls and ls-lcsv-cbweb01-cbossweb% lscsv-cbweb01-cbossweb%ls-l--viewing files cat|more[filename]--the cat command will display everything on the screen at once. So it's not often used--the more command displays the content on a page-by-page. SPACEBAR to page, enter to roll, Q to exit Csv-cbweb01-cbossweb%more fbst--read the beginning and end of the file--head used to display the beginning of the file specify the number of rows displayed with the-n parameter--tail is used to display the end of the file, Usage is the same as head
5. Better text reading tools: less
Less is much more similar, but more powerful. Less displays a colon at the bottom of the screen: waits for the user's input command. The space is page down and the B key is page up. Use "/" to find what you want, q to exit
6. Find File Contents: grep
Grep[options] Pattern[file ...] --To find the row grep un day that contains UN in the file day
7. Locate the file within the specified range: find
Find[option] [path ...] [expression]-- find the Zip command in the User/bin directory csv-cbweb01-cbossweb%cd /directory: /csv-cbweb01-cbossweb% find /usr/bin/ lib/ sbin/ [email protected]games/ lib64/ share/ X11R6/include/ local/ src/ x86_64-suse-linux/csv-cbweb01-cbossweb %find /usr/bin/ -name zip -ppath perm print print0 printf prune csv-cbweb01-cbossweb%find /usr/bin/ -name zip - The Print/usr/bin/zipcsv-cbweb01-cbossweb%--find command also enables you to specify the type of file and to locate the file type by using the type parameter. -type -b fast device files -c character device files -d directory file -f common file -p Named pipes l Symbolic Links
8. Quickly locate files
--View the path of all doc files locate *.doc
9. Find a specific program: Whereis
The Whereis command is primarily used to locate program files
Csv-cbweb01-cbossweb%whereis Findfind:/usr/bin/find/usr/bin/x11/find/usr/share/man/man1p/find.1p.gz/usr/share/ Man/man1/find.1.gz
10, user and version information view
--who Command View current system has those people logged in Csv-cbweb01-cbossweb%whocbossweb pts/0 2016-05-27 12:28 (10.73.141.8) cbossweb PTS/1 2016 -05-26 10:42 (10.73.141.43) cbossweb pts/4 2016-05-26 16:26 (10.73.141.43)--If you forget what you are logged into the system, use Whoamicsv-cbweb01-c Bossweb%whoami cbossweb--uname-a View version information for the current system csv-cbweb01-cbossweb%uname-alinux csv-cbweb01 3.0.101-63-default #1 SMP Tue June 16:02:31 UTC (4b89d0c) x86_64 x86_64 x86_64 Gnu/linuxcsv-cbweb01-cbossweb%uname-r3.0.101-63-default
11. Ask for help--man command
The man command provides easy access to a command's help information
Csv-cbweb01-cbossweb%man Findman: Find all matching hand albums * FIND (1) find (1p) man: What manual pages do you need? ...
12, get the command introduction--Whatis and apropos
The lengthy speeches in the man handbook are too wordy, and many times we just want to know what an order is, and use Whatis to see
Csv-cbweb01-cbossweb%whatis Findfind (1p)-Find Filesfind (1)-Search for files in a directory hi Erarchy
The opposite command is apropos, which can be reversed by using the command in the manual. For example, if a user wants to search for a file and cannot remember which command to use, they can ask for help apropos
apparmor.d applydeltaiso aptcsv-cbweb01-cbossweb%apropos searchanemotaxis (6x) - directional search on a plane.apropos (1) - search the manual page names and descriptionsausearch (8) - a tool to query audit daemon logsausearch-expression (5) - audit search expression formatbadblocks (8) - search a device for bad blocksbsearch (3) - binary search of a sorted arraybsearch (3p) - binary search a sorted tablebzgrep (1) - search possibly bzip2 compressed files  FOR A REGULAR&NBSP, ..... class::isa (3pm) - report the search path for A class ' s isa treecpanplus::internals::search (3pm) - (δ) find (1) - search for files in a directory hierarchygetgrnam (3p) - search group database for a namegetgrnam_r (3p) - search group database for a namegetpwnam (3p) - search user database for a namegetpwnam_r (3p) - search user database for a namegetpwuid (3p) - search user database for a user idgetpwuid_r (3p) - search user database for a user idgnome-search-tool (1) - the GNOME Search Toolgrep (1p) - search a file for a patterngrepjar (1) - search files in a jar file for a patternhcreate (3p) - manage hash search tablehdestroy (3p) - manage hash search table...-- can see that the apropos command lists the entries that contain "search", where the user can find the one they want.
13. Summary
The command line is the quintessential part of Linux. All system management operations can be done under the shell
There are many different shells to choose from. Currently, the most widely used Linux is bash
You can use command line completion and wildcard characters to improve the efficiency of using the shell
The PWD command is used to display the current directory information
cd command in the directory key switch, which is one of the most frequently used commands in Linux
The LS command provides a number of options for users to view directory content
Dir and VDir are simplified versions of the LS command
Use the Cat command to view files (all file contents). More command to display a longer text file in pagination
Use the head and tail commands to display a header and end of file,-N to specify how many rows are displayed
The less command provides more advanced functionality for viewing files. The man command is to display the help book information by calling less.
The tool for finding the contents of a file when grep is in process
The find command can find a specific file on demand
Locate command to quickly locate file locations
Whereis command to find where a particular program is located
Who view current system with those people logged in
Uname for displaying current system information
Whatis and Apropos commands to extract brief information from the man manual
This article is from the "Ah Cool blog source" blog, please make sure to keep this source http://aku28907.blog.51cto.com/5668513/1783805
Shell basic Commands