LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2019, 02:41 AM   #1
ajeet_singh
LQ Newbie
 
Registered: Dec 2019
Posts: 15

Rep: Reputation: Disabled
Question Disabling tty using script


How to write script to disable "tty" in Ubuntu 18.04 ?
 
Old 12-19-2019, 02:58 AM   #2
berndbausch
LQ Guru
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,670

Rep: Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701
You can just remove the command:
Code:
rm /usr/bin/tty
or make it non-executable:
Code:
chmod -x /usr/bin/tty
I am sure, however, that either solution would break several applications. Why do you want to disable it?
 
Old 12-19-2019, 03:12 AM   #3
ajeet_singh
LQ Newbie
 
Registered: Dec 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Question

You provided me good suggestion. But I only want to disable it using script, I don't have to remove it.

I don't know the purpose because my guide just asked me to complete the task and tell him the procedure.
 
Old 12-19-2019, 05:34 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,627

Rep: Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123Reputation: 5123
so it is your homework. I'm afraid you need to specify what do you really (exactly) mean by disabling tty.
From the other hand see: https://www.linuxquestions.org/linux/rules.html
Quote:
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
 
Old 12-19-2019, 05:47 AM   #5
ajeet_singh
LQ Newbie
 
Registered: Dec 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hey, I am undergraduate student. This is not my homework, my guide is working on some project and I am also involved into it. We are facing difficulty in this part because we both are new to this. I am doing all these stuffs apart from my syllabus. LoL!!

Yeah, I will tell you the problem :- I want to write a script to disable tty. I know the other ways to disable tty but we want to write script so that by single click only(after adding it to API) we can disable the tty.
We want this for some security reasons.

Here disabling means, after running the script no one can access tty interface to write any command.
 
Old 12-19-2019, 06:02 AM   #6
berndbausch
LQ Guru
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,670

Rep: Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701
Quote:
Originally Posted by ajeet_singh View Post
Here disabling means, after running the script no one can access tty interface to write any command.
The instructions I gave you either remove or disable the tty command. Now you are talking about some tty interface.

Which interface do you mean? There are serial ttys such as /dev/ttyS0, pseudo-ttys such as /dev/pts/0, and virtual ttys such as /dev/tty0. Oh, and there are also USB-based ttys as far as I know.

Or perhaps you mean the physical interface?

In short, you need to be more specific for getting help.
 
Old 12-19-2019, 06:08 AM   #7
ajeet_singh
LQ Newbie
 
Registered: Dec 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Okay, I am also new to this thing.

Tty which we get after pressing Ctrl+Alt+F2, I want to disable this. Right now, I am also exploring this concept. Your any guidance will be very valuable for me.
 
Old 12-19-2019, 07:20 AM   #8
berndbausch
LQ Guru
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,670

Rep: Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701Reputation: 1701
Quote:
Originally Posted by ajeet_singh View Post
Okay, I am also new to this thing.

Tty which we get after pressing Ctrl+Alt+F2, I want to disable this. Right now, I am also exploring this concept. Your any guidance will be very valuable for me.
That's a virtual terminal, /dev/tty0, /dev/tty1 etc., also known as virtual console.

What exactly do you want to disable? By default, there are 6 such terminals, if I am not wrong.

I experimented a bit. The command to close a virtual terminal is deallocvt. This requires that no process runs on that terminal. Use ps -fttty6 to list processes running on /dev/tty6.

Normally, however, the agetty process will be launched when all other processes are killed. It outputs the login prompt and waits for your input. To kill it on a systemd-based computer: systemctl stop getty@tty6 (again, this is for tty6).

After that, you should be able to remove the console with deallocvt 6, but when I tried it, I got an error message saying that the console is still in use. I don't know why, but perhaps you or your friend have a chance to find out.

When all consoles are deallocated, only root can create new consoles.

Last edited by berndbausch; 12-19-2019 at 07:23 AM.
 
Old 12-19-2019, 07:53 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 23,278

Rep: Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523
Quote:
Originally Posted by ajeet_singh View Post
Hey, I am undergraduate student. This is not my homework, my guide is working on some project and I am also involved into it. We are facing difficulty in this part because we both are new to this. I am doing all these stuffs apart from my syllabus. LoL!!

Yeah, I will tell you the problem :- I want to write a script to disable tty. I know the other ways to disable tty but we want to write script so that by single click only(after adding it to API) we can disable the tty.
We want this for some security reasons.

Here disabling means, after running the script no one can access tty interface to write any command.
This is much like your other two threads, where you're asking for code and someone to do your homework for you. Saying this is 'not my homework', then saying your 'guide is working on some project' says that it *IS* your homework, since you have to tell your 'guide' what procedure you're using. Since your other two threads were asking about writing a C code to compare strings, it's hard to know why a simple bash script would be a problem.

We know what you WANT to do, as you've said it multiple times so far. What we have not seen is what effort YOU have put into solving your issue. What ideas/thoughts have you had? What have you done and tried to accomplish your task?? As you were told, you can remove the device file which 'disables' it, since it won't exist, or chmod the device. You were also told to read the "Question Guidelines" before...have you read them, and the LQ Rules about posting homework questions???
 
Old 12-20-2019, 12:21 AM   #10
ajeet_singh
LQ Newbie
 
Registered: Dec 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks berndbausch for providing me the soultion. My problem is solved now.


Dear TBOne,

I hope before replying to this post you did lot of efforts to check my previous posts and ways to make yourself dominant. Important thing here was to first check in which forum you are. Let me remind you that this is "LinuxQuestions" platform where I am asking question in Linux-newbie(Hope you know the meaning of newbie).

You mentioned that I am asking here about my homework (asking for codes of "Kernel"), which no one has provided me. If you are providing me all the mentioned things then only say these things. I am newbie to Linux as well as programming that's why I am searching and asking all(simple bash script as well) the difficult things, if you don't want to help I don't care about you but please don't try to do criticism.
About my efforts in solving the problems:
Before coming here I did everything myself but everytime my kernel was damaging and was wasting lot of time.
I learnt how to make kernel module and developed few modules in C. When my kernel started hanging and not working then I asked previous posts(to provide complete C code so that I can learn also).

For this problem I was aware of the removing the device file and making changes inside the file that's why I mentioned clearly that I want to write "script" for this.

By reading two lines you can't judge anyone.

Instead of judging me from my post, you should consider the problem of the post.
I came here to get help which other people are doing. I am not here to read your foolish replies.
 
Old 12-20-2019, 04:56 AM   #11
ajeet_singh
LQ Newbie
 
Registered: Dec 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks TBOne, for providing me the "Bash Scripting Tutorial" link. It is very helpful for me.
 
Old 12-20-2019, 09:22 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 23,278

Rep: Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523Reputation: 6523
Quote:
Originally Posted by ajeet_singh View Post
Thanks berndbausch for providing me the soultion. My problem is solved now.
Oh?? So since you came here looking for this assistance from the community, why don't you post your script/solution, so others can learn from it??
Quote:
Dear TBOne,

I hope before replying to this post you did lot of efforts to check my previous posts and ways to make yourself dominant. Important thing here was to first check in which forum you are. Let me remind you that this is "LinuxQuestions" platform where I am asking question in Linux-newbie(Hope you know the meaning of newbie).
Not "dominant"...INFORMED. Good to know about someone before engaging them; since you've asked about writing a kernel module, and posted C++ code, it's then hard to know why someone, who can ostensibly write such things, is then going to ask for help with a VERY simple bash script, isn't it?
Quote:
You mentioned that I am asking here about my homework (asking for codes of "Kernel"), which no one has provided me. If you are providing me all the mentioned things then only say these things. I am newbie to Linux as well as programming that's why I am searching and asking all(simple bash script as well) the difficult things, if you don't want to help I don't care about you but please don't try to do criticism.
We're always glad to HELP someone, who shows effort of their own...that is the definiton of "help". It is NOT help when someone is just asking for a handout, or for someone to write their scripts for them. That's what you were asked for, because in both of your threads (one was a duplicate), you were given hints/answers, but (for some reason) couldn't implement them, and just asked for code (twice in that thread):
https://www.linuxquestions.org/quest...8/#post6063812
Quote:
About my efforts in solving the problems: Before coming here I did everything myself but everytime my kernel was damaging and was wasting lot of time. I learnt how to make kernel module and developed few modules in C. When my kernel started hanging and not working then I asked previous posts(to provide complete C code so that I can learn also).
Yes, that's what 'learning' is...making mistakes, and then figuring things out, so what you call 'wasting lot of time' is actually the learning process. Which you didn't seem to learn from, since berndbausch had to actually HAND YOU the code, before you stopped asking.
Quote:
For this problem I was aware of the removing the device file and making changes inside the file that's why I mentioned clearly that I want to write "script" for this. By reading two lines you can't judge anyone. Instead of judging me from my post, you should consider the problem of the post. I came here to get help which other people are doing. I am not here to read your foolish replies.
Then if you were aware, why did you ask? And again, we knew what you WANTED to do, but what we didn't see (and still don't) is any of **YOUR ACTUAL EFFORT** to write this 'script'.

You have repeatedly asked for handouts, and now don't like it that people noticed, and want to call them 'foolish'. Bear in mind that those 'foolish' people could easily perform all the tasks you've been asking for handouts about, without the need to ask others. The bash scripting tutorial has been in my posting signature, and in berndbausch's...why didn't you reference it before? Why didn't you just put "bash scripting tutorial" into Google and find THOUSANDS more?? Again...you have shown little to no effort, and this is your second homework assignment you've posted.
 
  


Reply

Tags
kernel, newbies, script, tty


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling TTY Terminals using Xubuntu 10.10 metallica1973 Ubuntu 3 12-02-2010 05:34 PM
How to reset/restart a tty from another tty? armandino Linux - General 4 02-25-2009 04:09 AM
can a tty execute command on another tty? BeacoN Linux - Desktop 3 11-08-2008 10:39 AM
I it possible to kill a tty or find which tty is being using by which process? geletine Linux - Software 2 01-15-2006 09:40 AM
change tty => system crashes (ati driver/tty resolution) mosca Debian 6 08-05-2004 08:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration