您的位置:首页 > 运维架构 > Linux

结合工作对linux做个入门小结

2014-03-31 18:21 477 查看
对Linux的接触小记:

【对开发环境的搭建】

2012年,我还不懂Linux。但工作中用到了,央广现场用到的媒资系统在我发过更新包出现了问题(而我在本地windows系统更新后是没有问题的)。于是我就想着把现成的web应用文件夹整个拷贝过来,放在本地来跑,然后再做更新,方便进行追踪和调试。

解决问题后,我就想着在自己的笔记本电脑上也装个Linux虚拟机玩玩。

这里是我当初安装Linux虚拟机的笔记,记得凌晨安装好时进入到Linux桌面颇有轻松感,小有成就感~

http://note.youdao.com/share/?id=f4d19e70da6bcd18846e39bb93079e49&type=note

【对tomcat的重启】

之前安装好环境后,在重启tomcat时用的是这招

http://blog.csdn.net/wangchenggong88/article/details/9147199

思路是进入到Tomcat的bin目录下,执行  

./shutdown.sh

然后
ps -ef|grep java
通过该命令来确认Tomcat是否真的被干掉。


如果没有的话,该进程信息会显示得比较长;——这时可以用kill -9 进程号 直接将Tomcat进程干掉

然后 在bin目录下执行

./startup.sh

***********************************************************************************************

另一种方案是对jps命令的使用(后来才经常使用),如下:

jps  (注意bootstrap的进程号)

kill -9 XX

jps

cd XXX/bin

tail - f ../logs/catalina.out

./startup.sh

【对linux基本命令的熟悉——12年9月】



【对网易云课堂linuxcast的学习】
A.对文件的操作、对文本的修改(vi的使用)
1.如何复制文件?如何复制目录?如何在复制目录的同时给出详细信息?
cp (-r/-v/-rv) 源文件 目标文件
2.如何移动文件?如何移动文件的同时并且重命名?如何使用mv对文件重命名?
mv (-r/-v/-rv) 源文件 目标目录/重命文件名
3.如何创建文件?如何删除文件?如何删除文件夹呢?(文件夹比文件多了一个-r参数)怎样在删除时加入交互呢?(-i)如何强制删除?(-f)
创建/删除 文件: touch, rm -i(交互式)/-r(递归的删除包括目录中的所有内容)/-f(强制删除) 目标文件

4.如何创建一个目录?非空的话怎么才能删除呢?

创建目录:mkdir
删除空目录 rmdir
rm -r (-f) 删除非空文件夹

希望能通过走一遍测试流程,能对常用的参数也能有个印象

测试流程:
在~下新建一个文件wangchenggong.wangfei 并删除
[whatyeditor@awstats ~]$ ls

apache-tomcat-6.0.35  editor  wangchenggong.wangfei

[whatyeditor@awstats ~]$ rm -i wangchenggong.wangfei 

rm: remove regular empty file `wangchenggong.wangfei'? y

[whatyeditor@awstats ~]$ ls

apache-tomcat-6.0.35  editor

在~下新建一个测试目录 test_file_opt,并在其下新建测试文件test.jsp,测试目录test_dir,在测试目录test_dir下再新建一级目录test_child_dir,在子目录下新建一个测试文件test_chile_file.jps

[whatyeditor@awstats ~]$ mkdir test_file_opt

[whatyeditor@awstats ~]$ l

-bash: l: command not found

[whatyeditor@awstats ~]$ ls

apache-tomcat-6.0.35  editor  test_file_opt

[whatyeditor@awstats ~]$ cd test_file_opt/

[whatyeditor@awstats test_file_opt]$ touch test/jsp

touch: cannot touch `test/jsp': No such file or directory

[whatyeditor@awstats test_file_opt]$ touch test.jsp

[whatyeditor@awstats test_file_opt]$ mkdir test_dir

[whatyeditor@awstats test_file_opt]$ cd test_dir

-bash: cd: test_dir: No such file or directory

[whatyeditor@awstats test_file_opt]$ ls

test??_dir  test.jsp

[whatyeditor@awstats test_file_opt]$ rm test??_dir

