虚拟机VM15 Ubuntu18.04写第一个c程序并实现ssh连接

输入“su”,再输入密码进入根用户

1.开启ssh服务

/etc/init.d/ssh start

  若没有安装会出现:

  

   (1).安装ssh

apt-get install openssh-server

   

   (2).若仍存在丢失问题,修复安装

apt-get install openssh-server --fix-missing

  

   (3).重启ssh服务并开启ssh服务

/etc/init.d/ssh restart
/etc/init.d/ssh start

  

  出现“OK”即成功

  service ssh restart  重启服务  service ssh stop  关闭服务 service ssh status 查看服务状态

 2.编写程序的方法(可在虚拟机或在xhell中):

(1)使用vi/vim编辑器书写

vi hello.c
或者
vim hello.c

(2)通过“touch hello.c”命令直接创建文件

touch hello.c

  再输入"gedit hello.c"命令,弹出编辑对话框

gedit hello.c

3.采用上述中的一种方法打开编写代码的界面,然后输入内容,如:

includ <stdio.h>
int main(){
   printf("hello!
");      
  return 0;  
}

  

  保存并退出

 4.编译文件

gcc hello.c -o hello

解释:gcc :gcc命令;hello.c: C源程序;-o:-o选项后接你想要执行的文件名,如“hello”

5.运行程序

./hello

在虚拟机中运行

         在xshell中运行

原文地址:https://www.cnblogs.com/Monster-su/p/12434083.html