A. Installing Ubuntu
- Main page (do not select Chinese, because this version has bug)
- The default host name to
- Set the user name
- Set a password and confirm the password back
- It is not the use of weak passwords password
- Encrypt Folder
- Select the disk partition format
-
LVM disk partition must be the format, in particular under the production environment
- Whether to write Lvm
- And whether the change is written to disk
- Do you want to configure a proxy server, do not configure
-
Do you want to automatically update, do not choose to automatically update
-
The pre-selection service, simply select a pre-installed services, press (spacebar) selections on and
-
Whether the grub boot partition
-
The installation is complete
Two .Linux remote connection, the connection can be used xshell
Three .Linux directory structure
- Here the first clone this virtual machine
- Firstly shutdown shutdown command: sudo shutdown -h now
- Shutdown operation after cloning
- Directory Structure
-
-
- ls view the current directory, what if your current user is not the root directory, then use the ls command can not see, because not in the root directory
- pwd view the current path where you are
- cd / switch to the root directory, then this time you use such as ls or ll or ls -s command you can see the current Linux directory structure of the course layout root directory of a different command displays may have different settings
- More important usr file directory is usually installed to / user / local we manually installed / directory
- var directory to store important data files directory
-
IV. Operating directory
- Into their own user directory using the cd home / it suchuanqi enters their user directory in the root directory
-
Love you create a folder using mkdir download in its own folder, create a single folder
- Parent directory generated directly create folders mkdir -p download / soft / vm
-
Generates an empty file touch test.txt can create an empty file with the command
-
echo intended meaning of the text is printed for example using echo "helloWorld" at any location, the system will print the text in the console (just a simple print)
- 我们也可以使用echo把文本写入到某个文件夹中echo "helloWorld" > text.txt,这里的text.txt就是一个txt文件
- 我们可以使用cat text.txt 对某个文件的内容进行查看
-
使用echo命令进行对同一个文件的内容进行追加操作echo "helloLinux" >> text.txt
- cp文件复制:使用cp text.txt text1.txt cp表示赋值 text.txt表示目标文件,赋值到新建的text1.txt
- rm删除:
- rm text1.txt 删除某个文件在某个文件夹下的操作
- rm -rf text.txt 删除文件夹及文件的操作
- mv移动:mv text.txt text1.txt 把text.txt 移动到新建文件text.txt
-
find查找:find -name text1.txt 在文件夹中查找指定的文件
-
grep管道命令在指定的文本文件中查找指定的字符串:cat text1.txt | grep Linux 通过cat命令和grep命令一起使用查找有Linxu的一行数据
-
tree当前系统没有装不说了
-
pwd查看当前目录
-
ln建立软连接后面说
-
more 分页显示文件内容
- 首先通过绝对路径进入cd /etc/apt/目录
- 使用 cat sources.list命令会全部显示所内容
- 使用 more sources.list 会分页显示内容
-
使用 head sources.list会显示文件开头内容
- 使用 tail sources.list会显示文件结尾内容
五.系统管理命令
-
stat:显示文件的详细信息:
- 首先进入cd /home/suchuanqi/download/sort/vm/进入vm目录开始使用stat命名
-
使用 stat text1.txt进行查看文件
-
who:使用who命令显示当前在线用户
- hostname:显示主机名称
- uname:显示系统信息
- top:显示当前系统中耗费资源最多的进程,他相当于windows的任务管理器,使用top命令后打开的进程称为前台程序,他会卡住你的主线程,此时你做什么的话是没有任何反应的 按住ctrl + c退出top了
- ps:显示瞬间的进程状态
-
du:显示指定的文件(目录)已使用的磁盘空间的总量。只写一个命令du是看不什么东西的,他是给计算机看的。如果想给人看我们可以使用 du -h命令
-
df:命令显示文件系统磁盘空间的使用情况。如果想给我们自己看可以使用df -h命令
-
free:显示当前内存和交换空间的使用情况
-
ifconfig显示网络接口信息
-
ping:会卡主当前主线程-----如ping www.baidu.com
-
netstat:显示网络状态信息
-
kill:杀死一个进程
-
在shell中使用top打开任务管理器然后开另外一个窗口来进行操作
-
先使用管道命令来进行查看---------ps -ef | grep top
-
然后使用命令kill -9 1767来进行杀死进行 1767为top的进程编号
-
六.开关机命令
-
重启命令:
-
sudo reboot
- sudo shutdown -r now
-
- 关机命令:
-
- sudo init 0
- sudo shutdown -h now
七.压缩命令
-
这里主要说的tar的方式:
-
tar -zcvf download.tar.gz download/ 把download文件夹打包
- tar -zxvf download.tar.gz 把download文件解压
- 删除的另外一种方,这里要对download及该文件里面的内容进行学习
- rm download 不能够删除,因为该文件夹下面有内容,所以应该使用下面的强制删除
- rm -fr download 强制删除文件夹及文件里面的文件
-
八.Linux编辑器
-
vi操作文件是删除整行数据的键盘操作为双击d键,还要进入编辑模式才可以,不是插入模式或命令模式
九.Linux的软件包管理
- APT(Advanced Packaging Tool) 是 Debian/Ubuntu 类 Linux 系统中的软件包管理程序, 使用它可以找到想要的软件包, 而且安装、卸载、更新都很简便;也可以用来对 Ubuntu 进行升级; APT 的源文件为 /etc/apt/ 目录下的 sources.list 文件
十.修改数据源 (linux下的粘贴为Shift+Insert 复制为Ctrl+Insert)
- 由于国内的网络环境问题,我们需要将 Ubuntu 的数据源修改为国内数据源
-
首先查看版本:lsb_release -a,使用这个命令主要来查看他的版本操作,如下所示:
-
suchuanqi@localhost:~/download/sort/vm$ lsb_release -a
-
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial ----------主要关注的这里名字,每一个版本的名字都不一样
注意: Codename 为 xenial,该名称为我们 Ubuntu 系统的名称,修改数据源需要用到该名称
-
- 然后编辑数据源:使用命令 cd /etc/apt进入到apt目录下,然后使用命令 vi sources.list进入该文件中进行从新编译即可,在编译的过程中可能会出现问题,如下所示:
-
在修改数据源的时候如果出现了sources.list" E212: Can't open file for writing时,是告诉我们
没有修改该文件的 权限所以我们应该加上管理员的权限才可以----具体的操作如
sudo vi sources.list 然后把里面内容全部删除掉替换换下面的内容即可
然后把下面这段话替换掉里面所有的内容即可:
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
-
- 然后wq退出操作即可
-
那么当前的文件修改完数据源后并没有生效我们还要使用命令sudo apt-get update来更新数据源,让更新后的数据源生效
十一.常用的APT命令(注意以下命令如果没有没有权限使用的话在前面写上 sudo命令进行权限授予)
-
安装软件包:apt-get install packagename
-
使用它安装nano--具体命令是:sudo apt-get install nano
-
找到home文件夹下text.txt文件 的目录输入 nano text.txt进行编辑该文件的操作
-
保存nano编译的文件使用 Ctrl+x+y即保存并退出 安装 tree软件包:apt-get install tree
- 在这里我们可以使用下建立软连接(ln就是把某个目录或文件的快捷方式放到某个目下即可)
-
ln download/soft/vm/test.txt test.txt
我们可以通过tree命令看到软连接的那个目录:
├── download
│ ├── loft
│ │ └── test1.txt
│ └── soft
│ └── vm
│ └── test.txt
├── download.tar.gz
└── test.txt
- 删除软件包:apt-get remove packagename
- 卸载tree软件包:sudo apt-get remove tree
-
更新软件包:apt-get update
- 升级有可用更新的系统(慎用,尤其是系统升级是不能做的):apt-get upgrade
-
(以下是其它 APT 命令)
-
搜索:apt-cache search package
-
获取包信息:apt-cache show package
-
删除包及配置文件:apt-get remove package --purge
-
了解使用依赖:apt-cache depends package
-
查看被哪些包依赖:apt-cache rdepends package
-
安装相关的编译环境:apt-get build-dep package
-
下载源代码:apt-get source package
-
清理无用的包:apt-get clean && apt-get autoclean
-
检查是否有损坏的依赖:apt-get check
-