Friday, April 19, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2436  / 2 Years ago, sat, july 2, 2022, 3:09:52

Is there any config file that is evaluated once, everytime operating system starts up. bashrc does not qualifies since it gets evaluated everytime a gnome terminal starts..


More From » configuration

 Answers
6

There are 2 places I use when I need to add "run-once" commands:



Once at every user login (be it Graphical/GDM or text/console login): ~/.profile



Pros:




  • It works even if no GDM/X11/Graphical server is used. Meaning it will work with SSH and text-mode logins

  • It is NOT evaluated when a gnome terminal starts, as required. ONLY at login

  • Executed with user priveleges, its secure while allowing full access to personal scripts.

  • Run after all mounts are done, so the whole filesystem is avaliable.



Cons:




  • If a user logs in, logs out and logs in again, it will be executed again, once per login. So its not a "true" system start up only. But it may suit your need.

  • Since this is executed even in text-mode logins, its advisable NOT to place any command that requires a GDM/X11 server (like synergy daemon)

  • Bash is only used with text-mode logins. So if using GDM, no bashisms are accepted in the script, since Ubuntu will run it with dash



Once when GDM starts (before any user logs in): /etc/gdm/Init/Default



Pros:




  • Executed only once, no matter how many users log in or out

  • Can be used for both text and graphical commands

  • Run after all mounts are done, so the whole filesystem is avaliable.



Cons:




  • Run using gdm user. So personal scripts and path to them must be world-readable and executable

  • Cannot be used if no GDM server is used (duh). So it wont run in text-mode start-ups

  • Again, not run in bash, so bashisms must be avoided.



Use the method that suits your need.


[#44928] Sunday, July 3, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tusmuumu

Total Points: 195
Total Questions: 122
Total Answers: 104

Location: Oman
Member since Tue, Feb 7, 2023
1 Year ago
;