man+命令可以查看该命令的帮助
man ls
Ctrl+Shift+加号可以放大终端自体,减小则是Ctrl+减号。
Ctrl+u可以撤销输入的命令
pwd 打印当前目录
root@IdeaPad:~# pwd
/root
cd命令可直接回到用户主目录
evilxr@IdeaPad:~$ cd /tmp
evilxr@IdeaPad:/tmp$ pwd
/tmp
evilxr@IdeaPad:/tmp$ cd
evilxr@IdeaPad:~$ pwd
/home/evilxr
evilxr@IdeaPad:~$
rmdir可以删除空目录
touch可创建文件,rm则可以删除文件
xv9@IdeaPad:~$ touch a.tzt
xv9@IdeaPad:~$ ls
a.tzt Documents examples.desktop Pictures Templates
Desktop Downloads Music Public Videos
xv9@IdeaPad:~$ rm a.tzt
xv9@IdeaPad:~$ ls
Desktop Downloads Music Public Videos
Documents examples.desktop Pictures Templates
一次创建或者删除多个对象:
xv9@IdeaPad:/tmp/test$ touch a.txt b.txt c.txt
xv9@IdeaPad:/tmp/test$ ls
a.txt b.txt c.txt
xv9@IdeaPad:/tmp/test$ rm a.txt b.txt c.txt
xv9@IdeaPad:/tmp/test$ ls
xv9@IdeaPad:/tmp/test$ touch a.txt b.txt c.txt
xv9@IdeaPad:/tmp/test$ rm *.txt
xv9@IdeaPad:/tmp/test$ ls
xv9@IdeaPad:/tmp/test$
用mkdir创建多级目录的话,需要加上-p
xv9@IdeaPad:/tmp/test$ mkdir -p a/b/c
xv9@IdeaPad:/tmp/test$ ls
a
xv9@IdeaPad:/tmp/test$ cd a
xv9@IdeaPad:/tmp/test/a$ ls
b
xv9@IdeaPad:/tmp/test/a$ cd b
xv9@IdeaPad:/tmp/test/a/b$ ls
c
xv9@IdeaPad:/tmp/test/a/b$ cd c
xv9@IdeaPad:/tmp/test/a/b/c$ ls
rm 强制删除:
xv9@IdeaPad:/tmp/test$ rm -rf a
xv9@IdeaPad:/tmp/test$ ls
xv9@IdeaPad:/tmp/test$
mv可移动并修改目录
cat 可以读出并打印文件内容
还有 head teil more les这四个,不过效果各有不同
tar打包:
xv9@IdeaPad:/tmp$ tar -cvf ab.tar aa.c evilxr.txt
aa.c
evilxr.txt
xv9@IdeaPad:/tmp$ ls
aa.c evilxr.txt ibus.log orbit-xv9
aa.c.save GkVFj8EQTl jknKDn_vui ssh-eR7evKkCyTQB
ab.tar HxwocPXeXB lost+found unity_support_test.0
xv9@IdeaPad:/tmp$ cat aa.c
enter another words
hello nice
www.evilxr.com
write in Nano
c = 12;
d = 13;
z = c+d;
xv9@IdeaPad:/tmp$ cat evilxr.txt
你好,欢迎来到我的博客,
我是彩笔~~~
xv9@IdeaPad:/tmp$
解压包则用该命令
xv9@IdeaPad:/tmp$ tar -xvf ab.tar
查看包内的内容:
xv9@IdeaPad:/tmp$ tar -tvf ab.tar
-rw-rw-r-- evilxr/evilxr 86 2014-05-28 13:00 aa.c
-rw-rw-r-- evilxr/evilxr 53 2014-05-28 12:58 evilxr.txt
xv9@IdeaPad:/tmp$
解压包中指定文件:
xv9@IdeaPad:/tmp$ tar -tvf ab.tar a
gzip 打包,压缩效率很高~
root@IdeaPad:~/test# tar -cvf ab.tar 1.txt 2.txt
1.txt
2.txt
root@IdeaPad:~/test# ls
1.txt 2.txt ab.tar
root@IdeaPad:~/test# cp ab.tar aa.tar
root@IdeaPad:~/test# cp ab.tar ac.tar
root@IdeaPad:~/test# ls
1.txt 2.txt aa.tar ab.tar ac.tar
root@IdeaPad:~/test# ls -l
total 44
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 10240 5月 29 09:20 aa.tar
-rw-r--r-- 1 root root 10240 5月 29 09:20 ab.tar
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
root@IdeaPad:~/test# gzip aa.tar
root@IdeaPad:~/test# ls
1.txt 2.txt aa.tar.gz ab.tar ac.tar
root@IdeaPad:~/test# ls -l
total 36
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 445 5月 29 09:20 aa.tar.gz
-rw-r--r-- 1 root root 10240 5月 29 09:20 ab.tar
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
root@IdeaPad:~/test# gunzip aa.tar.gz
root@IdeaPad:~/test# ls -l
total 44
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 10240 5月 29 09:20 aa.tar
-rw-r--r-- 1 root root 10240 5月 29 09:20 ab.tar
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
bzip2打包,效率要低些,
root@IdeaPad:~/test# bzip2 ab.tar
root@IdeaPad:~/test# ls -l
total 28
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 445 5月 29 09:20 aa.tar.gz
-rw-r--r-- 1 root root 467 5月 29 09:20 ab.tar.bz2
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
bunzip2解压:
root@IdeaPad:~/test# bunzip2 ab.tar.bz2
root@IdeaPad:~/test# ls -l
total 36
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 445 5月 29 09:20 aa.tar.gz
-rw-r--r-- 1 root root 10240 5月 29 09:20 ab.tar
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
root@IdeaPad:~/test#
tar命令扩展:
root@IdeaPad:~/test# tar -zcvf ac.tar.gz ac.tar
ac.tar
root@IdeaPad:~/test# ls
1.txt 2.txt aa.tar.gz ab.tar.bz2 ac.tar ac.tar.gz
root@IdeaPad:~/test# ls -l
total 32
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 445 5月 29 09:20 aa.tar.gz
-rw-r--r-- 1 root root 467 5月 29 09:20 ab.tar.bz2
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
-rw-r--r-- 1 root root 483 5月 29 09:31 ac.tar.gz
root@IdeaPad:~/test# tar -jcvf ac.tar.bz2 ac.tar
ac.tar
root@IdeaPad:~/test# ls
1.txt 2.txt aa.tar.gz ab.tar.bz2 ac.tar ac.tar.bz2 ac.tar.gz
root@IdeaPad:~/test# ls -l
total 36
-rw-r--r-- 1 root root 54 5月 27 23:31 1.txt
-rw-r--r-- 1 root root 332 5月 27 23:54 2.txt
-rw-r--r-- 1 root root 445 5月 29 09:20 aa.tar.gz
-rw-r--r-- 1 root root 467 5月 29 09:20 ab.tar.bz2
-rw-r--r-- 1 root root 10240 5月 29 09:20 ac.tar
-rw-r--r-- 1 root root 497 5月 29 09:32 ac.tar.bz2
-rw-r--r-- 1 root root 483 5月 29 09:31 ac.tar.gz
root@IdeaPad:~/test#
tar解压的话,就把对应的c换成x就好
查看CPU情况:
cat /proc/cupinfo
后记:head、tail、grep、cat、wc、
[root@evilxr ~]# head /var/log/messages
Jul 14 11:21:23 evilxr kernel: imklog 5.8.10, log source = /proc/kmsg started.
Jul 14 11:21:23 evilxr rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="1218" x-info="http://www.rsyslog.com"] start
Jul 14 11:21:23 evilxr kernel: Initializing cgroup subsys cpuset
Jul 14 11:21:23 evilxr kernel: Initializing cgroup subsys cpu
Jul 14 11:21:23 evilxr kernel: Linux version 2.6.32-431.el6.i686 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 00:26:36 UTC 2013
Jul 14 11:21:23 evilxr kernel: KERNEL supported cpus:
Jul 14 11:21:23 evilxr kernel: Intel GenuineIntel
Jul 14 11:21:23 evilxr kernel: AMD AuthenticAMD
Jul 14 11:21:23 evilxr kernel: NSC Geode by NSC
Jul 14 11:21:23 evilxr kernel: Cyrix CyrixInstead
[root@evilxr ~]# tail /var/log/messages
Jul 15 10:07:22 evilxr vmusr[2774]: [ warning] [GLib-GObject] Two different plugins tried to register 'BasicEngineFc'.
Jul 15 10:07:22 evilxr vmusr[2774]: [critical] [GLib-GObject] g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
Jul 15 10:07:22 evilxr vmusr[2774]: [ warning] [GLib-GObject] Two different plugins tried to register 'BasicEngineFc'.
Jul 15 10:07:22 evilxr vmusr[2774]: [critical] [GLib-GObject] g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
Jul 15 10:07:22 evilxr vmusr[2774]: [ warning] [GLib-GObject] Two different plugins tried to register 'BasicEngineFc'.
Jul 15 10:07:22 evilxr vmusr[2774]: [critical] [GLib-GObject] g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
Jul 15 10:09:19 evilxr evilxr: tesrlog fff
Jul 15 10:10:20 evilxr pulseaudio[2732]: alsa-sink.c: ALSA 提醒我们在该设备中写入新数据,但实际上没有什么可以写入的!
Jul 15 10:10:20 evilxr pulseaudio[2732]: alsa-sink.c: 这很可能是 ALSA 驱动程序 'snd_ens1371' 中的一个 bug。请向 ALSA 开发人员报告这个问题。
Jul 15 10:10:20 evilxr pulseaudio[2732]: alsa-sink.c: 提醒我们设置 POLLOUT -- 但结果是 snd_pcm_avail() 返回 0 或者另一个小于最小可用值的数值。
#日志监控
[root@evilxr ~]# tail -f /var/log/messages
[root@evilxr ~]# tailf /var/log/messages
grep可以帮助我们从众多杂乱的信息中挑出我们想要的
#显示/etc/passwd 中与SSH相关的
[root@evilxr ~]# cat /etc/passwd |grep ssh
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
#参数-n可以显示该内容在文件中所在行数
[root@evilxr ~]# cat /etc/passwd |grep -n ssh
42:sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
# -v 取反
#-AX、-BX 将与类容相关的后几行或者钱几行
#--color 将显示的内容高亮起来
#用wc实现对行数的统计
[root@evilxr ~]# ls /
bin cgroup etc lib media mnt opt root selinux sys usr
boot dev home lost+found misc net proc sbin srv tmp var
[root@evilxr ~]# ls / | wc -l
22
2014-9-30
Linux 修改文件夹所有者:
chown -R apache evilxr
Linux Shell
Shell分为CLI与GUI两种
CLI:Command Line Interface
GUI:Grophical User Interface
操作系统的Shell:
GUI:GNOME
CLI:BASH
命令+&符号:将命令放在后台运行
firefox &
locate
updatedb
1. Shell等号两边不能有空格
2. 环境变量称为全局变量,按照惯例需要大写
#export LANG
3. 只读变量是指不能被清除或重新赋值的变量
#readonly myvar
4. 分号可以链接两条命令
5. 位置参量是一组特殊的内置变量, 通常被Shell脚本用来从命令接受参数, 或被用来保存传递给他的参数。
6. 执行Shell脚本时,用户可以通过命令向脚本传递信息,跟在脚本后面的用空格隔开的每个字符都称为位置参量
7. 在脚本使用这些参数时, 需通过位置参量来引用。
$1表示第一个参数
二:输入输出
可以指定输出文本的前景和背景色
Ubuntu 安装LAMP
sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql
Linux查看指定端口的进程号
netstat -antup | grep 5000
rmdir删除非空目录
使用方式: rmdir [-p] dirName
参数: -p 是当子目录被删除后使它也成为空目录的话,则顺便一并删除。
Pytho-vimrc
:set nu
:syntax on
:set showmatch
:set tabstop=4
将普通用户加入wheel组
usermod -G wheel username
ubuntu更新flsh
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install freshplayerplugin
linux更新系统时间
sudo ntpdate time.nist.gov