Linux操作笔记

来源:互联网 发布:网络大电影计划 编辑:程序博客网 时间:2024/06/05 07:10

1.关闭死程序

[root@node3 ~]# ps -aux | grep fire
root 2105 0.0 0.0 112660 964 pts/0 S+ 15:10 0:00 grep –color=auto fire
root 10620 0.0 0.1 1215096 239328 ? Sl 1月11 19:02 /usr/lib64/firefox/firefox
[root@node3 ~]# kill -9 10620

2.动态显示

动态跟踪文件file的增长情况(output appended data as the file grows),tail会每隔一秒去检查一下文件是否增加新的内容,如果增加就追加在原来的输出后面显示。但这种情况,必须保证在执行tail命令时,文件已经存在
[root@webServer logs]# tail -f catalina.out

3.Ubuntu卸载软件

删除软件及其配置文件
apt-get –purge remove
删除没用的依赖包
apt-get autoremove

kylin@Ubuntu:~$ sudo apt-get remove --purge antkylin@Ubuntu:~$ sudo apt-get autoremove --purge ant

4.tar解压与压缩

解压到当前目录:
[root@webServer ~]# tar -zxvf xxx.tar.gz
解压到指定目录:
[root@hadron ~]# tar -zxvf xxx.tar.gz -C /opt
打包压缩命令:
[root@hadron ~]# tar -zcvf xxx.tar.gz xxx/

参数的意义

  • c Create a new archive.
  • t List the contents of an archive.
  • x Extract the contents of an archive.
  • f The archive file name is given on the command line (required whenever the tar output is going to a file)
  • M The archive can span multiple floppies.
  • v Print verbose output (list file names as they are processed).
  • u Add files to the archive if they are newer than the copy in the tar file.
  • z Compress or decompress files automatically.

5.CentOS7 设置截图的快捷键

1) 截图工具所在位置:应用(Applications)-工具(Utilities)-截图(Screenshot)
2) 快捷键设置的位置:应用程序(Applications)-系统工具(System Tools)-设置(Settings)-键盘(Keyboard)
3) 切换到快捷键选项卡:快捷键(Shortcuts),找到截图(Screenshots),单击右侧想要设置的项,按下要设置的快捷键即可(不用输入)。比如:我常用的是选定区域的截图(Save a screenshot of an area to Pictures),并且我使用的比较多的快捷键是QQ的截图快捷键(Ctrl+Alt+A)
这里写图片描述

6.hosts

Hosts文件是一个用于储存计算机网络中各节点信息的计算机文件。这个文件负责将主机名映射到相应的IP地址。hosts文件通常用于补充或取代网络中DNS的功能。和DNS不同的是,计算机的用户可以直接对hosts文件进行控制。
hosts文件在不同操作系统(甚至不同Windows版本)的位置都有所区别:

  • Windows系统
    一般在C:\WINDOWS\system32\drivers\etc目录下
  • Linux系统
    在/etc目录下

7.SSH

7.1 无选项参数运行 SSH

默认的,ssh 会尝试用当前用户作为用户名来连接。

[root@hadron ~]# ssh 192.168.1.160The authenticity of host '192.168.1.160 (192.168.1.160)' can't be established.ECDSA key fingerprint is ac:f1:e0:63:72:f7:1c:70:a5:4f:65:2b:ab:0d:9f:12.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.1.160' (ECDSA) to the list of known hosts.root@192.168.1.160's password: Last login: Wed Mar 15 00:39:04 2017 from 192.168.1.81[root@cnode0 ~]# exit登出Connection to 192.168.1.160 closed.

本示例命令中,ssh 会尝试用root的用户身份来登入192.168.1.160服务器

7.2 指定登录用户

因为192.168.1.156是Ubuntu服务器,不能使用root用户登录,这时可以指定用户登录。

[root@hadron ~]# ssh kylin@192.168.1.156The authenticity of host '192.168.1.156 (192.168.1.156)' can't be established.ECDSA key fingerprint is b2:34:8c:09:32:d2:1a:cb:cf:c2:60:ed:ad:d9:d7:46.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.1.156' (ECDSA) to the list of known hosts.kylin@192.168.1.156's password: Welcome to YHKylin 4.0-1D (GNU/Linux 3.14.57-20160128.kylin.4.server.generic+ aarch64)Last login: Tue Mar 15 09:00:09 2016 from 192.168.1.81kylin@tdh02:~$ 

8 scp

8.1 复制文件

命令格式1:
scp local_file remote_username@remote_ip:remote_folder
或者
scp local_file remote_username@remote_ip:remote_file

命令格式2:
scp local_file remote_ip:remote_folder
或者
scp local_file remote_ip:remote_file

命令格式1指定了用户名,命令执行后需要输入用户密码,第1个命令仅指定了远程的目录,文件名字不变,第2个指定了文件名(可以自定义文件名)
比如:

[root@anode1 ~]# scp ReadFile.jar root@192.168.1.81:/root/ReadFile2.jarroot@192.168.1.81's password: ReadFile.jar                             100% 1248     1.2KB/s   00:00

到81机器上查询

[root@hadron ~]# ls |grep ReadFile2.jarReadFile2.jar

命令格式2没有指定用户名,默认是当前用户”root”访问

[root@anode1 ~]# scp ReadFile.jar 192.168.1.81:/root/root@192.168.1.81's password: ReadFile.jar                             100% 1248     1.2KB/s   00:00    

到81机器上查询

[root@hadron ~]# ls |grep ReadFile.jarReadFile.jar

8.2 复制目录

命令格式:
scp -r local_folder remote_username@remote_ip:remote_folder

或者
scp -r local_folder remote_ip:remote_folder

9 终端显示样式

\33[0m 关闭所有属性
\33[1m 设置高亮度
\33[7m 反显

\33[30m – \33[37m 设置前景色
\33[40m – \33[47m 设置背景色

[root@hadron ~]# echo -e “\033[1m something here \033[0m”
something here
[root@hadron ~]# echo -e “\033[7m something here \033[0m”
something here
[root@hadron ~]# echo -e “\033[41;36m something here \033[0m”
something here
[root@hadron ~]#
这里写图片描述

0 0