a shortcut for linux( from linux journal )
来源:互联网 发布:天津软件学院一卡通 编辑:程序博客网 时间:2024/05/21 10:01
Of course, the world of pretty graphics and windows provides ways of creating symlinks. However, for the impatient, the command line allows you to do the job with less clicking around. Let's have a look at an example.
Suppose I'm working on a Web site, and I want all of the Web site files to be located in /home/jonesy/public_html/websites/testing/site1. I need to have quick access to this directory on a pretty regular basis, so it would be nice to have a shortcut on my desktop so I can get to it in a single click. It also would be nice to be able to drag files to the folder without having to browse to it first.
In this scenario, we call /home/jonesy/public_html/websites/testing/site1 the source directory, and I create that directory using the mkdir command. Follow along at home:
mkdir -p /home/jonesy/public_html/websites/testing/site1
Remember to change jonesy to your own login name.
Again, we've just created the source directory. The mkdir command creates a directory anywhere you have permission to do so. The -p option tells mkdir to create any parent directories along the way that don't already exist.
We call the symlink itself the target, and it points to the source we just created. Note that we can call the target whatever we want. In this case, I just call it site1. To make a link that shows up on my desktop, I open up Konsole and run the following command:
@cx:ln -s /home/jonesy/public_html/websites/testing/site1</n>/home/jonesy/Desktop/site1
Again, remember to change jonesy in the above command to your own login name.
The ln command can make other types of links besides symbolic links, so it's important to remember to feed it the -s option to let it know that you want to create a symbolic link. Though it happens, it is relatively rare to use the ln command without the -s option, even for hard-core geeks.
For Aspiring Geeks
If you forget the -s option, you'll create what's called a hard link. Though the differences are subtle, they are significant. Depending on the location of the link in relationship to the source, you can generate an error, because hard links cannot cross drive partition boundaries. In the guts of the system, the plain facts are that a hard link is actually just another alternative name for the same bunch of data stored somewhere on the disk (in technical terms, the hard link and the original file would point to the same inode).
But Wait! There's More!
Of course, making a link to a particular file is exactly like making a link to a directory. So, if I want to make a link to my favorite photo (/home/jonesy/Photos/mypic.jpg) on my desktop, I can do it like this:
ln -s /home/jonesy/Photos/mypic.jpg /home/jonesy/Desktop/
I threw in a little trick in the above command. Because I didn</#213>t want the symlink to have a different name from the file it points to, I simply use a . (period), which is shorthand for saying, don't change the name.
For more information about the ln command, try running
man ln
, which is the manual or man page for the ln command.
About the Author
Brian Jones is a system/network/database administrator and sometime Web developer for the Computer Science Department at Princeton University. He is also a freelance writer and editor, spending most of his freelance time writing about technology for various Web and print publications. In his free time, he enjoys brewing beer, home recording and playing billiards.- a shortcut for linux( from linux journal )
- linux for qq (create a shortcut )
- shortcut keys for linux
- linux shortcut
- [Linux Journal]Using DMA
- [Linux Journal]Understanding Caching
- DMA in linux journal
- Linux Terminal Shortcut
- Linux Shortcut Key
- [Linux Journal]LinuxBIOS at Four
- Linux Journal (Linux学报) 宣布停刊
- Linux下mongo启动报:Insufficient free space for journal files
- Create a shortcut for a program at user Desktop
- Switching From Windows to Nix or a Newbie to Linux – 20 Useful Commands for Linux Newbies
- Switching From Windows to Nix or a Newbie to Linux – 20 Useful Commands for Linux Newbies
- Switching From Windows to Nix or a Newbie to Linux – 20 Useful Commands for Linux Newbies
- Qt for Linux/X11 - Building from Source
- port from solaris to linux for c
- Teach Yourself Programming in Ten Years
- Thinking recursively
- CLISTCTRL SetItemState用法
- 汇编-32位寄存器的功能及其使用之整理篇
- the tips of Yum
- a shortcut for linux( from linux journal )
- 在线文档展示——M2M寻路算法论文
- 列车时刻表的数据存储策略
- 判断一个程序员是不是好的程序员
- Using std::basic_string the extensible way
- 项目管理之工作分解结构(WBS)
- 安装sql 2000提示挂起错误解决方法
- kerb stone
- Permission problem on a derived private method from public method