Linux Questions ( I have a few )

piratemouse

New Member
Messages
22
Reaction score
0
Points
0
Greetings everyone.

I am currently running Zorin OS 6 ( http://zorin-os.com/ ) and am slowly learning the ins and outs of running a linux system. However, with that said, I have a long way to still go on how to do various things inside terminal.
So, I come to you ... hoping someone out there in x10 universe can put up with me a little and offer some helpful and guided advice.

1. I have always liked when you SSH into somewhere, you get a friendly ( or not so friendly ) message, warning or introduction.

e.g.

-----------
|Warning|
-----------
This system is for authorized persons only
Your IP address has been logged.

login:

How would I go about doing something like this? ( What file do I edit? )

Also, on that same note, when said person logs in - I would like to give a friendly greetings, server time, etc. How does one go about editing that information?

2.I am interested in setting up ( and SLOWLY ) learning how to create a M.U.D. - since programming isn't my strong suit, I figure maybe having a place to work on it ( that's free anyway ) might give me a better chance at finally getting something up. However, I have no clue how to go about setting up a M.U.D. server on my system. What would I need to do? Any suggestions?

Thank you in advance.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
I'm not a sysadmin, so I'll leave that part to others.

As for the MUD, unless you want to make programming your strong suit, it's going to start with selecting and installing a MUD engine. You can Google "mud engine linux" (without the quotes) to get an idea of what's available out there. Some are more "engine-y" than other; some of them are pretty close to a turn-key, no-fun-at-all, ready-made going concern that just needs users. You'll (probably) want something that lets you do the world-building without having to worry too much about the under-the-cover implementation details. At least at first. thankfully, most of them are free (libre) and open source, so you can study in some detail how things were done, and adapt/improve what you find.

MUD (and other game engine) programming is mostly declarative. That is, you develop a list of facts and truths that the engine uses to do its thing. In a lot of ways, it's like building an XML or HTML file. There is often a bit of dynamic scripting as well, but the description of the world and its rules is the primary part of building the dungeon/domain. Each engine is a little different, so exactly what's required will vary depending on the engine you select, and each engine is biased a little towards a certain subset of the larger MUD genre (not much point in skulking about underground tunnels trying to avoid orcs using an engine that assumes a space opera paradigm).

Take a look through the available engines, and find something that has a bias towards the kind of MUD you're imagining, and that seems to have an unusually small number of "I can't make it work at all" complaints -- those usually come with a "works on my machine" certification from the developer -- and an active and at least semi-friendly community. (Remember that you're dealing with the deep end of the geek pool -- sometimes tempers seem short and manners seem entirely optional.) If the project is hosted on one of the more trustworthy code sources (code.google.com, as one example), then so much the better. The engine itself is an executable, so dodgy sites are best avoided, and don't trust anybody who won't show you the source code.

Good luck, and have fun.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
1. I have always liked when you SSH into somewhere, you get a friendly ( or not so friendly ) message, warning or introduction.
[...]

How would I go about doing something like this? ( What file do I edit? )

This is the "message of the day", and is held in /etc/motd. You may also need to set the "PrintMotd" sshd config option to "yes", though that should be the default. sshd also displays the last login information depending on the "PrintLastLog" directive. Both directives are set in sshd_config (see the sshd_config man page for its location on your system (likely /etc/ssh/sshd_config or /etc/config) and other details).

If you're ever wondering about how to config something (or just have some free time), start digging around in /etc. There's all sorts of interesting stuff there. That, and always read the man page (`apropos [topic]` or `man -k [topic]` can help you find man pages when you don't know the appropriate command or file; see the apropos man page for more). The sshd man page has a section titled "LOGIN PROCESS" that mentions the printing of /etc/motd and how to suppress it.

Also, on that same note, when said person logs in - I would like to give a friendly greetings, server time, etc. How does one go about editing that information?

The motd is just a text file, so can't display any dynamic information. You can use terminal escape codes for some effects (such as color and text animations), but as people have their emulators set up to emulate different terminals, you'd better skip escape sequences entirely, or at least stick to something that will work on most terminals, such as the ANSI escape codes. Xterm escape codes will likely be supported on terminal emulators on most PCs, but may be problematic on the emulators that run on some mobile devices. If you desperately want to make use of these escape sequences, do so in shell startup scripts (keep reading for more on this topic), as you can (indirectly) test whether the terminal supports them by checking $TERM and then use whichever escape sequences are appropriate. If your system has it, you can use tput to output the appropriate terminal escape sequences; the terminfo man page will list the various named terminal capabilities that you can use and a fair bit of info on the vagaries of their use (not every terminal uses the same color handling capabilities, for example).

Code:
# display "bar" red & underlined
echo foo$(tput setaf 1)$(tput smul)bar$(tput reset)baz

When it comes to dynamic information, you could create a daemon that updates the motd. Simpler would be to add commands to the system-wide startup scripts; /etc/profile and /etc/csh.login should cover most common shells (see the man pages for each shell for specifics). The shell startup scripts are run whenever an interactive shell starts, including local terminals. If you only want to display information for users that ssh in, you can add commands to /etc/sshrc (which is also mentioned in the "LOGIN PROCESS" section of sshd man page).

To display the server time, try a command like:

Code:
echo "The server time is $(date +'%T %Z')"

Read the strftime man page for date formats

In some shells (e.g. bash, zsh), $(...) is one way of performing command substitution, which executes the given command in a sub-shell and interpolates the output into the command line (see also the article on the bash hackers wiki). Note the substitution can occur anywhere, even in the first word of a command line (i.e. the command name) or when assigning to a variable:

Code:
# run $cmd using the current user's default shell
$(grep "^$USER:" /etc/passwd | cut -d ':' -f 10) -c $cmd
# store the current time (as a UNIX timestamp) in $start
start=$(date +%s)

Welcome to the deep end.
 
Last edited:
Top