rm: cannot remove `test\241\252_dir': Is a directory

[whatyeditor@awstats test_file_opt]$ rm -r  test??_dir

[whatyeditor@awstats test_file_opt]$ ls

test.jsp

[whatyeditor@awstats test_file_opt]$ mkdir test_dir

[whatyeditor@awstats test_file_opt]$ cd test_dir/

[whatyeditor@awstats test_dir]$ mkdir test_child_dir

[whatyeditor@awstats test_dir]$ cd test_child_dir/

[whatyeditor@awstats test_child_dir]$ touch test_child_file.jsp

将test.jsp从test_file_opt目录下拷贝到test_child_dir目录下
[whatyeditor@awstats test_child_dir]$ cd ~

[whatyeditor@awstats ~]$ ls

apache-tomcat-6.0.35  editor  test_file_opt

[whatyeditor@awstats ~]$ cd test_file_opt/

[whatyeditor@awstats test_file_opt]$ cp -v test.jsp test_dir/test_cp.jsp

`test.jsp' -> `test_dir/test_cp.jsp'

将test.jsp从test_file_opt目录下拷贝到test_child_dir目录下

[whatyeditor@awstats test_dir]$ cd ../

[whatyeditor@awstats test_file_opt]$ cp -rv test_dir test_dir_cp

`test_dir' -> `test_dir_cp'

`test_dir/test_child_dir' -> `test_dir_cp/test_child_dir'

`test_dir/test_child_dir/test_child_file.jsp' -> `test_dir_cp/test_child_dir/test_child_file.jsp'

`test_dir/test_cp.jsp' -> `test_dir_cp/test_cp.jsp'

`test_dir/test_cp2.jsp' -> `test_dir_cp/test_cp2.jsp'

`test_dir/test_cp3.jsp' -> `test_dir_cp/test_cp3.jsp'

