- 姓名:雷坛春
- 学号:201821121030
- 班级:计算1811
一、实验目的
熟练Linux命令行操作。
二、实验内容
- 使用
man
查询命令使用手册 - 基本命令使用
三、实验报告
1. 实验环境介绍
- 操作系统:Ubuntu 18.04.4 LTS
- 平台:虚拟机
leitanchun@leitanchun:~$ sudo lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic
2. 常用命令使用
1.pwd:查看当前所在目录
2.cd+路径:进入该路径
3.cd ..:返回上级
4.ls:查看当前目录下的文件
5.touch+文件名:创建文件
6.rm+文件名:删除文件
7.mkdir+文件夹名:创建文件夹
8.rmdir+文件夹名:删除文件夹
1 leitanchun@leitanchun:~$ pwd 2 /home/leitanchun 3 leitanchun@leitanchun:~$ cd Desktop 4 leitanchun@leitanchun:~/Desktop$ cd .. 5 leitanchun@leitanchun:~$ ls 6 Desktop examples.desktop 公共的 模板 视频 图片 文档 下载 音乐 桌面 7 leitanchun@leitanchun:~$ touch 201821121030.txt 8 leitanchun@leitanchun:~$ ls 9 201821121030.txt examples.desktop 模板 图片 下载 桌面 10 Desktop 公共的 视频 文档 音乐 11 leitanchun@leitanchun:~$ rm 201821121030.txt 12 leitanchun@leitanchun:~$ ls 13 Desktop examples.desktop 公共的 模板 视频 图片 文档 下载 音乐 桌面 14 leitanchun@leitanchun:~$ mkdir LTC 15 leitanchun@leitanchun:~$ ls 16 Desktop LTC 模板 图片 下载 桌面 17 examples.desktop 公共的 视频 文档 音乐 18 leitanchun@leitanchun:~$ rmdir LTC 19 leitanchun@leitanchun:~$ ls 20 Desktop examples.desktop 公共的 模板 视频 图片 文档 下载 音乐 桌面 21 leitanchun@leitanchun:~$
3. 剖析ps命令
ps
使用方法
1 EXAMPLES 2 To see every process on the system using standard syntax: 3 ps -e 4 ps -ef 5 ps -eF 6 ps -ely 7 8 To see every process on the system using BSD syntax: 9 ps ax 10 ps axu 11 12 To print a process tree: 13 ps -ejH 14 ps axjf 15 16 To get info about threads: 17 ps -eLf 18 ps axms 19 20 To get security info: 21 ps -eo euser,ruser,suser,fuser,f,comm,label 22 ps axZ 23 ps -eM 24 25 To see every process running as root (real & effective ID) in user 26 format: 27 ps -U root -u root u 28 29 To see every process with a user-defined format: 30 ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm 31 ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm 32 ps -Ao pid,tt,user,fname,tmout,f,wchan 33 34 Print only the process IDs of syslogd: 35 ps -C syslogd -o pid= 36 37 Print only the name of PID 42: 38 ps -q 42 -o comm=
ps
参数
1 SIMPLE PROCESS SELECTION 2 a Lift the BSD-style "only yourself" restriction, which is imposed 3 upon the set of all processes when some BSD-style (without "-") 4 options are used or when the ps personality setting is BSD-like. 5 The set of processes selected in this manner is in addition to 6 the set of processes selected by other means. An alternate 7 description is that this option causes ps to list all processes 8 with a terminal (tty), or to list all processes when used 9 together with the x option. 10 11 -A Select all processes. Identical to -e. 12 13 -a Select all processes except both session leaders (see getsid(2)) 14 and processes not associated with a terminal. 15 16 -d Select all processes except session leaders. 17 18 --deselect 19 Select all processes except those that fulfill the specified 20 conditions (negates the selection). Identical to -N. 21 22 -e Select all processes. Identical to -A. 23 24 g Really all, even session leaders. This flag is obsolete and may 25 be discontinued in a future release. It is normally implied by 26 the a flag, and is only useful when operating in the sunos4 27 personality. 28 29 -N Select all processes except those that fulfill the specified 30 conditions (negates the selection). Identical to --deselect. 31 32 T Select all processes associated with this terminal. Identical 33 to the t option without any argument. 34 35 r Restrict the selection to only running processes. 36 37 x Lift the BSD-style "must have a tty" restriction, which is 38 imposed upon the set of all processes when some BSD-style 39 (without "-") options are used or when the ps personality 40 setting is BSD-like. The set of processes selected in this 41 manner is in addition to the set of processes selected by other 42 means. An alternate description is that this option causes ps 43 to list all processes owned by you (same EUID as ps), or to list 44 all processes when used together with the a option.
1.ps
命令有很多参数,运行命令,比如ps -aux
,则系统返回如下结果:
1 leitanchun@leitanchun:~$ ps -aux 2 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 3 root 1 0.1 0.2 225352 5356 ? Rs 21:09 0:02 /sbin/init splash 4 root 2 0.0 0.0 0 0 ? S 21:09 0:00 [kthreadd] 5 root 3 0.0 0.0 0 0 ? I< 21:09 0:00 [rcu_gp] 6 root 4 0.0 0.0 0 0 ? I< 21:09 0:00 [rcu_par_gp]
参数解释:
1 a 显示现行终端机下的所有程序,包括其他用户的 程序 2 u 以用户为主的格式来显示程序状况 3 x 显示所有程序,不以终端机来区
字段解释:
1 USER: 进程拥有者 2 PID: pid 3 %CPU: 占用的 CPU 使用率 4 %MEM: 占用的记忆体使用率 5 VSZ: 占用的虚拟记忆体大小 6 RSS: 占用的记忆体大小 7 TTY: 终端的次要装置号码 (minor device number of tty) 8 STAT: 该行程的状态,linux的进程有5种状态: 9 – D 不可中断 uninterruptible sleep (usually IO) 10 – R 运行 runnable (on run queue) – S 中断 sleeping 11 – T 停止 traced or stopped 12 – Z 僵死 a defunct (”zombie”) process 13 – 注: 其它状态还包括W(无驻留页), <(高优先级进程), N(低优先级进程), L( 内存锁页). 14 START: 行程开始时间 15 TIME: 执行的时间 16 COMMAND:所执行的指令
2.ps
命令有很多参数,运行命令,比如ps -ef
,则系统返回如下结果:
1 leitanchun@leitanchun:~$ ps -ef 2 UID PID PPID C STIME TTY TIME CMD 3 root 1 0 0 21:09 ? 00:00:02 /sbin/init splash 4 root 2 0 0 21:09 ? 00:00:00 [kthreadd] 5 root 3 2 0 21:09 ? 00:00:00 [rcu_gp] 6 root 4 2 0 21:09 ? 00:00:00 [rcu_par_gp]
参数解释:
1 e 选择所有进程。与-A相同 2 f 做完整的格式列表。此选项可以与许多其他UNIX样式的选项组合,以添加其他列。它还导致命令参数被打印。与-L一起使用时,将添加NLWP(线程数)和LWP(线程ID)列。请参见c选项、format关键字args和format关键字comm。
字段解释:
1 UID: 代表执行者身份 2 PID: 进程的ID号 3 PPID: 父进程的ID 4 C: CPU使用的资源百分比 5 SZ: 使用的内存大小 6 RSS: 该进程占用的固定的内存量 (Kbytes) 7 PSR: 当前程序状态寄存 8 STIME: 系统启动时间 9 TTY: 终端的次要装置号码,该进程是在终端机上面运作,若与终端机无关,则显示。 10 TIME: 使用的 CPU 时间 11 CMD: 所下达的指令名称
4. 通过该实验产生新的疑问及解答
疑问:无法进入特权模式
解答:
1、运行终端,并输入以下代码
sudo passwd root
2、输入密码(此时无回显):xxxx(这里输入的是ubuntu系统的登录密码)
3、敲入一个新密码,这个密码就是之后我们进入ubuntu系统特权模式的密码
4、设置完成,以后我们再进入特权模式只需要输入su,再输入密码即可
来源:https://www.cnblogs.com/BarnettOne/p/12431287.html