Find the answer to your Linux question:
Results 1 to 6 of 6
Like Tree2Likes
  • 1 Post By Cabhan
  • 1 Post By Cabhan
Hi Everyone, Im currently working on a project that involves a ssh connection to a remote machine that i often have to pkill x and reboot, trouble is every now ...
  1. #1
    Just Joined!
    Join Date
    Jul 2011
    Posts
    5

    Question Overwriting Poweful commands?

    Hi Everyone,

    Im currently working on a project that involves a ssh connection to a remote machine that i often have to pkill x and reboot, trouble is every now and then i do it on my dev machine, and its getting on my nerves so i thought i could do something like this:

    alias reboot= "echo 'you didnt mean to do that! if you did try reallyreboot"
    alias reallyreboot = "shutdown -r now"
    alias pkill = "echo 'you didnt mean to do that try reallypkill"
    alias reallypkill=??

    at first i thought i might get away with it if i defined the "really" alias before the overwrite, but that proved unsuccessful. is there anyway i can do the real pkill in a reallpkill alias but overwrite the pkill command? or at least add a "are you sure?"

    maybe just an overwrite for the specific command "pkill -9 X"??

    I would appreciate any help with this, if its not possible
    I could just use an alternative command on the target, but we do have to keep changing the targets distro so doing it on the dev machine is a little bit more efficient

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    You can provide the full path to the program:
    Code:
    alias reboot="echo 'Try reallyreboot'"
    alias reallyreboot="/sbin/shutdown -r now"
    chrispepper1989 likes this.
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    Just out of curiosity:
    Are you working on kernel modules, glibc or X modules?

    I am just wondering, what kind of development would need constant reboots.
    Last edited by Irithori; 08-01-2011 at 06:40 PM. Reason: spelling
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    Jul 2011
    Posts
    5

    Smile

    Thanks Cabhan that will probably do it, any idea where pkill lives? i would of though sbin or bin but i cant find it, or is pkill an alias for kill???

    @ Irithori its not really constant reboots, i actually find that i have to reboot most often when sshd throws a wobbly and i cant tunnel to the host from the target anymore, i think it has something to do with the connection timing out / the firewall blocking it. but my efforts so far haven't fixed this, ive tried extending the length of ServerAliveInterval on both the target and the host. Annoyingly just kill sshd and restarting it doesnt seem to do the trick and niether does killing the firewall on the target side, it might work if i kill the firewall on the host side but im not sure if i want to do that.

    but only a reboot seems to fix the problem it causes. It is actually a kernel module that im working on but the reboots rarely have anything to do with the actual module.

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    You can always use the "which" command to find the full path of a command:
    Code:
    alex@niamh:~$ which pkill
    /usr/bin/pkill
    chrispepper1989 likes this.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Just Joined!
    Join Date
    Jul 2011
    Posts
    5

    Thank you :)

    Thank you that's really helpful! i Appreciate it very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...