关于MongoDB的学习计划
详见:https://blog.youkuaiyun.com/tyzh2010/article/details/111169621
本篇开始记录第二个课程的笔记
Source: MongoDB University https://university.mongodb.com/
Course: M103: Basic Cluster Administration
【Chapter 0】: Chapter 0: Introduction & Setup
这一节的主要讲了Linux操作系统的基本知识
Key points:
Introduction to Linux Basics
- Basics of Linux Directory Structure
- Important Definitions
- Concept of users in Linux
- Commands You Should Know
- Linux process management
1.Basics of Linux Directory Structure
不同于Windows系统,所有的文件都存在了 C、D、E盘等等,Linux系统中,所有的文件存在于一个树的结构中,起始于一个root节点。 root路径包含了全部文件夹以及全部路径。
root的代表符号是 /
Root包含常用路径有 /bin, /etc, /home,/root, /var等。更多路径详见(https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard)
/etc : 包含了系统的配置文件, Contains the system configuration files for the host computer. You should be careful when making changes to the files contained in this directory.
/home: 包含了用户的个人文件。
/var: 包含变量相关的文件。例如log 和 loc文件夹
2.Important Definitions重要的定义
-当前工作路径,当登陆Linux系统的时候,默认当前工作路径是/home ,用pwd (Print work Directory) 命令可查看当前工作路径。
-绝对路径, 文件完整的路径,从root开始的的路径,
-相对路径,与当前工作路径相关的路径。
例如:
当前文件夹是 mongodb
绝对路径: /data/mongodb/database/db1 (从root开始,第一个/代表root
相对路径: database/db1
3.Concept of users in Linux
1)linux是多用户操作系统,同一时间多个用户可同时操作。
有三种用户:root、regular 、service
root user:是linux系统里的主要用户,有着最高权限,系统安装的时候自动生成。也可以被称为 superuser 或者 administrator
regular user: 正常的用户,有着适当的权利。
2)sudo 命令 代表 supersuer do,这个命令可以给普通用户赋予最高权利(root权利)
3)权限: read 、write、execute三种权限
chmod 命令可以修改权限,详见(https://en.wikipedia.org/wiki/Chmod)
例:给m103-keyfile 修改权限为 read only.
chmod 400 /var/mongodb/pki/m103-keyfile
400代表着read-only权限,每个数字代表着一种权限。
- 0 = no permissions whatsoever; this person cannot read, write, or execute the file
- 1 = execute only
- 2 = write only
- 3 = write and execute (1+2)
- 4 = read only
- 5 = read and execute (4+1)
- 6 = read and write (4+2)
- 7 = read and write and execute (4+2+1)
详细见:https://www.december.com/unix/ref/chmod.html
4)所有权 Ownership
chown 命令可修改所有权
语法如下:
chown [new owner]:[group] <file name>
例:将/var/mongodb_directory的所有权更改为 myuser.
sudo chown myuser:myuser /var/mongodb_directory
如果文件属于root,需要用到sudo
4.Commands You Should Know
1) mkdir 创建一个新的文件夹
语法如下:
mkdir [modifiers] <name of the directory>
例:
mkdir -p /db/mongodb_data/
-p 代表如何需要的话创造一个parent 路径
If db directory already exists then this command will create only mongodb_data directory. Otherwise it will create the missing directory as well.
例:
sudo mkdir -p /var/data
2)rm 删除一个路径
语法如下:
rm [options] [directory|file]
删除文件以及该文件下面的所有子文件,谨慎操作
rm -rf <directory name>
3)ls The ls command is used to list information about files and directories within the file system.
To get a long listing of every file in a directory, including the hidden files, use
ls -la
4)cd 改变当前工作路径
语法如下:cd <directory>
5)cat 在termianl中查看文件
语法如下:cat <name of the file>
6)rm 从当前工作路径中移除某文件
语法如下:rm <file name>
5.Linux process management
1) ps命令
Linux中的 ps 命令是Process Status的缩写, ps 命令用来列出系统中当前运行的那些进程。 ps 命令可以列出当前进程的运行情况(状态、时间等信息)。
例:列出含有mongo的所有进程
ps -ef | grep mongo
参数
- -e,-A 显示所有进程
- -f 显示完整格式的输出
grep用来匹配字符
2)kill 命令
语法如下:kill <pid>