使用移动文件的命令对文件重命名:
[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_dir_cp  test.jsp

[whatyeditor@awstats test_file_opt]$ mv -v test.jsp test_rename.jsp

`test.jsp' -> `test_rename.jsp'

[whatyeditor@awstats test_file_opt]$ mv -r test_rename.jsp  test_rename_twice.jsp

mv: invalid option -- 'r'

Try `mv --help' for more information.

删除文件:
[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_dir_cp  test_rename.jsp

[whatyeditor@awstats test_file_opt]$ rm -i test_rename.jsp 

rm: remove regular empty file `test_rename.jsp'? y

[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_dir_cp

强行删除文件:
[whatyeditor@awstats test_file_opt]$ touch test_del.jsp

[whatyeditor@awstats test_file_opt]$ ls

test_del.jsp  test_dir  test_dir_cp

[whatyeditor@awstats test_file_opt]$ rm -f test_del.jsp 

[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_dir_cp

删除文件夹(如果文件夹为空,可以使用rmdir来删除;不论文件夹是否为空,文件夹都可以用rm来进行删除):
[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_dir_cp

[whatyeditor@awstats test_file_opt]$ rmdir test_dir_cp/

rmdir: failed to remove `test_dir_cp/': Directory not empty

[whatyeditor@awstats test_file_opt]$ rm -r test_dir_cp/

[whatyeditor@awstats test_file_opt]$ ls

test_dir

删除空文件夹:
[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_dir_cp

[whatyeditor@awstats test_file_opt]$ rmdir test_dir_cp/

rmdir: failed to remove `test_dir_cp/': Directory not empty

[whatyeditor@awstats test_file_opt]$ rm -r test_dir_cp/

[whatyeditor@awstats test_file_opt]$ ls

test_dir

[whatyeditor@awstats test_file_opt]$ cd ../

[whatyeditor@awstats ~]$ cd test_file_opt/

[whatyeditor@awstats test_file_opt]$ mkdir test_empty

[whatyeditor@awstats test_file_opt]$ ls

test_dir  test_empty

[whatyeditor@awstats test_file_opt]$ rmdir test_empty/

[whatyeditor@awstats test_file_opt]$ ls

test_dir

对文本的操作——希望能对vi工具的三种模式灵活使用

①文本的编辑操作:  使用vi命令打开文本文件后,按i即可进入插入模式(这个有用)
②按exc可以进入命令模式:
i 在光标前插入文本  (这种情况下就进入了插入模式,在文本的末尾会有 --INSERT--的提示)

o 在当前行的下面插入新行(这种情况下也会进入插入模式,在文本的末尾会有 --INSERT--的提示)

dd 删除正行

u 撤销上一个操作

yy 复制当前行

n+yy 先按5,接着按yy,则是将5行内容复制(这个我试了,不管用~)

p 粘贴

r 替换当前关键字(相当于windows操作系统下的insert键效果)

/ 查找关键字(这个很有用,便于在文本中查找关键词,比如查tomcat下的server.xml中某个web应用的部署情况)

③EX模式——在命令模式中按":"可以进入ex模式,在ex模式中可以保存、修改和退出
:w 保存当前修改
:q 退出
:q! 强制退出
:x 保存并退出(这个我很常用)
:setr number 显示行号( 这个是不正确的,要想显示行号,可以在命令模式下,执行:set
nu)
:! 执行一个系统命令并显示结果
:sh 切换到命令行,使用ctrl+d切换回vim

B.对权限的理解
对r w x和UGO有了理解;权限除了可以用字母表示外,还可以用数字来表示;
-R可以进行递归修改
使用chown 改变文件所属用户 ,使用chgrp 改变文件的所属组
工作中用到了一次chmod命令
[whatyeditor@awstats test_file_opt]$ ll

total 8

drwxrwxr-x 3 whatyeditor whatyeditor 4096 Mar 31 16:59 test_dir

-rw-rw-r-- 1 whatyeditor whatyeditor   27 Mar 31 17:16 test_vi.txt

[whatyeditor@awstats test_file_opt]$ chmod 444 test-vi.txt

chmod: cannot access `test-vi.txt': No such file or directory

[whatyeditor@awstats test_file_opt]$ chmod 444 test_vi.txt

[whatyeditor@awstats test_file_opt]$ ll

total 8

drwxrwxr-x 3 whatyeditor whatyeditor 4096 Mar 31 16:59 test_dir

-r--r--r-- 1 whatyeditor whatyeditor   27 Mar 31 17:16 test_vi.txt

[whatyeditor@awstats test_file_opt]$ chmod u+w test_vi.txt 

[whatyeditor@awstats test_file_opt]$ ll

total 8

drwxrwxr-x 3 whatyeditor whatyeditor 4096 Mar 31 16:59 test_dir

-rw-r--r-- 1 whatyeditor whatyeditor   27 Mar 31 17:16 test_vi.txt、

把目录test_dir下的权限进行递归修改,就是将一个文件夹及其下面的文件一起改变用户
[whatyeditor@awstats ~]$ chmod -r 744
test_file_opt/

chmod: cannot access `744': No such file or directory

[whatyeditor@awstats ~]$ chmod -R 744 test_file_opt/
[whatyeditor@awstats ~]$ ll
total 12
drwxrwxr-x 9 whatyeditor whatyeditor 4096 Feb 26 15:16 apache-tomcat-6.0.35
drwxrwxr-x 6 whatyeditor whatyeditor 4096 Mar  5 13:50 editor
drwxr--r-- 3 whatyeditor whatyeditor 4096 Mar 31 17:18 test_file_opt
[whatyeditor@awstats ~]$ cd test_file_opt/
[whatyeditor@awstats test_file_opt]$ ll
total 8
drwxr--r-- 3 whatyeditor whatyeditor 4096 Mar 31 16:59 test_dir
-rwxr--r-- 1 whatyeditor whatyeditor   27 Mar 31 17:16 test_vi.txt
[whatyeditor@awstats test_file_opt]$ cd test_dir/
[whatyeditor@awstats test_dir]$ ll
total 4
drwxr--r-- 2 whatyeditor whatyeditor 4096 Mar 31 09:58 test_child_dir
-rwxr--r-- 1 whatyeditor whatyeditor    0 Mar 31 10:08 test_cp2.jsp
-rwxr--r-- 1 whatyeditor whatyeditor    0 Mar 31 10:08 test_cp3.jsp
-rwxr--r-- 1 whatyeditor whatyeditor    0 Mar 31 10:02 test_cp.jsp

当然,还有其他方面的基础知识的了解。但这块印象很深刻。

现在只能说自己对linux的了解仅仅是入门级的。有个同时陶总很擅长shell脚本,回头学习一下。
希望自己打好基础,能了解嵌入式C的开发,将来作为兴趣自己设计点小玩意儿丰富自己的生活,该多棒啊~加油吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: