Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I'm using Slackware 9, and I want to start X and go into the window manager immediately when logging into some accounts. However, with others, such as root, I just want to login to the command line. So, I figured that I could just put "startx" in the .bash_profile, but what will happen when the user logs in remotely? I'm eventually going to set up the ssh server, so I want to prevent any errors now. Is there any simple way to check if the login is local (and then startx if it is)?
Also, one the problems I'm having as a new Linux user is finding in exactly what configuration file I need to make a change. Specifically, I want to mount the cd-rom and floppy for every user on startup. What file should this be done in? And is there some website that lists what the most important config files are and what should go in them?
Distribution: Lots of distros in the past, now Linux Mint
Posts: 748
Rep:
My preference is to make separate logins for local and remote users. This is mostly for logging and security purposes. Often times you'll want to limit remote users access to files, especially when corporate, government or military secrets are involved, even though the remote user would normally have full access to such information while at a localized computer. Some people will try to argue, but if you present it properly, there is no real argument against this setup. This kind of setup might also help your situation, where you might want totally different programs available to someone on a 56k connection, than someone on your lan. (X, is a good example.)
For your drive question, fstab is probably your choice. 'man fstab' should give you some hints. Automounting might be an option, or using the 'user' or 'users' option may be what you're looking for. It depends on your needs, of course.
As far as important config files, anything in man page 5 is important. Man 5 deals specifically with config files. if you're new to man pages, you can access them through the console (the DOS looking thing). 'man man' contains instructions for using the manual page system. (Hint: 'q' is to exit.) 'info' is also another great source for linux information.
Don't try to understand everything at once. This is where people get confused. Just look for what you need to know, and work from there.
Other important files to know: .profile (in you home directory, also in /etc [/etc ones count towards all users]--they contain setup information for your users, as do .bashrc files--one is for original login, the other is for each time you start a terminal). XF86Config(-4) -- the X system configuration file.
Other than that, you can probably get by learning the other configs as you go. If you use dial-up, it wouldn't hurt to learn about ppp configuration either, even though most of it is automated nowadays, remote use may necessitate your advanced knowledge.
Thanks for the help. I did end up using the "user" option in the fstab for the cdrom and floppy.
I see what you're saying with the separate logins. So, for example, I could make two accounts for a user that would be logging in via the console and lan. And then I would allow the user to only login to the console-specific account at the console, and vise-versa. But where do these settings go? In the config files for each server, I'm guessing, but what about local logins? How do I prevent a local user from logging into a remote-only account?
However, in my specific case, I think I will just be using the computer myself. I want to be able to automatically use X when logging in from home. When I am at school, I would like to be able access all my files (most likely through a command-line interface such as putty or psftp), so I can't have the "startx" command alone in .bash_profile. I was hoping I would be able to do something like this:
if(login from localhost){
startx
}
Is something like that possible?
In Linux, the terminal number is assigned with every login. For local users, the TTY values are from 0-9 like tty0, tty1, etc. But for remote users, it's ptty0, ptty1, etc. So, in your shell script match the environment variable $TTY with the starting pattern 'tty' and not 'ptty'. This may work out well for you. Is that enough?
Thanks, praveenk. However, there doesn't seem to be a TTY environment variable ($TTY on the command-line returns nothing), but there is a command tty that returns the name. I guess I could run it in the login script and then check its output. How would the comparison be done?
But when I first posted I figured this was a pretty common problem. Is it just the case that separate accounts are typically made for local and remote logins, as scott_R had suggested?
SpecialK5106, you need not have separate logins for remote and local users. That is not a good way to do it. I will tell you the simple way to do it with your bashrc or bash_profile
A=`tty`
B="tty"
if [ $A < $B ]; then
# Commands for remote login here.
else
# Commands for local login here.
fi
Note: Since ptty < tty*, this should work fine. You may also used sed or awk to match patterns, but that will make the work complicated. This is a simple way and it should work fine.
FYI: A xterm also uses pts/? devices, like your ssh connection. It's the way a terminal device connects to your system; as terminal (serial line, or virtual terminal), or remote console (xterm, telnet, ssh)
I'm just curious why you want to "startx" when a user logs in. You could set the runlevel of the systems to 4 or 5, to get a graphical login.
Quote:
Originally posted by SpecialK5106 Specifically, I want to mount the cd-rom and floppy for every user on startup.
You can't. You mount a device to 'hook' the file system into your file hierachy. You can't mount untill you have inserted a disk, and should unmount if you remove the disk. It's like adding a network share in Microsoft Windows (and you'll see another drive letter.. this can't be done automatically if the server is unavailable)
For example, a floppy disk won't be written untill the cache is full / the "syn" command clears the cache, or you unmount (which calls sync)
You can try to use "supermount", or "automount", but there is another thing. Add a kde desktop shortcut. If you click on the the shortcut, the KDE will mount the device automatically. (And can press "umount / eject" in the context menu of your right mouse.) But I'm wondering... do you really want people to insert CD disks? (It has been limited to the root user by default for a security reason)
Thanks for the suggestion, praveenk, but it doesn't seem to work in that form. The command tty returns /dev/tty# from a local login and /dev/pts/# from a remote login. So, I tried this:
A='tty'
B="/dev/tty"
if [ $A > $B ]; then
#local commands
fi
The if block is entered no matter whether I'm using < or >. If I type $A afterwards, then I correctly get /dev/pts/# or /dev/tty#, but $B results in -bash: /dev/tty: Permission denied.
>>I'm just curious why you want to "startx" when a user logs in.
yapp, I installed Linux for the first time on an old 133MHz Pentium that I got. I want to make the boot time as short as possible, so I want a text login. Also, as I'm learning to configure everything as root, I don't need a GUI. But, I do want at least one user account that automattically starts a window manager, so I put "startx" in that user profile.
>>do you really want people to insert CD disks? (It has been
>> limited to the root user by default for a security reason)
Yeah, I just was accustomed to Windows, so I got a little sick of typing mount /dev/cdrom /mnt/cdrom every time I wanted to access the CD. Now that everything is installed, I no longer have that need. Also, now I understand a little more of why it's done that way.
>>Add a kde desktop shortcut.
The system's a little slow for kde :-). I'm now using Blackbox, which brings me to another question. What's the fastest graphical web browser out there? I tried Mozilla, but was a bit disappointed. I've also heard about Opera and Firebird. How are they?
Thanks alot! I just learned two things there. I didn't know that I only had to type "mount /dev/cdrom" instead of "mount /dev/cdrom /mnt/cdrom", and thanks for telling me about aliases. I had to put quotes around the command to get them to work, though.
Any recommendations for the script problem above? It seems that bash has a problem with B="/dev/tty" because the string starts with the forward slash? I guess the alternative would be to cut "/dev/" from the output of the tty command, but how would that be done? Using sed or awk as praveenk had mentioned?
>>i would recommend firebird
I'm downloading that and Opera now. I'll give them both a shot, and whichever's faster will stay on my hard drive.
I'm not sure whether the graphical boot will slow down your system a lot. but It's your system off course.
If you want a fast boot, there are some other things you could do:
- check for unrequired network services: "netstat -anpA inet", and try to disable the daemons.
- disable useless services, the /etc/rc.d/rc.* files at slackware. (use "chmod -x /etc/rc.d/rc.<name>" to disable it, and chmod +x to enable it)
- compile a kernel that is adjusted to your system+hardware. Only compile what you need, and compile the required drivers as module. Disable hotplug and the kmod autoloader things, instead, tell your system what modules you want to load. (rewrite the file /etc/rc.d/rc.modules)
for your login check, I hope these lines and pointers are helpfull:
Code:
# Check if the word pts is found in the output of "tty":
if tty | grep "pts" 1> /dev/null; then
echo 11
else
echo 00
fi
# Check if the first 3 characters match "tty"
if "`tty | cut -c 0-3`" -eq "tty"; then
echo 11
else
echo 00
fi
Very cool. yapp, the code you gave a couple posts up does exactly what I want. Thanks.
However, when it comes to the part
<code>grep "pts" 1</code>
I get the error "grep: 1: No such file or directory". If I remove the '1', it runs properly. I checked the man pages, so now I know what it's supposed to do, but using that argument just won't work.
Also, I tried the code above, with the quotes around everything, and the same thing happens: the if block is entered no matter what.
But anyway, thanks again. I just installed my first Linux distro, and it's going pretty smoothly because of this site.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.