大数据学习——linux常用命令(五)

1 挂载外部存储设备

可以挂载光盘、硬盘、磁带、光盘镜像文件等

1/ 挂载光驱

mkdir   /mnt/cdrom      创建一个目录,用来挂载

mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom/     将设备/dev/cdrom挂载到 挂载点 :  /mnt/cdrom

2/ 挂载光盘镜像文件(.iso文件)(Alt+P)

mount -t iso9660 -o loop  /home/hadoop/Centos-6.7.DVD.iso /mnt/centos

注:挂载的资源在重启后即失效,需要重新挂载。要想自动挂载,可以将挂载信息设置到/etc/fstab配置文件中,如下:

/dev/cdrom              /mnt/cdrom              iso9660 defaults        0 0

/root/CentOS-6.7-x86_64-bin-DVD1.iso    /mnt/centos     iso9660 defaults,ro,loop        0 0

3/ 卸载 umount

umount /mnt/cdrom

** 存储空间查看

df -h

2 统计文件或文件夹的大小

du -sh  /mnt/cdrom/packages   ## 统计指定路径下的所有子目录和文件的大小

df -h    查看磁盘的剩余空间

3 系统服务管理

service --status-all   # 查看系统所有的后台服务进程

service sshd status   # 查看指定的后台服务进程的状态

service sshd stop

service sshd start

service sshd restart

配置后台服务进程的开机自启

chkconfig httpd on  ## httpd服务开机自启

chkconfig httpd off  ## httpd服务开机不要自启

[root@localhost ~]# chkconfig httpd off

[root@localhost ~]# chkconfig --list | grep httpd

httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off

[root@localhost ~]# chkconfig --level 35 httpd on

[root@localhost ~]# chkconfig --list | grep httpd

httpd           0:off   1:off   2:off   3:on    4:off   5:on    6:off

4 系统启动级别管理

vi  /etc/inittab

# Default runlevel. The runlevels used are:

#   0 - halt (Do NOT set initdefault to this)

#   1 - Single user mode

#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)

#   3 - Full multiuser mode     ##  没有图形界面的全功能的多用户的启动级别

#   4 - unused

#   5 - X11           ##  有图形界面的启动级别

#   6 - reboot (Do NOT set initdefault to this)

#

id:3:initdefault:         ##  配置默认启动级别

## 通常将默认启动级别设置为:3

5 进程管理

top

free

ps -ef | grep ssh

kill -9 2358     ## 将指定进程号的进程杀死

注意:grep搜索关键词的时候会把自己也搜索出来,对比以下两种写法

[root@localhost ~]# ps -ef | grep sixunhuan

root       2857   2465 30 02:41 pts/0    00:00:07 sh sixunhuan.sh

root       2874   2858  0 02:42 pts/1    00:00:00 grep sixunhuan

[root@localhost ~]# ps -ef | grep sixunhuan | grep -v grep

root       2857   2465 34 02:41 pts/0    00:00:25 sh sixunhuan.sh

[root@localhost ~]# kill -9 2857

原文地址:https://www.cnblogs.com/feifeicui/p/10075364.html