LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 05: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, 06:06 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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, 01: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, 02:57 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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, 11:41 AM   #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, 11:43 AM   #6
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

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

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

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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, 05: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, 12:36 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 12: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



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 10:34 AM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 06:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 06:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:39 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
Open Source Consulting | Domain Registration