本人是linux新手,把一些常用的命令记在这里。
查看ubuntu版本 sudo lsb_release -a
安装软件 sudo apt-get install *** eg:sudo apt-get install apt-file
删除软件 sudo apt-get remove ***
查找文件
dpkg -s glfw.h 只能找已经存在的package
apt-file search glfw.h
locate glfw.h
改名字
mv oldfilename newfilename
查看权限
ls -l filename
ls -l|more filename (查看你当前的权限)
修改权限
chmod 755 twitter
chmod 644 twitter/*.*
显示文件
cat filename
压缩当前文件夹的所有文件
zip -r ./project.zip ./*
unzip project.zip
unzip -d -o project.zip ./project (-d表示解压路径,-o不提示的情况下覆盖文件)
其他压缩和解压
unzip: gunzip project.gz
gzip -d project.gz
tar -zxvf project.tar.gz
tar -xvf project.tar
zip: gzip project.tar.gz
gzip project.tgz
tar -zcvf project.tar.gz
tar -cvf project.tar
查看文件多少行
wc -l edit.txt
查看文件具体的某一行
sed -n '190,196p' a.txt 查看的是190到196
sed -n '190,1p' a.txt 查看190那一行
批量删除文件夹里同一后缀名的文件
find -name "*.s" -exec rm -f {} \;
快捷键
打开新的终端 ctrl+alt+t
切换界面 alt+tab
杀死进程 ctrl+c
emacs
ctrl+@ set mark
alt+w copy
ctrl+y paste
ctrl+/ cancel
ctrl+x s save
ctrl+x c quit
C-x 0 : 关闭当前窗口
C-x 1 : 将当前窗口最大化
C-x 2 : 垂直分割窗口
C-x 3 : 水平分割窗口
C-x o: 不同窗口间移动光标
从缓存中恢复原文件 M-x recover file<Return> (M:ESC)
查找 M-x grep-find ***
• To exit emacs editor:
CTRL-x CTRL-c
Manipulating files with emacs
CTRL-x CTRL-f read a file into an emacs buffer
CTRL-x CTRL-s save file to disk
CTRL-x i inserts another file into this file
CTRL-x CTRL-w writes buffer to a file you name (use this like "save as")
Moving around in emacs
CTRL-f move forward one character
CTRL-b move backward one character
CTRL-n move forward one line
CTRL-p move backward one line
M-f move forward one word
M-b move backward one word
CTRL-a move to the beginning of line
CTRL-e move to the end of the line
CTRL-v scroll to next screen
M-v scroll to previous screen
CTRL-x b move to another buffer
Changing and moving text
Backspace, or CTRL-d : delete the character behind or at the cursor
M-d : delete the next word
CTRL-k : delete to the end of the line
CTRL-@ or CTRL-SPC : mark the beginning of a region
CTRL-w : cut (wipe) from here to beginning of the region
CTRL-y : insert here what you last deleted/cut/copied
M-w : copy from here to beginning of the region (same effect as CTRL-w CTRL-y)
Abort and undo
CTRL-g aborts a partially typed or executing command
CTRL- _(underscore) undoes the last change (repeatedly using undo will undo the last several changes)
Using two windows
• Create two windows:
CTRL-x 2 (this will split your screen into two windows)
CTRL-x o (move in the bottom window; use the same command to get back into the
upper window; here o is the letter not zero)
CTRL-x 1 (to kill one window)
Other Editors 0r Help with unix