Common commands:
Pwd:print working directory, view the current working directory;
CD ~user_name: Enter the user's home directory;
[Email protected] ~]# CD ~bob[[email protected] bob]#
ln file Link: Create a hard link;
Note: Hard links cannot refer to files that are not on the same partition
Hard links cannot refer to directories
LN-S Item Link: Create a soft link;
Note: Soft links can refer to the table of contents
Type: Displays the types of a command;
Which: Displays the location of an executable command that does not work for bash built-in commands and alias;
Man: (Category of Man)
1 Users commands--General user commands
2 programming interfaces Kernel System calls--programming interface for kernel systems calls
3 programming interfaces to the C Library--c programming interface of the language library
4 special files such as device nodes and drivers--special file such as device number and driver
5 file Format formats--
6 games and amusements such as screen savers--game Entertainment
7 miscellaneous--Miscellaneous
8 System Administration commands--Administrator command related
Man 5 passwd: View the fifth part of the man document of the passwd command;
Apropos: Display the appropriate command
[Email protected] ~]# apropos FLOPPYFD (4)-Floppy disk Devicefdformat (8)-Low-level format a FL Oppy diskmbadblocks (1)-tests a floppy disk, and marks the bad blocks in the Fatmformat (1)-Add an MSDO S filesystem to a low-level formatted floppy disk
Whatis: Displays a simple description of a command
[Email protected] ~]# Whatis Lsls (1)-List directory Contentsls (1p)-List directory Conten Ts
Info about actions:
?—— Display Command Help
PgUp or Backspace--display previous page
PgDn or Space--display next page
n Next--display the Next node
P Previous--display the Previous node
U up--display The parent node of the currently displayed
node, usually a menu.
Enter--follow the hyperlink at the cursor location
Q--quit
/usr/share/doc: This directory has many programs to help the document;
Use alias to create your own commands:
[[email protected] ~]# alias foo= "cd /usr;ls -l;cd -" [[email protected ] ~]# foototal 300dr-xr-xr-x. 2 root root 81920 feb 13 08:29 bindrwxr-xr-x. 2 root root 4096 jun 9 2014 etcdrwxr-xr-x. 2 root root 4096 jun 9 2014 gamesdrwxr-xr-x. 177 root root 16384 dec 21 11:16 includedr-xr-xr-x. 49 root root 4096 feb 13 08:28 libdr-xr-xr-x. 204 root root 135168 dec 21 11:17 lib64drwxr-xr-x. 46 root root 12288 Dec 21 11:14 libexecdrwxr-xr-x. 12 root root 4096 dec 21 10:08 localdr-xr-xr-x. 2 root root 20480 feb 13 08:29 sbindrwxr-xr-x. 330 root root 12288 Dec 21 11:17 sharedrwxr-xr-x. 4 root root 4096 Dec 21 10:08 srclrwxrwxrwx. 1 root root 10 Dec 21 10:08 tmp -> &NBSP, .... /var/tmp/root[[email protected] ~]#
(Use Unalias to dismiss the command defined by alias: Unalias foo)
Type alias directly to see the system-defined alias:
[[email protected] ~]# aliasalias cp= ' cp-i ' Alias egrep= ' Egrep--color=auto ' Alias fgrep= ' Fgrep--color=auto ' Alias foo= ' CD/USR;LS-L;CD-' Alias grep= ' grep--color=auto ' Alias l.= ' ls-d. *--color=auto ' Alias ll= ' Ls-l--color=auto ' Alias ls= ' ls --color=auto ' Alias mv= ' mv-i ' Alias perlll= ' eval ' perl-mlocal::lib ' Alias rm= ' rm-i ' Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '
Redirect: (0 for standard input, 1 for standard output, 2 for standard error output)
Output redirection
[[email protected] ~]# ls -l > test.txt #重定向 [[email protected] ~]# cat test.txttotal 64- Rwxr-xr-x. 1 root root 148 feb 27 05:00 0227_2.sh-rwxr-xr-x. 1 root root 696 feb 27 05:53 02273.sh......drwxr-xr-x. 7 root root 4096 nov 20 16:49 vmware-tools-distrib
[Email protected] ~]# (CD/USR;LS-L;CD-) >>test.txt #追加重定向 [[email protected]tos7rzc ~]# Cat Test.txttotal 64-RW Xr-xr-x. 1 root root 148 Feb 05:00 0227_2.sh......drwxr-xr-x. 7 root root 4096 16:49 vmware-tools-distribtotal 300dr-xr-xr-x. 2 root root 81920 Feb 08:29 bindrwxr-xr-x. 2 root root 4096 June 9 etc
(connected up and down to see) ... lrwxrwxrwx. 1 root root Dec 10:08 tmp. /var/tmp/root
Error output redirection:
[Email protected] ~]# ls/noexist 2>err.txtyou have new mail in/var/spool/mail/root[[email protected] ~]# cat Err.txt Ls:cannot access/noexist:no such file or directory
REDIRECT StdOut and stderr to the same file
$ ls-l/bin/usr > Ls-output.txt 2>&1
Or
$ ls-l/bin/usr &> ls-output.txt
$ ls-l/bin/usr &>> ls-output.txt
Uniq-Outputs or filters duplicate rows;
tee– reads input from standard input, then outputs to standard output and file;
This article is from "Sunshine Kiss" blog, please make sure to keep this source http://kissofsun.blog.51cto.com/9686609/1617667
One of the Linux command line learning notes