LinuxQuestions.org
Register a domain and help support LQ
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 05-18-2009, 06:57 PM   #1
tigertim71
Member
 
Registered: Oct 2008
Location: London, England
Distribution: Puppy
Posts: 93

Rep: Reputation: 15
terminal commands in ubuntu


If I put in the terminal
Code:
cmp abc.txt acd.txt
, this isn't recognised (although this seems to be what is suggested in training manuals).

However, if I put in the full file path, instead of the file name (as above) it is accepted e.g.
Code:
/home/timk/Documents/abc.txt.
What's the best way to do this without writing out the whole file path?
 
Old 05-18-2009, 07:06 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You can't. If the file is not in your current directory, you must specify a path. If you use the absolute path you can run that command from any place in the directory tree. If you use a relative path you have to know the position of the file in respect of your current directory. For example:
Code:
$ cd
$ pwd
/home/timk
$ cmp Documents/abc.txt Documents/acd.txt
 
Old 05-19-2009, 02:02 AM   #3
tigertim71
Member
 
Registered: Oct 2008
Location: London, England
Distribution: Puppy
Posts: 93

Original Poster
Rep: Reputation: 15
OK, thanks. I suppose the above code would be normal for someone wanting to perform internal commands on a regular basis...
 
Old 05-19-2009, 03:57 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You can spare typing the full or relative path of the commands (if they are in a place included in the PATH environment variable) but for files you have always to tell the system where the files are. The unique search path for files is the current directory, whereas for executables (commands) the search path can have multiple directories (as specified by echo $PATH).
 
Old 05-19-2009, 12:41 PM   #5
tigertim71
Member
 
Registered: Oct 2008
Location: London, England
Distribution: Puppy
Posts: 93

Original Poster
Rep: Reputation: 15
terminal commands in ubuntu

Was just wondering about the
Code:
$
in the above code - is this needed and what does it stand for?

I'm just not sure I understood fully the previous answer.
 
Old 05-19-2009, 12:43 PM   #6
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
$ is the promt from a user
# is the prompt from root

Code:
repo@cannabis:~$ su
Password: 
cannabis:/home/repo#
 
Old 05-19-2009, 12:53 PM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
As repo said. I put the prompt in the posted code to distinguish between the commands I type and the output I get:
Code:
$ whoami   ### This is the command
colucix    ### This is the output
 
Old 05-19-2009, 06:14 PM   #8
tigertim71
Member
 
Registered: Oct 2008
Location: London, England
Distribution: Puppy
Posts: 93

Original Poster
Rep: Reputation: 15
terminal commands in ubuntu

This makes perfect sense now, and I can understand this from the setup process of various Linux apps.

It's interesting that the terminal in Ubuntu is defaulted to $ , however Puppy and Knoppix are in root with #, but I suppose the programmers of each application had something different in mind, with Puppy and Knoppix more suited to being used as live cds.
 
Old 05-20-2009, 01:36 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
No, as pointed out the default prompt char/string is '$' if you are not root, '#' if you are root.
However you can customise it if you want (google "linux PS1").
 
Old 05-20-2009, 01:37 AM   #10
Quads
Member
 
Registered: Jul 2008
Location: Indiana
Distribution: Fedora, Ubuntu, Slackware
Posts: 203

Rep: Reputation: 34
Quote:
Originally Posted by tigertim71 View Post
This makes perfect sense now, and I can understand this from the setup process of various Linux apps.

It's interesting that the terminal in Ubuntu is defaulted to $ , however Puppy and Knoppix are in root with #, but I suppose the programmers of each application had something different in mind, with Puppy and Knoppix more suited to being used as live cds.
I don't know about Knoppix, but in Puppy you are always root.
 
  


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
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 11:34 AM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 07:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 07:53 AM


All times are GMT -5. The time now is 04:32 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration