Solved

Unix Command Clarification

Posted on 2012-03-22
29
363 Views
Last Modified: 2012-04-11
Hello Experts,

I'm getting the following error message when I try and enter the directory command ls or ls -l

Get someone shed some light on the issue.

Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
carltonp@access-server:~$

or

carltonp@access-server:~$ ls -l
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
carltonp@access-server:~$

Cheers

Carlton
0
Comment
Question by:cpatte7372
  • 13
  • 7
  • 5
  • +1
29 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 37753090
Why don't you include /bin in PATH? try adding it with

PATH=$PATH:/bin ; export PATH
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37753098
PATH is a variable which contains a string composed of the names of a number of directories.

These directories are searched by the shell for commands when you enter a command without a path specification.

Issue

export PATH=/bin/:/usr/bin

Now ls should work.

To make this setting permanent edit /etc/environment, with

sudo nano /etc/environment
or
sudo vi /etc/environment.

Look for the PATH=... line and correct (or add) it to look like this:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

or the like.
0
 
LVL 76

Expert Comment

by:arnold
ID: 37753101
echo $PATH
PATH=/bin/:$PATH
export PATH

You may have a .login .profile .bashrc, etc. that redefines the PATH omitting the default system settings i.e. not including the $PATH on the end..
0
 

Author Comment

by:cpatte7372
ID: 37753143
To be totally straight I'm trying to find what directory a file called startup-config is located. I thought that ls -l would point me in the right direction - I'm a total newbie with unix.

Is there a command that I can use to find files, and their locations?

Cheers
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 37753157
try this command to find files

find / -name startup-config -exec ls -l {} \;
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 37753160
Try "find"

"man find" will tell you more. Basically it's

find / -type f -name "startup-config"

By the way, this file is most probably in /etc or one of its subdirectories, so try first

find /etc -type f -name "startup-config"
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 37753165
Or simply use below command for location

find / -name startup-config
0
 

Author Comment

by:cpatte7372
ID: 37753233
When I entered the command:

find /etc -type f -name "startup-config"

I got the following...

carltonp@access-server:~$ find /etc -type f -name "startup-config"
find: `/etc/ppp/peers': Permission denied
find: `/etc/ssl/private': Permission denied
find: `/etc/chatscripts': Permission denied
find: `/etc/skel/.ssh': Permission denied
find: `/etc/skel/.config/gtk-2.0': Permission denied
find: `/etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml': Permission denied
find: `/etc/skel/.config/xfce4/panel': Permission denied
find: `/etc/skel/.config/xfce4/desktop': Permission denied
find: `/etc/skel/.config/xfce4/xfwm4': Permission denied
find: `/etc/skel/.config/Terminal': Permission denied
find: `/etc/skel/.config/Thunar': Permission denied
find: `/etc/skel/.config/squeeze': Permission denied
find: `/etc/skel/.config/xfce4-session': Permission denied
find: `/etc/skel/.config/mousepad': Permission denied
find: `/etc/skel/.config/xfce4-dict': Permission denied
find: `/etc/skel/.config/ristretto': Permission denied
carltonp@access-server:~$  


Not sure where to look for startup-config ???
0
 

Author Comment

by:cpatte7372
ID: 37753265
After entering the search commands I couldn't find 'startup-config', although I know its up there...
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 37753271
can you run the command as root user?

Are you sure the file is there?
0
 
LVL 76

Expert Comment

by:arnold
ID: 37753290
Based on the responses you received you are likely using debian or ubuntu.
/bin/ls -l is the command you can run until you update the PATH which is what the message/error suggests.
0
 

Author Comment

by:cpatte7372
ID: 37753297
Unfortunately, I can't run the command as root user.

Yes, very sure the file is there....
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37753313
sudo find /etc -type f -name "startup-config"
0
 

Author Comment

by:cpatte7372
ID: 37753326
OK, is there a command I can issue to 'Get' the file 'startup-config' from where-ever its located?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37753341
sudo find / -type f -name "startup-config"
0
 

Author Comment

by:cpatte7372
ID: 37753343
Arnold,

You're correct. See below:

Linux access-server 2.6.32-38-generic-pae #83-Ubuntu SMP Wed Jan 4 12:11:13 UTC 2012 i686 GNU/Linux
Ubuntu 10.04.4 LTS
0
 

Author Comment

