switch user

[oracle@mac ~]$ vi /etc/host
[oracle@mac ~]$ su - root
Password:
-bash: /etc/profile: line 54: syntax error near unexpected token `&'
-bash: /etc/profile: line 54: ` '
[root@mac ~]#


user is switched ..

but there is a small error what is that...
tomvvAsked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
Seems that you used copy-and-paste to get /etc/profile (or parts of it) from some web page leaving the contained HTML entities intact.

Either try to get a version not containing these HTML elements or edit /etc/profile using vi or the like to remove them all.

&nbsp is a "non-breaking space", by the way.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
View/edit  /etc/profile and see what is at line #54 - can you post that line?
0
 
tomvvAuthor Commented:
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
           if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
           else
              PATH=$1:$PATH
           fi
        fi
}

# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then
        EUID=`id -u`
        UID=`id -ru`
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

if [ -x /usr/bin/id ]; then
        USER="`id -un`"
        LOGNAME=$USER
        MAIL="/var/spool/mail/$USER"
fi

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done
unset i
unset pathmunge
 
if [ $USER = "oracle" ]; then
if [ $SHELL="/bin/ksh" ] ; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -p 16384 -n 65536
fi
fi
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
woolmilkporcConnect With a Mentor Commented:
Removing this bolded line

...
unset pathmunge
 
if [ $USER = "oracle" ]; then
...

should do the trick
0
 
arnoldConnect With a Mentor Commented:
As others pointed out and the comment by WMP
  is the HTML code for non-breaking space
0
 
MysidiaConnect With a Mentor Commented:
This whole block appears to be  non-standard and unusual. Removing the nbsp  should eliminate the warning, but won't change the fact  that there is a poor practice in place (A file that is supposed to be a vendor-supplied program has been altered), by adding code:

" 
if [ $USER = "oracle" ]; then
if [ $SHELL="/bin/ksh" ] ; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -p 16384 -n 65536
fi
fi
"

I would strongly recommend you restore  /etc/profile
to the version supplied by the distributor of your OS in their package management system,
and that you specify your user-specific  numfiles limit   and number of processes limit,
by either editing a script location intended for local customization, or by editing a configuration file, instead of  altering vendor code.

/etc/profile   is not a file that local customizations go in, and you can expect any custom entries here may be lost in the future while applying security patches or other updates,
in other words -- the improper customization could be a source of future pain.


In addition, these ulimit statements running as a non-root user won't actually even work unless the hard limit was already raised by root through other means.


There are other places that are appropriate  to enter local script customizations in,
that will be preserved.


In this case, they should generally go in a  .bashrc   or .kshrc file  in the user  oracle's home directory  ~oracle .

Or by creating a custom script for your ulimits in /etc/profile.d/oracle.sh
and issuing  chmod 755  /etc/profile.d/oracle.sh

Of course the best way will depend on the exact OS distribution you are using.

Also having all users run extra script code, that tests the current user id before running a block is still unusual,  generally,  if you install a script in a global place, it should be something that isn't user-specific;  if something's user-specific, it goes in user-specific  RC files,  .profile, .bash_profile,  or .bash_login  in their home directory.


On most OSes, there will be a system configuration file such as /etc/security/limits.conf

where your custom   nofile      and nproc  limits      can be specified by using

oracle    hard     nofile  65536
oracle     soft    nofile  65536
oracle   hard    nproc  16384
oracle     soft    nproc  16384

For example.
Then when a login to the user occurs,  during session setup,  the pam_limits  module is invoked to set the limits.

If starting a program using init or cron,  the two ulimit commands should be in the init RC script, for just that one program   that needs to run the script code.
0
 
tomvvAuthor Commented:
now that problem is over

now this
'[root@mac ~]# su - oracle
-bash: ulimit: pipe size: cannot modify limit: Invalid argument
[oracle@mac ~]$
0
 
woolmilkporcCommented:
"-p nnn" of "ulimit" tries to modify the pipe size, which is not allowed.

This seems to be an error (typo?)  in the Oracle docs.
0
 
tomvvAuthor Commented:
any way to edit that file to get rid of that error..

from /etc/profile
0
 
woolmilkporcConnect With a Mentor Commented:
At the end of the file remove the bolded line as a whole plus the bolded string.


if [ $USER = "oracle" ]; then
if [ $SHELL="/bin/ksh" ] ; then
ulimit -p 16384     #-- Remove this line completely
ulimit -n 65536
else
ulimit -p 16384 -n 65536  #-- Remove "-p 16384" from this line
fi
fi

Alternatively you can remove the check for the shell completely, because both "ulimit" statements look the same now:

if [ $USER = "oracle" ]; then
ulimit -n 65536
fi
0
 
tomvvAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for tomvv's comment #a38410970

for the following reason:

problem solved..
0
 
woolmilkporcCommented:
The comment you're going to accept is not a solution to your issue,
au contraire - it's a further question instead.

Please revisit your decision!

wmp
0
 
MysidiaCommented:
I recommend
http:#a38402142, http:#38402208, http:#38402509,  http:#38402614,  http:#38411048

And  http:#38402142  by woolmilkporc   especially  strongly

As definite correct answers to the original question;  although they may not all address the 2nd  related but different question the author brought up.

 Of course; it's possible the author ignored the recommendations and found a different solution.  It's  highly unlikely the author could possibly have solved the display of the error message without removing or disabling the offending " "  as recommended.
0
All Courses

From novice to tech pro — start learning today.