Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Commands not working.

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Commands not working.

#1 Post by hack3rcon »

Hello,
When I write a command name then it don't worked and I should write the full command path:

Code: Select all

# mkfs.ext4
bash: mkfs.ext4: command not found
But below command worked:

Code: Select all

# /usr/sbin/mkfs.ext4 
Why?

Thank you.

User avatar
sickpig
Posts: 589
Joined: 2019-01-23 10:34

Re: Commands not working.

#2 Post by sickpig »

try fasting on moonless Sunday nights for a few moons to fix it.

Alternatively, make an effort to learn what PATH is in linux.

I donate blood to help vampires(sometimes on moonless nights), don't judge me :)

mm3100
Posts: 337
Joined: 2020-10-21 21:39
Has thanked: 8 times
Been thanked: 14 times

Re: Commands not working.

#3 Post by mm3100 »

Check if that is in your path environmental variable https://wiki.debian.org/EnvironmentVariables.
To see what is in path of current user run

Code: Select all

echo $PATH
If /usr/sbin is not in there, then that is the culprit. Bash can't find command as it is not where it looks, and when you type full path to the file it knows where to look so it runs it.

User avatar
sunrat
Administrator
Administrator
Posts: 6458
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 472 times

Re: Commands not working.

#4 Post by sunrat »

Do you ever read or search anything before posting here? Read this:
http://forums.debian.net/viewtopic.php?f=16&t=142973
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
NFT5
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 598
Joined: 2014-10-10 11:38
Location: Canberra, Australia
Has thanked: 10 times
Been thanked: 43 times

Re: Commands not working.

#5 Post by NFT5 »

Why bother searching when people keep solving the problems.

H.o.a.S. had a better solution.

User avatar
RU55EL
Posts: 546
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Commands not working.

#6 Post by RU55EL »


KitchM
Posts: 175
Joined: 2019-06-11 18:11

Re: Commands not working.

#7 Post by KitchM »

I agree with the original poster. There is something that does not make sense.

I am using Debian 10, with all latest updates, and Xfce 4.12.

When I type:

Code: Select all

echo $path
there is nothing returned (I get a blank line before new prompt). Trying:
sudo echo $path
does the same thing, and also if I log in as root.

So the question is "Where is the universal path setting kept?" I have looked into /etc/environment (which is empty), /ect/profile (which has:

Code: Select all

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
), ~/.bash_profile (which is empty), /etc/logins.deg (which has similar to above:

Code: Select all

ENV_SUPATH	PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH	PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
), ???????? Running out of ideas.

So here's the problem. Normally we need do nothing special to set a path variable. Especially when using a proper .deb install. Therefore, in the very odd situation that one installs something that must have a manual setting added to the path command, there is no clearly defined location one should add it so that everyone has it forever.

Debian does not seem to address this in any definitive way.

User avatar
sunrat
Administrator
Administrator
Posts: 6458
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 472 times

Re: Commands not working.

#8 Post by sunrat »

Code: Select all

echo $PATH
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

KitchM
Posts: 175
Joined: 2019-06-11 18:11

Re: Commands not working.

#9 Post by KitchM »

Right, as noted above, it is empty.

User avatar
sunrat
Administrator
Administrator
Posts: 6458
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 472 times

Re: Commands not working.

#10 Post by sunrat »

KitchM wrote:Right, as noted above, it is empty.
You wrote

Code: Select all

echo $path
Which is wrong so it will be empty.

Code: Select all

echo $PATH
is totally different and should work. If it doesn't, your Debian is screwed.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

sgosnell
Posts: 975
Joined: 2011-03-14 01:49

Re: Commands not working.

#11 Post by sgosnell »

Everything in Linux is case sensitive. At least everything I can think about offhand.
Take my advice, I'm not using it.

KitchM
Posts: 175
Joined: 2019-06-11 18:11

Re: Commands not working.

#12 Post by KitchM »

Nope. Sunrat was correct. I missed that.

KitchM
Posts: 175
Joined: 2019-06-11 18:11

Re: Commands not working.

#13 Post by KitchM »

Of course, the question still remains unanswered. There must be some definitive answer.

CwF
Global Moderator
Global Moderator
Posts: 2672
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 196 times

Re: Commands not working.

#14 Post by CwF »

KitchM wrote:Of course, the question still remains unanswered. There must be some definitive answer.
I think it varies...
/etc/gconf/2/path

KitchM
Posts: 175
Joined: 2019-06-11 18:11

Re: Commands not working.

#15 Post by KitchM »

But that doesn't help me directly. We want to know where to make the settings once and for all. Surely some expert knows.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Commands not working.

#16 Post by Head_on_a_Stick »

KitchM wrote:We want to know where to make the settings once and for all
Note that LightDM doesn't run the user's shell as a login session so ~/.profile won't be read. Use ~/.xsessionrc to either source ~/.profile or set PATH explicitly from there. The former approach will allow ~/.profile to work for console (TTY) logins also.

See also https://wiki.debian.org/Xsession
deadbang

KitchM
Posts: 175
Joined: 2019-06-11 18:11

Re: Commands not working.

#17 Post by KitchM »

And does that work for all users then?

reinob
Posts: 1195
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: Commands not working.

#18 Post by reinob »

KitchM wrote:And does that work for all users then?
I don't think your question, or rather request, has any sensible answer.
There is no such thing as a "universal" PATH that applies to all programs. Some programs will inherit the PATH (and/or the whole environment) of their parent process, others won't.

Some programs will apply restrictions to the environment they get (e.g. sudo) and/or load optional environments which will override the default (e.g. ~/.ssh/environment).

Even if you only focus on terminals, some will run your shell as a login shell, and others won't.

So just make sure that in *your* system the PATH for *your* particular program is set correctly.
Note that in general there's absolutely no need to adjust anything, as the PATH is rather static (mostly /usr/local/bin, /usr/bin, /bin, and /usr/local/sbin, /usr/sbin and /sbin if root). Also /usr/local/games and /usr/games is rather common.

Normally ~/.local/bin and/or ~/bin if they exist will be added to the PATH, but only for interactive shells (at .profile).

So, please ask if you have a specific question or problem.

Maybe it's even worth opening a new thread, as this one was about the OP not reading the manual, which inevitably leads to the classic "su vs su -" misunderstanding.

Post Reply