Linux基础系列:常用命令(1)
1、开启Linux操作系统,要求以root用户登录GNOME图形界面,语言支持选择为汉语
2、使用快捷键切换到虚拟终端2,使用普通用户身份登录,查看系统提示符
命令:ctrl+alt+F2
3、使用命令退出虚拟终端2上登录的用户
命令:exit
4、使用快捷键切换到虚拟终端5,使用管理员身份登录,查看系统提示符
命令:ctrl+alt+F5
5、使用命令退出虚拟终端5上登录的用户
命令:exit
6、切回图形界面,右单击桌面打开终端,输入关闭系统的命令
命令:ctrl+alt+F2
命令:init 0
7、查看哪些用户在系统上工作
命令:whoami
id 当前用户信息
who 当前登录用户
whoami 当前登录用户信息
:0 图形界面
pts图形界面打开的终端
tty 命令行登录的终端
8、修改当前时间为2018年8月26号11:28
命令:date -s '2018-08-26 11:28'
或者:date 082611282018 #按照 ‘月日时分年’ 的格式
9、查看2015年10月份日历
命令:cal 10 2015
10、使用两种方法查看ls命令的使用说明
命令:man - ls
或者:ls --help
11、清除屏幕
命令:clear
或者:ctrl+L
12、使用“useradd tom”命令新建tom用户,为tom用户设置密码“123”
命令:1)useradd tom
2)echo '123' | passwd --stdin tom
13、切换当前用户为tom
命令:su - tom
14、查看当前登陆Linux系统所使用的用户名
命令:whoami
15、开启Linux操作系统,要求以root用户登录GNOME图形界面
16、右击桌面打开终端,使用“useradd lucy”命令创建lucy用户
命令:useradd lucy
17、使用鼠标点击的方法进入根目录
18、点击进入root用户的家目录
路径: /root
19、点击进入lucy用户的家目录
路径: /home/lucy
20、点击进入用来存放常用的可执行文件的目录
路径: /bin
21、点击进入用来存放系统的可执行文件的目录
路径: /sbin
22、点击进入设备文件目录
路径:/dev
23、点击进入配置文件目录
路径:/etc
另:
home 用户文件
root 用户的家目录---》 /root
普通用户的家目录 –》 /home/用户名文件夹
pwd 查看当前所在路径
lib lib64 库文件
media opt mnt 挂载用件夹
proc 进程文件夹
run
tmp 临时文件夹
var 库文件
cd (change directory) 切换文件目录
~ 当前用户家目录
.. 代表上一层目录
- 代表上一次目录
touch 新建文件
mkdir 新建文件夹/目录
-p 递归建目录
rm 删除文件
-r 删除目录
–rf 强制删除文件、目录
ctrl+A 定位到命令行开头
ctrl+E 定位点命令行结尾
24、创建目录wg,使用绝对路径的方法在wg目录下新建文件a.txt
命令:1)mkdir wg
2)touch /wg/a.txt
25、进入wg目录,使用相对路径的方法在当前目录下新建wg01目录和b.txt文件
命令:1)cd /wg
2)mkdir -p wg01/b.txt
26、以长列表格式列出当前目录下的内容
命令:ls -l 查看/home目录:
27、删除空目录wg01
命令: rm -r /wg/wg01
或者:rm -rf /wg/wg01
28、进入上一级工作目录
命令:cd ..
29、强制删除非空目录wg
命令:rm -rf /wg
30、复制/etc/passwd到当前目录,名为file1
命令:1)mkdir /day4 在/ 目录下新建一个临时文件夹day4
2)cp /etc/passwd /day4/file1/
另:
cp 强制覆盖
cp –r 递归拷贝(源文件信息改变)
cp –a 保存原文件信息拷
31、不停的以只读的方式查看file1文件的内容
命令:tail -f /day4/file1
32、查看file1文件的前3行内容
命令:head -3 /day4/file1
33、查看file1文件的后2行内容
命令:tail -2 /day4/file1
34、以百分比的方式分页查看file1文件的内容
命令:more /day4/file1
35、以上下翻页的方法分页查看file1文件的内容
命令:less /day4/file
36、创建如下目录结构
sh-3.2# tree /FtpServer/
/FtpServer/
├── bin
│ ├── register.py
│ └── start.py
├── conf
│ └── settings.py
├── core
│ └── server.py
├── db
│ └── user.db
├── lib
│ └── common.py
└── log
└── access.log
命令:
1 [root@localhost /]# mkdir -p /FtpServe/bin 2 [root@localhost /]# mkdir -p /FtpServe/conf 3 [root@localhost /]# mkdir -p /FtpServe/core 4 [root@localhost /]# mkdir -p /FtpServe/db 5 [root@localhost /]# mkdir -p /FtpServe/lib 6 [root@localhost /]# mkdir -p /FtpServe/log 7 [root@localhost /]# touch /FtpServe/bin/register.py 8 [root@localhost /]# touch /FtpServe/bin/start.py 9 [root@localhost /]# touch /FtpServe/conf/settinfs.py 10 [root@localhost /]# touch /FtpServe/core/server.py 11 [root@localhost /]# touch /FtpServe/db/user.db 12 [root@localhost /]# touch /FtpServe/lib/common.py 13 [root@localhost /]# touch /FtpServe/log/access.log 14 [root@localhost /]# tree /FtpServe/
1:切换到路径/tmp下,以追加的方式往start.py内写入内容
命令:1) cd /temp
2)echo 'hedeyong_linux'>> /FtpServe/bin/start.py # > 为覆盖 >>为追加
查看当前所在的路径
命令:pwd
3:切换到log目录下,新建目录access,然后把access.log移动到该目录下。
命令:1)cd /FtpServer/log
2)mkdir access
3)mv /FtpServer/access.log /FtpServer/log/access/access.log
4:切换到core目录下,然后在该路径下新建auth.py文件
命令:1)touch /FtpServer/core/auth.py
5. 开启两个终端,一个终端往access.log文件中追加内容,然后在另外一个终端动态查看access.log新增的内容。
命令:1)tail -f /FtpServer/log/access/access.log # 动态监控accesss.log文件
2)echo 'hedeyong_linux' >> /FtpServe/log/access/access.log #网access.log文件追加内容
1、
2、
3、
6. 关闭上述的终端,然后以覆盖的方式往access.log中写入内容
命令:echo 'hedeyong_linux_lin2' > /FtpServe/log/access/access.log
7: 删除/FtpServer目录
命令:rm -rf /FtpServer/