Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have 2 small problems, i have the sw11.0.
The 1st one, i want that my root directory be in the PATH, i add it, but i cant execute my C executable files directly.
I added the following directories into the PATH, /~, /root. It is wrong?
The 2nd is a vim remaping problem, i want to remap the f1 key to work like esc, i cant do it,i can remap esc to work calling help, but my f1 key dont work like esc. (i have the esc key a little far away and it force my hand to move out of the writing keys).
well your root directory should *NOT* be in your path. it's a really bad idea. if you wish to run your own compiled software, then you should put it in somewhere like /usr/local/bin/, or just run it with a relative or absolute path. now if you deicide to go against stnadard conventions then "/~" doesn't really make sense, it's invalid, but /root should be fine, so you've presumably got a syntax problem in the way you are defining it, or you are applying incorrectly somehow.
I put in the cmdln
export PATH=$PATH:root/java
it work. But i want it to be executed in the boot.
I put the same line in etc/rc.d/rc.local
and it isnt working, what must put instead?
acid_kewpie, a folder into the root directory is also unrecomended?
why i mustnt put the root directory into the path?
/root is where the system administrator puts all sorts of little bits of information and such, it's just not an organizd place to pur exectuables in the long term.
but if you must, edit your own personal /root/.bashrc file and add it there, e.g. "export PATH=$PATH:/root"
I do it, but it dosnt work. The .bashrc file was empty, and i dont know if it already exist before i open it with: vim .bashrc
I put the ls command, and i cant see the file. Why i cant see it?, it is ocult?.
a file that starts with a . is hidden. add the -a flag in ls and you'll see them. your bashrc really will always exist, unless you don't use bash or have a distro i've never seen before. you can also try ~/.profile too, which is largely shell agnostic.
It is common to have a ~/bin/ personal bin directory to execute your own scripts and personal program files. Commands you install from a tarball probably should be installed in /usr/bin/ or /usr/local/bin/.
You can add the line "export PATH=$PATH:$HOME/bin" to your ~/.profile file. The .profile is run when you login, so you will need to run it manually "./.profile" if you haven't logged out. Also, the ~/.bashrc file is run every time a new subshell is run, so if you used ~/.bashrc instead, your added paths will be added twice.
.bashrc is not executed on login shells.
And bash_profile is not executed if bash is called by #!/bin/sh.
So the best, IMO, would be to put this at end of /etc/profile:
Code:
if [ "`id -u`" -eq 0 ]; then
PATH=$PATH:/root/java
fi
export PATH
what do you mean not exectued on login shells? of course it is... and why would you want a single uid specific test to be run on a system wide script? can't see the logic there at all
This is what comes when you install debian, it looks very similar:
Code:
root@debian# more /etc/profile
# /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="/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/
usr/bin/X11"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
fi
if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
export PATH
umask 077
yes, it calls ~/.bash_profile which as a standard for years and years has sourced ~/.bashrc if it's found. not sure why it really goes round the houses like that, but it's the way i've always known it.
Not that I would recommend this, but to map your F1 key in vi to be Esc you'll need to edit a file called .exrc in your home directory. Once in there enter the following.
Code:
:map! #1 ^[
Note: the ^[ is made using the keys Cntl+V Esc. To be more clear you hold down the control key and V at the same time, let go, then hit the Esc key. Using the map with ! means it will work while in insert mode, #1 is F1, and ^[ is how it interprets the escape key.
You may still encounter a problem if you are using a terminal window in Gnome(I don't have KDE, so don't know). The Gnome terminal will capture your F1 and bring up help before it gets to vi. This can be overridden. On the Terminal screen menu go to Edit, then Keyboard Shortcuts. At the bottom of the list you'll see F1 listed as the shortcut key for help.
Now, having said all that, it is not a good practice to use F1. F1 has been the standard help key on applications since function keys were first invented.
For the $PATH question I would not put an entry in /etc/profile since that is system wide. It would be better to put it in /root/.bash_profile. That is always executed during login and typically where your environment is set. Also since SW-ANIKY is talking C executables and not java, /root/bin would be a more appropriate directory. A few people have said something similar to this already, but here is the entry I would use.
While most distributions include 'if' logic to execute .bashrc in their .bash_profile, it is possible that is missing in SW-ANIKY's .bash_profile and that is why it's not working. A more probable explanation is that he did not logout and log back in or execute the .bashrc using the command source ~/.bashrc.
Some may disagree with me, but it is common practice to use .bashrc more for entering aliases and functions. I would put anything to do with the environment in .bash_profile.
Well disagree or not, don't care.
There is a manual page, people have to read it. You are right for alias and stuff: there shouldn't be any export command in bashrc files
This is the most common error found in Linux, bashrc, profile and such things. Amazing.
I agree with putting it in .bash_profile but it will only work if bash is invoked as bash, not as /bin/sh. Okay I'm fussy
Edit : won't work with dash,csh,.. for example
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.