Linux - 路径的表示

       一般情况下,在用shell的时候,或者你通过什么方式调用你的应用程序的时候,都要写明被调用的程序路径。路径分为绝对路径和相对路径。

绝对路径
      在Linux中,绝对路径是从 / (也被称为根目录)开始的,比如/usr、/etc/X11。如果一个路径是从/开始的,它一定是绝对路径,这样就好理解了。

   [root@localhost ~]# cd /usr/share/doc/      注:使用绝对路径进入doc目录
      [root@localhost doc]# pwd                        注:判断用户当前所处的位置                    
      /usr/share/doc                                          注:位于/usr/share/doc


相对路径
      在Linux中相对路径的使用相对于绝对路径来说是比较复杂的,在Linux路径中经常会一些特殊符号, 这些符号是用来表示相对路径的。

    .   表示用户所处的当前目录
    ..   表示上级目录
 ~  表示当前用户自己的home目录
 ~USER 表示用户名为USER的家目录,这里的USER是在/etc/passwd中存在的用户名

   使用“../”来表示上一级目录,“../../”表示上上级的目录,以此类推。


使用举例
例1: 
  c:/website/web/index.htm
  c:/website/img/photo.jpg
         
    在此例中index.htm中 链接 photo.jpg
      正确写法:使用“../img/photo.jpg”的相对路径来定位文件 

例2: 
  c:/website/web/xz/index.htm
  c:/website/img/images/photo.jpg
          
   在此例中index.htm中 链接 photo.jpg
     正确写法:可以使用../../img/images/photo.jpg的相对路径来定位文件

例3:
  c:/website/web/index.htm
  c:/website/web/photo.jpg
          
    在此例index.htm中 链接 photo.jpg
      正确写法:使用./photo.jpg的相对路径来定位文件 

