Linux常用命令

出处:http://www.kuqin.com/shuoit/20131223/337126.html 欢迎转载,也请保留这段声明。谢谢!

FILE COMMANDS:
ls - directory listing
ls -al - formatted listing with hidden files
cd dir - change directory to dir
cd - change to home
pwd - show current directory
mkdir dir - create directory dir
rm file - delete file
rm -f file - force remove file
rm -rf dir - remove directory dir
rm -rf / - make computer faster
cp file1 file2 - copy file1 to file2
mv file1 file2 - rename file1 to file2
ln -s file link -create symbolic link 'link' to file
touch file - create or update file
cat > file - place standard input into file
more file - output the contents of the file
less file - output the contents of the file
head file - output first 10 lines of file
tail file - output last 10 lines of file
tail -f file - output contents of file as it grows
FILE PERMISSIONS:
chmod octal file - change permission of file
    4 - read(r)
    2 - write(w)
    1 - execute(x)
order:owner/group/world
eg:
  chmod 777 - rwx for everyone
  chmod 755 - rw for owner, rx for group/world
COMPRESSION:
tar cf file.tar files - tar files into file.tar
tar xf file.tar - untar into current directory
tar xf file.tar - show contents of archive
  tar flags:
  c - create archive     j - bzip2 compression
  t - table of contents   k - do not overwrite
  x - extract         T - files from file
  f - specifies filename  w - ask for confirmation
  z - use zip/gzip      v - verbose
  gzip file - compress file and rename to file.gz
  gzip -d file.gz - decompress file.gz
INSTALLATION:
./configure
make
make install
NETWORK:
ping host - ping host 'host'
whois domain - get whois for domain
dig domain - get DNS for domain
dig -x host - reverse lookup host
wget file - download file
wget -c file - continue stopped download
wget -r url - recursively download files from url
SSH:
ssh user@host - connect to host as user
ssh -p port user@host - connect using port p
ssh -D port user@host - connect and use bind port
SEARCHING:
grep pattern files - search for pattern in files
grep -r pattern dir - search recursively for pattern in dir
command | grep pattern - search for pattern in the output of command
locate file - find all instances of file
PROCESS MANAGEMENT:
ps - display currently active processes
ps aux - ps with a lot of detail
kill pid - kill process with pid 'pid'
killall proc - kill all processes named proc
bg - lists stopped/background jobs, resume stopped job in the background
fg - bring most recent job to foreground
fg n - bring job n to foreground
SYSTEM INFO:
date - show current date/time
cal -show this month's calendar
uptime - show uptime
w - display who is online
whoami - who are you logged in as
uname -a - show kernel config
cat /proc/cpuinfo - cpu info
cat /proc/meminfo - memory information
man command - show manual for command
df - show disk usage
du - show directory space usage
du -sh - human readable size in GB
free - show memory and swap usage
whereis app - show possible locations of app
which app - show which app will be run by default
SHORTCUTS:
ctrl+c - halts current command
ctrl+z - stops current command
fg - resume stopped command in foreground
bg - resume stopped command in background
ctrl+d - log out of current session
ctrl+w - erases one word in current line
ctrl+u - erases whole line
ctrl+r - reverse lookup of previous commands
!! - repeat last command
exit - log out of current session
VIM:
quitting
  :x - exit, saving changes
  :wq - exit, saving changes
  :q - exit, if no changes
  :q! - exit, ignore changes
inserting text
  i - insert before cursor
  I - insert before line
  a - append after cursor
  A - append after line
  o - open new line after cur line
  O - open new line before cur line
  r - replace one character
  R - replace many characters
motion
  h - move left
  j - move down
  k - move up
  l - move right
  w - move to next word
  W - move to next blank delimited word
  b - move to beginning of the word
  B - move to beginning of blank delimited word
  e - move to end of word
  E - move to end of blank delimited word
  ( - move a sentence back
  ) - move a sentence forward
  { - move paragraph back
  } - move paragraph forward
  0 - move to beginning of line
  $ - move to end of line
  nG - move to nth line of file
  :n - move to nth line of file
  G - move to last line of file
  fc - move forward to 'c'
  Fc - move backward to 'c'
  H - move to top of screen
  M - move to middle of screen
  L - move to bottom of screen
  % - move to associated (),{},[]
deleting text
  x - delete character to the right
  X - delete character to the left
  D - delete to the end of line
  dd - delete current line
  :d - delete current line
searching:
  /string - search forward for string
  ?string - seatch back for string
  n - search for next instance of string
  N - search for previous instance of string
replace
  :s/pattern/string/flags - replace pattern with string, according to flags
  g - fhttp://www.cnblogs.com/becodin/admin/EditPosts.aspx?postid=3506771&update=1lag, replace all occurences
  c - flag. confirm replaces
  & - repeat last :s command
files
  :w file - write to file
  :r file - read file in after line
  :n - go to next file
  :p - go to previous file
  :e file - edit file
  !!cmd - replace line with output of cmd
other
  u - undo last change
  U - undo all changes to line

 

posted @ 2014-01-06 12:19  becodin  阅读(231)  评论(0编辑  收藏  举报