开发者

Seeing what files are run at startup (linux)

开发者 https://www.devze.com 2022-12-25 12:57 出处:网络
How do a chec开发者_Python百科k what startup scripts are run after I ssh into a machine?You may try this, if your remote login shell is bash

How do a chec开发者_Python百科k what startup scripts are run after I ssh into a machine?


You may try this, if your remote login shell is bash

$ ssh user@ssh.example.com /bin/bash -xlic exit

and you'll get something like this

+ for i in '/etc/profile.d/*.sh'
+ '[' -r /etc/profile.d/00functions.sh ']'
+ . /etc/profile.d/00functions.sh
+ for i in '/etc/profile.d/*.sh'
+ '[' -r /etc/profile.d/aliases.sh ']'
+ . /etc/profile.d/aliases.sh
++ :
++ alias 'l=ls -l'
++ alias 'lc=ls -c'
++ alias pg=less
++ alias 'la=ls -la'
+ for i in '/etc/profile.d/*.sh'
+ '[' -r /etc/profile.d/colorls.sh ']'
+ . /etc/profile.d/colorls.sh
++ alias 'll=ls -l'


Trace it. I'm not really familiar with the tracing tool on linux, but on Solaris I'd do one of these:

# truss -p `pgrep sshd` -f -t open  

These flags make it attach to the sshd process, also trace child processes, and only trace the open system call. Just ssh in while that puppy is running, and should dump out the name of every file it's opening, as that's one of the arguments to the open system call.

On linux I believe you'd use strace, which I'm sure has its own flags for these things.

There's a pretty good chance you'll need superuser permission to do this. If you don't have it, and want a solution that doesn't require it, you'll need some other technique.


I don't think you can find this out if your admin(root) doesn't want you to. But one thing is guaranteed, the moment you login, your login script is executed, generally, .bash_profile under bash and .profile under most other shells(both at your home directory). Again, your admin can alter what to run on login.

0

精彩评论

暂无评论...
验证码 换一张
取 消