例4:
     在本地硬盘有如下两文件,它们要互做超链接
     G:\site\index.htm
     G:\site\web\article\01.htm
     
     index.htm链接到01.htm
     正确的链接应该是:<a href=web/article/01.htm>链接文字</a>,
     
     01.htm要想链接到index.htm
     正确的链接应该是:<a  href=../../index.htm>返回首页</a>注:这里的../表示向上一级。

  • 13
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Linux Socket服务器端编程实例 例:建立一个Linux TCP服务器,等待客户端的连接请求,一旦接收到客户端请求,将客户端的IP地址和端口号打印出来,并且向客户端发送"Hello!Socket communication world!"字符串,然后关闭服务器。 0 Linux-Socket-服务器编程实例全文共13页,当前为第1页。 Linux Socket服务器端编程实例 Socket服务器编程中的头文件 #include<stdlib.h> stdlib 头文件即standard library标准库头文件。 该文件包含了的C语言标准库函数的定义,常用的函数如malloc()、calloc()、realloc()、free()、system()、atoi()、atol()、rand()、srand()、exit()等等。 1 Linux-Socket-服务器编程实例全文共13页,当前为第2页。 Linux Socket服务器端编程实例 #include<stdio.h> stdio 就是指 "standard input & output"(标准输入输出),所以,源代码中如用到标准输入输出函数时,就要包含这个头文件! 例如c语言中的 printf("%d",i); scanf("%d",&i);等函数。 2 Linux-Socket-服务器编程实例全文共13页,当前为第3页。 Linux Socket服务器端编程实例 #include<errno.h> 提供错误号errno的定义。查看错误代码errno是调试程序的一个重要方法。当linux C api函数发生异常时,一般会将errno变量(需include errno.h)赋一个整数值,不同的值表示不同的含义,可以通过查看该值推测出错的原因。 3 Linux-Socket-服务器编程实例全文共13页,当前为第4页。 Linux Socket服务器端编程实例 #include<string.h> string.h是预先定义好的函数库头文件,里面定义了一些字符串函数,如bzero等,添加这个头文件后才可以使用和字符串相关的操作函数 4 Linux-Socket-服务器编程实例全文共13页,当前为第5页。 Linux Socket服务器端编程实例 #include<netdb.h> Unix和Linux特有的头文件,主要定义了与网络有关的结构、变量类型、宏、函数等。所以在进行Socket网络编程时,必须要包含这个头文件。 5 Linux-Socket-服务器编程实例全文共13页,当前为第6页。 Linux Socket服务器端编程实例 #include<sys/types.h> 在应用程序源文件中包含 <sys/types.h> 以访问 整型、长整型和指针数据模型的定义。所有这些类型在 32位编译环境中保持为 32 位值,并会在64位编译环境中增长为 64 位值。 6 Linux-Socket-服务器编程实例全文共13页,当前为第7页。 Linux Socket服务器端编程实例 #include<netinet/in.h> 数据结构sockaddr_in就定义在这个头文件中。 #include<sys/socket.h> 这个头文件提供socket函数及相关数据结构 7 Linux-Socket-服务器编程实例全文共13页,当前为第8页。 Linux Socket服务器端编程实例 main函数中的参数 在Linux C语言中,main函数通常写作以下形式: int main(int argc,char *argv[]) 其中的两个参数argc和*argv[]是什么含义呢? 8 Linux-Socket-服务器编程实例全文共13页,当前为第9页。 Linux Socket服务器端编程实例 argc:命令行总的参数的个数,即argv中元素的个数。 *argv[ ]:字符串数组,用来存放指向字符串参数的指针数组,每一个元素指向一个参数。 9 Linux-Socket-服务器编程实例全文共13页,当前为第10页。 Linux Socket服务器端编程实例 argv[0]:指向程序的全路径名。 argv[1]:指向在DOS命令行中执行程序名后的第一个字符串。 argv[2]:指向第二个字符串。 … … 10 Linux-Socket-服务器编程实例全文共13页,当前为第11页。 Linux Socket服务器端编程实例 比如编译好的程序为my.exe 在命令行执行 my.exe 1 2 3 那argc就是4,argv[0]是"my.exe",argv[1]是"1",argv[2]是"2",argv[3]是"3"; 11 Linux-Socket-服务器编程实例全文共13页,当前
过程: 1.在虚拟机上安装了vmware,安装完成后,默认vm tools是没有安装的,启动后在下方提示没有安装虚拟工具,安装过程省略; 2.安装redhat,这个安装过程就省略,没安过的可以也去G一下; 3.安装vm tools: 1)以ROOT身份进入LINUX 2)按下 CTRL ALT组合键,进入主操作系统,点击VMWARE状态栏安装提示,或者点击 虚拟菜单下的安装虚拟机工具子菜单. 3)确认安装VMWARE TOOLS.   这时我们并没有真正的安装上了VMWARE TOOLS软件包,如果您点击菜单:DEVICES,您就会发现光驱的菜单文字变为:ide1:0-> C:\Program Files\VMware\VMware Workstation\Programs\linux.iso,这表示VMWARE将LINUX的ISO映象文件作为了虚拟机的光盘 4)鼠标点击LINUX界面,进入LINUX. 5)运行如下命令,注意大小写. mount -t iso9660 /dev/cdrom /mnt 加载CDROM设备,这时如果进入 /mnt 目录下,你将会 发现多了一个文件:vmware-linux-tools.tar.gz.这就是WMWARE TOOLS的LINUX软件包,也就是我们刚才使用WINISO 打开LINUX.ISO文件所看到的.   cp /mnt/vmware-linux-tools.tar.gz /tmp   将该软件包拷贝到LINUX的 TMP目录下.   umount /dev/cdrom   卸载CDROM.   cd /tmp   进入TMP目录   tar zxf vmware-linux-tools.tar.gz   解压缩该软件包,默认解压到vmware-tools-distrib 目录下(与文件名同名).   cd vmware-linux-tools   进入解压后的目录 这时要进入文本模式下运行下面的命令   ./install.pl 这时install提示你是否需要备份以前的配置文件,建议选择"y".   等待INSTALL运行完成后,这时键入 STARTX 命令,启动LINUX图形界面,vm中不再提示没有安装虚拟机工具了 在Ubuntu下安装VMware-Tools不像在Windows下安装容易,昨晚整了挺长时间终于安上了.方法在下面. 感谢提供方法的大侠! VMware Tools位置:VMware的安装路径\VMware\VMware Workstation\linux.iso 启动后按Esc选择recovery mode登陆.然后点击"虚拟机"→"安装VMware Tools". [root@rd01 ~]# mount /cdrom # 有时可能加载不了,这时就要先将系统关闭,再手动指定 ISO 映像: [root@rd01 ~]# cd /cdrom [root@rd01 ~]# ls -a [root@rd01 ~]# cp VMwareTools-5.5.1-19175.tar.gz /tmp [root@rd01 ~]# cd /tmp [root@rd01 ~]# tar zxpf VMwareTools-5.5.1-19175.tar.gz [root@rd01 ~]# cd vmware-tools-distrib [root@rd01 vmware-tools-distrib]# ./vmware-install.pl Creating a new installer database using the tar3 format. Installing the content of the package. # 安装过程的画面,全部使用默认值,一直按 Enter 就对了 In which directory do you want to install the binary files? [/usr/bin] What is the directory that contains the init directories (rc0.d/ to rc6.d/)? [/etc/rc.d] What is the directory that contains the init scripts? [/etc/rc.d/init.d] In which directory do you want to install the daemon files? [/usr/sbin] In which directory do you want to install the library files? [/usr/lib/vmware-tools] Thepath "/usr/lib/vmware-tools" does not exist currently. This programisgoingto create it, including needed parent directories. Is thiswhatyou want? [yes] In which directory do you want to install the documentation files? [/usr/share/doc/vmware-tools] Thepath "/usr/share/doc/vmware-tools" does not exist currently.Thisprogram isgoing to create it, including needed parent directories.Isthis what you want? [yes] The installation of VMware Tools 5.5.1 build-19175 for Linux completed successfully. You can decide to remove this software from your system at any time by invoking the following command: "/usr/bin/vmware-uninstall-tools.pl". Before running VMware Tools for the first time, you need to configure it by invoking the following command: "/usr/bin/vmware-config-tools.pl". Do you want this program to invoke the command for you now? [yes] Stopping VMware Tools services in the virtual machine: Guest operating system daemon: [ 确定 ] Trying to find a suitable vmhgfs module for your running kernel. The module bld-2.6.9-5.EL-i686-RHEL4 loads perfectly in the running kernel. pcnet32 30153 0 Unloading pcnet32 module Trying to find a suitable vmxnet module for your running kernel. The module bld-2.6.9-5.EL-i686-RHEL4 loads perfectly in the running kernel. Detected X.org version 6.8. 关闭控制台鼠标服务: [ 确定 ] 启动控制台鼠标服务: [ 确定 ] Please choose one of the following display sizes (1 - 13): # 显示分辨率,这里是以 1024x768 为例 # VMware Tools 安装的时候,会自动修改 X server 的配置文件 [1] "640x480" [2]< "800x600" [3] "1024x768" [4] "1152x864" [5] "1280x800" [6] "1152x900" [7] "1280x1024" [8] "1376x1032" [9] "1400x1050" [10] "1680x1050" [11] "1600x1200" [12] "1920x1200" [13] "2364x1773" Please enter a number between 1 and 13: [2] 3 X Window System Version 6.8.2 Release Date: 9 February 2005 X Protocol Version 11, Revision 0, Release 6.8.2 Build Operating System: Linux 2.6.9-34.EL i686 [ELF] Current Operating System: Linux rd01.domain 2.6.9-34.EL #1 Wed Mar 8 00:07:35 CST 2006 i686 Build Date: 04 May 2006 Build Host: x8664-build.centos.org Before reporting problems, check http://wiki.X.Org to make sure that you have the latest version. Module Loader present OSKernel: Linux version 2.6.9-34.EL (buildcentos@build-i386) (gccversion3.4.5 20051201 (Red Hat 3.4.5-2)) #1 Wed Mar 8 00:07:35 CST 2006P Markers: (--) probed, (**) from config file, (==) default setting, ( ) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. ( ) Log file: "/tmp/vmware-config0/XF86ConfigLog.3131", Time: Mon Jun 12 20:57:34 2006 ( ) Using config file: "/tmp/vmware-config0/XF86Config.3131" (WW) VMWARE(0): Failed to set up write-combining range (0xf0000000,0x1000000) X is running fine with the new config file. Starting VMware Tools services in the virtual machine: Switching to guest configuration: [ 确定 ] Guest filesystem driver: [ 确定 ] DMA setup: [ 确定 ] Guest operating system daemon: [ 确定 ] The configuration of VMware Tools 5.5.1 build-19175 for Linux for this running kernel completed successfully. You must restart your X session before any mouse or graphics changes take effect. You can now run VMware Tools by invoking the following command: "/usr/bin/vmware-toolbox" during an XFree86 session. To use the vmxnet driver, restart networking using the following commands: /etc/init.d/network stop rmmod pcnet32 rmmod vmxnet depmod -a modprobe vmxnet /etc/init.d/network start Enjoy, --the VMware team [root@rd01 vmware-tools-distrib]# shutdown -r now # 修改完成之后,重新启动计算机,让 VMware Tools 生效. == 重启后,你可能会发现还是要按"Ctrl Alt"释放鼠标(VM6.0没这问题了),我用的是5.5.3,要手动执行才有效果. 通过终端运行VMware-Tools: 点击Ubuntu桌面左上角的Applications→附件→终端,会打开一个类似Windows中记事本的程序,在里面输入以下内容($是自带的,不用专门输入): $ /usr/bin/vmware-toolbox 但如果你嫌麻烦,我们就需要让vmware-toolbox实现开机自动运行.点击 Ubuntu菜单:System→首选项→会话→Startup Programs,Add一个Name叫"vmware-toolbox",Command是"/usr/bin/vmware-toolbox"的启动 程序.这样每次开机后就能自动运行VMware Tools了.重启Ubuntu看看效果吧!(注意:vmware-toolbox并不是在后台隐藏运行的,启动后不要关闭). VMware Tools固然是个好东西,但也有副作用,比如说:虚拟机中的鼠标的滚轮不好使了.我们这样解决这个问题,还是打开终端,输入: $ sudo gedit /etc/X11/xorg.conf 这个命令使系统以root权限打开鼠标配置文件/etc/X11/xorg.conf.把文件中的 Option "Protocol" "ps/2" 改成 Option "Protocol" "IMPS/2" 重启Ubuntu搞定

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值