新聞中心
在Linux操作系統(tǒng)中,文件路徑是指用來(lái)定位一個(gè)文件或目錄的字符串。對(duì)于經(jīng)常在Linux中工作的人來(lái)說(shuō),熟練掌握文件路徑的使用是非常重要的。

創(chuàng)新互聯(lián):2013年開(kāi)創(chuàng)至今為各行業(yè)開(kāi)拓出企業(yè)自己的“網(wǎng)站建設(shè)”服務(wù),為千余家公司企業(yè)提供了專業(yè)的成都網(wǎng)站制作、成都做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)和網(wǎng)站推廣服務(wù), 按需規(guī)劃網(wǎng)站由設(shè)計(jì)師親自精心設(shè)計(jì),設(shè)計(jì)的效果完全按照客戶的要求,并適當(dāng)?shù)奶岢龊侠淼慕ㄗh,擁有的視覺(jué)效果,策劃師分析客戶的同行競(jìng)爭(zhēng)對(duì)手,根據(jù)客戶的實(shí)際情況給出合理的網(wǎng)站構(gòu)架,制作客戶同行業(yè)具有領(lǐng)先地位的。
文件路徑可以分為絕對(duì)路徑和相對(duì)路徑兩種。相對(duì)路徑是相對(duì)于當(dāng)前工作目錄而言的路徑,而絕對(duì)路徑則是從根目錄開(kāi)始的路徑。相對(duì)路徑一般都比較簡(jiǎn)短,對(duì)于有些操作,使用相對(duì)路徑比絕對(duì)路徑更加方便。
下面我們來(lái)詳細(xì)講解。
1. 確定當(dāng)前工作目錄
在使用相對(duì)路徑時(shí),我們需要先確定當(dāng)前工作目錄??梢酝ㄟ^(guò)使用pwd命令來(lái)確定當(dāng)前目錄的路徑。
$ pwd
/home/user/documents
在這個(gè)例子中,當(dāng)前工作目錄是/home/user/documents。
2. 使用相對(duì)路徑訪問(wèn)文件
使用相對(duì)路徑來(lái)訪問(wèn)文件非常簡(jiǎn)單。如果我們要在當(dāng)前工作目錄下訪問(wèn)相對(duì)路徑為subdir/file的文件,只需要在命令行中輸入文件名即可。
$ cat subdir/file
在這個(gè)例子中,cat命令用來(lái)打印出subdir目錄下的file文件的內(nèi)容。
3. 使用相對(duì)路徑訪問(wèn)文件夾
使用相對(duì)路徑來(lái)訪問(wèn)文件夾同樣非常簡(jiǎn)單。如果我們要在當(dāng)前工作目錄下訪問(wèn)相對(duì)路徑為subdir的文件夾,只需要在命令行中輸入文件夾名即可。
$ cd subdir
在這個(gè)例子中,cd命令用來(lái)進(jìn)入subdir目錄。
4. 相對(duì)路徑表示父目錄和當(dāng)前目錄
有時(shí)候,我們需要使用相對(duì)路徑來(lái)表示父目錄和當(dāng)前目錄。在Linux中,表示當(dāng)前目錄的符號(hào)為.(一個(gè)點(diǎn)),表示父目錄的符號(hào)為..(兩個(gè)點(diǎn))。
例如,如果我們要在當(dāng)前工作目錄下打印出父目錄中的file文件的內(nèi)容,只需要輸入下面的命令。
$ cat ../file
在這個(gè)例子中,../表示父目錄下的文件。
5. 相對(duì)路徑中的~表示根目錄
在Linux中,~符號(hào)表示用戶的根目錄。如果我們要在任何目錄下都能訪問(wèn)用戶根目錄下的file文件,只需要輸入下面的命令。
$ cat ~/file
在這個(gè)例子中,~表示用戶根目錄。
相對(duì)路徑在Linux中的使用非常方便,可以簡(jiǎn)化文件路徑的編寫(xiě),同時(shí)也有利于提高工作效率。熟練使用相對(duì)路徑可以讓我們更加深入地理解Linux的文件系統(tǒng),更好地掌握它的使用方法。
相關(guān)問(wèn)題拓展閱讀:
- 如何設(shè)置linux環(huán)境變量?
- 虛擬機(jī)怎么安裝vmware tools
如何設(shè)置linux環(huán)境變量?
1、控制臺(tái)中設(shè)置,不贊成這種型差方式,因?yàn)樗粚?duì)當(dāng)前的shell 起作用,換一個(gè)shell設(shè)置就無(wú)效了:
直接控制臺(tái)中輸入 : $PATH=”$PATH”:/NEW_PATH (關(guān)閉shell Path會(huì)還原為原來(lái)的path)
對(duì)所有的用戶的都起作用的環(huán)境變量
2、修改 /etc/profile 文件,如果你的計(jì)算機(jī)僅僅作為開(kāi)發(fā)使用時(shí)推存使用這種方法,因?yàn)樗杏脩舻膕hell都有權(quán)使用這個(gè)環(huán)境變量,可能會(huì)給系統(tǒng)帶來(lái)安全性問(wèn)題。這里是針對(duì)所有的用戶的,所有的shell
vi /etc/profile
在/etc/profile的最下面添加: export PATH=”$PATH:/NEW_PATH”
針對(duì)當(dāng)前伏培特定的用戶起作用的環(huán)境變量
3、修改bashrc文件,這種方法更為缺租唯安全,它可以把使用這些環(huán)境變量的權(quán)限控制到用戶級(jí)別,這里是針對(duì)某一特定的用戶,如果你需要給某個(gè)用戶權(quán)限使用這些環(huán)境變量,你只需要修改其個(gè)人用戶主目錄下的 .bashrc文件就可以了。
vi ~/.bashrc
在下面添加:
Export PATH=”$PATH:/NEW_PATH”
可以多看看《linux就該這么學(xué)》希望可以幫到你
黑馬程序員老師告訴你:
暫時(shí)的:export MYNAME=”new name”
echo $MYNAME
new name
永久的:通過(guò)改變/etc/慎腔profile實(shí)現(xiàn)
EG: export CLASSPATH=./java_HOME/lib;$JAVA_HOME/jre/寬頃衫lib
更改文件后執(zhí)行 source /乎返etc/profile。
虛擬機(jī)怎么安裝vmware tools
現(xiàn)在的人們都會(huì)在電腦上裝一個(gè)虛擬機(jī),來(lái)安裝別的操作系統(tǒng),比如像“Red
Hat
Linux”不過(guò)在虛擬機(jī)運(yùn)行的時(shí)候,在跟虛擬機(jī)外面的操作系統(tǒng)切換時(shí)很痛苦啊!每次都得按“Ctrl”+“Alt”才能完成兩者之間的切換!忒痛苦,有木有??!各位童鞋。不過(guò)可以安裝一個(gè)虛擬機(jī)的插件就可以再兩者之間完成鼠標(biāo)平滑的切換,超爽。不過(guò)呢,有很多人在VMware
Workstation虛擬機(jī)安裝VMware
Tools時(shí)總是安裝不上,不知道是什么原因!我之前也是安裝了無(wú)數(shù)道,可是還是一纖冊(cè)樣!失敗。后來(lái)我去問(wèn)了我大學(xué)了老師,知道原來(lái)我的老師也是經(jīng)過(guò)了無(wú)數(shù)道的失敗才找到原因的!所以我把失敗的原因告訴大家,免得大家在苦惱了!
裝不上VMware
Tools的原因是VMware
Workstation虛擬機(jī)版本的問(wèn)題!只有“VMware
Workstation虛擬機(jī)7.0”版本才能裝上去。之前我用的是“VMware
Workstation虛擬機(jī)5.0”版本,所以一直都沒(méi)裝上去。后來(lái),我用了“VMware
Workstation虛擬租豎粗機(jī)1.0”在創(chuàng)建虛擬機(jī)的時(shí)候我把版本改成“VMware
Workstation虛擬機(jī)6.5-7.x”就可以了!
步驟如下:
進(jìn)入虛擬機(jī),待虛擬機(jī)完全啟動(dòng)好后!點(diǎn)擊虛擬機(jī)的菜單“虛擬機(jī)(M)”選擇“設(shè)置”
然后在設(shè)置里面的“硬件”下面選擇“CD/DVD(IDE)”!
然后在選項(xiàng)“使用ISO映像文件(M)”的“瀏覽(B)”選擇“VMware
Tools的映像文件”!
完成上的步驟后,點(diǎn)擊虛擬機(jī)的菜單“虛擬機(jī)(M)”選擇“安裝VMware
Tools(T)”
然后點(diǎn)擊”Computer“在彈出的窗口點(diǎn)擊“CD-EM/DVD+RW
Drive:VMware
Tools”
然后在彈出的窗口點(diǎn)擊紅色方弊鎮(zhèn)形。
然后在彈出的窗口點(diǎn)擊紅色方形,這是解壓到哪里的路徑。
然后在彈出的窗口點(diǎn)擊紅色方形,這是解壓到哪里的路徑。
選擇上面紅色方形里面的“Desktop”點(diǎn)擊右下角紅色方形“Extract”,解壓到桌面上。
這時(shí)回到桌面上去,會(huì)看到解壓到桌面上的文件“VMware-Tools-distrib”然后彈出窗口“vmware-tools-distrib”點(diǎn)擊里面的“vmware-intsall。pl”運(yùn)行文件!
點(diǎn)擊后彈出運(yùn)行”窗口“點(diǎn)擊紅色方形“Run
in
Terminal”
然后彈出命令窗口,選擇“y”鍵,之后就一直按Enter回車鍵!
這時(shí)會(huì)出現(xiàn)選擇分辨率的命令,根據(jù)自己的電腦分辨率就行了!
等命令窗口全部運(yùn)行完后!重啟系統(tǒng)就“OK”了
Linux VMware Tools安裝步驟簡(jiǎn)易版
Linux VMware Tools安裝估計(jì)有點(diǎn)困難,我也在網(wǎng)上看了好多版本的Linux安裝VMware Tools,方法都一樣。但是自己在安裝過(guò)程中,還是遇到了點(diǎn)問(wèn)題。但是最終還是搞定。我運(yùn)行的是VMware workstation 8.0.4 , OS: CentOS 6.0
1. 在CD-ROM虛擬光驅(qū)中選擇使用ISO鏡像,找到VMWARE TOOLS 安裝文件,如C:\program\VMware\VMware Workstation\Programs\linux.iso
當(dāng)然這個(gè)ISO是你安裝VMware workstation 的目錄下的Linux.iso,不是你的Linux OS 鏡像文件。VMware Tools一般都在這個(gè)文件里。
2. 以管理員身份進(jìn)入Linux,root賬號(hào)
3. 退出到windows,在虛擬機(jī)菜單欄中點(diǎn)擊 虛擬機(jī)盯櫻-> 安裝 VMWARE TOOLS 子菜單,會(huì)彈出對(duì)話框,點(diǎn)擊”確認(rèn)” 安裝
4. 掛載光驅(qū):Mount -t iso9660 /dev/cdrom /mnt
加載CDROM設(shè)備,這是如果進(jìn)入/mnt 目錄下,你會(huì)發(fā)現(xiàn)一個(gè)文件:
VMwareTools-8.8..tar.gz
這個(gè)就死VMware Tools的則察Linux軟件包,也是我們剛才使用的WinISO打開(kāi)的Liunx.ISO
有的虛擬機(jī)上估計(jì)執(zhí)行mount /dev/cdrom /mnt/cdrom
如果提示如下錯(cuò)誤,掛載點(diǎn)不存在。,#mount /dev/cdrom /mnt/cdrom
mount: mount point /mnt/cdrom dose not exist
請(qǐng)直接執(zhí)行此命令:
mount /dev/cdrom /opt
cd /opt
或者應(yīng)該可以使用自動(dòng)掛載,直接進(jìn)入
cd /misc/cd
5. copy 此文件到臨時(shí)文件夾
cp /mnt/mVMwareTools-8.8..tar.gz /tmp
6. 卸載CDROM,執(zhí)行 umount /dev/cdrom
7. 進(jìn)入tmp文件目錄并解壓此文件包
cd /tmp
tar zxf vmware-linux-tools.tar.gz
解壓默認(rèn)到vmware-tools-distrib目錄下:此時(shí)你可以使用ls -ll 查看文件夾下的文件
8. 進(jìn)入vmware-tools-distrib,安裝vmware tools.
./vmware-install.pl 執(zhí)行安裝,
安裝過(guò)程中他會(huì)一步一步的有問(wèn)題回應(yīng),此過(guò)程中,你遇到后面顯示,,的直接輸入yes,然后回車。其他的問(wèn)題不管里面是什么,直接回車就好了,不要輸入。
9. 大約5分鐘左右安裝完成。 執(zhí)行init 6重啟ok。
Linux VMware Tools安裝步驟圖文版,大家可以參考下
展臺(tái)搭建 機(jī)器視覺(jué)系統(tǒng) windows7旗艦版凱盯叢 電腦重裝系統(tǒng) arm9開(kāi)發(fā)板 科比球鞋 機(jī)器視覺(jué)
虛擬機(jī) 制作網(wǎng)頁(yè) 網(wǎng)頁(yè)制作模板 展臺(tái)搭建 科比球鞋 電腦系統(tǒng)重裝 windows7旗艦版
虛擬機(jī) 網(wǎng)站開(kāi)發(fā) 安德瑪籃球鞋 展臺(tái)搭建 網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)公司 html5網(wǎng)頁(yè)模板
網(wǎng)站開(kāi)發(fā) 安卓軟件開(kāi)發(fā) 電腦裝win7系統(tǒng) ios編程入門(mén) 蘋(píng)果刷機(jī) 外置顯卡 現(xiàn)在做什么賺錢(qián)
html5網(wǎng)站 u盤(pán)安裝系統(tǒng) html5模板 單片機(jī) 電腦重裝系統(tǒng) 女裝免費(fèi)代理 展臺(tái)搭建
近視眼恢復(fù) 恢復(fù)刪除文件 二合一平板電腦 u盤(pán)安裝系統(tǒng) 平板電腦排行榜 jordan 呼叫系統(tǒng)
操作過(guò)程如下:
# cd /
# ls
bin dev home lost+found misc net proc in srv tftpboot usr
boot etc lib mediamnt opt root selinux sys tmpvar
# cd /media
# ls
VMware Tools
# cd VMware\ Tools/
# ls
manifest.txt VMwareTools-8.1..tar.gz
# cp VMwareTools-8.1..tar.gz /tmp
# cd /tmp
# ls
gconfd-root scim-helper-manager-socket-root
keyring-lbbFvv scim-panel-socket:0-root
mapping-root scim-socket-frontend-root
orbit-root ssh-FmnVlj2751
scim-bridge-0.3.0.lockfile-0@localhost:0.0 virtual-root.ZxmHUV
scim-bridge-0.3.0.socket-0@localhost:0.0 VMwareTools-8.1..tar.gz
# tar -zxf VMwareTools-8.1..tar.gz
# ls
gconfd-root scim-panel-socket:0-root
keyring-lbbFvv scim-socket-frontend-root
mapping-root ssh-FmnVlj2751
orbit-root virtual-root.ZxmHUV
scim-bridge-0.3.0.lockfile-0@localhost:0.0 VMwareTools-8.1..tar.gz
scim-bridge-0.3.0.socket-0@localhost:0.0 vmware-tools-distrib
scim-helper-manager-socket-root
# cd vmware-tools-distrib/
# ls
bin doc etc FILES INSTALL installer lib vmware-install.pl
# ./vmware-install.pl
Creating a new VMware Tools installer database using the tar4 format.
Installing VMware Tools.
In which directory do you want to install the binary files?
yes
The path “yes” is a relative path. Please enter an absolute path.
In which directory do you want to install the binary files?
What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
What is the directory that contains the init scripts?
In which directory do you want to install the daemon files?
In which directory do you want to install the library files?
The path “/usr/lib/vmware-tools” does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
yes
In which directory do you want to install the documentation files?
The path “yes” is a relative path. Please enter an absolute path.
In which directory do you want to install the documentation files?
The path “/usr/share/doc/vmware-tools” does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want?
The installation of VMware Tools 8.1.3 buildfor 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?
Stopping VMware Tools services in the virtual machine:
Guest operating system daemon:
Virtual Printing daemon:
Unmounting HGFS shares:
Guest filesystem driver:
Found a compatible pre-built module for vmmemctl. Installing it…
Found a compatible pre-built module for vmhgfs. Installing it…
Found a compatible pre-built module for vmxnet. Installing it…
Found a compatible pre-built module for vmblock. Installing it…
The VMware FileSystem Sync Driver (vmsync) is a new feature that
creates backups of virtual machines. Please refer to the VMware Knowledge Base
for more details on this capability. Do you wish to enable this feature?
Found a compatible pre-built module for vmci. Installing it…
Found a compatible pre-built module for vsock. Installing it…
Found a compatible pre-built module for vmxnet3. Installing it…
Found a compatible pre-built module for pvscsi. Installing it…
Detected X.org version 7.1.
Host resolution detected as “1440 x 900”.
Please choose one of the following display sizes that X will start with:
“320×200”
“320×240”
“400×300”
“512×384”
“640×400”
“640×480”
“720×480”
“800×480”
“854×480”
“720×576”
“800×600”
“1024×768”
“1280×720”
“1280×768”
“1152×864”
“1280×800”
Warning:Multiple symbols for level 1/group 1 on key
> Using XF86Sleep, ignoring XF86Standby
> Warning:Symbol map for key redefined
> Using last definition for conflicting fields
Errors from xkbcomp are not fatal to the X server
X is running fine with the new config file.
FreeFontPath: FPE “unix/:7100” refcount is 2, should be 1; fixing.
Creating a new initrd boot image for the kernel.
Starting VMware Tools services in the virtual machine:
Switching to guest configuration:
Paravirtual SCSI module:
Guest filesystem driver:
Mounting HGFS shares:
Guest memory manager:
Guest vmxnet fast network device:
VM communication interface:
VM communication interface socket family:
Blocking file system:
File system sync driver:
Guest operating system daemon:
Virtual Printing daemon:
The configuration of VMware Tools 8.1.3 buildfor 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 X server session.
To enable advanced X features (e.g., guest resolution fit, drag and drop, and
file and text copy/paste), you will need to do one (or more) of the following:
1. Manually start /usr/bin/vmware-user
2. Log out and log back into your desktop session; and,
3. Restart your X session.
To use the vmxnet driver, restart networking using the following commands:
/etc/init.d/network stop
rmmod pcnet32
rmmod vmxnet
modprobe vmxnet
/etc/init.d/network start
Enjoy,
–the VMware team
Found VMware Tools CDROM mounted at /media/VMware Tools. Ejecting device
/dev/hdc …
#
網(wǎng)絡(luò)安全工程師演示:黑客如何安裝VMware-tools虛擬雹伏族源弊機(jī)增強(qiáng)工具廳衫?
relative path linux的介紹就聊到這里吧,感謝你花時(shí)間閱讀本站內(nèi)容,更多關(guān)于relative path linux,如何在Linux中使用相對(duì)路徑,如何設(shè)置linux環(huán)境變量?,虛擬機(jī)怎么安裝vmware tools的信息別忘了在本站進(jìn)行查找喔。
創(chuàng)新互聯(lián)服務(wù)器托管擁有成都T3+級(jí)標(biāo)準(zhǔn)機(jī)房資源,具備完善的安防設(shè)施、三線及BGP網(wǎng)絡(luò)接入帶寬達(dá)10T,機(jī)柜接入千兆交換機(jī),能夠有效保證服務(wù)器托管業(yè)務(wù)安全、可靠、穩(wěn)定、高效運(yùn)行;創(chuàng)新互聯(lián)專注于成都服務(wù)器托管租用十余年,得到成都等地區(qū)行業(yè)客戶的一致認(rèn)可。
網(wǎng)頁(yè)題目:如何在Linux中使用相對(duì)路徑(relativepathlinux)
網(wǎng)站鏈接:http://m.fisionsoft.com.cn/article/dhiopes.html


咨詢
建站咨詢