by:cpatte7372
ID: 37753375
After entering sudo find /etc -type f -name "startup-config" I got a message saying that I wasn't in the 'sudoers file'
0
 
LVL 76

Expert Comment

by:arnold
ID: 37753391
export PATH=/bin/:$PATH
will eliminate the error you reference.

To avoid doing this piece meal, can you provide details on what it is you want to do as the end result?

http://www.cyberciti.biz/tips/how-to-controlling-access-to-linux-services.html

echo $PATH should tell you the current search path the system will use to locate commands.
i.e. if you run /bin/ls there is no searching,
when you run
ls the system will use the search path ($PATH) to see whether it can locate the command to run.  Ubuntu and debian have a tie in when a command can not be "found" to provide suggestions on how to address and resolve the issue. i.e. if you run a command that is unavailable because the package is not installed, the message will be the command is part of packageX run apt-get install packageX.

etc.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37753421
You'll have to be a member of the admin group.

If you can't login as a member of this group you will have to ask your administrator to add you to this group, otherwise you won't be able to accomplish your task.
0
 

Author Comment

by:cpatte7372
ID: 37753506
Arnold,

I would like to locate the file 'startup-config' and then ftp to my local pc.

Cheers
0
 
LVL 76

Expert Comment

by:arnold
ID: 37753565
find / -name "startup-config"
as others pointed out.
the command will go through the filesystem looking for the filename
do you have l2tpns installed? startup-config might be a generic name that is part of multiple packages
http://manpages.ubuntu.com/manpages/dapper/man5/startup-config.5.html

What is the end result that you want to achieve? i.e. you locate the file you make the alterations, what is it you are looking for the alterations to do?
0
 

Author Comment

by:cpatte7372
ID: 37753687
Hi Arnold,

The unix box being used to simulate cisco routers. The configs are copied into a file called startup-config and I'm trying to copy the file to my desktop.
0
 

Author Comment

by:cpatte7372
ID: 37753781
This might not be right place to ask this question, but I've mentioned to copy a file into sftp (secure file transfer). When I connect to the unix box with sftp I get all the unix commands that I asked about. However, I still can't locate the file....
0
 
LVL 76

Expert Comment

by:arnold
ID: 37754007
Your sftp session might be restricted to a location that does not contain the file.
Once you locate the file, you could use scp to transfer it.
scp file user@remotesyste:/path/to/where/you/want/the/file/
0
 

Author Comment

by:cpatte7372
ID: 37754904
So guys/gals,

I have these files on the Linux access-server 2.6.32-38-generic-pae #83-Ubuntu SMP Wed Jan 4 12:11:13 UTC 2012 i686 GNU/Linux
Ubuntu 10.04.4 LTS

DLS2#copy unix:?
unix:NETMAP          unix:config.sh       unix:kill.sh
unix:mefile          unix:myfile          unix:netmap.sh
unix:nvram_00191     unix:nvram_00192     unix:nvram_00193
unix:nvram_00194     unix:nvram_00195     unix:nvram_00196
unix:nvram_00197     unix:nvram_00198     unix:pid
unix:sftp            unix:start.sh        unix:startup-config
unix:vlan.dat-00195  unix:vlan.dat-00196  unix:vlan.dat-00197
unix:vlan.dat-00198  unix:wrapper-linux  


Is there anywhere I can transfer them through Get to my pc?

Cheers

Carlton
0
 
LVL 76

Expert Comment

by:arnold
ID: 37755045
You can download pscp.exe and transfer the data

On the windows box you would run
pscp.exe -R user@ubuntubox:/path/to/files .

This will copy the contents of the directory to the location where the command is run. Note the user used has to have access to the location where the files are.
D you have samba setup on the Ubuntu system? You could use it to share the folder so that it can be accessed by the windows workstation or alternatively mount a share from a windows platform and copy the files there.

mount -t cifs \\windows\share -o .......
http://ubuntuforums.org/showthread.php?t=288534
0
 

Author Comment

by:cpatte7372
ID: 37755071
arnold

Wow. That would be exactly what I need but I can't seem to find the path to any of the files I mentioned above....
0
 
LVL 76

Expert Comment

by:arnold
ID: 37755104
I am unsure what you mean. What do these files represent?
I am also not in a position to tell you where they might be.

pwd, cwd are commands to let you know where you are.
/bin/ls -l
0
 

Author Closing Comment

by:cpatte7372
ID: 37832260
Cheers
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now