Linux是什么
开源、免费、稳定、安全的操作系统(OS)
- 命令行模式
- 目录结构
- 权限控制
Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn’t function.
What is Linux? - Linux.com
召唤Linux——阿里云服务器
- Mac上可用自带的terminal或iterms直接使用
- Windows需配置虚拟机或启动适用于Linux的Windows子系统
登录服务器
以Windows为例
下载 xSHELL 和xFTP
XSHELL - NetSarang Website
XFTP - NetSarang Website (xshell.com)
安装完成后打开xshell界面——新建会话——输入名称、及ip地址——用户名、密码
基本操作
pwd
: print working directory显示当前路径
bio03@VM-0-6-ubuntu:~$ pwd
/home/bio03
mkdir
:make directory-- 创建你的空目录
bio03@VM-0-6-ubuntu:~$ mkdir biosoft
bio03@VM-0-6-ubuntu:~$ mkdir project
bio03@VM-0-6-ubuntu:~$ mkdir tmp
bio03@VM-0-6-ubuntu:~$ mkdir scr
ls
显示列表
bio03@VM-0-6-ubuntu:~$ ls
biosoft project scr tmp
rm
删除对象
1.删除文件——rm
2.删除空目录 ——rmdir
3.删除非空目录 ——rm -r
bio03@VM-0-6-ubuntu:~$ rmdir tmp
bio03@VM-0-6-ubuntu:~$ ls
biosoft project scr
cd
接一个目录名,进入该目录
cd -
返回刚才的目录
bio03@VM-0-6-ubuntu:~$ mkdir rm_test
bio03@VM-0-6-ubuntu:~$ cd rm_test
bio03@VM-0-6-ubuntu:~/rm_test$ touch doodle.txt
bio03@VM-0-6-ubuntu:~/rm_test$ mkdir huahua
bio03@VM-0-6-ubuntu:~/rm_test$ cd huahua
bio03@VM-0-6-ubuntu:~/rm_test/huahua$ touch haha.txt
bio03@VM-0-6-ubuntu:~/rm_test/huahua$ cd -
bio03@VM-0-6-ubuntu:~/rm_test$ rm doodle.txt #删除doodle.txt
bio03@VM-0-6-ubuntu:~/rm_test$ rm -r huahua #删除整个花花目录
bio03@VM-0-6-ubuntu:~/rm_test$ cd
bio03@VM-0-6-ubuntu:~$ rmdir rm_test #删除rm_test
vi
新建脚本或文本文档
bio03@VM-0-6-ubuntu:~$ cd tmp
bio03@VM-0-6-ubuntu:~/tmp$ vi hello_world.txt
#Esc键退出编辑模式
#左下角输入
:x #保存并退出
cat
接文本文件名,查看并输出到屏幕,按q退出cat
head
输出前10行
tail
输出后10行
后面加上-n
自定义输出几行
bio03@VM-0-6-ubuntu:~/tmp$ cat hello_world.txt
I don't want to consider
if I'll be able to succeed.
Since I've decided to go to a distant place,
I'll try my best to make the trip.
bio03@VM-0-6-ubuntu:~/tmp$ head -n 4 hello_world.txt
I don't want to consider
if I'll be able to succeed.
Since I've decided to go to a distant place,
I'll try my best to make the trip.
bio03@VM-0-6-ubuntu:~/tmp$
cp
复制文件 cp file1 file2
bio03@VM-0-6-ubuntu:~/tmp$ cp hello_world.txt new_file.txt
bio03@VM-0-6-ubuntu:~/tmp$ ls
hello_world.txt new_file.txt
mv
将文件移入文件夹,重命名
mv file路径
mv file1 file2
bio03@VM-0-6-ubuntu:~/tmp$ mv new_file.txt home.txt #重命名文件
bio03@VM-0-6-ubuntu:~/tmp$ mv home.txt ~ #移动到主目录下
bio03@VM-0-6-ubuntu:~/tmp$ cd ~
bio03@VM-0-6-ubuntu:~$ ls
biosoft home.txt project scr tmp
解决以下几个问题
1.ls
输出的是横向的列表,怎样输出长格式列表(提示:搜索ls)
ls -l
2.如何查看长格式列表中文件的大小?(提示:ls)
ls -l -h
ls -lh
3.查看Linux系统版本、内存与硬盘空间?(提示:分别是三个命令)
查看Linux内核版本
cat/ proc /version
uname -a
查看内存
vmstat
sar
查看硬盘空间
df -h
4.怎样建立类似/tmp/tmp1/tmp1.1 这样的层级目录(提示:搜索mkdir)
mkdir -p tmp/tmp1/tmp1.1
5.怎样删除这些层级目录(提示:搜索rm)
rm -r tmp