Ask Your Question
1

how to login a tty in startup

asked 2015-10-05 05:18:15 -0600

hamedBB gravatar image

I want to execute some command on special tty (for example tty2) in my linux startup so every time the system reboots this commands execute on that tty. I used this link to do : http://www.humbug.in/2010/utility-to-... It works fine but problem is , in startup I need to login desired tty then execute the commands. Is there any way to login a tty by some command at the beginning? Thanks

edit retag flag offensive close merge delete

Comments

2

It would help to know specifically what you want to accomplish by this method. I suspect there is a better method, perhaps rc.local as @Florian suggested, or a service unit.

randomuser gravatar imagerandomuser ( 2015-10-05 22:53:41 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2015-10-06 02:47:06 -0600

hamedBB gravatar image

updated 2015-10-06 06:27:08 -0600

I solved the problem somehow.

first I make desired ttys login automatically by changing /etc/inittab, change below :

2:2345:respawn:/sbin/mingetty tty[1-6] -> 2:2345:respawn:/sbin/mingetty tty[1-6] --autologin USER_NAME

then I make a script which check tty index and execute command on a tty which I wanted to, code below :

if [[ $(tty) = /dev/tty[1-6] ]]; then MY_COMMAND fi

then I just put my script at /root/.bash_profile

edit flag offensive delete link more
2

answered 2015-10-05 14:22:09 -0600

florian gravatar image

updated 2015-10-05 14:23:39 -0600

Hi @hamedBB, Welcome to ask.fedora.

It may not be exactly what you want but you could use rc.local for executing commands on boot. Check out this Q/A and this Q/A for more information and setup.

You are not getting a feedback from this service as you would get it in a plain terminal. Not sure if you need it...

edit flag offensive delete link more

Comments

1

STDOUT and STDERR goes to the journal, you'd get feedback this way.

randomuser gravatar imagerandomuser ( 2015-10-05 22:54:08 -0600 )edit

You are right I didn't need that service :)

hamedBB gravatar imagehamedBB ( 2015-10-06 02:47:51 -0600 )edit
-2

answered 2015-10-05 12:43:40 -0600

msx gravatar image

Hi,

"Is there any way to login a tty by some command at the beginning?" Yes, it has been there since at least 1997. Please try: $ man chvt

HTH

edit flag offensive delete link more

Comments

2
  1. Your answer is really not friendly. If a users asking for help is usually because he or she doesn't know a command or a function, or so. And that doesn't change, no matter how long this command is out there.
  2. The way I read the question, your answer is not answering his question. Isn't @hamedBB asking how to execute commands on tty without the need of first logging into the corresponding tty? chvt N makes N the active tty but is doesn't log you in.
florian gravatar imageflorian ( 2015-10-05 14:15:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-05 05:18:15 -0600

Seen: 1,314 times

Last updated: Oct 06 '15