LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-10-2010, 06:21 PM   #31
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60

Point taken. It wasn't taken personally.
 
Old 03-11-2010, 02:59 AM   #32
runinguy
LQ Newbie
 
Registered: Mar 2010
Location: CA
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bret381 View Post
you can move executables to your /usr/bin directory and you won't have to use the ./ in front of it
I don't know what would be required to move each executable from its source code directory to this /usr/bin directory, but it seems like it would be simpler to type ./ before each executable. Maybe someone can enlighten me on what the /usr/bin directory is, and how I would go about moving these executable files to there, and then I can make a more informed decision.

Also, I would still like to know exactly what it is that I am doing when I use the ./ command?
 
Old 03-11-2010, 03:45 AM   #33
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Quote:
Originally Posted by runinguy View Post
Also, I would still like to know exactly what it is that I am doing when I use the ./ command?
You should definitively read something about where the shell look for commands and the PATH environment variable. Here is a good starting point.

Personally, I'd not put my own executables in /usr/bin, since this is the place where many system wide commands are placed (moreover you need root privileges to add/remove something from /usr/bin). Better to keep them in your HOME directory, for example in /home/user/bin (user being your true user name). Furthermore, this directory is already listed in the PATH environment variable by many Linux distributions.

Hope this helps.
 
Old 03-11-2010, 12:59 PM   #34
runinguy
LQ Newbie
 
Registered: Mar 2010
Location: CA
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
You should definitively read something about where the shell look for commands and the PATH environment variable. Here is a good starting point.

Personally, I'd not put my own executables in /usr/bin, since this is the place where many system wide commands are placed (moreover you need root privileges to add/remove something from /usr/bin). Better to keep them in your HOME directory, for example in /home/user/bin (user being your true user name). Furthermore, this directory is already listed in the PATH environment variable by many Linux distributions.

Hope this helps.
Hey that's great thanks for the link, very informative.

Through my experimentation, it seems then that to move a file from its current directory to a subdirectory I use the command mv, then the name of the fie, then the name of the subdirectory into which I want to move the file. What if I want to go in the other direction though? For example:

BenardLenards-MacBook-Pro:g95 BenardLenard$ mv g95manual.pdf "fortran code files"
BenardLenards-MacBook-Pro:g95 BenardLenard$ ls
Fortran Code Files bin
INSTALL lib
BenardLenards-MacBook-Pro:g95 BenardLenard$ cd "fortran code files"
BenardLenards-MacBook-Pro:fortran code files BenardLenard$ ls
a.out g95manual.pdf ini_1.f95 ini_2.f95
BenardLenards-MacBook-Pro:fortran code files BenardLenard$ pwd
/Users/BenardLenard/g95/fortran code files
BenardLenards-MacBook-Pro:fortran code files BenardLenard$ ls
a.out g95manual.pdf ini_1.f95 ini_2.f95
BenardLenards-MacBook-Pro:fortran code files BenardLenard$ mv g95manual.pdf g95
BenardLenards-MacBook-Pro:fortran code files BenardLenard$ ls
a.out g95 ini_1.f95 ini_2.f95
BenardLenards-MacBook-Pro:fortran code files BenardLenard$

Here we can see that I have moved the file "g95manual.pdf" from the G95 directory into the subdirectory "Fortran Code Files" with success. Then, when trying to move the same file back to its original position, I seem to have somehow renamed the file to "g95" instead of moving it to the g95 directory.

My questions are:
How can I rename it to what it originally was.
How can I move the file to where it originally was.

(on a side note, what does the command "cd `" do? I accidentally entered this instead of "cd ~" and it gave me a ">".
 
Old 03-11-2010, 01:14 PM   #35
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
I would recommend you not use spaces in filenames, they are difficult to deal with because the shell assumes that spaces separate a list of filenames.
 
Old 03-11-2010, 01:44 PM   #36
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Code:
mv g95manual.pdf g95
This caused the file g95manual.pdf to be renamed as g95. What you really need when moving/copy files is to specify an absolute or relative path for the destination directory. Examples:
Code:
mv g95manual.pdf ..     # .. is a shortcut for the upper level directory

mv g95manual.pdf g95    # it moves the file in the g95 directory at the
                        # same level (if it exists, otherwise it simply
                        # renames the file as "g95" - this is what happened)

mv g95manual.pdf ./g95  # same as above, but we have specified a
                        # relative path here, where . is a shortcut
                        # for the current working directory

mv g95manual.pdf /Users/BenardLenard/g95
                        # full (absolute) path here: no way to mis-understand:
                        # the shell moves the file in that exact location (if it
                        # exists, otherwise move it to /Users/BenardLenard/ and
                        # rename it as "g95" at the same time
Hopefully, now you should be able to rename the file "g95" as "g95manual.pdf" and move it to its original location!
Quote:
cd `
Here you (accidentally) used an opening reverse quote (backtick) and the shells expects a closing one to complete the pair. When you press enter, the shell just offers its secondary prompt (the symbol ">" you have seen) to let you complete the command line. If you had typed another backtick and pressed enter the command would have been actually executed. You can try that and see what happens (trust me, nothing harmful... just use the pwd command after that, to see what is your current directory)
Code:
cd `
> `
 
Old 03-11-2010, 02:11 PM   #37
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
The way the backticks work is that they are substituted for the output of the command in them.

Code:
$ pwd
/home/michael
$ cd `echo '..'`
$ pwd
/home
The output of echo '..' is a pair of dots, which are then substituted for the backticks and their contents.

Note that the backticks are sometimes considered "deprecated". This is the new way:

Code:
$ pwd
/home/michael
$ cd $(echo '..')
$ pwd
/home
The $() is not as easily confused for single quotes, and also it makes nesting easier.
 
Old 03-11-2010, 04:06 PM   #38
runinguy
LQ Newbie
 
Registered: Mar 2010
Location: CA
Posts: 9

Original Poster
Rep: Reputation: 0
So it seems that the ticks can be used to embed one command within another. Why is it then that if I put nothing between the ticks, for example:
Code:
 cd ``
or
Code:
 cd `
>`
it takes me directly to my user directory?

Also, if . is a shortcut for the current working directory, what is the / for?
 
Old 03-11-2010, 05:06 PM   #39
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
The default action for cd is to change to your home directory. cd `` is equivalent to cd.

Path name components are separated by /, so when you specify the current directory with ., a slash must separate it from the file name following.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLC + sudo = "cannot find any file in directory" error skubik Linux - General 3 11-30-2009 02:52 PM
Error: "libdmx.so.1: cannot open shared object file: No such file or directory" ESC201 Linux - Software 4 11-01-2008 09:38 PM
Format command shows "Cannot get current directory - I/O error" devn Solaris / OpenSolaris 1 06-18-2008 02:26 AM
Error in man command "sh: line 1: /usr/bin/gtbl: No such file or directory" MinA Slackware 1 09-06-2004 07:36 PM
error while trying to install program: "X11/Xlib.h: No such file or directory" nate1 Linux - Newbie 3 05-21-2004 09:08 AM


All times are GMT -5. The time now is 11:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration