Solved Confusion about boot process

carlcaulkett

Member

Reaction score: 3
Messages: 85

Hello. Can somebody tell me all the places where it is possible to set the path for both root and a standard user.

I'm getting myself confused because I have a situation where if I boot into XFCE and go to the terminal as the standard user and type echo $PATH I see the following

Screen Shot 2018-03-19 at 18.08.55.png


This is despite my $HOME/.profile containing the following path setting...

Screen Shot 2018-03-19 at 18.37.06.png


If I then switch to root via the su command, and type $PATH, I see the following...

Screen Shot 2018-03-19 at 18.40.30.png


Note the presence of the /usr/local/go/bin entry. Yet my /root/.profile just consists of this...

Screen Shot 2018-03-19 at 18.45.48.png


What I need are two lists. One labelled "Root" and the other labelled "User". Each containing all the places where the path can be set. I will the take these lists and tattoo them to the inside of my eyelids, thus forcing me to learn them.

Can anyone help? With the lists, that is. I'll take care of the tattooing!
 
Last edited:
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

That didn't help. All I want is that the path for my user account has the additional entry /usr/local/go/bin in it.

Somehow I have managed to add it to the path for root, I suspect via /root/.cshrc.

I've tried adding it to the default section of /etc/login.conf...

Screen Shot 2018-03-19 at 21.30.39.png


But that hasn't worked.

I've just tried adding it to $HOME/.shrc (I'm using the sh shell for user accounts). That hasn't worked.

What am I missing here? Please end my misery!
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

This question already got answered in another thread.
I applied the idea suggested by scottro after a bit of working out in which particular part of the thread the question had been answered, and created a new $HOME/.bash_profile containing the line source ~/.bashrc. Within source ~/.bashrc I placed the sh format PATH and other export commands.

That didn't work, I'm guessing because if you run source by itself within the user shell, you get source: not found.

So ShelLuser, could you tell me if, in fact, I located the correct part of the other thread, or do I just have to face the fact that I don't have the intellectual chops to deal with this problem.

Alternatively, if anyone else is reading and can offer some useful and relevant help, please feel free to contribute. Thanks!
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

If I run su I can access source although which source gives shell built in command, whereas running terminal as standard user, source gives not found. Is this because standard user is running the sh shell where root is running the csh shell? Is it worth me changing the standard user to use the csh shell? are there any disadvantages of doing this?

Don't forget I'm relatively inexperienced using *nix type OS's so please bear that in mind when answering me. I do have about 30 years experience in computer programming so a little bit of respect is always welcome!
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

ShelLuser It's just occurred to me. Is English not your first language. It's just that in this forum you come across as a little abrupt. Maybe it's a language/cultural difference. Maybe I was being a bit too sensitive. If so, my apologies!
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

I decided to take the plunge and I changed my default user shell to csh. Now, of course, my modified $HOME/.cshrc comes into play and I have the path just as I wanted.
 

scottro

Daemon

Reaction score: 550
Messages: 1,530

Going back to the earlier mention of creating .bash_profile and .bashrc, the issue would be that you're not running bash. :) The source command is a bash builtin, not a sh builtin. (Which I didn't know till I saw your post). :)
I know you've solved your issue in another way already, but figured I should mention that in case it was still confusing.

The sh shell uses $HOME/.profile and $HOME/.shrc. The command to tell .profile to look at .shrc isn't source, it's setting environment. If you look at the end of $HOME/.profile, you will see
ENV=$HOME/.shrc; export ENV which does the same thing as bash's source $HOME/.bashrc.

Completely non-relevant question, I wonder if I'm the only one who sees ENV and reads it as envelope rather than environment. I don't know why, probably an assumption I made when I was first exposed to this stuff.
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

Thanks for the reply scottro. I'm altering things in incremental stages: I've now upgraded my user shell to tshrc, which allows me some rather nice color options...

Screen Shot 2018-03-20 at 17.48.28.png


It seems that source works with csh and tcsh as well as bash.

It was worth mentioning scottro as all of these disparate bits of information are slowly congealing into what I hope is a coherent whole, as opposed to a black hole!
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

I've just noticed something strange. When I posted the message above, the prompt was given as carlcaulkett@FreeBDS rather than carlcaulkett@FreeBSD, despite the prompt being set as...

Screen Shot 2018-03-21 at 14.52.12.png


Today that part of the prompt has vanished entirely..

.
Screen Shot 2018-03-21 at 14.53.57.png


What's going on, I wonder? Multiple glitches in the Matrix?
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

Weird! The prompt is back, and is now spelt correctly!!

Screen Shot 2018-03-21 at 17.48.29.png


Screen Shot 2018-03-21 at 17.50.00.png


I've been messing around with the network settings, both in my VM and in Parallels. I must have disturbed something!!
 

ILUXA

Aspiring Daemon

Reaction score: 508
Messages: 735

I advise you to try to use shells/zsh.
save this as ~/.zshrc:
Code:
# start tmux with shell
#[[ -z $TMUX ]] && exec tmux

# autologout when no commands were entered for 30 min.
export TMOUT=1800

export EDITOR='vi'
export PAGER='less'
export LESS='-giMrRAK'
export LESSOPEN='|/usr/bin/lesspipe.sh %s'
export GREP_COLOR='0;31'
export LS_COLORS='di=32:ln=35:so=33:pi=31:ex=34:bd=34;40:cd=35;40:su=30;42:sg=37;42:tw=30;46:ow=31;46'
export LSCOLORS='cxfxdxbxexeafaachcagbg'
export CLICOLOR='1'


PROMPT=' %B%F{green}%C %f%#%b '
WORDCHARS='*?_-.[]~'
HISTFILE=$HOME/.zsh_history
HISTSIZE=SAVEHIST=100000
LISTMAX=999

setopt notify                   # report the status of background jobs immediately
setopt correct                  # try to correct the spelling of commands
setopt auto_cd                  # if the command is the name of a directory, perform cd
setopt auto_list                # automatically list choices on an ambiguous completion
setopt auto_continue            # unsuspend suspended jobs on `disown' command
setopt chase_links              # show symlink real value when cd into it
setopt interactive_comments     # allow comments in interactive shells
setopt cdablevars               # when argument to cd is a parameter whose value is a valid directory, perform cd
setopt append_history           # append history to the history file, rather than replace it
setopt extended_history         # save command beginning timestamp and the duration
setopt hist_reduce_blanks       # remove superfluous blanks from history
setopt hist_ignore_all_dups     # if new command duplicates an older one, remove the older from history
setopt hist_ignore_space        # do not save line to the history list when first character is a space
setopt hist_verify              # perform history expansion and reload the line into the editing buffer
setopt share_history            # share history between all sessions
setopt bang_hist                # perform textual history expansion, treating the character `!' specially
setopt rec_exact                # recognize exact matches even if they are ambiguous
setopt auto_pushd               # cd push the old directory onto the directory stack
setopt pushd_ignore_dups        # don't push multiple copies of the same directory onto the directory stack
setopt check_jobs               # report the status of jobs before exiting
setopt long_list_jobs           # list jobs in long format by default
setopt glob_complete            # do not insert all the words resulting from the wildcard expansion
setopt extended_glob            # treat the `#', `~' and `^' characters as part of patterns
#setopt dotglob                 # completion shows filenames beginning with a dot
unsetopt nomatch                # do not warn when using glob with no matches
unsetopt bg_nice                # do not run all background jobs at a lower priority
unsetopt hup                    # do not kill running jobs when shell exits
unsetopt checkjobs              # don't complain about still running background jobs
unsetopt auto_remove_slash      # disable automatic removing of slash
unsetopt prompt_sp              # do not preserve a partial line
unsetopt auto_menu              # do not use menu completion
unsetopt always_last_prompt     # print completion suggestions above prompt
unsetopt beep                   # disable beep

autoload -Uz compinit; compinit
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*' use-cache true
zstyle ':completion:*' cache-path ~/.zsh/
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' completer _expand _complete _match
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' file-sort links reverse
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:commands' rehash true
autoload -U select-word-style; select-word-style b
zstyle ':zle:*' word-chars "$WORDCHARS"
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -U $USER'
zstyle ':completion:*:functions' ignored-patterns '_*'

