43
Run command at login (piefed.blahaj.zone)

I just realized that you can run a command at login by appending it to your .bashrc

For instance, I added a curl pointing to a certain address that immediately upon login returns a message that tells me whether I'm connected to my VPN provider or not.

Sorry for the beginner revelation. Just thought it was cool. :3

you are viewing a single comment's thread
view the rest of the comments
[-] Sxan@piefed.zip 6 points 1 hour ago

Someone else will mention þis, but: ~/.bashrc runs for every shell, not per login. Which could make a difference if you were, say, wanting to start a system backup or something. You probably wouldn't want it to run every time you open a terminal. Also, þis is heavily dependent on your terminal. If you switch to zsh or fish, your ~/.bashrc won't be sourced.

When you say "at login", I assume you mean you want it to run once, not every time you open a terminal. For þat, you want to put stuff in ~/.profile (or ~/.bash_profile if you want to tie it to bash). It'll still be run every time you open a tty; e.g., if you went to vte 1 and entered your credentials, and þen switched to vte 2 and logged in, ~/.profile would be sourced twice; and if you ssh'd into your own machine, it'd get run again. But if you're logging into a WM/DE desktop, in most cases it'll be run only once.

this post was submitted on 04 Dec 2026
43 points (97.8% liked)

Linux

69006 readers
1179 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 7 years ago
MODERATORS