1. 查看 系统信息-- uname -- http://www.cyberciti.biz/faq/command-to-show-linux-version/
[krystal@localhost survey]$ uname -r 3.18.3-201.fc21.x86_64 [krystal@localhost survey]$ uname -mrs Linux 3.18.3-201.fc21.x86_64 x86_64 [krystal@localhost survey]$ uname -a Linux localhost.localdomain 3.18.3-201.fc21.x86_64 #1 SMP Mon Jan 19 15:59:31 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2. 比较文件 -- sdiff/diff http://www.cyberciti.biz/faq/how-do-i-compare-two-files-under-linux-or-unix/
[krystal@localhost Public]$ cat file1 this is file1. now below is the content. this line is the same. only file1 has this line. [krystal@localhost Public]$ cat file2 this is file2. now below is the content. this line is the same. [krystal@localhost Public]$ sdiff file1 file2 this is file1. | this is file2. now below is the content. this line is the same. now below is the content. this line is the same. only file1 has this line. <
3. 获得所有的用户名 -- cut -f 1 -d ":" /etc/passed
cut: -f 获得第一列, -d 定义定界符号
[krystal@localhost nginx]$ cut -f 1 -d ":" /etc/passwd root bin daemon adm lp
...<more>
4. 获得用户的组 -- groups
[krystal@localhost nginx]$ groups
krystal wheel
[krystal@localhost nginx]$ groups root
root : root
[krystal@localhost nginx]$ groups krystal
krystal : krystal wheel
默认情况下,任何普通用户都可以通过su命令获得root用户的权限,对系统进行任何的操作。为了加强系统安全,Linux提供一个管理员组,只有属于这个组的用户才能使用su命令获得root权限,这个组通常为wheel.
5. 远程传输文件 -- scp
#从rivendell.fantasticsid.com拷贝id_rsa.pub文件到本地Downloas文件夹(需要配置远程服务器的github.) [krystal@localhost ~]$ scp jy@rivendell.fantasticsid.com:/home/jy/.ssh/id_rsa.pub ~/Downloads/ jy@rivendell.fantasticsid.com's password: id_rsa.pub 100% 750 0.7KB/s 00:01
6. 复制文件内容到剪切板 -- xclip
#1. pipe the output into xclip to be copied into the clipboard: $cat file | xclip #2. To paste the text you just copied, you shall use: $xclip -o #3. To simplify life, you can setup an alias in your .bashrc file as I did: alias "c=xclip" alias "v=xclip -o" To see how useful this is, imagine I want to open my current path in a new terminal window (there may be other ways of doing it like Ctrl+T on some systems but this is just for illustration purposes): Terminal 1: pwd | c Terminal 2: cd `v` Notice the ` ` around v. This executes v as a command first and then substitutes it in-place for cd to use. #4. cat file | xclip` only copies the content to the 'X' clipboard, if you want to paste somewhere else other than a 'X' application, try this one: cat file | xclip -selection clipboard
7. 自定义命令别名 -- alias
#1. show all command aliases for user krystal [krystal@localhost ~]$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -lh -d .* --color=auto' alias ll='ls -lh --color=auto' alias ls='ls --color=auto' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' #2. edit /etc/bashrc or ~/.bashrc to add alias permanently. #alias of commands alias ll='ls -lh --color=auto' alias l.='ls -lh -d .* --color=auto''