Could you help me add alias for user?

Discussion in 'Linux Beginners' started by Alex Mamatuik, Apr 11, 2023.

Tags:
  1. Alex Mamatuik

    Alex Mamatuik Member

    There are 2 questions in it:
    1) assign alias to use by user locally;
    2) declare global linux alias for system-wide usage by any user.

    Earlier i mentioned, that could be good to simplify an alias for composer...
    Reason:
    During my normal activity with drupal modules, their paths of installation are always copied seamlessly as: composer require 'drupal/video:^3.0'.

    When we use different versions of the Composer, it comes an inconvenient way to prepend:
    Code:
    php82 /usr/local/bin/composer82 require 'drupal/video:^3.0'
    Necessarily and would be useful to use a such alias:
    PHP:
    alias composer82='/opt/remi/php82/root/usr/bin/php /usr/local/bin/composer82'
    or

    Steps, that were reproduced:
    1) adding to local /home/drupal/.bashrc file of a user required fragment of the alias:
    Problem
    to activate this script we need to run
    Code:
    source /home/drupal/.bashrc
    response:
    bash: /home/drupal/.bashrc: Permission denied

    Not placing the user to the wheel-group, we can't also execute: sudo source /home/drupal/.bashrc
    We trust you have received the usual lecture from the local System
    Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

    [sudo] password for web1:


    Neither the root, nor the user password grants access.

    2) Declare global alias
    Creation of a script at /etc/profile.d/
    This method is also unsuccessful to achieve our aim.
     
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

  3. Alex Mamatuik

    Alex Mamatuik Member

  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    In what way does it not work? What happens instead?
    The AskUbuntu article says:
    1. create file 00-aliases.sh in directory /etc/profile.d/ -directory.
    2. write in that file
      Code:
      alias composer82='php82 /usr/local/bin/composer82'
    3. save the file
    4. log in as test user to get the settings activated and test with command alias if the alias is now defined.
     
  5. Alex Mamatuik

    Alex Mamatuik Member

    Unfortunately, Sir, it doesn't work.

    And i even changed it some an alias name for composer8 due to not mingle with the /usr/local/bin/composer82

    But... :) i celebrate you with the Accession to the Alliance; this is a really good news.
     
  6. Alex Mamatuik

    Alex Mamatuik Member

    update!
    if we create some occasional user through useradd, then this alias works.

    but in case ISP Config (not chroot) created user, this won't work.

    The difference:
    PHP:
    defaultdrupal:x:5004:5005::/var/www/websites/client0/domain1/home/defaultdrupal:/bin/bash
    testify
    :x:5009:5010::/home/testify:/bin/bash
    /var/www/websites/client0/domain1/home/defaultdrupal ~ /home/testify

    Question: How to declare global alias, which isp_config created user will comply with?
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I use only jailed shell users on my ISPConfig setups. You would need to examine how the defaultdrupal user is set up to login and get environment and settings.
    Or, forget the alias thing, and use the other way to accomplish same thing, which was explained in that AskUbuntu thread (creating composer8 command file a directory included in PATH).
    You should show in what way it does not work, how you verified it does not work and what happens instead. Generally, just stating "it does not work" is not helpful when trying to give advice.
     
  8. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    for ispconfig jailkit users, aliases will not work unless the path to the file containing the alias, and the file/command referenced by the alias are included in the jailkit.
     
  9. Alex Mamatuik

    Alex Mamatuik Member

    I suppose, the problem is hidden somewhere here inside: /usr/local/ispconfig/interface/web/sites/shell_user_edit.php.
    No-no-no, :D:):) i have already sent it:
    Code:
    bash: composer8: command not found
    - that was a reply.

    Olay, let's chroot it with the Jailkit:
    new user: defaultchrooted
    pass: drupalize
    root_server_1.png

    root_server_2.png

    Which way do i have to use it?:rolleyes:
     
  10. Alex Mamatuik

    Alex Mamatuik Member

    Do you know, how practically, but not metaphysically to solve my issue?

    Sorry for this irony, sometimes i am rude
     
  11. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    the instructions i linked to, and which @Taleman explicitly repeated, state exactly where and how to create the alias.
    the path /etc/profile is already included in the basicshell section of the jailkit, so what you need to do is make sure the php version you want to use, and composer are enabled in your jailkits. either for the site, under site options under 'Jailkit chroot app sections', in this case, as 'PHP8_2' and 'composer', or the same in the control panel system - server config - <servername> - jailkit
     
  12. Alex Mamatuik

    Alex Mamatuik Member

    So, one more time:
    1. this alias was created;
      /etc/profile.d/ALIAS.sh
      Code:
      alias composer8='php82 /usr/local/bin/composer82'
    2. is /etc/profile.d included to the basicshell?
      How to verify?

      My knowledge of the jailkit is boiled down to the steps from the "Perfect Centos Server" tutorial:
      ISPConfig jailkit.png
    3. How to add my local versions of php and of composer to jailkit?
      -> Site Options
      seems, not 'Jailkit chroot app sections', but 'Jailkit chrooted applications'

      php8.2 path: /opt/remi/php82/root/usr/bin/php
      composer for php 8.2 path: /usr/local/bin/composer82
      ISPConfig local jailkit.png


      Am i right?
    Even for the chrooted user it has had the same effect - zero.


    Okay, i give up
    Dash it all
     
  13. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    no.
    as i said. jailkit chroot app sections. 'PHP8_2' (assuming you have php8.2 installed and working and want to use this version) and 'composer'

    you would need to check the php8_2 section in /etc/jailkit/jk_init.ini though.. make sure it's pointing to the right location for php.. i know what it has in there for ubuntu/debian, don't know what it has in there for centos
    for composer, is /usr/local/bin/composer82 a file, or another directory? you might need to add it to the paths line in the composer section of jk_init.ini
     
  14. Alex Mamatuik

    Alex Mamatuik Member

    For such an occasion, let's figure out it together...
    Any objections, my man?!

    My php 8.2
    PHP Name - PHP 8.2.3
    Path to the PHP FastCGI binary: /opt/remi/php82/root/usr/bin/php-cgi
    Path to the php.ini directory: /etc/opt/remi/php82

    It responds to:
    php82 because the enabled symbolic link
    {/usr/bin} php82 -> /opt/remi/php82/root/usr/bin/php

    My composer 2.5
    Composer was compiled to be named composer82
    php82 composer-setup.php --2.5 --install-dir=/usr/local/bin --filename=composer82
    /usr/local/bin/composer82


    No written record,ever made mention of any composer on there than the default one:
    /etc/jailkit/jk_init.ini
    Code:
    [basicshell]
    comment = bash based shell with several basic utilities
    paths = /bin/sh, bash, ls, cat, chmod, mkdir, cp, cpio, date, dd, echo, egrep, false, fgrep, grep, gunzip, gzip, ln, ls, mkdir, mktemp, more, mv, pwd, rm, rmdir, sed, sh, sleep, sync, tar, touch, true, uncompress, zcat, /etc/motd, /etc/issue, /etc/bash.bashrc, /etc/bashrc, /etc/profile, /usr/lib/locale/en_US.utf8, uname, expr, xargs
    users = root
    groups = root
    includesections = uidbasics
    
    [composer]
    comment = composer
    paths = composer, /usr/local/bin/composer, /usr/share/doc/composer
    includesections = php, uidbasics, netbasics
    
    [php8_2]
    comment = php version 8.2
    paths = /usr/bin/php8.2, /usr/lib/php/8.2/, /usr/lib/php/20210902/, /usr/share/php/8.2/, /etc/php/8.2/cli/, /etc/php/8.2/mods-available/
    includesections = php_common
    Do i have to add:
    What i also noticed:
    [basicshell] has no path to /etc/profile.d, but to /etc/profile, which doesn't exist.
     
  15. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    i'm not sure how much more help i can be, i don't use the OS or repo's you're using so don't know what should be where.

    that said, i believe /etc/profile should exist on any linux variant, certainly should exist on centos from what i can see, as should /etc/profile.d
    so i guess that's the first issue you'd need to sort out.

    that said, i notice on jailkit'd users on ubuntu, the file /etc/profile is included in the jailkit files, and that does try to load .sh files from /etc/profile.d, but that folder isn't included in the jailkit. @till should /etc/profile.d not be included in the path line for basicshell by default?
     
  16. Alex Mamatuik

    Alex Mamatuik Member

    Oh, no!
    Please, do not call GrandMaster for help.
    I intentionally didn't do that, because am assured that this forum must have more high class pundits, who is able to cope with

    Mr. Till, @till , it was a false alarm

    @nhybgtvfr , Bro, thanks for your efforts.
    Consider, something else - is a solution.
     

Share This Page