# emacs keybindings
bindkey -e
# alt+z/shift+alt+z
bindkey '\ez' undo
bindkey '\eZ' redo
# del key
bindkey '\e[3~' delete-char
# alt+del
bindkey '\e[3;3~' kill-word
# alt+left/right
bindkey '\e[1;3D' backward-kill-word
bindkey '\e[1;3C' kill-word
# alt+up/down
bindkey '\e[1;3A' backward-kill-line
bindkey '\e[1;3B' kill-line
# ctrl+left/right
bindkey '\e[1;5D' backward-word
bindkey '\e[1;5C' forward-word
# ctrl+up/down
bindkey '\e[1;5A' beginning-of-line
bindkey '\e[1;5B' end-of-line
# end/home
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line
# pgup/pgdown
bindkey '\e[5~' up-line-or-history
bindkey '\e[6~' down-line-or-history
# up/down to autocomplete from history, moving cursor to end of line
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey '\e[A' history-beginning-search-backward-end
bindkey '\e[B' history-beginning-search-forward-end
bindkey '\eOA' history-beginning-search-backward-end
bindkey '\eOB' history-beginning-search-forward-end
# ctrl+alt+up/down to search history
bindkey '\e[1;7A' history-incremental-search-backward
bindkey '\e[1;7B' history-incremental-search-forward
# shift+tab - reverse menu
bindkey '\e[Z' reverse-menu-complete

# list dir with TAB when there are only spaces/no text before cursor
# or complete words, that are before cursor only (like in tcsh)
function tcsh_autolist() {
    if [[ -z ${LBUFFER// } ]]
    then BUFFER='ls ' CURSOR=3 zle list-choices
    else zle expand-or-complete-prefix
    fi }
zle -N tcsh_autolist
bindkey '\CI' tcsh_autolist

# ctrl+b - return to previous dir
function back() {
    echo
    pushd +1
    zle reset-prompt }
zle -N back
bindkey '\Cb' back

# ctrl+f - resume job
function foreground() {
    CURSOR=0
    LBUFFER+="fg %"
    zle accept-line }
zle -N foreground
bindkey '\CF' foreground

# completion system recognizes 's' as 'sudo'
compdef    s='sudo'
# alias -es
alias    s='sudo'
alias    ss='sudo -s'
alias    c='cat'
alias    r='readlink -f'
alias    i='img2xterm'
alias    history='fc -l -E 1'
alias    h='fc -l -E -25'
alias    j='jobs -l'
alias    .='pwd'
alias    ...='../..'
alias    ls='ls -F'
alias    la='ls -a'
alias    ll='ls -lht'
alias    rm='rm -I'
alias    grep='grep --color -I'
alias    g='\grep --color -i'
alias    v='vi'
alias    e='builtin echo'
alias    du='du -h'
alias    mkdir='mkdir -p'
alias    stat='stat -x'
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

I advise you to try to use shells/zsh.
I'm tempted. I'm using zsh on my Apple Mac, along with an @ohmyzsh replacement called Prezto (as the name suggests, it's much faster than @ohmyzsh). In FreeBSD, i've moved from sh, csh, to tcsh. It would be a logical next step to move to zsh, I guess. Are there any known problems with tcsh, as far as you know, and what are the plus points of zsh on FreeBSD?
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

Cool! Thanks, I didn't see the sample .zshrc until a second ago. I'll give it a go in a moment. What's the best way of installing zsh, using pkg or from ports?
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

I'll have to use ports, I forgot that I am battling with an internet connection problem in my FreeBSD guest OS running under Parallels on an Apple Mac!
 

ILUXA

Aspiring Daemon

Reaction score: 508
Messages: 735

# cd /usr/ports/shells/zsh
# make rmconfig
# BATCH=yes make install clean

or if you use tcsh
# env BATCH=yes make install clean
 
OP
carlcaulkett

carlcaulkett

Member

Reaction score: 3
Messages: 85

Good news. I finally got my internet connection working, and the virtual machine is backed up. I was able to install zsh from ports. One small thing, I wasn't able to get either BATCH=yes or even export BATCH=yes to work. So I just went straight to make install clean. I had to press enter with the options dialog but I survived that and the rest was completely painless, and I now have zsh installed on my user account, along with your .zshrc file.

Thanks again! ILUXA, much appreciated!
 
Top